branding: add LEDE branding
[openwrt/staging/dedeckeh.git] / package / network / services / lldpd / files / lldpd.init
index fca0ebfcc77e59cab9649d64db2f473f48c505ae..633a8fbc073973111c60c2d9e61fdac9549e7625 100644 (file)
@@ -1,9 +1,12 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2008-2012 OpenWrt.org
+# Copyright (C) 2008-2015 OpenWrt.org
 
 START=90
+STOP=01
 
 USE_PROCD=1
+LLDPCLI=/usr/sbin/lldpcli
+LLDPSOCKET=/var/run/lldpd.socket
 
 find_release_info()
 {
@@ -11,7 +14,7 @@ find_release_info()
        [ -z "$DISTRIB_DESCRIPTION" ] && [ -s /etc/openwrt_version ] && \
                DISTRIB_DESCRIPTION="$(cat /etc/openwrt_version)"
 
-       echo "${DISTRIB_DESCRIPTION:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
+       echo "${DISTRIB_DESCRIPTION:-Unknown Lede release} @ $(cat /proc/sys/kernel/hostname)"
 }
 
 start_service() {
@@ -54,20 +57,38 @@ start_service() {
        procd_set_param command /usr/sbin/lldpd
        procd_append_param command -d # don't daemonize, procd will handle that for us
 
-       [ -n "$ifnames" ] && procd_append_param command "-I $ifnames"
+       [ -n "$ifnames" ] && procd_append_param command -I "$ifnames"
        [ $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'
-       [ -n "$lldp_class" ] && procd_append_param command "-M $lldp_class"
-       [ -n "$lldp_description" ] && procd_append_param command "-S $lldp_description"
+       [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class"
+       [ -n "$lldp_description" ] && procd_append_param command -S "$lldp_description"
 
        # set auto respawn behavior
        procd_set_param respawn
+       procd_append_param respawn 3600
+       procd_append_param respawn 5
+       procd_append_param respawn -1
        procd_close_instance
 }
 
+service_running() {
+       pgrep -x /usr/sbin/lldpd &> /dev/null
+}
+
+reload_service() {
+       running || return 1
+       # Custom TLVs are special and should be
+       # reloaded from config during lldpd reload
+       $LLDPCLI -u $LLDPSOCKET unconfigure lldp custom-tlv &> /dev/null
+       $LLDPCLI -u $LLDPSOCKET -c /etc/lldpd.conf -c /etc/lldpd.d &> /dev/null
+       # Broadcast update over the wire
+       $LLDPCLI -u $LLDPSOCKET update &> /dev/null
+       return 0
+}
+
 stop_service() {
-       rm -f /var/run/lldpd.socket /var/run/lldpd.pid
+       rm -rf /var/run/lldp $LLDPSOCKET
 }