packages/lldpd: use new service functions
[openwrt/svn-archive/archive.git] / net / lldpd / files / lldpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008-2011 OpenWrt.org
3
4 START=90
5
6 SERVICE_USE_PID=1
7
8 start() {
9 local enable_cdp
10 local enable_fdp
11 local enable_sonmp
12 local enable_edp
13 local lldp_class
14 local lldp_location
15
16 config_load 'lldpd'
17 config_get_bool enable_cdp 'config' 'enable_cdp' 0
18 config_get_bool enable_fdp 'config' 'enable_fdp' 0
19 config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
20 config_get_bool enable_edp 'config' 'enable_edp' 0
21 config_get lldp_class 'config' 'lldp_class'
22 config_get lldp_location 'config' 'lldp_location'
23
24 [ $enable_cdp -gt 0 ] && append args '-c'
25 [ $enable_fdp -gt 0 ] && append args '-f'
26 [ $enable_sonmp -gt 0 ] && append args '-s'
27 [ $enable_edp -gt 0 ] && append args '-e'
28
29 service_start /usr/sbin/lldpd $args \
30 ${lldp_location:+ -L "$lldp_location"} \
31 ${lldp_class:+ -M $lldp_class}
32 }
33
34 stop() {
35 service_stop /usr/sbin/lldpd
36 }