packages/net: add lldpd link-layer discovery protocol daemon
[openwrt/svn-archive/archive.git] / net / lldpd / files / lldpd.init
1 #!/bin/sh /etc/rc.common
2
3 START=90
4
5 start() {
6 local enable_cdp
7 local enable_fdp
8 local enable_sonmp
9 local enable_edp
10 local lldp_class
11 local lldp_location
12 local args="-d"
13
14 config_load lldpd
15 config_get_bool enable_cdp config enable_cdp
16 config_get_bool enable_fdp config enable_fdp
17 config_get_bool enable_sonmp config enable_sonmp
18 config_get_bool enable_edp config enable_edp
19 config_get lldp_class config lldp_class
20 config_get lldp_location config lldp_location
21
22 [ "$enable_cdp" == 1 ] && append args "-c"
23 [ "$enable_fdp" == 1 ] && append args "-f"
24 [ "$enable_sonmp" == 1 ] && append args "-s"
25 [ "$enable_edp" == 1 ] && append args "-e"
26 [ -n "$lldp_location" ] && append args "-L '$lldp_location'"
27 append args "-M ${lldp_class:-4}"
28
29 eval start-stop-daemon -S -x lldpd -b -q -- $args
30 }
31
32 stop() {
33 start-stop-daemon -K -q -x lldpd
34 rm -f /var/run/lldpd.socket
35 }