Author: nbd
Date: 2015-11-03 12:59:09 +0100 (Tue, 03 Nov 2015)
New Revision: 47367

Modified:
   trunk/package/network/services/lldpd/files/lldpd.init
Log:
lldpd: implement a reload hook

Seems the default one is not working as expected.
The way that reload should work is that the 'start' service
call should return 1 (if lldpd is running) and then a normal
restart would be called.

However, for lldpd a reload would mean just clearing all custom TLVs
(if they're configured) and reloading the configuration.

So, this patch adds a reload hook, which would:
 - 'start' lldpd if it's not running (because we return 1 if not running)
 - reload configuration if it is running (also previously
    clearing custom TLVs if present)

Signed-off-by: Alexandru Ardelean <[email protected]>

Modified: trunk/package/network/services/lldpd/files/lldpd.init
===================================================================
--- trunk/package/network/services/lldpd/files/lldpd.init       2015-11-03 
11:08:53 UTC (rev 47366)
+++ trunk/package/network/services/lldpd/files/lldpd.init       2015-11-03 
11:59:09 UTC (rev 47367)
@@ -4,6 +4,8 @@
 START=90
 
 USE_PROCD=1
+LLDPCLI=/usr/sbin/lldpcli
+LLDPSOCKET=/var/run/lldpd.socket
 
 find_release_info()
 {
@@ -71,6 +73,21 @@
        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
 }
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to