From fa22fdbe2a851f5292eeca0f302106e6497b3e6c Mon Sep 17 00:00:00 2001 From: gSpot Date: Tue, 10 May 2022 01:22:25 +0300 Subject: [PATCH] v0.9.3. DATA_DIR moved to /tmp --- autoinstall/autoinstall.sh | 53 ++----------------- autoinstall/uninstall.sh | 20 ++----- luci-app-ruantiblock/Makefile | 2 +- .../resources/view/ruantiblock/service.js | 4 +- .../resources/view/ruantiblock/settings.js | 10 ++-- luci-app-ruantiblock/po/ru/ruantiblock.po | 6 +++ .../po/templates/ruantiblock.pot | 6 +++ .../rpcd/acl.d/luci-app-ruantiblock.json | 2 +- ruantiblock-mod-lua/Makefile | 2 +- ruantiblock-mod-py/Makefile | 2 +- ruantiblock/Makefile | 25 ++------- ruantiblock/files/etc/config/ruantiblock | 1 + ruantiblock/files/etc/init.d/ruantiblock | 22 +++++--- .../files/etc/ruantiblock/ruantiblock.conf | 4 +- .../etc/ruantiblock/scripts/config_script | 2 +- .../etc/ruantiblock/scripts/start_script | 5 -- ruantiblock/files/usr/bin/ruantiblock | 16 +++--- 17 files changed, 68 insertions(+), 114 deletions(-) delete mode 100755 ruantiblock/files/etc/ruantiblock/scripts/start_script diff --git a/autoinstall/autoinstall.sh b/autoinstall/autoinstall.sh index 05dd414..d7fbf72 100755 --- a/autoinstall/autoinstall.sh +++ b/autoinstall/autoinstall.sh @@ -4,14 +4,13 @@ PREFIX="" TOR_USER="tor" PROXY_MODE=1 -RAM_CONFIG=0 LUA_MODULE=1 LUCI_APP=1 OWRT_VERSION="current" -RUAB_VERSION="0.9.2-0" -RUAB_MOD_LUA_VERSION="0.9.2-0" -RUAB_LUCI_APP_VERSION="0.9.2-0" +RUAB_VERSION="0.9.3-0" +RUAB_MOD_LUA_VERSION="0.9.3-0" +RUAB_LUCI_APP_VERSION="0.9.3-0" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" PKG_DIR="/tmp" @@ -37,9 +36,6 @@ URL_LUA_IDN="https://raw.githubusercontent.com/haste/lua-idn/master/idn.lua" RUAB_CFG_DIR="${PREFIX}/etc/ruantiblock" EXEC_DIR="${PREFIX}/usr/bin" BACKUP_DIR="${RUAB_CFG_DIR}/autoinstall.bak.`date +%s`" -DATA_DIR="${RUAB_CFG_DIR}/var" -DATA_DIR_RAM="/var/ruantiblock" -RC_LOCAL="/etc/rc.local" ### packages FILE_RUAB_PKG="${PKG_DIR}/ruantiblock_${RUAB_VERSION}_all.ipk" FILE_MOD_LUA_PKG="${PKG_DIR}/ruantiblock-mod-lua_${RUAB_MOD_LUA_VERSION}_all.ipk" @@ -171,8 +167,6 @@ InstallPackages() { echo "Error during installation of the package (${_pkg})" >&2 exit 1 fi - else - : fi done } @@ -183,6 +177,7 @@ InstallBaseConfig() { RemoveFile "$FILE_RUAB_PKG" > /dev/null DlFile "$URL_RUAB_PKG" "$FILE_RUAB_PKG" && $OPKG_CMD install "$FILE_RUAB_PKG" > /dev/null _return_code=$? + # костыль для остановки сервиса, который запускается автоматически после установки пакета! AppStop return $_return_code } @@ -222,17 +217,6 @@ InstallTorConfig() { $UCI_CMD commit } -RamConfigPrepare() { - $AWK_CMD -v DATA_DIR_RAM="$DATA_DIR_RAM" '{ - sub(/^DATA_DIR=.*$/, "DATA_DIR=\"" DATA_DIR_RAM "\""); - print $0; - }' "$FILE_CONFIG" > "${FILE_CONFIG}.tmp" && mv -f "${FILE_CONFIG}.tmp" "$FILE_CONFIG" - $AWK_CMD -v FILE_MAIN_SCRIPT="$FILE_MAIN_SCRIPT" '{ - if($0 ~ /^exit 0/) next; - print $0; - } END { print FILE_MAIN_SCRIPT " update\nexit 0" }' "$RC_LOCAL" > "${RC_LOCAL}.tmp" && mv -f "${RC_LOCAL}.tmp" "$RC_LOCAL" -} - InstallLuaModule() { InstallPackages "lua" "luasocket" "luasec" "luabitop" RemoveFile "$FILE_MOD_LUA_PKG" > /dev/null @@ -283,28 +267,6 @@ ConfirmProxyMode() { esac } -ConfirmRamConfig() { - local _reply - printf " Would you like to set the RAM-configuration? [y|n] (default: n, quit: q) > " - read _reply - case $_reply in - y|Y) - RAM_CONFIG=1 - break - ;; - n|N|"") - RAM_CONFIG=0 - break - ;; - q|Q) - printf "Bye...\n"; exit 0 - ;; - *) - InputError ConfirmRamConfig - ;; - esac -} - ConfirmLuaModule() { local _reply printf " Would you like to install the lua module? [y|n] (default: y, quit: q) > " @@ -367,14 +329,12 @@ ConfirmProcessing() { } ConfirmProxyMode -ConfirmRamConfig ConfirmLuciApp ConfirmProcessing AppStop PrintBold "Updating packages list..." UpdatePackagesList PrintBold "Saving current configuration..." -#BackupCurrentConfig PrintBold "Installing basic configuration..." InstallBaseConfig if [ $? -eq 0 ]; then @@ -390,11 +350,6 @@ if [ $? -eq 0 ]; then fi fi - if [ $RAM_CONFIG = 1 ]; then - PrintBold "Setting the RAM-configuration..." - RamConfigPrepare - fi - if [ $LUA_MODULE = 1 ]; then PrintBold "Installing lua module..." InstallLuaModule diff --git a/autoinstall/uninstall.sh b/autoinstall/uninstall.sh index 2094496..3f183cb 100755 --- a/autoinstall/uninstall.sh +++ b/autoinstall/uninstall.sh @@ -10,10 +10,8 @@ BACKUP_DIR="${RUAB_CFG_DIR}/autoinstall.bak.`date +%s`" HTDOCS_VIEW="${PREFIX}/www/luci-static/resources/view" HTDOCS_RUAB="${HTDOCS_VIEW}/ruantiblock" CRONTAB_FILE="/etc/crontabs/root" -DATA_DIR="${RUAB_CFG_DIR}/var" -DATA_DIR_RAM="/var/ruantiblock" -RC_LOCAL="/etc/rc.local" -DNSMASQ_CONF_LINK="/tmp/dnsmasq.d/ruantiblock.conf" +DATA_DIR="/tmp/ruantiblock" +DNSMASQ_DATA_FILE="/tmp/dnsmasq.d/ruantiblock.conf" ### ruantiblock FILE_CONFIG="${RUAB_CFG_DIR}/ruantiblock.conf" FILE_FQDN_FILTER="${RUAB_CFG_DIR}/fqdn_filter" @@ -61,7 +59,6 @@ BackupCurrentConfig() { } AppStop() { - rm -f $DNSMASQ_CONF_LINK FileExists "$FILE_MAIN_SCRIPT" && $FILE_MAIN_SCRIPT destroy } @@ -76,12 +73,6 @@ RemoveCronTask() { /etc/init.d/cron restart } -RemoveRcLocalEntry() { - $AWK_CMD -v FILE_MAIN_SCRIPT="$FILE_MAIN_SCRIPT" '$0 !~ FILE_MAIN_SCRIPT { - print $0; - }' "$RC_LOCAL" > "${RC_LOCAL}.tmp" && mv -f "${RC_LOCAL}.tmp" "$RC_LOCAL" -} - RestoreTorConfig() { [ -e "${FILE_TORRC}.bak" ] && mv -f "${FILE_TORRC}.bak" "$FILE_TORRC" if [ -x "/etc/init.d/tor" ]; then @@ -93,9 +84,9 @@ RestoreTorConfig() { RemoveAppFiles() { RestoreTorConfig - rm -rf "$DATA_DIR" - rm -rf "$DATA_DIR_RAM" $OPKG_CMD remove ruantiblock-mod-py ruantiblock-mod-lua luci-i18n-ruantiblock-ru luci-app-ruantiblock ruantiblock + rm -f "$DNSMASQ_DATA_FILE" + rm -rf "$DATA_DIR"/* rmdir "${RUAB_CFG_DIR}/scripts" 2> /dev/null rmdir "$HTDOCS_RUAB" 2> /dev/null rm -f /tmp/luci-modulecache/* /tmp/luci-indexcache* @@ -126,10 +117,9 @@ ConfirmRemove() { ConfirmRemove AppStop -BackupCurrentConfig +#BackupCurrentConfig DisableStartup RemoveCronTask -RemoveRcLocalEntry RemoveAppFiles exit 0 diff --git a/luci-app-ruantiblock/Makefile b/luci-app-ruantiblock/Makefile index a309e9b..f213a48 100644 --- a/luci-app-ruantiblock/Makefile +++ b/luci-app-ruantiblock/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk -PKG_VERSION:=0.9.2-0 +PKG_VERSION:=0.9.3-0 LUCI_TITLE:=LuCI support for ruantiblock LUCI_DEPENDS:=+ruantiblock LUCI_PKGARCH:=all diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/service.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/service.js index b459c72..be06524 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/service.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/service.js @@ -83,14 +83,14 @@ return view.extend({ let btnStartStateOn = () => { btn_start.onclick = ui.createHandlerFn( - this, this.serviceAction, 'stop', 'btn_start'); + this, this.appAction, 'stop', 'btn_start'); btn_start.textContent = _('Enabled'); btn_start.className = btn_style_positive; } let btnStartStateOff = () => { btn_start.onclick = ui.createHandlerFn( - this, this.serviceAction,'start', 'btn_start'); + this, this.appAction,'start', 'btn_start'); btn_start.textContent = _('Disabled'); btn_start.className = btn_style_negative; } diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js index ef35231..92c7d5b 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js @@ -123,6 +123,12 @@ return view.extend({ _('Logging events')); o.rmempty = false; + // update_at_startup + o = s.taboption('main_settings', form.Flag, 'update_at_startup', + _('Update at startup')); + o.description = _('Update blacklist after system startup'); + o.rmempty = false; + // IPSET_CLEAR_SETS o = s.taboption('main_settings', form.Flag, 'ipset_clear_sets', _('Clean up ipsets before updating blacklist')); @@ -330,10 +336,8 @@ return view.extend({ handleSaveApply: function(ev, mode) { return this.handleSave(ev).then(() => { ui.changes.apply(mode == '0'); - if(this.appStatusCode != 1 && this.appStatusCode != 2) { - window.setTimeout(() => tools.handleServiceAction( - tools.appName, 'restart'), 3000); + window.setTimeout(() => fs.exec(tools.execPath, [ 'restart' ]), 3000); }; }); }, diff --git a/luci-app-ruantiblock/po/ru/ruantiblock.po b/luci-app-ruantiblock/po/ru/ruantiblock.po index 57ef334..772e81d 100644 --- a/luci-app-ruantiblock/po/ru/ruantiblock.po +++ b/luci-app-ruantiblock/po/ru/ruantiblock.po @@ -413,9 +413,15 @@ msgstr "Невозможно сохранить содержимое" msgid "Update" msgstr "Обновить" +msgid "Update at startup" +msgstr "Обновление при запуске" + msgid "Update blacklist" msgstr "Обновить блэклист" +msgid "Update blacklist after system startup" +msgstr "Обновлять блэклист после запуска системы" + msgid "Updating" msgstr "Обновление" diff --git a/luci-app-ruantiblock/po/templates/ruantiblock.pot b/luci-app-ruantiblock/po/templates/ruantiblock.pot index 36d7c16..6e6d0c8 100644 --- a/luci-app-ruantiblock/po/templates/ruantiblock.pot +++ b/luci-app-ruantiblock/po/templates/ruantiblock.pot @@ -375,9 +375,15 @@ msgstr "" msgid "Update" msgstr "" +msgid "Update at startup" +msgstr "" + msgid "Update blacklist" msgstr "" +msgid "Update blacklist after system startup" +msgstr "" + msgid "Updating" msgstr "" diff --git a/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json b/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json index 3a2cba8..77faa06 100644 --- a/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json +++ b/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json @@ -11,7 +11,7 @@ "/var/run/ruantiblock.token": [ "read" ], "/etc/tor/torrc": [ "read" ], "/etc/crontabs/root": [ "read" ], - "/usr/bin/ruantiblock": [ "exec" ], + "/usr/bin/ruantiblock*": [ "exec" ], "/sbin/logread -e ruantiblock": [ "exec" ], "/usr/sbin/logread -e ruantiblock": [ "exec" ] }, diff --git a/ruantiblock-mod-lua/Makefile b/ruantiblock-mod-lua/Makefile index 436673c..b348da9 100644 --- a/ruantiblock-mod-lua/Makefile +++ b/ruantiblock-mod-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-lua -PKG_VERSION:=0.9.2 +PKG_VERSION:=0.9.3 PKG_RELEASE:=0 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock-mod-py/Makefile b/ruantiblock-mod-py/Makefile index f51c2d4..6fe0b05 100644 --- a/ruantiblock-mod-py/Makefile +++ b/ruantiblock-mod-py/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-py -PKG_VERSION:=0.9.2 +PKG_VERSION:=0.9.3 PKG_RELEASE:=0 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock/Makefile b/ruantiblock/Makefile index 5e71e6b..99625dc 100644 --- a/ruantiblock/Makefile +++ b/ruantiblock/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock -PKG_VERSION:=0.9.2 +PKG_VERSION:=0.9.3 PKG_RELEASE:=0 PKG_MAINTAINER:=gSpot @@ -24,11 +24,6 @@ define Package/$(PKG_NAME)/description endef define Package/$(PKG_NAME)/conffiles -/etc/config/ruantiblock -/etc/ruantiblock/ruantiblock.conf -/etc/ruantiblock/fqdn_filter -/etc/ruantiblock/ip_filter -/etc/ruantiblock/user_entries endef define Build/Configure @@ -51,7 +46,6 @@ define Package/$(PKG_NAME)/install $(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_BIN) ./files/etc/ruantiblock/scripts/start_script $(1)/etc/ruantiblock/scripts/start_script $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) ./files/usr/bin/ruantiblock $(1)/usr/bin/ruantiblock endef @@ -60,15 +54,13 @@ define Package/$(PKG_NAME)/preinst #!/bin/sh RUAB_CFG_DIR="/etc/ruantiblock" -EXEC_DIR="/usr/bin" BACKUP_DIR="$${RUAB_CFG_DIR}/autoinstall.bak.`date +%s`" FILE_CONFIG="$${RUAB_CFG_DIR}/ruantiblock.conf" FILE_FQDN_FILTER="$${RUAB_CFG_DIR}/ruab_fqdn_filter" FILE_IP_FILTER="$${RUAB_CFG_DIR}/ruab_ip_filter" FILE_USER_ENTRIES="$${RUAB_CFG_DIR}/ruab_user_entries" FILE_UCI_CONFIG="/etc/config/ruantiblock" -FILE_MAIN_SCRIPT="$${EXEC_DIR}/ruantiblock" - +FILE_MAIN_SCRIPT="/usr/bin/ruantiblock" test -e "$$FILE_MAIN_SCRIPT" && $$FILE_MAIN_SCRIPT destroy @@ -84,15 +76,12 @@ endef define Package/$(PKG_NAME)/prerm #!/bin/sh -EXEC_DIR="/usr/bin" FILE_INIT_SCRIPT="/etc/init.d/ruantiblock" -FILE_MAIN_SCRIPT="$${EXEC_DIR}/ruantiblock" +FILE_MAIN_SCRIPT="/usr/bin/ruantiblock" CRONTAB_FILE="/etc/crontabs/root" -RC_LOCAL="/etc/rc.local" -DNSMASQ_CONF_LINK="/tmp/dnsmasq.d/ruantiblock.conf" +DNSMASQ_DATA_FILE="/tmp/dnsmasq.d/ruantiblock.conf" - -rm -f $$DNSMASQ_CONF_LINK +rm -f $$DNSMASQ_DATA_FILE test -e "$$FILE_MAIN_SCRIPT" && $$FILE_MAIN_SCRIPT destroy test -e "$$FILE_INIT_SCRIPT" && $$FILE_INIT_SCRIPT disable @@ -102,10 +91,6 @@ awk -v FILE_MAIN_SCRIPT="$$FILE_MAIN_SCRIPT" '$$0 !~ FILE_MAIN_SCRIPT { }' "$$CRONTAB_FILE" > "$${CRONTAB_FILE}.tmp" && mv -f "$${CRONTAB_FILE}.tmp" "$$CRONTAB_FILE" /etc/init.d/cron restart -awk -v FILE_MAIN_SCRIPT="$$FILE_MAIN_SCRIPT" '$$0 !~ FILE_MAIN_SCRIPT { - print $$0; -}' "$$RC_LOCAL" > "$${RC_LOCAL}.tmp" && mv -f "$${RC_LOCAL}.tmp" "$$RC_LOCAL" - exit 0 endef diff --git a/ruantiblock/files/etc/config/ruantiblock b/ruantiblock/files/etc/config/ruantiblock index 3a5b59e..db3da3f 100644 --- a/ruantiblock/files/etc/config/ruantiblock +++ b/ruantiblock/files/etc/config/ruantiblock @@ -32,3 +32,4 @@ config main 'config' option bllist_enable_idn '0' option bllist_alt_nslookup '0' option bllist_alt_dns_addr '8.8.8.8' + option update_at_startup '1' diff --git a/ruantiblock/files/etc/init.d/ruantiblock b/ruantiblock/files/etc/init.d/ruantiblock index 18ab1d1..7ace15f 100755 --- a/ruantiblock/files/etc/init.d/ruantiblock +++ b/ruantiblock/files/etc/init.d/ruantiblock @@ -1,22 +1,32 @@ #!/bin/sh /etc/rc.common -START=92 +START=96 STOP=01 -RUAB="/usr/bin/ruantiblock" +APP_NAME="ruantiblock" +APP_EXEC="/usr/bin/${APP_NAME}" + +config_load $APP_NAME start() { - $RUAB start + local update_at_startup + config_get update_at_startup config update_at_startup + $APP_EXEC start + if [ $? -eq 0 -a "$update_at_startup" = "1" ]; then + $APP_EXEC update + else + /etc/init.d/dnsmasq restart + fi } stop() { - $RUAB stop + $APP_EXEC stop } restart() { - $RUAB restart + $APP_EXEC restart } reload() { - $RUAB reload + $APP_EXEC reload } diff --git a/ruantiblock/files/etc/ruantiblock/ruantiblock.conf b/ruantiblock/files/etc/ruantiblock/ruantiblock.conf index 2a14850..53a5b9c 100644 --- a/ruantiblock/files/etc/ruantiblock/ruantiblock.conf +++ b/ruantiblock/files/etc/ruantiblock/ruantiblock.conf @@ -2,9 +2,11 @@ ### Настройки ruantiblock ### ### Директория данных (генерируемые конфиги dnsmasq, ipset и пр.) -DATA_DIR="/etc/ruantiblock/var" +DATA_DIR="/tmp/ruantiblock" ### Директория модулей MODULES_DIR="/usr/libexec/ruantiblock" +### Дополнительный конфиг dnsmasq с FQDN записями блэклиста +DNSMASQ_DATA_FILE="/tmp/dnsmasq.d/ruantiblock.conf" ### Команда для перезапуска dnsmasq DNSMASQ_RESTART_CMD="/etc/init.d/dnsmasq restart" ### Директория для html-страницы статуса (не используется в OpenWrt) diff --git a/ruantiblock/files/etc/ruantiblock/scripts/config_script b/ruantiblock/files/etc/ruantiblock/scripts/config_script index 18baf01..7a69ced 100644 --- a/ruantiblock/files/etc/ruantiblock/scripts/config_script +++ b/ruantiblock/files/etc/ruantiblock/scripts/config_script @@ -1,6 +1,6 @@ AWK_CMD="awk" UCI_SECTION="ruantiblock.config" -UCI_VARS="proxy_mode proxy_local_clients ipset_clear_sets allowed_hosts_mode allowed_hosts_list if_vpn tor_trans_port tor_allow_udp onion_dns_addr add_user_entries user_entries_dns enable_logging bllist_module bllist_preset bllist_ip_limit bllist_gr_excluded_nets bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_sd_limit bllist_gr_excluded_sld bllist_fqdn_filter bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr" +UCI_VARS="proxy_mode proxy_local_clients ipset_clear_sets allowed_hosts_mode allowed_hosts_list if_vpn tor_trans_port tor_allow_udp onion_dns_addr add_user_entries user_entries_dns enable_logging bllist_module bllist_preset bllist_ip_limit bllist_gr_excluded_nets bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_sd_limit bllist_gr_excluded_sld bllist_fqdn_filter bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup" eval `uci show "$UCI_SECTION" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" ' BEGIN { diff --git a/ruantiblock/files/etc/ruantiblock/scripts/start_script b/ruantiblock/files/etc/ruantiblock/scripts/start_script deleted file mode 100755 index 24d7ec1..0000000 --- a/ruantiblock/files/etc/ruantiblock/scripts/start_script +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -_link="/tmp/dnsmasq.d/ruantiblock.conf" -ln -fs $DNSMASQ_DATA_FILE $_link -eval `echo "$DNSMASQ_RESTART_CMD"` diff --git a/ruantiblock/files/usr/bin/ruantiblock b/ruantiblock/files/usr/bin/ruantiblock index 1739ab6..19b8232 100755 --- a/ruantiblock/files/usr/bin/ruantiblock +++ b/ruantiblock/files/usr/bin/ruantiblock @@ -15,9 +15,10 @@ export LANGUAGE="en" CONFIG_DIR="/etc/${NAME}" CONFIG_FILE="${CONFIG_DIR}/${NAME}.conf" -export DATA_DIR="${CONFIG_DIR}/var" +export DATA_DIR="/var/${NAME}" export MODULES_DIR="/usr/libexec/${NAME}" - +### Дополнительный конфиг dnsmasq с FQDN записями блэклиста +export DNSMASQ_DATA_FILE="/var/dnsmasq.d/${NAME}.conf" ### Команда для перезапуска dnsmasq export DNSMASQ_RESTART_CMD="/etc/init.d/dnsmasq restart" ### Директория для html-страницы статуса (не используется в OpenWrt) @@ -35,7 +36,7 @@ export IPSET_CLEAR_SETS=0 export ALLOWED_HOSTS_MODE=0 ### Список IP адресов хостов для фильтра, через пробел (прим.: 192.168.0.10 192.168.0.15) export ALLOWED_HOSTS_LIST="" -### VPN интерфейс для правил iptables +### VPN интерфейс для правил маршрутизации export IF_VPN="tun0" ### Порт транспарентного proxy Tor (параметр TransPort в torrc) export TOR_TRANS_PORT=9040 @@ -183,7 +184,6 @@ if [ $ENABLE_LOGGING = "1" -a $? -ne 0 ]; then ENABLE_LOGGING=0 fi LOGGER_PARAMS="-t `basename $0` -p user.notice" -export DNSMASQ_DATA_FILE="${DATA_DIR}/${NAME}.dnsmasq" export IP_DATA_FILE="${DATA_DIR}/${NAME}.ip" export IPSET_ALLOWED_HOSTS="${NAME}_allowed_ip" export IPSET_IP="${NAME}_ip" @@ -213,9 +213,9 @@ fi Help() { cat << EOF - Usage: `basename $0` start|force-start|stop|destroy|restart|update|force-update|data-files|renew-ipt|status|status-html|--help + Usage: `basename $0` start|force-start|stop|destroy|restart|update|force-update|data-files|status|status-html|help start : Start - force-start : + force-start : Removing the pid-file before running stop : Stop destroy : Stop + destroy ipsets and clear all data files restart : Restart @@ -226,7 +226,7 @@ cat << EOF status : Status & some info raw-status : Return code: 0 - enabled, 1 - error, 2 - disabled, 3 - starting, 4 - updating html-info : Return the html-info output - -h|--help : This message + -h|--help|help : This message Examples: `basename $0` start `basename $0` force-start @@ -288,7 +288,7 @@ AddIptRules() { } DelIptRules() { - IptLocalClientsDel + IptLocalClientsDel IptMainDel }