2021-02-01 02:38:08 +03:00
|
|
|
|
#
|
|
|
|
|
|
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
|
|
|
|
PKG_NAME:=ruantiblock
|
2023-02-18 15:52:13 +03:00
|
|
|
|
PKG_VERSION:=1.1
|
2023-04-24 17:59:35 +03:00
|
|
|
|
PKG_RELEASE:=1
|
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
|
2023-02-09 20:53:20 +03:00
|
|
|
|
DEPENDS:=+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
|
2023-04-24 17:59:35 +03:00
|
|
|
|
$(INSTALL_DIR) $(1)/usr/share/ruantiblock
|
|
|
|
|
|
$(INSTALL_DATA) ./files/usr/share/ruantiblock/config_script $(1)/usr/share/ruantiblock/config_script
|
|
|
|
|
|
$(INSTALL_DATA) ./files/usr/share/ruantiblock/info_output $(1)/usr/share/ruantiblock/info_output
|
|
|
|
|
|
$(INSTALL_DATA) ./files/usr/share/ruantiblock/nft_functions $(1)/usr/share/ruantiblock/nft_functions
|
2021-12-17 17:01:46 +03:00
|
|
|
|
$(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)))
|