mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-14 14:40:58 +00:00
v0.9.3. DATA_DIR moved to /tmp
This commit is contained in:
+5
-20
@@ -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 <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
_link="/tmp/dnsmasq.d/ruantiblock.conf"
|
||||
ln -fs $DNSMASQ_DATA_FILE $_link
|
||||
eval `echo "$DNSMASQ_RESTART_CMD"`
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user