aboutsummaryrefslogtreecommitdiff
path: root/src/unbound/rc.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/unbound/rc.d')
-rwxr-xr-xsrc/unbound/rc.d39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/unbound/rc.d b/src/unbound/rc.d
new file mode 100755
index 0000000..b5b6466
--- /dev/null
+++ b/src/unbound/rc.d
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+name=unbound
+prog="/usr/sbin/unbound"
+
+PID=$(pidof -o %PPID $prog)
+
+case "$1" in
+start)
+ stat_busy "Starting $name daemon"
+ [[ -z "$PID" ]] && eval $prog &>/dev/null \
+ && { add_daemon $name; stat_done; } \
+ || { stat_fail; exit 1; }
+ ;;
+stop)
+ stat_busy "Stopping $name daemon"
+ [[ -n "$PID" ]] && kill $PID &>/dev/null \
+ && { rm_daemon $name; stat_done; } \
+ || { stat_fail; exit 1; }
+ ;;
+reload)
+ stat_busy "Reloading $name daemon"
+ [[ -n "$PID" ]] && kill -SIGHUP $PID &>/dev/null \
+ && { stat_done; } \
+ || { stat_fail; exit 1; }
+ ;;
+restart)
+ $0 stop
+ sleep 2
+ $0 start
+ ;;
+*)
+ echo "usage: $0 {start|stop|restart|reload}"
+ exit 1
+ ;;
+esac