mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-13 22:20:59 +00:00
Packages
This commit is contained in:
+104
-129
@@ -8,79 +8,54 @@ RAM_CONFIG=0
|
||||
LUA_MODULE=1
|
||||
LUCI_APP=1
|
||||
|
||||
### ruantiblock
|
||||
URL_CONFIG="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/ruantiblock.conf"
|
||||
URL_FQDN_FILTER="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/fqdn_filter"
|
||||
URL_CONFIG_SCRIPT="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/scripts/config_script"
|
||||
URL_INFO_OUTPUT="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/scripts/info_output"
|
||||
URL_IPT_FUNCTIONS="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/scripts/ipt_functions"
|
||||
URL_START_SCRIPT="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/ruantiblock/scripts/start_script"
|
||||
URL_UCI_CONFIG="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/config/ruantiblock"
|
||||
URL_INIT_SCRIPT="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/init.d/ruantiblock"
|
||||
URL_MAIN_SCRIPT="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/usr/bin/ruantiblock"
|
||||
URL_VPN_UP="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock/files/etc/hotplug.d/iface/40-ruantiblock"
|
||||
OWRT_VERSION="19.07"
|
||||
RUAB_VERSION="0.9.0-1"
|
||||
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master"
|
||||
PKG_DIR="/tmp"
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
OWRT_VERSION="$1"
|
||||
fi
|
||||
|
||||
### URLs
|
||||
|
||||
### packages
|
||||
URL_RUAB_PKG="${BASE_URL}/packages/${OWRT_VERSION}/ruantiblock_${RUAB_VERSION}_all.ipk"
|
||||
URL_MOD_LUA_PKG="${BASE_URL}/packages/${OWRT_VERSION}/ruantiblock-mod-lua_${RUAB_VERSION}_all.ipk"
|
||||
URL_LUCI_APP_PKG="${BASE_URL}/packages/${OWRT_VERSION}/luci-app-ruantiblock_${RUAB_VERSION}_all.ipk"
|
||||
URL_LUCI_APP_RU_PKG="${BASE_URL}/packages/${OWRT_VERSION}/luci-i18n-ruantiblock-ru_${RUAB_VERSION}_all.ipk"
|
||||
### tor
|
||||
URL_TORRC="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/tor/etc/tor/torrc"
|
||||
URL_TORRC="${BASE_URL}/tor/etc/tor/torrc"
|
||||
### ruantiblock-mod-lua
|
||||
URL_PARSER_LUA="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock-mod-lua/files/usr/bin/ruab_parser.lua"
|
||||
URL_LUA_IPTOOL="https://raw.githubusercontent.com/gSpotx2f/iptool-lua/master/5.1/iptool.lua"
|
||||
URL_LUA_SUM_IP="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/ruantiblock-mod-lua/files/usr/lib/lua/ruab_sum_ip.lua"
|
||||
URL_LUA_IDN="https://raw.githubusercontent.com/haste/lua-idn/master/idn.lua"
|
||||
### luci-app-ruantiblock
|
||||
URL_LUCI_CONTROLLER="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/luasrc/controller/ruantiblock.lua"
|
||||
URL_LUCI_MENU="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/root/usr/share/luci/menu.d/luci-app-ruantiblock.json"
|
||||
URL_LUCI_RPCD_ACL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json"
|
||||
URL_LUCI_JS_CRON="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/cron.js"
|
||||
URL_LUCI_JS_INFO="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/info.js"
|
||||
URL_LUCI_JS_SERVICE="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/service.js"
|
||||
URL_LUCI_JS_SETTINGS="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js"
|
||||
URL_LUCI_JS_TOOLS="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/tools.js"
|
||||
URL_LUCI_JS_LOG="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/log.js"
|
||||
URL_LUCI_JS_STATUS="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/luci-app-ruantiblock/htdocs/luci-static/resources/view/status/include/80_ruantiblock.js"
|
||||
URL_LUCI_I18N_RU="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_openwrt/master/translations/ruantiblock.ru.lmo"
|
||||
|
||||
### Local files
|
||||
|
||||
RUAB_CFG_DIR="${PREFIX}/etc/ruantiblock"
|
||||
EXEC_DIR="${PREFIX}/usr/bin"
|
||||
LUCI_ROOT="${PREFIX}/usr/lib/lua/luci"
|
||||
HTDOCS_VIEW="${PREFIX}/www/luci-static/resources/view"
|
||||
HTDOCS_RUAB="${HTDOCS_VIEW}/ruantiblock"
|
||||
BACKUP_DIR="${RUAB_CFG_DIR}/autoinstall.bak"
|
||||
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_VERSION}_all.ipk"
|
||||
FILE_LUCI_APP_PKG="${PKG_DIR}/luci-app-ruantiblock_${RUAB_VERSION}_all.ipk"
|
||||
FILE_LUCI_APP_RU_PKG="${PKG_DIR}/luci-i18n-ruantiblock-ru_${RUAB_VERSION}_all.ipk"
|
||||
### ruantiblock
|
||||
FILE_CONFIG="${RUAB_CFG_DIR}/ruantiblock.conf"
|
||||
FILE_FQDN_FILTER="${RUAB_CFG_DIR}/fqdn_filter"
|
||||
FILE_IP_FILTER="${RUAB_CFG_DIR}/ip_filter"
|
||||
FILE_USER_ENTRIES="${RUAB_CFG_DIR}/user_entries"
|
||||
FILE_CONFIG_SCRIPT="${RUAB_CFG_DIR}/scripts/config_script"
|
||||
FILE_INFO_OUTPUT="${RUAB_CFG_DIR}/scripts/info_output"
|
||||
FILE_IPT_FUNCTIONS="${RUAB_CFG_DIR}/scripts/ipt_functions"
|
||||
FILE_START_SCRIPT="${RUAB_CFG_DIR}/scripts/start_script"
|
||||
FILE_UCI_CONFIG="${PREFIX}/etc/config/ruantiblock"
|
||||
FILE_INIT_SCRIPT="${PREFIX}/etc/init.d/ruantiblock"
|
||||
FILE_MAIN_SCRIPT="${EXEC_DIR}/ruantiblock"
|
||||
FILE_VPN_UP="${PREFIX}/etc/hotplug.d/iface/40-ruantiblock"
|
||||
### tor
|
||||
FILE_TORRC="${PREFIX}/etc/tor/torrc"
|
||||
### ruantiblock-mod-lua
|
||||
FILE_PARSER_LUA="${EXEC_DIR}/ruab_parser.lua"
|
||||
FILE_LUA_IPTOOL="${PREFIX}/usr/lib/lua/iptool.lua"
|
||||
FILE_LUA_SUM_IP="${PREFIX}/usr/lib/lua/ruab_sum_ip.lua"
|
||||
FILE_LUA_IDN="${PREFIX}/usr/lib/lua/idn.lua"
|
||||
### luci-app-ruantiblock
|
||||
FILE_LUCI_CONTROLLER="${LUCI_ROOT}/controller/ruantiblock.lua"
|
||||
FILE_LUCI_I18N_RU="${LUCI_ROOT}/i18n/ruantiblock.ru.lmo"
|
||||
FILE_LUCI_MENU="${PREFIX}/usr/share/luci/menu.d/luci-app-ruantiblock.json"
|
||||
FILE_LUCI_RPCD_ACL="${PREFIX}/usr/share/rpcd/acl.d/luci-app-ruantiblock.json"
|
||||
FILE_LUCI_JS_CRON="${HTDOCS_RUAB}/cron.js"
|
||||
FILE_LUCI_JS_INFO="${HTDOCS_RUAB}/info.js"
|
||||
FILE_LUCI_JS_SERVICE="${HTDOCS_RUAB}/service.js"
|
||||
FILE_LUCI_JS_SETTINGS="${HTDOCS_RUAB}/settings.js"
|
||||
FILE_LUCI_JS_TOOLS="${HTDOCS_RUAB}/tools.js"
|
||||
FILE_LUCI_JS_LOG="${HTDOCS_RUAB}/log.js"
|
||||
FILE_LUCI_JS_STATUS="${HTDOCS_VIEW}/status/include/80_ruantiblock.js"
|
||||
|
||||
AWK_CMD="awk"
|
||||
WGET_CMD=`which wget`
|
||||
@@ -100,20 +75,6 @@ if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
InstallPackages() {
|
||||
local _pkg
|
||||
for _pkg in $@
|
||||
do
|
||||
if [ -z "`$OPKG_CMD list-installed $_pkg`" ]; then
|
||||
$OPKG_CMD --force-overwrite install $_pkg
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error during installation of the package (${_pkg})" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
FileExists() {
|
||||
test -e "$1"
|
||||
}
|
||||
@@ -130,8 +91,11 @@ ChmodExec() {
|
||||
chmod 755 "$1"
|
||||
}
|
||||
|
||||
UpdatePackagesList() {
|
||||
$OPKG_CMD update
|
||||
RemoveFile() {
|
||||
if [ -e "$1" ]; then
|
||||
echo "Removing ${1}"
|
||||
rm -f "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
DlFile() {
|
||||
@@ -164,18 +128,61 @@ BackupCurrentConfig() {
|
||||
done
|
||||
}
|
||||
|
||||
RunAtStartup() {
|
||||
$FILE_INIT_SCRIPT enable
|
||||
}
|
||||
|
||||
AppStop() {
|
||||
FileExists "$FILE_MAIN_SCRIPT" && $FILE_MAIN_SCRIPT destroy
|
||||
}
|
||||
|
||||
AppStart() {
|
||||
modprobe ip_set > /dev/null
|
||||
modprobe ip_set_hash_ip > /dev/null
|
||||
modprobe ip_set_hash_net > /dev/null
|
||||
modprobe ip_set_list_set > /dev/null
|
||||
modprobe xt_set > /dev/null
|
||||
$FILE_INIT_SCRIPT start
|
||||
}
|
||||
|
||||
SetCronTask() {
|
||||
echo "0 3 */3 * * ${FILE_MAIN_SCRIPT} update" >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart 2> /dev/null
|
||||
/etc/init.d/cron enable
|
||||
}
|
||||
|
||||
Reboot() {
|
||||
reboot
|
||||
}
|
||||
|
||||
UpdatePackagesList() {
|
||||
$OPKG_CMD update
|
||||
}
|
||||
|
||||
InstallPackages() {
|
||||
local _pkg
|
||||
for _pkg in $@
|
||||
do
|
||||
if [ -z "`$OPKG_CMD list-installed $_pkg`" ]; then
|
||||
$OPKG_CMD --force-overwrite install $_pkg
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error during installation of the package (${_pkg})" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
:
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
InstallBaseConfig() {
|
||||
_return_code=1
|
||||
InstallPackages "ipset" "kmod-ipt-ipset" "dnsmasq-full"
|
||||
DlFile "$URL_CONFIG" "$FILE_CONFIG"
|
||||
DlFile "$URL_FQDN_FILTER" "$FILE_FQDN_FILTER"
|
||||
DlFile "$URL_CONFIG_SCRIPT" "$FILE_CONFIG_SCRIPT"
|
||||
DlFile "$URL_INFO_OUTPUT" "$FILE_INFO_OUTPUT"
|
||||
DlFile "$URL_IPT_FUNCTIONS" "$FILE_IPT_FUNCTIONS"
|
||||
DlFile "$URL_START_SCRIPT" "$FILE_START_SCRIPT" && ChmodExec "$FILE_START_SCRIPT"
|
||||
DlFile "$URL_UCI_CONFIG" "$FILE_UCI_CONFIG"
|
||||
DlFile "$URL_INIT_SCRIPT" "$FILE_INIT_SCRIPT" && ChmodExec "$FILE_INIT_SCRIPT"
|
||||
DlFile "$URL_MAIN_SCRIPT" "$FILE_MAIN_SCRIPT" && ChmodExec "$FILE_MAIN_SCRIPT"
|
||||
DlFile "$URL_VPN_UP" "$FILE_VPN_UP" && ChmodExec "$FILE_VPN_UP"
|
||||
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
|
||||
}
|
||||
|
||||
InstallVPNConfig() {
|
||||
@@ -229,60 +236,25 @@ RamConfigPrepare() {
|
||||
|
||||
InstallLuaModule() {
|
||||
InstallPackages "lua" "luasocket" "luasec" "luabitop"
|
||||
DlFile "$URL_PARSER_LUA" "$FILE_PARSER_LUA" && ChmodExec "$FILE_PARSER_LUA"
|
||||
DlFile "$URL_LUA_IPTOOL" "$FILE_LUA_IPTOOL"
|
||||
DlFile "$URL_LUA_SUM_IP" "$FILE_LUA_SUM_IP"
|
||||
RemoveFile "$FILE_MOD_LUA_PKG" > /dev/null
|
||||
DlFile "$URL_MOD_LUA_PKG" "$FILE_MOD_LUA_PKG" && $OPKG_CMD install "$FILE_MOD_LUA_PKG"
|
||||
FileExists "$FILE_LUA_IPTOOL" || DlFile "$URL_LUA_IPTOOL" "$FILE_LUA_IPTOOL"
|
||||
FileExists "$FILE_LUA_IDN" || DlFile "$URL_LUA_IDN" "$FILE_LUA_IDN"
|
||||
$UCI_CMD set ruantiblock.config.bllist_module="/usr/bin/ruab_parser.lua"
|
||||
$UCI_CMD commit
|
||||
}
|
||||
|
||||
InstallLuciApp() {
|
||||
InstallPackages "luci-mod-rpc" "rpcd-mod-luci" "uhttpd-mod-ubus"
|
||||
DlFile "$URL_LUCI_CONTROLLER" "$FILE_LUCI_CONTROLLER"
|
||||
DlFile "$URL_LUCI_I18N_RU" "$FILE_LUCI_I18N_RU"
|
||||
DlFile "$URL_LUCI_MENU" "$FILE_LUCI_MENU"
|
||||
DlFile "$URL_LUCI_RPCD_ACL" "$FILE_LUCI_RPCD_ACL"
|
||||
DlFile "$URL_LUCI_JS_CRON" "$FILE_LUCI_JS_CRON"
|
||||
DlFile "$URL_LUCI_JS_INFO" "$FILE_LUCI_JS_INFO"
|
||||
DlFile "$URL_LUCI_JS_SERVICE" "$FILE_LUCI_JS_SERVICE"
|
||||
DlFile "$URL_LUCI_JS_SETTINGS" "$FILE_LUCI_JS_SETTINGS"
|
||||
DlFile "$URL_LUCI_JS_TOOLS" "$FILE_LUCI_JS_TOOLS"
|
||||
DlFile "$URL_LUCI_JS_LOG" "$FILE_LUCI_JS_LOG"
|
||||
DlFile "$URL_LUCI_JS_STATUS" "$FILE_LUCI_JS_STATUS"
|
||||
RemoveFile "$FILE_LUCI_APP_PKG" > /dev/null
|
||||
RemoveFile "$FILE_LUCI_APP_RU_PKG" > /dev/null
|
||||
DlFile "$URL_LUCI_APP_PKG" "$FILE_LUCI_APP_PKG" && $OPKG_CMD install "$FILE_LUCI_APP_PKG" && \
|
||||
DlFile "$URL_LUCI_APP_RU_PKG" "$FILE_LUCI_APP_RU_PKG" && $OPKG_CMD install "$FILE_LUCI_APP_RU_PKG"
|
||||
rm -f /tmp/luci-modulecache/*
|
||||
rm -f /tmp/luci-indexcache
|
||||
/etc/init.d/rpcd restart
|
||||
/etc/init.d/uhttpd restart
|
||||
}
|
||||
|
||||
RunAtStartup() {
|
||||
$FILE_INIT_SCRIPT enable
|
||||
}
|
||||
|
||||
AppStop() {
|
||||
FileExists "$FILE_MAIN_SCRIPT" && $FILE_MAIN_SCRIPT destroy
|
||||
}
|
||||
|
||||
AppStart() {
|
||||
modprobe ip_set > /dev/null
|
||||
modprobe ip_set_hash_ip > /dev/null
|
||||
modprobe ip_set_hash_net > /dev/null
|
||||
modprobe ip_set_list_set > /dev/null
|
||||
modprobe xt_set > /dev/null
|
||||
$FILE_INIT_SCRIPT start
|
||||
}
|
||||
|
||||
SetCronTask() {
|
||||
echo "0 3 */3 * * ${FILE_MAIN_SCRIPT} update" >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart 2> /dev/null
|
||||
/etc/init.d/cron enable
|
||||
}
|
||||
|
||||
Reboot() {
|
||||
reboot
|
||||
}
|
||||
|
||||
PrintBold() {
|
||||
printf "\033[1m - ${1}\033[0m\n"
|
||||
}
|
||||
@@ -400,7 +372,6 @@ ConfirmProxyMode
|
||||
ConfirmRamConfig
|
||||
ConfirmLuciApp
|
||||
ConfirmProcessing
|
||||
|
||||
AppStop
|
||||
PrintBold "Updating packages list..."
|
||||
UpdatePackagesList
|
||||
@@ -408,34 +379,38 @@ PrintBold "Saving current configuration..."
|
||||
BackupCurrentConfig
|
||||
PrintBold "Installing basic configuration..."
|
||||
InstallBaseConfig
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
if [ $PROXY_MODE = 2 ]; then
|
||||
if [ $PROXY_MODE = 2 ]; then
|
||||
PrintBold "Installing VPN configuration..."
|
||||
InstallVPNConfig
|
||||
else
|
||||
else
|
||||
PrintBold "Installing Tor configuration..."
|
||||
InstallTorConfig
|
||||
if `/etc/init.d/tor enabled`; then
|
||||
/etc/init.d/tor restart
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $RAM_CONFIG = 1 ]; then
|
||||
if [ $RAM_CONFIG = 1 ]; then
|
||||
PrintBold "Setting the RAM-configuration..."
|
||||
RamConfigPrepare
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $LUA_MODULE = 1 ]; then
|
||||
if [ $LUA_MODULE = 1 ]; then
|
||||
PrintBold "Installing lua module..."
|
||||
InstallLuaModule
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $LUCI_APP = 1 ]; then
|
||||
if [ $LUCI_APP = 1 ]; then
|
||||
PrintBold "Installing luci app..."
|
||||
InstallLuciApp
|
||||
fi
|
||||
|
||||
RunAtStartup
|
||||
SetCronTask
|
||||
else
|
||||
PrintBold "An error occurred while installing the ruantiblock package!"
|
||||
fi
|
||||
|
||||
RunAtStartup
|
||||
SetCronTask
|
||||
|
||||
exit 0
|
||||
|
||||
+30
-78
@@ -2,9 +2,10 @@
|
||||
|
||||
PREFIX=""
|
||||
|
||||
### Local files
|
||||
|
||||
RUAB_CFG_DIR="${PREFIX}/etc/ruantiblock"
|
||||
EXEC_DIR="${PREFIX}/usr/bin"
|
||||
LUCI_ROOT="${PREFIX}/usr/lib/lua/luci"
|
||||
HTDOCS_VIEW="${PREFIX}/www/luci-static/resources/view"
|
||||
HTDOCS_RUAB="${HTDOCS_VIEW}/ruantiblock"
|
||||
CRONTAB_FILE="/etc/crontabs/root"
|
||||
@@ -12,45 +13,19 @@ DATA_DIR="${RUAB_CFG_DIR}/var"
|
||||
DATA_DIR_RAM="/var/ruantiblock"
|
||||
RC_LOCAL="/etc/rc.local"
|
||||
DNSMASQ_CONF_LINK="/tmp/dnsmasq.d/ruantiblock.conf"
|
||||
|
||||
### ruantiblock
|
||||
FILE_CONFIG="${RUAB_CFG_DIR}/ruantiblock.conf"
|
||||
FILE_FQDN_FILTER="${RUAB_CFG_DIR}/fqdn_filter"
|
||||
FILE_IP_FILTER="${RUAB_CFG_DIR}/ip_filter"
|
||||
FILE_USER_ENTRIES="${RUAB_CFG_DIR}/user_entries"
|
||||
FILE_CONFIG_SCRIPT="${RUAB_CFG_DIR}/scripts/config_script"
|
||||
FILE_INFO_OUTPUT="${RUAB_CFG_DIR}/scripts/info_output"
|
||||
FILE_IPT_FUNCTIONS="${RUAB_CFG_DIR}/scripts/ipt_functions"
|
||||
FILE_START_SCRIPT="${RUAB_CFG_DIR}/scripts/start_script"
|
||||
FILE_STOP_SCRIPT="${RUAB_CFG_DIR}/scripts/stop_script"
|
||||
FILE_UCI_CONFIG="${PREFIX}/etc/config/ruantiblock"
|
||||
FILE_INIT_SCRIPT="${PREFIX}/etc/init.d/ruantiblock"
|
||||
FILE_MAIN_SCRIPT="${EXEC_DIR}/ruantiblock"
|
||||
FILE_VPN_UP="${PREFIX}/etc/hotplug.d/iface/40-ruantiblock"
|
||||
### tor
|
||||
FILE_TORRC="${PREFIX}/etc/tor/torrc"
|
||||
### ruantiblock-mod-lua
|
||||
FILE_PARSER_LUA="${EXEC_DIR}/ruab_parser.lua"
|
||||
FILE_LUA_IPTOOL="${PREFIX}/usr/lib/lua/iptool.lua"
|
||||
FILE_LUA_SUM_IP="${PREFIX}/usr/lib/lua/ruab_sum_ip.lua"
|
||||
FILE_LUA_IDN="${PREFIX}/usr/lib/lua/idn.lua"
|
||||
### ruantiblock-mod-py
|
||||
FILE_PARSER_PY="${EXEC_DIR}/ruab_parser.py"
|
||||
FILE_PY_SUM_IP="${PREFIX}/usr/lib/python3.7/ruab_sum_ip.py"
|
||||
### luci-app-ruantiblock
|
||||
FILE_LUCI_CONTROLLER="${LUCI_ROOT}/controller/ruantiblock.lua"
|
||||
FILE_LUCI_I18N_RU="${LUCI_ROOT}/i18n/ruantiblock.ru.lmo"
|
||||
FILE_LUCI_MENU="${PREFIX}/usr/share/luci/menu.d/luci-app-ruantiblock.json"
|
||||
FILE_LUCI_RPCD_ACL="${PREFIX}/usr/share/rpcd/acl.d/luci-app-ruantiblock.json"
|
||||
FILE_LUCI_JS_CRON="${HTDOCS_RUAB}/cron.js"
|
||||
FILE_LUCI_JS_INFO="${HTDOCS_RUAB}/info.js"
|
||||
FILE_LUCI_JS_SERVICE="${HTDOCS_RUAB}/service.js"
|
||||
FILE_LUCI_JS_SETTINGS="${HTDOCS_RUAB}/settings.js"
|
||||
FILE_LUCI_JS_TOOLS="${HTDOCS_RUAB}/tools.js"
|
||||
FILE_LUCI_JS_LOG="${HTDOCS_RUAB}/log.js"
|
||||
FILE_LUCI_JS_STATUS="${HTDOCS_VIEW}/status/include/80_ruantiblock.js"
|
||||
|
||||
AWK_CMD="awk"
|
||||
OPKG_CMD=`which opkg`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " Error! opkg doesn't exists" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FileExists() {
|
||||
test -e "$1"
|
||||
@@ -63,51 +38,6 @@ RemoveFile() {
|
||||
fi
|
||||
}
|
||||
|
||||
RestoreTorConfig() {
|
||||
[ -e "${FILE_TORRC}.bak" ] && mv -f "${FILE_TORRC}.bak" "$FILE_TORRC"
|
||||
if `/etc/init.d/tor enabled`; then
|
||||
/etc/init.d/tor restart
|
||||
fi
|
||||
}
|
||||
|
||||
RemoveAppFiles() {
|
||||
RestoreTorConfig
|
||||
rm -rf "$DATA_DIR"
|
||||
rm -rf "$DATA_DIR_RAM"
|
||||
RemoveFile "$FILE_VPN_UP"
|
||||
RemoveFile "$FILE_CONFIG_SCRIPT"
|
||||
RemoveFile "$FILE_INFO_OUTPUT"
|
||||
RemoveFile "$FILE_IPT_FUNCTIONS"
|
||||
RemoveFile "$FILE_START_SCRIPT"
|
||||
RemoveFile "$FILE_STOP_SCRIPT"
|
||||
rmdir "${RUAB_CFG_DIR}/scripts" 2> /dev/null
|
||||
RemoveFile "$FILE_UCI_CONFIG"
|
||||
RemoveFile "$FILE_INIT_SCRIPT"
|
||||
RemoveFile "$FILE_MAIN_SCRIPT"
|
||||
RemoveFile "$FILE_SEARCH_SCRIPT"
|
||||
RemoveFile "$FILE_PARSER_LUA"
|
||||
RemoveFile "$FILE_LUA_IPTOOL"
|
||||
RemoveFile "$FILE_LUA_SUM_IP"
|
||||
RemoveFile "$FILE_PARSER_PY"
|
||||
RemoveFile "$FILE_PY_SUM_IP"
|
||||
RemoveFile "$FILE_LUCI_CONTROLLER"
|
||||
RemoveFile "$FILE_LUCI_I18N_RU"
|
||||
RemoveFile "$FILE_LUCI_MENU"
|
||||
RemoveFile "$FILE_LUCI_RPCD_ACL"
|
||||
RemoveFile "$FILE_LUCI_JS_CRON"
|
||||
RemoveFile "$FILE_LUCI_JS_INFO"
|
||||
RemoveFile "$FILE_LUCI_JS_SERVICE"
|
||||
RemoveFile "$FILE_LUCI_JS_SETTINGS"
|
||||
RemoveFile "$FILE_LUCI_JS_TOOLS"
|
||||
RemoveFile "$FILE_LUCI_JS_LOG"
|
||||
RemoveFile "$FILE_LUCI_JS_STATUS"
|
||||
rmdir "$HTDOCS_RUAB" 2> /dev/null
|
||||
rm -f /tmp/luci-modulecache/*
|
||||
rm -f /tmp/luci-indexcache
|
||||
/etc/init.d/rpcd restart
|
||||
/etc/init.d/uhttpd restart
|
||||
}
|
||||
|
||||
AppStop() {
|
||||
rm -f $DNSMASQ_CONF_LINK
|
||||
FileExists "$FILE_MAIN_SCRIPT" && $FILE_MAIN_SCRIPT destroy
|
||||
@@ -130,13 +60,35 @@ RemoveRcLocalEntry() {
|
||||
}' "$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
|
||||
if `/etc/init.d/tor enabled`; then
|
||||
/etc/init.d/tor restart
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
rmdir "${RUAB_CFG_DIR}/scripts" 2> /dev/null
|
||||
rmdir "$HTDOCS_RUAB" 2> /dev/null
|
||||
rm -f /tmp/luci-modulecache/*
|
||||
rm -f /tmp/luci-indexcache
|
||||
/etc/init.d/rpcd restart
|
||||
/etc/init.d/uhttpd restart
|
||||
}
|
||||
|
||||
InputError () {
|
||||
printf "\033[1;31m Wrong input! Try again...\033[m\n"; $1
|
||||
}
|
||||
|
||||
ConfirmRemove() {
|
||||
local _reply
|
||||
printf " Files will be removed... Continue? [y|n] (default: y, quit: q) > "
|
||||
printf " Application will be removed... Continue? [y|n] (default: y, quit: q) > "
|
||||
read _reply
|
||||
case $_reply in
|
||||
y|Y|"")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=0.9.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_TITLE:=LuCI support for ruantiblock
|
||||
LUCI_DEPENDS:=+ruantiblock +luci-mod-admin-full
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include ../../luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=0.9.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_TITLE:=Translation for luci-app-ruantiblock - Русский (Russian)
|
||||
LUCI_DEPENDS:=+luci-app-ruantiblock
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include ../../luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock-mod-lua
|
||||
PKG_VERSION:=0.9.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Lua module for ruantiblock
|
||||
URL:=https://github.com/gSpotx2f/ruantiblock_openwrt
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+ruantiblock +lua +luasocket +luasec +luabitop +iconv +idn
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(CP) -r ./files $(PKG_BUILD_DIR)/files
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/usr/bin/ruab_parser.lua $(1)/usr/bin/ruab_parser.lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/usr/lib/lua/ruab_sum_ip.lua $(1)/usr/lib/lua/ruab_sum_ip.lua
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock-mod-py
|
||||
PKG_VERSION:=0.9.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Python module for ruantiblock
|
||||
URL:=https://github.com/gSpotx2f/ruantiblock_openwrt
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+ruantiblock +python3 +python3-setuptools +python3-openssl
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(CP) -r ./files $(PKG_BUILD_DIR)/files
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/usr/bin/ruab_parser.py $(1)/usr/bin/ruab_parser.py
|
||||
$(INSTALL_DIR) $(1)/usr/lib/python3.7
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/usr/lib/python3.7/ruab_sum_ip.py $(1)/usr/lib/python3.7/ruab_sum_ip.py
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -0,0 +1,112 @@
|
||||
#
|
||||
# (с) 2020 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock
|
||||
PKG_VERSION:=0.9.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Ruantiblock
|
||||
URL:=https://github.com/gSpotx2f/ruantiblock_openwrt
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+wget +ipset +kmod-ipt-ipset +dnsmasq-full
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/ruantiblock
|
||||
/etc/ruantiblock/fqdn_filter
|
||||
/etc/ruantiblock/ip_filter
|
||||
/etc/ruantiblock/user_entries
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(CP) -r ./files $(PKG_BUILD_DIR)/files
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/usr/bin/ruantiblock $(1)/usr/bin/ruantiblock
|
||||
$(INSTALL_DIR) $(1)/etc/ruantiblock
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/files/etc/ruantiblock/ruantiblock.conf $(1)/etc/ruantiblock/ruantiblock.conf
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/files/etc/ruantiblock/fqdn_filter $(1)/etc/ruantiblock/fqdn_filter
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/hotplug.d/iface/40-ruantiblock $(1)/etc/hotplug.d/iface/40-ruantiblock
|
||||
$(INSTALL_DIR) $(1)/etc/ruantiblock/scripts
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/etc/ruantiblock/scripts/config_script $(1)/etc/ruantiblock/scripts/config_script
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/etc/ruantiblock/scripts/info_output $(1)/etc/ruantiblock/scripts/info_output
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/files/etc/ruantiblock/scripts/ipt_functions $(1)/etc/ruantiblock/scripts/ipt_functions
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/ruantiblock/scripts/start_script $(1)/etc/ruantiblock/scripts/start_script
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/files/etc/config/ruantiblock $(1)/etc/config/ruantiblock
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/init.d/ruantiblock $(1)/etc/init.d/ruantiblock
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/preinst
|
||||
#!/bin/sh
|
||||
|
||||
RUAB_CFG_DIR="/etc/ruantiblock"
|
||||
EXEC_DIR="/usr/bin"
|
||||
BACKUP_DIR="$${RUAB_CFG_DIR}/autoinstall.bak"
|
||||
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"
|
||||
|
||||
|
||||
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
|
||||
|
||||
EXEC_DIR="/usr/bin"
|
||||
FILE_INIT_SCRIPT="/etc/init.d/ruantiblock"
|
||||
FILE_MAIN_SCRIPT="$${EXEC_DIR}/ruantiblock"
|
||||
CRONTAB_FILE="/etc/crontabs/root"
|
||||
RC_LOCAL="/etc/rc.local"
|
||||
DNSMASQ_CONF_LINK="/tmp/dnsmasq.d/ruantiblock.conf"
|
||||
|
||||
|
||||
rm -f $$DNSMASQ_CONF_LINK
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
Reference in New Issue
Block a user