From 545930b0bb2a47ade9a9abbae1be436b9f5ad5e5 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Thu, 22 Sep 2016 20:43:53 +0200 Subject: [PATCH] gluon-respondd: Adapt to new respondd version The new version supports loading the list of multicast interfaces from a file and brings its own initscript and UCI configuration. --- modules | 2 +- .../etc/hotplug.d/iface/10-gluon-respondd | 14 +++--- .../files/etc/init.d/gluon-respondd | 45 ------------------- .../lib/autoupdater/abort.d/50gluon-respondd | 2 +- .../autoupdater/download.d/50gluon-respondd | 2 +- .../{400-respondd-firewall => 400-respondd} | 6 +++ 6 files changed, 17 insertions(+), 54 deletions(-) delete mode 100755 package/gluon-respondd/files/etc/init.d/gluon-respondd rename package/gluon-respondd/luasrc/lib/gluon/upgrade/{400-respondd-firewall => 400-respondd} (73%) diff --git a/modules b/modules index c185e366..1945899a 100644 --- a/modules +++ b/modules @@ -9,7 +9,7 @@ PACKAGES_OPENWRT_COMMIT=73776792f7d58e982be9e5819450d4875b273159 PACKAGES_OPENWRT_BRANCH=for-15.05 PACKAGES_GLUON_REPO=git://github.com/freifunk-gluon/packages.git -PACKAGES_GLUON_COMMIT=90380414f10842238b7ebc21c34dbaf986659320 +PACKAGES_GLUON_COMMIT=b1249e72e5d42a5af6cb2fe7cc5d62fa17eb4860 PACKAGES_ROUTING_REPO=git://github.com/openwrt-routing/packages.git PACKAGES_ROUTING_COMMIT=a4eae82c155079a4372e4b910ec733f77288b717 diff --git a/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd b/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd index 4f49be52..30e10f55 100644 --- a/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd +++ b/package/gluon-respondd/files/etc/hotplug.d/iface/10-gluon-respondd @@ -3,7 +3,7 @@ . /usr/share/libubox/jshn.sh . /lib/functions/service.sh -DEVLIST=/var/run/gluon-respondd.devs +DEVLIST="$(uci_get "respondd.@respondd[0].iface_list_file")" ifname_to_dev () { json_load "$(ubus call network.interface.$1 status)" @@ -14,7 +14,8 @@ ifname_to_dev () { case "$ACTION" in ifdown) - sed "/ $INTERFACE$/d" $DEVLIST > $DEVLIST.new + DEVICE="$(ifname_to_dev "$INTERFACE")" + sed "/^$DEVICE$/d" $DEVLIST > $DEVLIST.new mv $DEVLIST.new $DEVLIST ;; ifup) @@ -23,12 +24,13 @@ case "$ACTION" in [ "$MESH" = "bat0" -o "$INTERFACE" = "client" ] || exit 0 - DEVS=$(cat $DEVLIST 2>/dev/null; echo $DEVICE $INTERFACE) - - echo "$DEVS" | sort -u > $DEVLIST.new + { + cat $DEVLIST 2>/dev/null + echo $DEVICE + } | sort -u > $DEVLIST.new mv $DEVLIST.new $DEVLIST - /etc/init.d/gluon-respondd restart_if_running & + /etc/init.d/respondd reload & ;; esac diff --git a/package/gluon-respondd/files/etc/init.d/gluon-respondd b/package/gluon-respondd/files/etc/init.d/gluon-respondd deleted file mode 100755 index a1bf979f..00000000 --- a/package/gluon-respondd/files/etc/init.d/gluon-respondd +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh /etc/rc.common - -EXTRA_COMMANDS='restart_if_running' - -START=50 - -SERVICE_WRITE_PID=1 -SERVICE_DAEMONIZE=1 - -DEVLIST=/var/run/gluon-respondd.devs -DAEMON=/usr/bin/respondd -LOCK=/var/run/gluon-respondd.lock - - -do_start() { - DEVS=$(cat $DEVLIST 2>/dev/null | while read dev iface; do echo -n " -i $dev"; done) - service_start $DAEMON -g ff02::2:1001 -p 1001 -d /lib/gluon/respondd $DEVS -} - -do_stop() { - service_stop $DAEMON -} - -start() { - lock $LOCK - do_start - lock -u $LOCK -} - -stop() { - lock $LOCK - do_stop - lock -u $LOCK -} - -restart_if_running() { - lock $LOCK - - if service_check $DAEMON; then - do_stop - do_start - fi - - lock -u $LOCK -} diff --git a/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd b/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd index d29af306..42c6a0e1 100755 --- a/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd +++ b/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd @@ -3,4 +3,4 @@ . /lib/gluon/autoupdater/lib.sh -start_enabled gluon-respondd +start_enabled respondd diff --git a/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd b/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd index 3edd5f1d..0c27a2b3 100755 --- a/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd +++ b/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd @@ -3,4 +3,4 @@ . /lib/gluon/autoupdater/lib.sh -stop gluon-respondd +stop respondd diff --git a/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall b/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd similarity index 73% rename from package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall rename to package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd index a78cfb3d..a35977cc 100755 --- a/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall +++ b/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd @@ -29,3 +29,9 @@ uci:section('firewall', 'rule', 'client_respondd', ) uci:save('firewall') + +uci:foreach('respondd', 'respondd', function(section) + uci:set('respondd', section['.name'], 'iface_list_file', '/var/run/gluon-respondd.devs') + uci:set('respondd', section['.name'], 'data_dir', '/lib/gluon/respondd/') +end) +uci:save('respondd')