]> git.ipfire.org Git - thirdparty/lldpd.git/blob - redhat/lldpd.init
build: bump actions/download-artifact from 3 to 4
[thirdparty/lldpd.git] / redhat / lldpd.init
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
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
19 # Description: 802.1ab (LLDP) daemon
20 ### END INIT INFO
21
22 # source function library
23 . /etc/rc.d/init.d/functions
24
25 LLDPD_OPTIONS=""
26 [ -e /etc/sysconfig/lldpd ] && . /etc/sysconfig/lldpd
27
28 RETVAL=0
29 prog="lldpd"
30 binary=/usr/sbin/lldpd
31 pidfile=/var/run/lldpd.pid
32 lockfile=/var/lock/subsys/$prog
33
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
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
48 daemon $daemonopts $binary $LLDPD_OPTIONS
49 RETVAL=$?
50 [ $RETVAL -eq 0 ] && touch $lockfile
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
62 killproc $pidopts $binary
63 RETVAL=$?
64 [ $RETVAL -eq 0 ] && rm -f $lockfile
65 fi;
66 echo
67 return $RETVAL
68 }
69
70 restart(){
71 stop
72 start
73 }
74
75 condrestart(){
76 [ -e $lockfile ] && restart
77 return 0
78 }
79
80 rh_status_q(){
81 status $pidopts $prog >/dev/null 2>&1
82 }
83
84 case "$1" in
85 start)
86 rh_status_q && exit 0
87 start
88 RETVAL=$?
89 ;;
90 stop)
91 rh_status_q || exit 0
92 stop
93 RETVAL=$?
94 ;;
95 restart)
96 restart
97 RETVAL=$?
98 ;;
99 reload)
100 rh_status_q || exit 7
101 exit 3
102 ;;
103 force-reload)
104 restart
105 RETVAL=$?
106 ;;
107 condrestart|try-restart)
108 rh_status_q || exit 0
109 condrestart
110 RETVAL=$?
111 ;;
112 status)
113 status $pidopts $prog
114 RETVAL=$?
115 ;;
116 *)
117 echo $"Usage: $0 {start|stop|status|restart|condrestart|force-reload}"
118 RETVAL=2
119 esac
120
121 exit $RETVAL