v0.9.3. DATA_DIR moved to /tmp

This commit is contained in:
gSpot
2022-05-10 01:22:25 +03:00
parent bbfc6595e3
commit fa22fdbe2a
17 changed files with 68 additions and 114 deletions
+4 -49
View File
@@ -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
+5 -15
View File
@@ -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
+1 -1
View File
@@ -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
@@ -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;
}
@@ -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);
};
});
},
@@ -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 "Обновление"
@@ -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 ""
@@ -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" ]
},
+1 -1
View File
@@ -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 <https://github.com/gSpotx2f/ruantiblock_openwrt>
+1 -1
View File
@@ -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 <https://github.com/gSpotx2f/ruantiblock_openwrt>
+5 -20
View File
@@ -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
+1
View File
@@ -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'
+16 -6
View File
@@ -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"`
+7 -7
View File
@@ -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