mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
luci-app-adguardhome: fix path error if core download from the Internet
Signed-off-by: Tianling Shen <cnsztl@project-openwrt.eu.org>
This commit is contained in:
parent
1706e45bc7
commit
d087251fed
@ -14,7 +14,7 @@ entry({"admin", "services", "AdGuardHome", "getlog"}, call("get_log"))
|
|||||||
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
|
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
|
||||||
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
|
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
|
||||||
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
|
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
|
||||||
end
|
end
|
||||||
function get_template_config()
|
function get_template_config()
|
||||||
local b
|
local b
|
||||||
local d=""
|
local d=""
|
||||||
|
@ -5,7 +5,7 @@ local m,s,o,o1
|
|||||||
local fs=require"nixio.fs"
|
local fs=require"nixio.fs"
|
||||||
local uci=require"luci.model.uci".cursor()
|
local uci=require"luci.model.uci".cursor()
|
||||||
local configpath=uci:get("AdGuardHome","AdGuardHome","configpath") or "/etc/AdGuardHome.yaml"
|
local configpath=uci:get("AdGuardHome","AdGuardHome","configpath") or "/etc/AdGuardHome.yaml"
|
||||||
local binpath=uci:get("AdGuardHome","AdGuardHome","binpath") or "/usr/bin/AdGuardHome/AdGuardHome"
|
local binpath=uci:get("AdGuardHome","AdGuardHome","binpath") or "/usr/bin/AdGuardHome"
|
||||||
httpport=uci:get("AdGuardHome","AdGuardHome","httpport") or "3000"
|
httpport=uci:get("AdGuardHome","AdGuardHome","httpport") or "3000"
|
||||||
m = Map("AdGuardHome", "AdGuard Home")
|
m = Map("AdGuardHome", "AdGuard Home")
|
||||||
m.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
|
m.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
|
||||||
@ -65,7 +65,7 @@ o.default = "none"
|
|||||||
o.optional = true
|
o.optional = true
|
||||||
---- bin path
|
---- bin path
|
||||||
o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
|
o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
|
||||||
o.default = "/usr/bin/AdGuardHome/AdGuardHome"
|
o.default = "/usr/bin/AdGuardHome"
|
||||||
o.datatype = "string"
|
o.datatype = "string"
|
||||||
o.optional = false
|
o.optional = false
|
||||||
o.rmempty=false
|
o.rmempty=false
|
||||||
@ -81,7 +81,7 @@ if fs.stat(value,"type")=="dir" then
|
|||||||
m.message ="error!bin path is a dir"
|
m.message ="error!bin path is a dir"
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
--- upx
|
--- upx
|
||||||
@ -113,12 +113,12 @@ if fs.stat(value,"type")=="dir" then
|
|||||||
m.message ="error!config path is a dir"
|
m.message ="error!config path is a dir"
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
---- work dir
|
---- work dir
|
||||||
o = s:option(Value, "workdir", translate("Work dir"), translate("AdGuardHome work dir include rules,audit log and database"))
|
o = s:option(Value, "workdir", translate("Work dir"), translate("AdGuardHome work dir include rules,audit log and database"))
|
||||||
o.default = "/usr/bin/AdGuardHome"
|
o.default = "/etc/AdGuardHome"
|
||||||
o.datatype = "string"
|
o.datatype = "string"
|
||||||
o.optional = false
|
o.optional = false
|
||||||
o.rmempty=false
|
o.rmempty=false
|
||||||
@ -131,7 +131,7 @@ if fs.stat(value,"type")=="reg" then
|
|||||||
m.message ="error!work dir is a file"
|
m.message ="error!work dir is a file"
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if string.sub(value, -1)=="/" then
|
if string.sub(value, -1)=="/" then
|
||||||
return string.sub(value, 1, -2)
|
return string.sub(value, 1, -2)
|
||||||
else
|
else
|
||||||
@ -153,14 +153,14 @@ if fs.stat(value,"type")=="dir" then
|
|||||||
m.message ="error!log file is a dir"
|
m.message ="error!log file is a dir"
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
---- debug
|
---- debug
|
||||||
o = s:option(Flag, "verbose", translate("Verbose log"))
|
o = s:option(Flag, "verbose", translate("Verbose log"))
|
||||||
o.default = 0
|
o.default = 0
|
||||||
o.optional = true
|
o.optional = true
|
||||||
---- gfwlist
|
---- gfwlist
|
||||||
local a=luci.sys.call("grep -m 1 -q programadd "..configpath)
|
local a=luci.sys.call("grep -m 1 -q programadd "..configpath)
|
||||||
if (a==0) then
|
if (a==0) then
|
||||||
a="Added"
|
a="Added"
|
||||||
@ -208,7 +208,7 @@ o = s:option(Flag, "waitonboot", translate("On boot when network ok restart"))
|
|||||||
o.default = 1
|
o.default = 1
|
||||||
o.optional = true
|
o.optional = true
|
||||||
---- backup workdir on shutdown
|
---- backup workdir on shutdown
|
||||||
local workdir=uci:get("AdGuardHome","AdGuardHome","workdir") or "/usr/bin/AdGuardHome"
|
local workdir=uci:get("AdGuardHome","AdGuardHome","workdir") or "/etc/AdGuardHome"
|
||||||
o = s:option(MultiValue, "backupfile", translate("Backup workdir files when shutdown"))
|
o = s:option(MultiValue, "backupfile", translate("Backup workdir files when shutdown"))
|
||||||
o1 = s:option(Value, "backupwdpath", translate("Backup workdir path"))
|
o1 = s:option(Value, "backupwdpath", translate("Backup workdir path"))
|
||||||
local name
|
local name
|
||||||
@ -234,7 +234,7 @@ o.optional=false
|
|||||||
o.description=translate("Will be restore when workdir/data is empty")
|
o.description=translate("Will be restore when workdir/data is empty")
|
||||||
----backup workdir path
|
----backup workdir path
|
||||||
|
|
||||||
o1.default = "/usr/bin/AdGuardHome"
|
o1.default = "/etc/AdGuardHome"
|
||||||
o1.datatype = "string"
|
o1.datatype = "string"
|
||||||
o1.optional = false
|
o1.optional = false
|
||||||
o1.validate=function(self, value)
|
o1.validate=function(self, value)
|
||||||
@ -245,7 +245,7 @@ if fs.stat(value,"type")=="reg" then
|
|||||||
m.message ="error!backup dir is a file"
|
m.message ="error!backup dir is a file"
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
if string.sub(value,-1)=="/" then
|
if string.sub(value,-1)=="/" then
|
||||||
return string.sub(value, 1, -2)
|
return string.sub(value, 1, -2)
|
||||||
else
|
else
|
||||||
|
@ -70,7 +70,7 @@ o.template = "AdGuardHome/yamleditor"
|
|||||||
if not fs.access(binpath) then
|
if not fs.access(binpath) then
|
||||||
o.description=translate("WARNING!!! no bin found apply config will not be test")
|
o.description=translate("WARNING!!! no bin found apply config will not be test")
|
||||||
end
|
end
|
||||||
--- log
|
--- log
|
||||||
if (fs.access("/tmp/AdGuardHometmpconfig.yaml")) then
|
if (fs.access("/tmp/AdGuardHometmpconfig.yaml")) then
|
||||||
local c=fs.readfile("/tmp/AdGuardHometest.log")
|
local c=fs.readfile("/tmp/AdGuardHometest.log")
|
||||||
if (c~="") then
|
if (c~="") then
|
||||||
|
@ -62,7 +62,7 @@ set_iptable()
|
|||||||
local ipv6_server=$1
|
local ipv6_server=$1
|
||||||
local tcp_server=$2
|
local tcp_server=$2
|
||||||
uci -q batch <<-EOF >/dev/null 2>&1
|
uci -q batch <<-EOF >/dev/null 2>&1
|
||||||
delete firewall.AdGuardHome
|
delete firewall.AdGuardHome
|
||||||
set firewall.AdGuardHome=include
|
set firewall.AdGuardHome=include
|
||||||
set firewall.AdGuardHome.type=script
|
set firewall.AdGuardHome.type=script
|
||||||
set firewall.AdGuardHome.path=/usr/share/AdGuardHome/firewall.start
|
set firewall.AdGuardHome.path=/usr/share/AdGuardHome/firewall.start
|
||||||
@ -91,13 +91,12 @@ EOF
|
|||||||
fi
|
fi
|
||||||
ip6tables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
ip6tables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_iptable()
|
clear_iptable()
|
||||||
{
|
{
|
||||||
uci -q batch <<-EOF >/dev/null 2>&1
|
uci -q batch <<-EOF >/dev/null 2>&1
|
||||||
delete firewall.AdGuardHome
|
delete firewall.AdGuardHome
|
||||||
commit firewall
|
commit firewall
|
||||||
EOF
|
EOF
|
||||||
local OLD_PORT="$1"
|
local OLD_PORT="$1"
|
||||||
@ -119,30 +118,33 @@ EOF
|
|||||||
ip6tables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
ip6tables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||||
ip6tables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
ip6tables -t nat -D PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $OLD_PORT >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
procd_add_reload_trigger "$CONFIGURATION"
|
procd_add_reload_trigger "$CONFIGURATION"
|
||||||
[ "$(uci get AdGuardHome.AdGuardHome.redirect)" == "redirect" ] && procd_add_reload_trigger firewall
|
[ "$(uci get AdGuardHome.AdGuardHome.redirect)" == "redirect" ] && procd_add_reload_trigger firewall
|
||||||
}
|
}
|
||||||
|
|
||||||
isrunning(){
|
isrunning(){
|
||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
_isrunning
|
_isrunning
|
||||||
local r=$?
|
local r=$?
|
||||||
([ "$r" == "0" ] && echo "running") || ([ "$r" == "1" ] && echo "not run" ) || echo "no bin"
|
([ "$r" == "0" ] && echo "running") || ([ "$r" == "1" ] && echo "not run" ) || echo "no bin"
|
||||||
return $r
|
return $r
|
||||||
}
|
}
|
||||||
|
|
||||||
_isrunning(){
|
_isrunning(){
|
||||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
[ ! -f "$binpath" ] && return 2
|
[ ! -f "$binpath" ] && return 2
|
||||||
pgrep $binpath 2>&1 >/dev/null && return 0
|
pgrep $binpath 2>&1 >/dev/null && return 0
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
force_reload(){
|
force_reload(){
|
||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
_isrunning && procd_send_signal "$CONFIGURATION" || start
|
_isrunning && procd_send_signal "$CONFIGURATION" || start
|
||||||
}
|
}
|
||||||
|
|
||||||
get_tz()
|
get_tz()
|
||||||
{
|
{
|
||||||
SET_TZ=""
|
SET_TZ=""
|
||||||
@ -206,11 +208,13 @@ use_port53()
|
|||||||
uci commit dhcp
|
uci commit dhcp
|
||||||
/etc/init.d/dnsmasq reload
|
/etc/init.d/dnsmasq reload
|
||||||
}
|
}
|
||||||
|
|
||||||
do_redirect()
|
do_redirect()
|
||||||
{
|
{
|
||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
_do_redirect $1
|
_do_redirect $1
|
||||||
}
|
}
|
||||||
|
|
||||||
_do_redirect()
|
_do_redirect()
|
||||||
{
|
{
|
||||||
local section="$CONFIGURATION"
|
local section="$CONFIGURATION"
|
||||||
@ -271,6 +275,7 @@ _do_redirect()
|
|||||||
use_port53
|
use_port53
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_filesystem()
|
get_filesystem()
|
||||||
{
|
{
|
||||||
# print out path filesystem
|
# print out path filesystem
|
||||||
@ -340,7 +345,7 @@ boot_service() {
|
|||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
config_get waitonboot $CONFIGURATION waitonboot "0"
|
config_get waitonboot $CONFIGURATION waitonboot "0"
|
||||||
config_get_bool enabled $CONFIGURATION enabled 0
|
config_get_bool enabled $CONFIGURATION enabled 0
|
||||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
[ -f "$binpath" ] && start_service
|
[ -f "$binpath" ] && start_service
|
||||||
if [ "$enabled" == "1" ] && [ "$waitonboot" == "1" ]; then
|
if [ "$enabled" == "1" ] && [ "$waitonboot" == "1" ]; then
|
||||||
procd_open_instance "waitnet"
|
procd_open_instance "waitnet"
|
||||||
@ -358,16 +363,18 @@ testbackup(){
|
|||||||
restore
|
restore
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
restore()
|
restore()
|
||||||
{
|
{
|
||||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
|
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
|
||||||
cp -u -r -f $backupwdpath/data $workdir
|
cp -u -r -f $backupwdpath/data $workdir
|
||||||
}
|
}
|
||||||
|
|
||||||
backup() {
|
backup() {
|
||||||
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
|
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
|
||||||
mkdir -p $backupwdpath/data
|
mkdir -p $backupwdpath/data
|
||||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
config_get backupfile $CONFIGURATION backupfile ""
|
config_get backupfile $CONFIGURATION backupfile ""
|
||||||
for one in $backupfile;
|
for one in $backupfile;
|
||||||
do
|
do
|
||||||
@ -391,6 +398,7 @@ backup() {
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
# Reading config
|
# Reading config
|
||||||
rm /var/run/AdGserverdis >/dev/null 2>&1
|
rm /var/run/AdGserverdis >/dev/null 2>&1
|
||||||
@ -411,7 +419,7 @@ start_service() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
#what need to do before reload
|
#what need to do before reload
|
||||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
|
|
||||||
config_get backupfile $CONFIGURATION backupfile ""
|
config_get backupfile $CONFIGURATION backupfile ""
|
||||||
mkdir -p $workdir/data
|
mkdir -p $workdir/data
|
||||||
@ -436,7 +444,7 @@ start_service() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
local ADDITIONAL_ARGS=""
|
local ADDITIONAL_ARGS=""
|
||||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
|
||||||
|
|
||||||
mkdir -p ${binpath%/*}
|
mkdir -p ${binpath%/*}
|
||||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -c $configpath"
|
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -c $configpath"
|
||||||
@ -448,7 +456,7 @@ start_service() {
|
|||||||
config_get upprotect $CONFIGURATION upprotect ""
|
config_get upprotect $CONFIGURATION upprotect ""
|
||||||
eval upprotect=${upprotect// /\\\\n}
|
eval upprotect=${upprotect// /\\\\n}
|
||||||
echo -e "$upprotect">/lib/upgrade/keep.d/luci-app-adguardhome
|
echo -e "$upprotect">/lib/upgrade/keep.d/luci-app-adguardhome
|
||||||
|
|
||||||
config_get logfile $CONFIGURATION logfile ""
|
config_get logfile $CONFIGURATION logfile ""
|
||||||
if [ -n "$logfile" ]; then
|
if [ -n "$logfile" ]; then
|
||||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -l $logfile"
|
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -l $logfile"
|
||||||
@ -492,6 +500,7 @@ start_service() {
|
|||||||
echo "luci enable switch=$enabled"
|
echo "luci enable switch=$enabled"
|
||||||
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
||||||
}
|
}
|
||||||
|
|
||||||
reload_service()
|
reload_service()
|
||||||
{
|
{
|
||||||
rm /var/run/AdGlucitest >/dev/null 2>&1
|
rm /var/run/AdGlucitest >/dev/null 2>&1
|
||||||
@ -500,22 +509,23 @@ reload_service()
|
|||||||
}
|
}
|
||||||
|
|
||||||
del_querylog(){
|
del_querylog(){
|
||||||
local btarget=$(ls $backupwdpath/data | grep -F "querylog.json" | sort -r | head -n 1)
|
local btarget=$(ls $backupwdpath/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||||
local wtarget=$(ls $workdir/data | grep -F "querylog.json" | sort -r | head -n 1)
|
local wtarget=$(ls $workdir/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||||
if [ "$btarget"x == "$wtarget"x ]; then
|
if [ "$btarget"x == "$wtarget"x ]; then
|
||||||
[ -z "$btarget" ] && return 1
|
[ -z "$btarget" ] && return 1
|
||||||
rm -f $workdir/data/$wtarget
|
rm -f $workdir/data/$wtarget
|
||||||
rm -f $backupwdpath/data/$btarget
|
rm -f $backupwdpath/data/$btarget
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ "$btarget" \> "$wtarget" ]; then
|
if [ "$btarget" \> "$wtarget" ]; then
|
||||||
rm -f $backupwdpath/data/$btarget
|
rm -f $backupwdpath/data/$btarget
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rm -f $workdir/data/$wtarget
|
rm -f $workdir/data/$wtarget
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service()
|
stop_service()
|
||||||
{
|
{
|
||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
@ -530,16 +540,19 @@ stop_service()
|
|||||||
echo "AdGuardHome service disabled"
|
echo "AdGuardHome service disabled"
|
||||||
touch /var/run/AdGserverdis
|
touch /var/run/AdGserverdis
|
||||||
}
|
}
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
rc_procd boot_service "$@"
|
rc_procd boot_service "$@"
|
||||||
if eval "type service_started" 2>/dev/null >/dev/null; then
|
if eval "type service_started" 2>/dev/null >/dev/null; then
|
||||||
service_started
|
service_started
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_crontab(){
|
test_crontab(){
|
||||||
config_load "${CONFIGURATION}"
|
config_load "${CONFIGURATION}"
|
||||||
do_crontab
|
do_crontab
|
||||||
}
|
}
|
||||||
|
|
||||||
do_crontab(){
|
do_crontab(){
|
||||||
config_get_bool enabled $CONFIGURATION enabled 0
|
config_get_bool enabled $CONFIGURATION enabled 0
|
||||||
config_get crontab $CONFIGURATION crontab ""
|
config_get crontab $CONFIGURATION crontab ""
|
||||||
@ -550,16 +563,16 @@ do_crontab(){
|
|||||||
default="30 3 * * * /usr/share/AdGuardHome/update_core.sh 2>&1"
|
default="30 3 * * * /usr/share/AdGuardHome/update_core.sh 2>&1"
|
||||||
[ "$enabled" == "0" ] || [ "${crontab//autoupdate/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
[ "$enabled" == "0" ] || [ "${crontab//autoupdate/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
crontab_editor
|
crontab_editor
|
||||||
|
|
||||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
|
||||||
config_get lastworkdir $CONFIGURATION lastworkdir "/usr/bin/AdGuardHome"
|
config_get lastworkdir $CONFIGURATION lastworkdir "/etc/AdGuardHome"
|
||||||
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||||
#[ -n "$lastworkdir" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastworkdir/data/querylog.json" && [ "$lastworkdir" != "$workdir" ] && replace="${lastworkdir//\//\\/}/${workdir//\//\\/}"
|
#[ -n "$lastworkdir" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastworkdir/data/querylog.json" && [ "$lastworkdir" != "$workdir" ] && replace="${lastworkdir//\//\\/}/${workdir//\//\\/}"
|
||||||
default="0 * * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
default="0 * * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||||
[ "$enabled" == "0" ] || [ "${crontab//cutquerylog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
[ "$enabled" == "0" ] || [ "${crontab//cutquerylog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
crontab_editor
|
crontab_editor
|
||||||
#[ "$lastworkdir" != "$workdir" ] && uci set AdGuardHome.AdGuardHome.lastworkdir="$workdir" && commit=1
|
#[ "$lastworkdir" != "$workdir" ] && uci set AdGuardHome.AdGuardHome.lastworkdir="$workdir" && commit=1
|
||||||
|
|
||||||
config_get logfile $CONFIGURATION logfile ""
|
config_get logfile $CONFIGURATION logfile ""
|
||||||
config_get lastlogfile $CONFIGURATION lastlogfile ""
|
config_get lastlogfile $CONFIGURATION lastlogfile ""
|
||||||
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
||||||
@ -568,7 +581,7 @@ do_crontab(){
|
|||||||
[ "$logfile" == "syslog" ] || [ "$logfile" == "" ] || [ "$enabled" == "0" ] || [ "${crontab//cutruntimelog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
[ "$logfile" == "syslog" ] || [ "$logfile" == "" ] || [ "$enabled" == "0" ] || [ "${crontab//cutruntimelog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
crontab_editor
|
crontab_editor
|
||||||
#[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set AdGuardHome.AdGuardHome.lastlogfile="$logfile" && commit=1
|
#[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set AdGuardHome.AdGuardHome.lastlogfile="$logfile" && commit=1
|
||||||
|
|
||||||
findstr="/usr/share/AdGuardHome/addhost.sh"
|
findstr="/usr/share/AdGuardHome/addhost.sh"
|
||||||
default="0 * * * * /usr/share/AdGuardHome/addhost.sh"
|
default="0 * * * * /usr/share/AdGuardHome/addhost.sh"
|
||||||
[ "$enabled" == "0" ] || [ "${crontab//autohost/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
[ "$enabled" == "0" ] || [ "${crontab//autohost/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||||
@ -582,6 +595,7 @@ do_crontab(){
|
|||||||
[ "$cronreload" -gt 0 ] && /etc/init.d/cron restart
|
[ "$cronreload" -gt 0 ] && /etc/init.d/cron restart
|
||||||
#[ "$commit" -gt 0 ] && uci commit AdGuardHome
|
#[ "$commit" -gt 0 ] && uci commit AdGuardHome
|
||||||
}
|
}
|
||||||
|
|
||||||
crontab_editor(){
|
crontab_editor(){
|
||||||
#usage input:
|
#usage input:
|
||||||
#findstr=
|
#findstr=
|
||||||
@ -591,7 +605,7 @@ crontab_editor(){
|
|||||||
#output:cronreload:if >1 please /etc/init.d/cron restart manual
|
#output:cronreload:if >1 please /etc/init.d/cron restart manual
|
||||||
local testline reload
|
local testline reload
|
||||||
local line="$(grep "$findstr" $CRON_FILE)"
|
local line="$(grep "$findstr" $CRON_FILE)"
|
||||||
[ -n "$replace" ] && [ -n "$line" ] && eval testline="\${line//$replace}" && [ "$testline" != "$line" ] && line="$testline" && reload="1" && replace=""
|
[ -n "$replace" ] && [ -n "$line" ] && eval testline="\${line//$replace}" && [ "$testline" != "$line" ] && line="$testline" && reload="1" && replace=""
|
||||||
if [ "${line:0:1}" != "#" ]; then
|
if [ "${line:0:1}" != "#" ]; then
|
||||||
if [ $cronenable -eq 1 ]; then
|
if [ $cronenable -eq 1 ]; then
|
||||||
[ -z "$line" ] && line="$default" && reload="1"
|
[ -z "$line" ] && line="$default" && reload="1"
|
||||||
@ -615,5 +629,4 @@ crontab_editor(){
|
|||||||
echo "$line" >> $CRON_FILE
|
echo "$line" >> $CRON_FILE
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
checkmd5(){
|
checkmd5(){
|
||||||
local nowmd5=$(md5sum /etc/hosts)
|
local nowmd5=$(md5sum /etc/hosts)
|
||||||
nowmd5=${nowmd5%% *}
|
nowmd5=${nowmd5%% *}
|
||||||
@ -9,6 +10,7 @@ if [ "$nowmd5" != "$lastmd5" ]; then
|
|||||||
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' /etc/hosts && checkmd5 "$2" && exit 0
|
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' /etc/hosts && checkmd5 "$2" && exit 0
|
||||||
/usr/bin/awk 'BEGIN{
|
/usr/bin/awk 'BEGIN{
|
||||||
while ((getline < "/tmp/dhcp.leases") > 0)
|
while ((getline < "/tmp/dhcp.leases") > 0)
|
||||||
@ -30,4 +32,4 @@ else
|
|||||||
cat /tmp/tmphost >> /etc/hosts
|
cat /tmp/tmphost >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
rm /tmp/tmphost
|
rm /tmp/tmphost
|
||||||
checkmd5 "$2"
|
checkmd5 "$2"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
logread -e AdGuardHome > /tmp/AdGuardHometmp.log
|
logread -e AdGuardHome > /tmp/AdGuardHometmp.log
|
||||||
logread -e AdGuardHome -f >> /tmp/AdGuardHometmp.log &
|
logread -e AdGuardHome -f >> /tmp/AdGuardHometmp.log &
|
||||||
@ -16,4 +17,4 @@ do
|
|||||||
else
|
else
|
||||||
echo "0">/var/run/AdGuardHomesyslog
|
echo "0">/var/run/AdGuardHomesyslog
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
checkmd5(){
|
checkmd5(){
|
||||||
local nowmd5=$(md5sum /tmp/adguard.list 2>/dev/null)
|
local nowmd5=$(md5sum /tmp/adguard.list 2>/dev/null)
|
||||||
nowmd5=${nowmd5%% *}
|
nowmd5=${nowmd5%% *}
|
||||||
@ -10,6 +12,7 @@ if [ "$nowmd5" != "$lastmd5" ]; then
|
|||||||
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
configpath=$(uci get AdGuardHome.AdGuardHome.configpath 2>/dev/null)
|
configpath=$(uci get AdGuardHome.AdGuardHome.configpath 2>/dev/null)
|
||||||
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' $configpath && checkmd5 "$2" && exit 0
|
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' $configpath && checkmd5 "$2" && exit 0
|
||||||
gfwupstream=$(uci get AdGuardHome.AdGuardHome.gfwupstream 2>/dev/null)
|
gfwupstream=$(uci get AdGuardHome.AdGuardHome.gfwupstream 2>/dev/null)
|
||||||
@ -83,4 +86,4 @@ else
|
|||||||
sed -i '/upstream_dns:/'r/tmp/adguard.list $configpath
|
sed -i '/upstream_dns:/'r/tmp/adguard.list $configpath
|
||||||
fi
|
fi
|
||||||
checkmd5 "$2"
|
checkmd5 "$2"
|
||||||
rm -f /tmp/gfwlist.txt /tmp/adguard.list
|
rm -f /tmp/gfwlist.txt /tmp/adguard.list
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
tail -n $1 "$2" > /var/run/tailtmp
|
tail -n $1 "$2" > /var/run/tailtmp
|
||||||
cat /var/run/tailtmp > "$2"
|
cat /var/run/tailtmp > "$2"
|
||||||
rm /var/run/tailtmp
|
rm /var/run/tailtmp
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
|
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
|
||||||
if [ -z "$binpath" ]; then
|
if [ -z "$binpath" ]; then
|
||||||
@ -21,6 +22,7 @@ check_wgetcurl(){
|
|||||||
[ "$1" == "1" ] && (opkg install curl ; check_wgetcurl 2 ; return)
|
[ "$1" == "1" ] && (opkg install curl ; check_wgetcurl 2 ; return)
|
||||||
echo error curl and wget && EXIT 1
|
echo error curl and wget && EXIT 1
|
||||||
}
|
}
|
||||||
|
|
||||||
check_latest_version(){
|
check_latest_version(){
|
||||||
check_wgetcurl
|
check_wgetcurl
|
||||||
latest_ver="$($downloader - https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
|
latest_ver="$($downloader - https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
|
||||||
@ -29,78 +31,79 @@ check_latest_version(){
|
|||||||
fi
|
fi
|
||||||
now_ver="$($binpath -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o)"
|
now_ver="$($binpath -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o)"
|
||||||
if [ "${latest_ver}"x != "${now_ver}"x ] || [ "$1" == "force" ]; then
|
if [ "${latest_ver}"x != "${now_ver}"x ] || [ "$1" == "force" ]; then
|
||||||
echo -e "Local version: ${now_ver}., cloud version: ${latest_ver}."
|
echo -e "Local version: ${now_ver}., cloud version: ${latest_ver}."
|
||||||
doupdate_core
|
doupdate_core
|
||||||
else
|
else
|
||||||
echo -e "\nLocal version: ${now_ver}, cloud version: ${latest_ver}."
|
echo -e "\nLocal version: ${now_ver}, cloud version: ${latest_ver}."
|
||||||
echo -e "You're already using the latest version."
|
echo -e "You're already using the latest version."
|
||||||
if [ ! -z "$upxflag" ]; then
|
if [ ! -z "$upxflag" ]; then
|
||||||
filesize=$(ls -l $binpath | awk '{ print $5 }')
|
filesize=$(ls -l $binpath | awk '{ print $5 }')
|
||||||
if [ $filesize -gt 8000000 ]; then
|
if [ $filesize -gt 8000000 ]; then
|
||||||
echo -e "start upx may take a long time"
|
echo -e "start upx may take a long time"
|
||||||
doupx
|
doupx
|
||||||
mkdir -p "/tmp/AdGuardHomeupdate/AdGuardHome" >/dev/null 2>&1
|
mkdir -p "/tmp/AdGuardHomeupdate/AdGuardHome" >/dev/null 2>&1
|
||||||
rm -fr /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
|
rm -fr /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
|
||||||
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $binpath -o /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
|
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $binpath -o /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
|
||||||
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
||||||
/etc/init.d/AdGuardHome stop nobackup
|
/etc/init.d/AdGuardHome stop nobackup
|
||||||
rm $binpath
|
rm $binpath
|
||||||
mv -f /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/} $binpath
|
mv -f /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/} $binpath
|
||||||
/etc/init.d/AdGuardHome start
|
/etc/init.d/AdGuardHome start
|
||||||
echo -e "finished"
|
echo -e "finished"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
EXIT 0
|
fi
|
||||||
|
EXIT 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
doupx(){
|
doupx(){
|
||||||
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
||||||
case $Archt in
|
case $Archt in
|
||||||
"i386")
|
"i386")
|
||||||
Arch="i386"
|
Arch="i386"
|
||||||
;;
|
;;
|
||||||
"i686")
|
"i686")
|
||||||
Arch="i386"
|
Arch="i386"
|
||||||
echo -e "i686 use $Arch may have bug"
|
echo -e "i686 use $Arch may have bug"
|
||||||
;;
|
;;
|
||||||
"x86")
|
"x86")
|
||||||
Arch="amd64"
|
Arch="amd64"
|
||||||
;;
|
;;
|
||||||
"mipsel")
|
"mipsel")
|
||||||
Arch="mipsel"
|
Arch="mipsel"
|
||||||
;;
|
;;
|
||||||
"mips64el")
|
"mips64el")
|
||||||
Arch="mips64el"
|
Arch="mips64el"
|
||||||
Arch="mipsel"
|
Arch="mipsel"
|
||||||
echo -e "mips64el use $Arch may have bug"
|
echo -e "mips64el use $Arch may have bug"
|
||||||
;;
|
;;
|
||||||
"mips")
|
"mips")
|
||||||
Arch="mips"
|
Arch="mips"
|
||||||
;;
|
;;
|
||||||
"mips64")
|
"mips64")
|
||||||
Arch="mips64"
|
Arch="mips64"
|
||||||
Arch="mips"
|
Arch="mips"
|
||||||
echo -e "mips64 use $Arch may have bug"
|
echo -e "mips64 use $Arch may have bug"
|
||||||
;;
|
;;
|
||||||
"arm")
|
"arm")
|
||||||
Arch="arm"
|
Arch="arm"
|
||||||
;;
|
;;
|
||||||
"armeb")
|
"armeb")
|
||||||
Arch="armeb"
|
Arch="armeb"
|
||||||
;;
|
;;
|
||||||
"aarch64")
|
"aarch64")
|
||||||
Arch="arm64"
|
Arch="arm64"
|
||||||
;;
|
;;
|
||||||
"powerpc")
|
"powerpc")
|
||||||
Arch="powerpc"
|
Arch="powerpc"
|
||||||
;;
|
;;
|
||||||
"powerpc64")
|
"powerpc64")
|
||||||
Arch="powerpc64"
|
Arch="powerpc64"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
||||||
EXIT 1
|
EXIT 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
upx_latest_ver="$($downloader - https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E '[0-9.]+' -o 2>/dev/null)"
|
upx_latest_ver="$($downloader - https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E '[0-9.]+' -o 2>/dev/null)"
|
||||||
$downloader /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/upx-${upx_latest_ver}-${Arch}_linux.tar.xz" 2>&1
|
$downloader /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/upx-${upx_latest_ver}-${Arch}_linux.tar.xz" 2>&1
|
||||||
@ -109,64 +112,65 @@ doupx(){
|
|||||||
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
||||||
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz| tar -x -C "/tmp" >/dev/null 2>&1
|
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz| tar -x -C "/tmp" >/dev/null 2>&1
|
||||||
if [ ! -e "/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx" ]; then
|
if [ ! -e "/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx" ]; then
|
||||||
echo -e "Failed to download upx."
|
echo -e "Failed to download upx."
|
||||||
EXIT 1
|
EXIT 1
|
||||||
fi
|
fi
|
||||||
rm /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz
|
rm /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz
|
||||||
}
|
}
|
||||||
|
|
||||||
doupdate_core(){
|
doupdate_core(){
|
||||||
echo -e "Updating core..."
|
echo -e "Updating core..."
|
||||||
mkdir -p "/tmp/AdGuardHomeupdate"
|
mkdir -p "/tmp/AdGuardHomeupdate"
|
||||||
rm -rf /tmp/AdGuardHomeupdate/* >/dev/null 2>&1
|
rm -rf /tmp/AdGuardHomeupdate/* >/dev/null 2>&1
|
||||||
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
||||||
case $Archt in
|
case $Archt in
|
||||||
"i386")
|
"i386")
|
||||||
Arch="386"
|
Arch="386"
|
||||||
;;
|
;;
|
||||||
"i686")
|
"i686")
|
||||||
Arch="386"
|
Arch="386"
|
||||||
;;
|
;;
|
||||||
"x86")
|
"x86")
|
||||||
Arch="amd64"
|
Arch="amd64"
|
||||||
;;
|
;;
|
||||||
"mipsel")
|
"mipsel")
|
||||||
Arch="mipsle"
|
Arch="mipsle"
|
||||||
;;
|
;;
|
||||||
"mips64el")
|
"mips64el")
|
||||||
Arch="mips64le"
|
Arch="mips64le"
|
||||||
Arch="mipsle"
|
Arch="mipsle"
|
||||||
echo -e "mips64el use $Arch may have bug"
|
echo -e "mips64el use $Arch may have bug"
|
||||||
;;
|
;;
|
||||||
"mips")
|
"mips")
|
||||||
Arch="mips"
|
Arch="mips"
|
||||||
;;
|
;;
|
||||||
"mips64")
|
"mips64")
|
||||||
Arch="mips64"
|
Arch="mips64"
|
||||||
Arch="mips"
|
Arch="mips"
|
||||||
echo -e "mips64 use $Arch may have bug"
|
echo -e "mips64 use $Arch may have bug"
|
||||||
;;
|
;;
|
||||||
"arm")
|
"arm")
|
||||||
Arch="arm"
|
Arch="arm"
|
||||||
;;
|
;;
|
||||||
"aarch64")
|
"aarch64")
|
||||||
Arch="arm64"
|
Arch="arm64"
|
||||||
;;
|
;;
|
||||||
"powerpc")
|
"powerpc")
|
||||||
Arch="ppc"
|
Arch="ppc"
|
||||||
echo -e "error not support $Archt"
|
echo -e "error not support $Archt"
|
||||||
EXIT 1
|
EXIT 1
|
||||||
;;
|
;;
|
||||||
"powerpc64")
|
"powerpc64")
|
||||||
Arch="ppc64"
|
Arch="ppc64"
|
||||||
echo -e "error not support $Archt"
|
echo -e "error not support $Archt"
|
||||||
EXIT 1
|
EXIT 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
echo -e "error not support $Archt if you can use offical release please issue a bug"
|
||||||
EXIT 1
|
EXIT 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo -e "start download"
|
echo -e "start download"
|
||||||
grep -v "^#" /usr/share/AdGuardHome/links.txt >/tmp/run/AdHlinks.txt
|
grep -v "^#" /usr/share/AdGuardHome/links.txt >/tmp/run/AdHlinks.txt
|
||||||
while read link
|
while read link
|
||||||
do
|
do
|
||||||
@ -178,14 +182,14 @@ doupdate_core(){
|
|||||||
else
|
else
|
||||||
local success="1"
|
local success="1"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done < "/tmp/run/AdHlinks.txt"
|
done < "/tmp/run/AdHlinks.txt"
|
||||||
rm /tmp/run/AdHlinks.txt
|
rm /tmp/run/AdHlinks.txt
|
||||||
[ -z "$success" ] && echo "no download success" && EXIT 1
|
[ -z "$success" ] && echo "no download success" && EXIT 1
|
||||||
if [ "${link##*.}" == "gz" ]; then
|
if [ "${link##*.}" == "gz" ]; then
|
||||||
tar -zxf "/tmp/AdGuardHomeupdate/${link##*/}" -C "/tmp/AdGuardHomeupdate/"
|
tar -zxf "/tmp/AdGuardHomeupdate/${link##*/}" -C "/tmp/AdGuardHomeupdate/"
|
||||||
if [ ! -e "/tmp/AdGuardHomeupdate/AdGuardHome" ]; then
|
if [ ! -e "/tmp/AdGuardHomeupdate/AdGuardHome" ]; then
|
||||||
echo -e "Failed to download core."
|
echo -e "Failed to download core."
|
||||||
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
|
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
|
||||||
EXIT 1
|
EXIT 1
|
||||||
fi
|
fi
|
||||||
@ -194,34 +198,35 @@ doupdate_core(){
|
|||||||
downloadbin="/tmp/AdGuardHomeupdate/${link##*/}"
|
downloadbin="/tmp/AdGuardHomeupdate/${link##*/}"
|
||||||
fi
|
fi
|
||||||
chmod 755 $downloadbin
|
chmod 755 $downloadbin
|
||||||
echo -e "download success start copy"
|
echo -e "download success start copy"
|
||||||
if [ -n "$upxflag" ]; then
|
if [ -n "$upxflag" ]; then
|
||||||
echo -e "start upx may take a long time"
|
echo -e "start upx may take a long time"
|
||||||
doupx
|
doupx
|
||||||
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $downloadbin
|
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $downloadbin
|
||||||
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
|
||||||
fi
|
fi
|
||||||
echo -e "start copy"
|
echo -e "start copy"
|
||||||
/etc/init.d/AdGuardHome stop nobackup
|
/etc/init.d/AdGuardHome stop nobackup
|
||||||
rm "$binpath"
|
rm "$binpath"
|
||||||
mv -f "$downloadbin" "$binpath"
|
mv -f "$downloadbin" "$binpath"
|
||||||
if [ "$?" == "1" ]; then
|
if [ "$?" == "1" ]; then
|
||||||
echo "mv failed maybe not enough space please use upx or change bin to /tmp/AdGuardHome"
|
echo "mv failed maybe not enough space please use upx or change bin to /tmp/AdGuardHome"
|
||||||
EXIT 1
|
EXIT 1
|
||||||
fi
|
fi
|
||||||
/etc/init.d/AdGuardHome start
|
/etc/init.d/AdGuardHome start
|
||||||
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
|
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
|
||||||
echo -e "Succeeded in updating core."
|
echo -e "Succeeded in updating core."
|
||||||
echo -e "Local version: ${latest_ver}, cloud version: ${latest_ver}.\n"
|
echo -e "Local version: ${latest_ver}, cloud version: ${latest_ver}.\n"
|
||||||
EXIT 0
|
EXIT 0
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT(){
|
EXIT(){
|
||||||
rm /var/run/update_core 2>/dev/null
|
rm /var/run/update_core 2>/dev/null
|
||||||
[ "$1" != "0" ] && touch /var/run/update_core_error
|
[ "$1" != "0" ] && touch /var/run/update_core_error
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
main(){
|
main(){
|
||||||
|
|
||||||
check_if_already_running
|
check_if_already_running
|
||||||
check_latest_version $1
|
check_latest_version $1
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
count=0
|
count=0
|
||||||
while :
|
while :
|
||||||
@ -31,4 +32,4 @@ do
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
configpath=$(uci get AdGuardHome.AdGuardHome.configpath)
|
configpath=$(uci get AdGuardHome.AdGuardHome.configpath)
|
||||||
while :
|
while :
|
||||||
@ -9,4 +10,4 @@ do
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user