This should allow the service to be activated even earlier during
the boot process and also avoids race condition against network.
Signed-off-by: Hiếu Lê <leorize+oss@disroot.org>
USE_PROCD=1
-# starts just after network starts to avoid some network race conditions
-START=25
+# matches dnsmasq
+START=19
# stops before networking stops
STOP=89
+boot() {
+ adguardhome_boot=1
+ start "$@"
+}
+
start_service() {
+ if [ -n "$adguardhome_boot" ]; then
+ # Do not start yet, wait for triggers
+ return 0
+ fi
+
config_load adguardhome
config_get WORK_DIR config workdir
procd_set_param stderr 1
procd_close_instance
}
+
+service_triggers() {
+ if [ -n "$adguardhome_boot" ]; then
+ # Wait for interfaces to be up before starting AdGuard Home for real.
+ # Prevents issues like https://github.com/openwrt/packages/issues/21868.
+ procd_add_raw_trigger "interface.*.up" 5000 /etc/init.d/adguardhome restart
+ fi
+}