summaryrefslogtreecommitdiffstats
path: root/network/AdGuardHome/rc.AdGuardHome
diff options
context:
space:
mode:
Diffstat (limited to 'network/AdGuardHome/rc.AdGuardHome')
-rw-r--r--network/AdGuardHome/rc.AdGuardHome55
1 files changed, 55 insertions, 0 deletions
diff --git a/network/AdGuardHome/rc.AdGuardHome b/network/AdGuardHome/rc.AdGuardHome
new file mode 100644
index 0000000000..73e09fdccb
--- /dev/null
+++ b/network/AdGuardHome/rc.AdGuardHome
@@ -0,0 +1,55 @@
+#!/bin/bash
+# Start/stop/restart the AdGuard Home
+
+bin=/usr/sbin/AdGuardHome
+config=/etc/AdGuardHome.yaml
+workdir=/var/lib/AdGuardHome
+pidfile=/run/AdGuardHome.pid
+
+start_AdGuardHome() {
+ echo "Starting AdGuard Home... "
+ if [ -f $pidfile ]; then
+ echo "AdGuard Home is already running with PID $(cat ${pidfile})."
+ exit 0
+ fi
+ mkdir -p $workdir
+ nohup $bin --config $config --work-dir $workdir --no-check-update \
+ --pidfile $pidfile 0<&- &>/dev/null &
+}
+
+stop_AdGuardHome() {
+ echo "Stoppping AdGuard Home... "
+ [ -f $pidfile ] && kill $(cat ${pidfile})
+}
+
+restart_AdGuardHome() {
+ stop_AdGuardHome
+ sleep 1
+ start_AdGuardHome
+}
+
+status_AdGuardHome() {
+ if [ -f $pidfile ]; then
+ echo "AdGuard Home is running with PID $(cat ${pidfile})."
+ else
+ echo "AdGuard Home is stopped."
+ exit 1
+ fi
+}
+
+case "$1" in
+'start')
+ start_AdGuardHome
+ ;;
+'stop')
+ stop_AdGuardHome
+ ;;
+'restart')
+ restart_AdGuardHome
+ ;;
+'status')
+ status_AdGuardHome
+ ;;
+*)
+ echo "usage $0 start|stop|restart|status"
+esac