@@ -149,6 +149,9 @@ o.template = "AdGuardHome/AdGuardHome_chpass"
---- database protect
o = s:option(Flag, "keepdb", translate("Keep database when system upgrade"))
o.default = 0
+---- wait net on boot
+o = s:option(Flag, "waitonboot", translate("Boot delay until network ok"))
+o.default = 1
function mp.on_commit(map)
io.popen("/etc/init.d/AdGuardHome reload &")
@@ -173,4 +173,7 @@ msgid "Keep database when system upgrade"
msgstr "系统升级时保留数据"
msgid "Use port 53 replace dnsmasq"
-msgstr "使用53端口替换dnsmasq"
+msgstr "使用53端口替换dnsmasq"
+
+msgid "Boot delay until network ok"
+msgstr "开机时直到网络准备好再启动"
@@ -293,7 +293,18 @@ config_editor()
}
}' $3
-
+boot() {
+ config_load "${CONFIGURATION}"
+ config_get waitonboot $CONFIGURATION waitonboot "0"
+ if [ "$waitonboot" == "1" ]; then
+ do_redirect 0
+ procd_open_instance "waitnet"
+ procd_set_param command "/usr/share/AdGuardHome/waitnet.sh"
+ procd_close_instance
+ else
+ start
+ fi
+}
start_service() {
# Reading config
config_load "${CONFIGURATION}"
@@ -0,0 +1,24 @@
+#!/bin/sh
+PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+count=0
+while :
+do
+ ping -c 1 -W 1 -q www.baidu.com 1>/dev/null 2>&1
+ if [ "$?" == "0" ]; then
+ /etc/init.d/AdGuardHome reload
+ break
+ sleep 5
+ ping -c 1 -W 1 -q www.google.com 1>/dev/null 2>&1
+ count=$((count+1))
+ if [ $count > 18 ]; then
+done
+return 0