File: init

package info (click to toggle)
dhcpy6d 1.2.3-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 840 kB
  • sloc: python: 4,479; sh: 231; sql: 67; makefile: 15
file content (104 lines) | stat: -rw-r--r-- 2,330 bytes parent folder | download | duplicates (5)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/sh
### BEGIN INIT INFO
# Provides: dhcpy6d
# Required-Start: $syslog $network $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop dhcpy6d DHCPv6 server
# Description: (empty)
### END INIT INFO

set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DHCPY6DBIN=/usr/sbin/dhcpy6d
DHCPY6DCONF=/etc/dhcpy6d.conf
DHCPY6DPID=/var/run/dhcpy6d.pid
NAME="dhcpy6d"
DESC="dhcpy6d DHCPv6 server"
USER=dhcpy6d
GROUP=dhcpy6d

RUN=no
DEFAULTFILE=/etc/default/dhcpy6d
if [ -f $DEFAULTFILE ]; then
    . $DEFAULTFILE
fi

. /lib/lsb/init-functions

check_status()
{
     if [ ! -r "$DHCPY6DPID" ]; then
         test "$1" != -v || echo "$NAME is not running."
         return 3
     fi
     if read pid < "$DHCPY6DPID" && ps -p "$pid" > /dev/null 2>&1; then
         test "$1" != -v || echo "$NAME is running."
         return 0
     else
         test "$1" != -v || echo "$NAME is not running but $DHCPY6DPID exists."
         return 1
     fi
}

test -x $DHCPY6DBIN || exit 0

case "$1" in
start)
if [ "$RUN" = "no" ]; then
echo "dhcpy6d is disabled in /etc/default/dhcpy6d. Set RUN=yes to get it running."
exit 0
fi

log_daemon_msg "Starting $DESC $NAME"

if ! check_status; then

start-stop-daemon --start --make-pidfile --pidfile ${DHCPY6DPID} \
--background --oknodo --no-close --exec $DHCPY6DBIN -- --config $DHCPY6DCONF \
                                            --user $USER \
                                            --group $GROUP \
                                            --duid $DUID \
                                            --really-do-it $RUN

sleep 2
if check_status -q; then
                        log_end_msg 0
                    else
                        log_end_msg 1
                        exit 1
fi
else
log_end_msg 1
exit 1
                fi
;;
stop)
                log_daemon_msg "Stopping $DESC $NAME"
                start-stop-daemon --stop --quiet --pidfile ${DHCPY6DPID} --oknodo
                log_end_msg $?
                rm -f $DHCPY6DPID
;;
restart|force-reload)
$0 stop
sleep 2
$0 start
if [ "$?" != "0" ]; then
exit 1
fi
;;
status)
echo "Status of $NAME: "
check_status -v
exit "$?"
;;
*)
echo "Usage: $0 (start|stop|restart|force-reload|status)"
exit 1
esac

exit 0