banip: release 0.9.6-1
[feed/packages.git] / net / geoip-shell / Makefile
1 # Copyright 2024 friendly-bits, antonk (antonk.d3v@gmail.com)
2 # This is free software, licensed under the GNU General Public License v3.
3
4 include $(TOPDIR)/rules.mk
5
6 PKG_NAME:=geoip-shell
7 PKG_VERSION:=0.5.2
8 PKG_RELEASE:=1
9 PKG_LICENSE:=GPL-3.0-or-later
10 PKG_MAINTAINER:=antonk <antonk.d3v@gmail.com>
11 PKG_SOURCE_PROTO:=git
12 PKG_SOURCE_VERSION:=db8bbf4ce04094843beea1b1aa4fbceb0d35688d
13 PKG_SOURCE_URL:=https://github.com/friendly-bits/geoip-shell-openwrt.git
14 PKG_MIRROR_HASH:=4b0b90a936b8e9b476a0b85bd2100fcc4d1da25cd6929c0bcc282ae7ff137e9f
15
16 include $(INCLUDE_DIR)/package.mk
17
18 define Package/geoip-shell/Default
19 CATEGORY:=Network
20 TITLE:=Flexible geoip blocker
21 URL:=https://github.com/friendly-bits/geoip-shell
22 MAINTAINER:=antonk <antonk.d3v@gmail.com>
23 DEPENDS:=+ca-bundle
24 PROVIDES:=geoip-shell
25 PKGARCH:=all
26 endef
27
28 define Package/geoip-shell
29 $(call Package/geoip-shell/Default)
30 TITLE+= with nftables support
31 DEPENDS+= +kmod-nft-core +nftables +firewall4
32 DEFAULT_VARIANT:=1
33 VARIANT:=nftables
34 endef
35
36 define Package/geoip-shell-iptables
37 $(call Package/geoip-shell/Default)
38 TITLE+= with iptables support
39 DEPENDS+= +kmod-ipt-ipset +IPV6:ip6tables +iptables +ipset
40 VARIANT:=iptables
41 CONFLICTS:=geoip-shell firewall4
42 endef
43
44 define Package/geoip-shell/description/Default
45 Flexible geoip blocker with a user-friendly command line interface (currently no LuCi interface).
46 For readme, please see
47 https://github.com/openwrt/packages/blob/master/net/geoip-shell/OpenWrt-README.md
48 endef
49
50 define Package/geoip-shell/description
51 $(call Package/geoip-shell/description/Default)
52 endef
53
54 define Package/geoip-shell-iptables/description
55 $(call Package/geoip-shell/description/Default)
56 endef
57
58 define Package/geoip-shell/postinst/Default
59 #!/bin/sh
60 rm "/usr/bin/geoip-shell" 2>/dev/null
61 ln -s "/usr/bin/geoip-shell-manage.sh" "/usr/bin/geoip-shell"
62 [ -s "/etc/geoip-shell/geoip-shell.conf" ] && /usr/bin/geoip-shell configure -z && exit 0
63 logger -s -t "geoip-shell" "Please run 'geoip-shell configure' to complete the setup."
64 exit 0
65 endef
66
67 define Package/geoip-shell/postinst
68 $(call Package/geoip-shell/postinst/Default)
69 endef
70
71 define Package/geoip-shell-iptables/postinst
72 $(call Package/geoip-shell/postinst/Default)
73 endef
74
75 define Package/geoip-shell/prerm/Default
76 #!/bin/sh
77 sh /usr/lib/geoip-shell/geoip-shell-owrt-uninstall.sh
78 exit 0
79 endef
80
81 define Package/geoip-shell/prerm
82 $(call Package/geoip-shell/prerm/Default)
83 endef
84
85 define Package/geoip-shell-iptables/prerm
86 $(call Package/geoip-shell/prerm/Default)
87 endef
88
89 define Package/geoip-shell/postrm
90 #!/bin/sh
91 sleep 1
92 echo "Reloading the firewall..."
93 fw4 -q reload
94 exit 0
95 endef
96
97 define Package/geoip-shell-iptables/postrm
98 #!/bin/sh
99 sleep 1
100 echo "Reloading the firewall..."
101 fw3 -q reload
102 exit 0
103 endef
104
105 define Build/Configure
106 endef
107
108 define Build/Compile
109 endef
110
111 define Package/geoip-shell/install/Default
112
113 $(INSTALL_DIR) $(1)/etc/init.d
114 $(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/geoip-shell-init $(1)/etc/init.d
115
116 $(INSTALL_DIR) $(1)/etc/geoip-shell
117 $(INSTALL_CONF) $(PKG_BUILD_DIR)/etc/geoip-shell/cca2.list $(1)/etc/geoip-shell
118 $(INSTALL_CONF) $(PKG_BUILD_DIR)/etc/geoip-shell/geoip-shell.const $(1)/etc/geoip-shell
119
120 $(INSTALL_DIR) $(1)/usr/bin
121 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-fetch.sh $(1)/usr/bin
122 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-fw-include.sh $(1)/usr/bin
123 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-backup.sh $(1)/usr/bin
124 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-geoinit.sh $(1)/usr/bin
125 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-run.sh $(1)/usr/bin
126 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-mk-fw-include.sh $(1)/usr/bin
127 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-manage.sh $(1)/usr/bin
128 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-apply.sh $(1)/usr/bin
129 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-detect-lan.sh $(1)/usr/bin
130 $(INSTALL_BIN) $(PKG_BUILD_DIR)/usr/bin/geoip-shell-cronsetup.sh $(1)/usr/bin
131
132 $(INSTALL_DIR) $(1)/usr/lib/geoip-shell
133 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-status.sh $(1)/usr/lib/geoip-shell
134 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-owrt-common.sh $(1)/usr/lib/geoip-shell
135 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-common.sh $(1)/usr/lib/geoip-shell
136 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-owrt-uninstall.sh $(1)/usr/lib/geoip-shell
137 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-arrays.sh $(1)/usr/lib/geoip-shell
138 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-setup.sh $(1)/usr/lib/geoip-shell
139 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-uninstall.sh $(1)/usr/lib/geoip-shell
140
141 endef
142
143
144 define Package/geoip-shell/install
145 $(call Package/geoip-shell/install/Default,$(1))
146 $(INSTALL_DIR) $(1)/usr/lib/geoip-shell
147 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-nft.sh $(1)/usr/lib/geoip-shell
148
149 endef
150
151
152 define Package/geoip-shell-iptables/install
153 $(call Package/geoip-shell/install/Default,$(1))
154 $(INSTALL_DIR) $(1)/usr/lib/geoip-shell
155 $(INSTALL_CONF) $(PKG_BUILD_DIR)/usr/lib/geoip-shell/geoip-shell-lib-ipt.sh $(1)/usr/lib/geoip-shell
156
157 endef
158
159 $(eval $(call BuildPackage,geoip-shell))
160 $(eval $(call BuildPackage,geoip-shell-iptables))
161
162