0
0
mirror of https://github.com/openwrt/packages.git synced 2025-07-13 04:24:48 +00:00
Files
packages/net/adguardhome/files/adguardhome.init
Ryan Keane c3a33e10a5 adguardhome: Update init files
Move working directory from `/var/adguardhome` to
`/var/lib/adguardhome`, according to Linux FHS.
Add option to store PID file, defaulting to `/run/adguardhome.pid`.

Signed-off-by: Ryan Keane <the.ra2.ifv@gmail.com>
2025-02-16 21:48:19 +08:00

44 lines
1.0 KiB
Bash

#!/bin/sh /etc/rc.common
PROG=/usr/bin/AdGuardHome
USE_PROCD=1
# 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 CONFIG_FILE config config "/etc/adguardhome.yaml"
config_get PID_FILE config pidfile "/run/adguardhome.pid"
config_get WORK_DIR config workdir "/var/lib/adguardhome"
[ -d "$WORK_DIR" ] || mkdir -m 0755 -p "$WORK_DIR"
procd_open_instance
procd_set_param command "$PROG" -c "$CONFIG_FILE" -w "$WORK_DIR" --pidfile "$PID_FILE" --no-check-update
procd_set_param stdout 1
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
}