aboutsummaryrefslogtreecommitdiff
path: root/network/unbound/rc.unbound
blob: c83d276725983598e8c77f3ac81ced392fdf4645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Slackware initialization script for Unbound.


UNBOUND=/usr/sbin/unbound
CONFIG=/etc/unbound/unbound.conf
PIDFILE=/var/run/unbound/unbound.pid

start() {
    if [ -r $PIDFILE ]; then
        echo 'Unbound is already running!'
        return
    else
	echo "Starting Unbound DNS validating resolver..."
        $UNBOUND -c $CONFIG || echo "Failed to start! The error messages above might help."
    fi
}

stop() {
    if [ ! -r $PIDFILE ]; then
        echo 'Unbound is not running.'
        return
    fi
    echo "Stopping Unbound DNS validating resolver..."
    kill `cat $PIDFILE`
    rm -f $PIDFILE
}

case "$1" in
    'start')
        start
        ;;
    'stop')
        stop
        ;;
    'restart')
        stop
	sleep 1
        start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac