1#!/bin/sh 2 3DAEMON="unbound" 4PIDFILE="/var/run/$DAEMON.pid" 5 6UNBOUND_ARGS="" 7 8# shellcheck source=/dev/null 9[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" 10 11start() { 12 printf 'Starting %s: ' "$DAEMON" 13 start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ 14 -- $UNBOUND_ARGS 15 status=$? 16 if [ "$status" -eq 0 ]; then 17 echo "OK" 18 else 19 echo "FAIL" 20 fi 21 return "$status" 22} 23 24stop() { 25 printf 'Stopping %s: ' "$DAEMON" 26 start-stop-daemon -K -q -p "$PIDFILE" 27 status=$? 28 if [ "$status" -eq 0 ]; then 29 rm -f "$PIDFILE" 30 echo "OK" 31 else 32 echo "FAIL" 33 fi 34 return "$status" 35} 36 37restart() { 38 stop 39 sleep 1 40 start 41} 42 43case "$1" in 44 start|stop|restart) 45 "$1";; 46 reload) 47 # Restart, since there is no true "reload" feature. 48 restart;; 49 *) 50 echo "Usage: $0 {start|stop|restart|reload}" 51 exit 1 52esac 53