Files
ruantiblock_openwrt/ruantiblock/Makefile
T

99 lines
3.0 KiB
Makefile
Raw Normal View History

2021-02-01 02:38:08 +03:00
#
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock
PKG_VERSION:=0.9.7
2022-12-25 19:45:07 +03:00
PKG_RELEASE:=0
2021-02-01 02:38:08 +03:00
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
2021-12-17 17:01:46 +03:00
SECTION:=net
CATEGORY:=Network
TITLE:=Ruantiblock
URL:=https://github.com/gSpotx2f/ruantiblock_openwrt
PKGARCH:=all
DEPENDS:=+wget +ipset +kmod-ipt-ipset +dnsmasq-full
2021-02-01 02:38:08 +03:00
endef
define Package/$(PKG_NAME)/description
endef
define Package/$(PKG_NAME)/conffiles
2021-12-17 17:01:46 +03:00
endef
define Build/Configure
2021-02-01 02:38:08 +03:00
endef
2021-12-17 17:01:46 +03:00
define Build/Compile
2021-02-01 02:38:08 +03:00
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/config
2021-12-17 17:01:46 +03:00
$(INSTALL_CONF) ./files/etc/config/ruantiblock $(1)/etc/config/ruantiblock
2021-02-01 02:38:08 +03:00
$(INSTALL_DIR) $(1)/etc/init.d
2021-12-17 17:01:46 +03:00
$(INSTALL_BIN) ./files/etc/init.d/ruantiblock $(1)/etc/init.d/ruantiblock
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/40-ruantiblock $(1)/etc/hotplug.d/iface/40-ruantiblock
$(INSTALL_DIR) $(1)/etc/ruantiblock
$(INSTALL_CONF) ./files/etc/ruantiblock/ruantiblock.conf $(1)/etc/ruantiblock/ruantiblock.conf
$(INSTALL_CONF) ./files/etc/ruantiblock/fqdn_filter $(1)/etc/ruantiblock/fqdn_filter
$(INSTALL_DIR) $(1)/etc/ruantiblock/scripts
$(INSTALL_DATA) ./files/etc/ruantiblock/scripts/config_script $(1)/etc/ruantiblock/scripts/config_script
$(INSTALL_DATA) ./files/etc/ruantiblock/scripts/info_output $(1)/etc/ruantiblock/scripts/info_output
$(INSTALL_DATA) ./files/etc/ruantiblock/scripts/ipt_functions $(1)/etc/ruantiblock/scripts/ipt_functions
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/usr/bin/ruantiblock $(1)/usr/bin/ruantiblock
2021-02-01 02:38:08 +03:00
endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
RUAB_CFG_DIR="/etc/ruantiblock"
2021-02-01 03:29:12 +03:00
BACKUP_DIR="$${RUAB_CFG_DIR}/autoinstall.bak.`date +%s`"
2021-02-01 02:38:08 +03:00
FILE_CONFIG="$${RUAB_CFG_DIR}/ruantiblock.conf"
2022-05-12 02:16:42 +03:00
FILE_FQDN_FILTER="$${RUAB_CFG_DIR}/fqdn_filter"
FILE_IP_FILTER="$${RUAB_CFG_DIR}/ip_filter"
FILE_USER_ENTRIES="$${RUAB_CFG_DIR}/user_entries"
2021-02-01 02:38:08 +03:00
FILE_UCI_CONFIG="/etc/config/ruantiblock"
2022-05-10 01:22:25 +03:00
FILE_MAIN_SCRIPT="/usr/bin/ruantiblock"
2021-02-01 02:38:08 +03:00
test -e "$$FILE_MAIN_SCRIPT" && $$FILE_MAIN_SCRIPT destroy
mkdir -p "$$BACKUP_DIR"
for _file in "$$FILE_CONFIG" "$$FILE_FQDN_FILTER" "$$FILE_IP_FILTER" "$$FILE_USER_ENTRIES" "$$FILE_UCI_CONFIG"
do
[ -e "$$_file" ] && cp -f "$$_file" "$${BACKUP_DIR}/`basename $$_file`"
done
exit 0
endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
FILE_INIT_SCRIPT="/etc/init.d/ruantiblock"
2022-05-10 01:22:25 +03:00
FILE_MAIN_SCRIPT="/usr/bin/ruantiblock"
2021-02-01 02:38:08 +03:00
CRONTAB_FILE="/etc/crontabs/root"
2022-05-12 02:16:42 +03:00
DNSMASQ_DATA_FILE="/tmp/dnsmasq.d/ruantiblock.dnsmasq"
2021-02-01 02:38:08 +03:00
2022-05-10 01:22:25 +03:00
rm -f $$DNSMASQ_DATA_FILE
2021-02-01 02:38:08 +03:00
test -e "$$FILE_MAIN_SCRIPT" && $$FILE_MAIN_SCRIPT destroy
test -e "$$FILE_INIT_SCRIPT" && $$FILE_INIT_SCRIPT disable
awk -v FILE_MAIN_SCRIPT="$$FILE_MAIN_SCRIPT" '$$0 !~ FILE_MAIN_SCRIPT {
print $$0;
}' "$$CRONTAB_FILE" > "$${CRONTAB_FILE}.tmp" && mv -f "$${CRONTAB_FILE}.tmp" "$$CRONTAB_FILE"
/etc/init.d/cron restart
exit 0
endef
$(eval $(call BuildPackage,$(PKG_NAME)))