summaryrefslogtreecommitdiff
path: root/network/pdnsd/rc.pdnsd
blob: 64115e1cb54a97c236020c13494f3a868b2cc86e (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
# /etc/rc.d/rc.pdnsd
#
# Starts the Proxy DNS Daemon
#
# description: Proxy DNS Daemon
# processname: pdnsd
# config: /etc/pdnsd.conf
# distribution: Slackware
# author: André Geraldo Vieira <andre.geraldo@gmail.com>
#
# Additional info:
# 1) put these lines in the /etc/rc.d/rc.local:
# if [ -x /etc/rc.d/rc.pdnsd ]; then
#    /etc/rc.d/rc.pdnsd start
# fi
#
# 2) put these lines in the /etc/rc.d/rc.local_shutdown:
# if [ -x /etc/rc.d/rc.pdnsd ]; then
#    /etc/rc.d/rc.pdnsd stop
# fi

start() {
    if ! [ -r /var/run/pdnsd.pid ]; then
       echo -n 'Starting pdnsd...' 
       /usr/sbin/pdnsd -d -p /var/run/pdnsd.pid
       echo 'OK'
    else
       echo 'The PDNSD is already running!'
   fi
}

stop() {
   if [ -r /var/run/pdnsd.pid ]; then
      echo -n "Shutting down pdnsd... "
      kill -15 `cat /var/run/pdnsd.pid` && rm -f /var/run/pdnsd.pid 2> /dev/null
      echo ' OK'
   else
      echo 'The PDNSD already stopped!'
   fi
}

restart() {
   stop
   sleep 3
   start
}

status() {
   if [ -r /var/run/pdnsd.pid ]; then
      pid=`cat /var/run/pdnsd.pid`
      echo "PDNSD (pid $pid) is running."
   else
      echo 'PDNSD is stopped.'
   fi
}

case "$1" in
  start)
   start
   ;;
  stop)
   stop
   ;;
  reload|restart)
   restart
   ;;
  status)
   status
   ;;
  *)
   echo "Usage: $0 {start|stop|restart|reload|status}"
   exit 1
   ;;
esac
exit 0
#EOF