]> git.ipfire.org Git - thirdparty/lldpd.git/blame - debian/lldpd.init.d
Change handling of conditional builds in the spec file
[thirdparty/lldpd.git] / debian / lldpd.init.d
CommitLineData
43c02e7b
VB
1#! /bin/sh
2### BEGIN INIT INFO
58695245
VB
3# Provides: lldpd
4# Required-Start: $remote_fs $network $syslog
5# Required-Stop: $network $remote_fs $syslog
43c02e7b
VB
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: LLDP daemon
9### END INIT INFO
10
11# Do NOT "set -e"
12
13# PATH should only include /usr/* if it runs after the mountnfs.sh script
14PATH=/sbin:/usr/sbin:/bin:/usr/bin
15DESC="LLDP daemon"
16NAME=lldpd
17DAEMON=/usr/sbin/$NAME
18DAEMON_ARGS=""
19PIDFILE=/var/run/$NAME.pid
20SCRIPTNAME=/etc/init.d/$NAME
21
22# Exit if the package is not installed
23[ -x "$DAEMON" ] || exit 0
24
25# Read configuration variable file if it is present
26[ -r /etc/default/$NAME ] && . /etc/default/$NAME
27
28[ -f /lib/init/vars.sh ] && . /lib/init/vars.sh
29. /lib/lsb/init-functions
30
31do_start()
32{
33 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
34 || return 1
35 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
36 $DAEMON_ARGS \
37 || return 2
38}
39
40do_stop()
41{
42 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
43 RETVAL="$?"
44 [ "$RETVAL" = 2 ] && return 2
45 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
46 [ "$?" = 2 ] && return 2
47 rm -f $PIDFILE
48 return "$RETVAL"
49}
50
51do_reload() {
52 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
53 return 0
54}
55
56case "$1" in
57 start)
58 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
59 do_start
60 case "$?" in
61 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
62 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
63 esac
64 ;;
65 stop)
66 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
67 do_stop
68 case "$?" in
69 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
70 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
71 esac
72 ;;
73 reload)
74 log_daemon_msg "Reloading $DESC" "$NAME"
75 do_reload
76 log_end_msg $?
77 ;;
78 restart|force-reload)
79 log_daemon_msg "Restarting $DESC" "$NAME"
80 do_stop
81 case "$?" in
82 0|1)
83 do_start
84 case "$?" in
85 0) log_end_msg 0 ;;
86 1) log_end_msg 1 ;; # Old process is still running
87 *) log_end_msg 1 ;; # Failed to start
88 esac
89 ;;
90 *)
91 # Failed to stop
92 log_end_msg 1
93 ;;
94 esac
95 ;;
96 *)
97 echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
98 exit 3
99 ;;
100esac
101
102: