mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-31 03:48:17 +03:00
ipset: Add ability for restore default ipset configs
This commit is contained in:
@@ -79,8 +79,14 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_BIN) ./init.d.sh $(1)/etc/init.d/zapret
|
||||
$(INSTALL_DATA) ./config.default $(1)/opt/zapret/config.default
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret/ipset/zapret-hosts-google.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret/ipset/zapret-hosts-user.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret/ipset/zapret-hosts-user-exclude.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret/ipset/zapret-ip-exclude.txt
|
||||
$(INSTALL_DIR) $(1)/opt/zapret/ipset_def
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret/ipset_def/zapret-hosts-google.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret/ipset_def/zapret-hosts-user.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret/ipset_def/zapret-hosts-user-exclude.txt
|
||||
$(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret/ipset_def/zapret-ip-exclude.txt
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./uci-def-cfg.sh $(1)/etc/uci-defaults/zapret-uci-def-cfg.sh
|
||||
$(INSTALL_BIN) ./uci-def-cfg.sh $(1)/opt/zapret/uci-def-cfg.sh
|
||||
@@ -91,6 +97,7 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_BIN) ./sync_config.sh $(1)/opt/zapret/sync_config.sh
|
||||
# Fix permisions
|
||||
chmod 644 $(1)/opt/zapret/ipset/*.txt
|
||||
chmod 644 $(1)/opt/zapret/ipset_def/*.txt
|
||||
chmod 644 $(1)/opt/zapret/config.default
|
||||
chmod 755 $(1)/opt/zapret/*.sh
|
||||
endef
|
||||
|
||||
@@ -90,6 +90,22 @@ function get_run_on_boot_option
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_ipset_txt
|
||||
{
|
||||
local cfgname=$1
|
||||
if [ -f "$ZAPRET_BASE/ipset_def/$cfgname" ]; then
|
||||
cp -f "$ZAPRET_BASE/ipset_def/$cfgname" "$ZAPRET_BASE/ipset/$cfgname"
|
||||
fi
|
||||
}
|
||||
|
||||
function restore_all_ipset_cfg
|
||||
{
|
||||
restore_ipset_txt zapret-hosts-google.txt
|
||||
restore_ipset_txt zapret-hosts-user.txt
|
||||
restore_ipset_txt zapret-hosts-user-exclude.txt
|
||||
restore_ipset_txt zapret-ip-exclude.txt.txt
|
||||
}
|
||||
|
||||
function create_default_cfg
|
||||
{
|
||||
local cfgname=${1:-$ZAPRET_CFG_NAME}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
cfg_run_on_boot="$( uci -q get zapret.config.run_on_boot )"
|
||||
|
||||
restore_all_ipset_cfg
|
||||
create_default_cfg
|
||||
|
||||
if [ "$cfg_run_on_boot" = "1" ]; then
|
||||
|
||||
Reference in New Issue
Block a user