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