2012-10-10 13:17:14 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
# Copyright (C) 2008-2012 OpenWrt.org
|
|
|
|
|
|
|
|
START=90
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
USE_PROCD=1
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2013-01-02 14:35:43 +00:00
|
|
|
find_release_info()
|
|
|
|
{
|
|
|
|
[ -s /etc/openwrt_release ] && . /etc/openwrt_release
|
|
|
|
[ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
|
|
|
|
DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
|
|
|
|
|
|
|
|
echo "${DISTRIB_DESCRIPTION:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
|
|
|
|
}
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
start_service() {
|
2013-01-02 14:35:43 +00:00
|
|
|
. /lib/functions/network.sh
|
|
|
|
|
2012-10-10 13:17:14 +00:00
|
|
|
local enable_cdp
|
|
|
|
local enable_fdp
|
|
|
|
local enable_sonmp
|
|
|
|
local enable_edp
|
|
|
|
local lldp_class
|
|
|
|
local lldp_location
|
2013-01-02 14:35:43 +00:00
|
|
|
local lldp_description
|
2015-03-12 10:06:08 +00:00
|
|
|
local readonly_mode
|
2012-10-10 13:17:14 +00:00
|
|
|
|
|
|
|
config_load 'lldpd'
|
|
|
|
config_get_bool enable_cdp 'config' 'enable_cdp' 0
|
|
|
|
config_get_bool enable_fdp 'config' 'enable_fdp' 0
|
|
|
|
config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
|
|
|
|
config_get_bool enable_edp 'config' 'enable_edp' 0
|
|
|
|
config_get lldp_class 'config' 'lldp_class'
|
|
|
|
config_get lldp_location 'config' 'lldp_location'
|
2013-01-02 14:35:43 +00:00
|
|
|
config_get lldp_description 'config' 'lldp_description' "$(find_release_info)"
|
2015-03-12 10:06:08 +00:00
|
|
|
config_get_bool readonly_mode 'config' 'readonly_mode' 0
|
2013-01-02 14:35:43 +00:00
|
|
|
|
|
|
|
local ifaces
|
|
|
|
config_get ifaces 'config' 'interface'
|
|
|
|
|
2015-03-01 12:25:02 +00:00
|
|
|
local iface ifnames=""
|
2013-01-02 14:35:43 +00:00
|
|
|
for iface in $ifaces; do
|
|
|
|
local ifname=""
|
|
|
|
if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
|
2015-03-01 12:25:02 +00:00
|
|
|
append ifnames "${ifname:-$iface}" ","
|
2013-01-02 14:35:43 +00:00
|
|
|
fi
|
|
|
|
done
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2015-09-16 08:32:27 +00:00
|
|
|
mkdir -p /var/run/lldp
|
|
|
|
chown lldp:lldp /var/run/lldp
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
procd_open_instance
|
|
|
|
procd_set_param command /usr/sbin/lldpd
|
|
|
|
procd_append_param command -d # don't daemonize, procd will handle that for us
|
2012-10-10 13:17:14 +00:00
|
|
|
|
2015-10-05 10:29:01 +00:00
|
|
|
[ -n "$ifnames" ] && procd_append_param command -I "$ifnames"
|
2015-09-16 08:32:33 +00:00
|
|
|
[ $enable_cdp -gt 0 ] && procd_append_param command '-c'
|
|
|
|
[ $enable_fdp -gt 0 ] && procd_append_param command '-f'
|
|
|
|
[ $enable_sonmp -gt 0 ] && procd_append_param command '-s'
|
|
|
|
[ $enable_edp -gt 0 ] && procd_append_param command '-e'
|
|
|
|
[ $readonly_mode -gt 0 ] && procd_append_param command '-r'
|
2015-10-05 10:29:01 +00:00
|
|
|
[ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class"
|
|
|
|
[ -n "$lldp_description" ] && procd_append_param command -S "$lldp_description"
|
2015-09-16 08:32:33 +00:00
|
|
|
|
|
|
|
# set auto respawn behavior
|
|
|
|
procd_set_param respawn
|
2015-09-16 08:32:41 +00:00
|
|
|
procd_append_param respawn 3600
|
|
|
|
procd_append_param respawn 5
|
|
|
|
procd_append_param respawn -1
|
2015-09-16 08:32:33 +00:00
|
|
|
procd_close_instance
|
2012-10-10 13:17:14 +00:00
|
|
|
}
|
|
|
|
|
2015-09-16 08:32:33 +00:00
|
|
|
stop_service() {
|
2012-10-12 11:58:19 +00:00
|
|
|
rm -f /var/run/lldpd.socket /var/run/lldpd.pid
|
2012-10-10 13:17:14 +00:00
|
|
|
}
|