]>
Commit | Line | Data |
---|---|---|
3d6585f3 VB |
1 | #!/bin/bash |
2 | # lldpd init file | |
3 | # | |
4 | # chkconfig: 2345 60 20 | |
5 | # description: 802.1ab (LLDP) daemon | |
6 | # | |
7 | # processname: lldpd | |
8 | # pidfile: /var/run/lldpd.pid | |
9 | ||
10 | ### BEGIN INIT INFO | |
11 | # Provides: lldpd | |
d623a64a VB |
12 | # Required-Start: $local_fs $remote_fs |
13 | # Required-Stop: $local_fs $remote_fs | |
14 | # Should-Start: $syslog $network $net-snmp | |
15 | # Should-Stop: $syslog $network $net-snmp | |
16 | # Default-Start: 2 3 5 | |
17 | # Default-Stop: 0 1 6 | |
18 | # Short-Description: LLDP daemon | |
3d6585f3 VB |
19 | # Description: 802.1ab (LLDP) daemon |
20 | ### END INIT INFO | |
21 | ||
22 | # source function library | |
8e555861 | 23 | . /etc/rc.d/init.d/functions |
3d6585f3 | 24 | |
d623a64a | 25 | LLDPD_OPTIONS="" |
8e555861 | 26 | [ -e /etc/sysconfig/lldpd ] && . /etc/sysconfig/lldpd |
3d6585f3 VB |
27 | |
28 | RETVAL=0 | |
29 | prog="lldpd" | |
30 | binary=/usr/sbin/lldpd | |
31 | pidfile=/var/run/lldpd.pid | |
8e555861 | 32 | lockfile=/var/lock/subsys/$prog |
c0ce5d1a | 33 | |
61723351 VB |
34 | # Determine if we can use the -p option to daemon, killproc, and status. |
35 | # RHEL < 5 can't. | |
36 | if status | grep -q -- '-p' 2>/dev/null; then | |
37 | daemonopts="--pidfile $pidfile" | |
38 | pidopts="-p $pidfile" | |
39 | fi | |
40 | ||
3d6585f3 VB |
41 | start() { |
42 | [ -x $binary ] || exit 5 | |
43 | echo -n $"Starting $prog: " | |
44 | if [ $UID -ne 0 ]; then | |
45 | RETVAL=1 | |
46 | failure | |
47 | else | |
61723351 | 48 | daemon $daemonopts $binary $LLDPD_OPTIONS |
3d6585f3 | 49 | RETVAL=$? |
8e555861 | 50 | [ $RETVAL -eq 0 ] && touch $lockfile |
3d6585f3 VB |
51 | fi; |
52 | echo | |
53 | return $RETVAL | |
54 | } | |
55 | ||
56 | stop() { | |
57 | echo -n $"Stopping $prog: " | |
58 | if [ $UID -ne 0 ]; then | |
59 | RETVAL=1 | |
60 | failure | |
61 | else | |
61723351 | 62 | killproc $pidopts $binary |
3d6585f3 | 63 | RETVAL=$? |
8e555861 | 64 | [ $RETVAL -eq 0 ] && rm -f $lockfile |
3d6585f3 VB |
65 | fi; |
66 | echo | |
67 | return $RETVAL | |
68 | } | |
69 | ||
3d6585f3 VB |
70 | restart(){ |
71 | stop | |
72 | start | |
73 | } | |
74 | ||
75 | condrestart(){ | |
8e555861 | 76 | [ -e $lockfile ] && restart |
3d6585f3 VB |
77 | return 0 |
78 | } | |
79 | ||
8e555861 | 80 | rh_status_q(){ |
61723351 | 81 | status $pidopts $prog >/dev/null 2>&1 |
8e555861 VB |
82 | } |
83 | ||
3d6585f3 VB |
84 | case "$1" in |
85 | start) | |
8e555861 | 86 | rh_status_q && exit 0 |
3d6585f3 VB |
87 | start |
88 | RETVAL=$? | |
89 | ;; | |
90 | stop) | |
8e555861 | 91 | rh_status_q || exit 0 |
3d6585f3 VB |
92 | stop |
93 | RETVAL=$? | |
94 | ;; | |
95 | restart) | |
96 | restart | |
97 | RETVAL=$? | |
98 | ;; | |
99 | reload) | |
8e555861 VB |
100 | rh_status_q || exit 7 |
101 | exit 3 | |
102 | ;; | |
103 | force-reload) | |
104 | restart | |
3d6585f3 VB |
105 | RETVAL=$? |
106 | ;; | |
107 | condrestart|try-restart) | |
8e555861 | 108 | rh_status_q || exit 0 |
3d6585f3 VB |
109 | condrestart |
110 | RETVAL=$? | |
111 | ;; | |
112 | status) | |
61723351 | 113 | status $pidopts $prog |
3d6585f3 VB |
114 | RETVAL=$? |
115 | ;; | |
116 | *) | |
8e555861 | 117 | echo $"Usage: $0 {start|stop|status|restart|condrestart|force-reload}" |
3d6585f3 VB |
118 | RETVAL=2 |
119 | esac | |
120 | ||
121 | exit $RETVAL |