olsrd: added hotplug script, which is needed for openwrt >= r38023 - otherwise it...
authorBastian Bittorf <bittorf@bluebottle.com>
Wed, 25 Sep 2013 12:35:25 +0000 (14:35 +0200)
committerBastian Bittorf <bittorf@bluebottle.com>
Wed, 25 Sep 2013 12:36:21 +0000 (14:36 +0200)
olsrd/Makefile
olsrd/files/olsrd.hotplug.sh [new file with mode: 0755]

index 364dea5e8a555b1f7f01985b58123e1cdfcd6855..10bbf0ceee366de791384bf52f28c53e7dd93fe2 100644 (file)
@@ -175,6 +175,8 @@ define Package/olsrd/install
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/olsrd.init $(1)/etc/init.d/olsrd
+       $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+       $(INSTALL_BIN) ./files/olsrd.hotplug.sh $(1)/etc/hotplug.d/iface/50-olsrd
 endef
 
 define Package/olsrd-mod-arprefresh/install
diff --git a/olsrd/files/olsrd.hotplug.sh b/olsrd/files/olsrd.hotplug.sh
new file mode 100755 (executable)
index 0000000..467156f
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+[ "$ACTION" = ifup ] || exit 0
+/etc/init.d/olsrd enabled || exit 0
+
+olsrd_list_configured_interfaces()
+{
+       local i=0
+       local interface
+
+       while interface="$( uci -q get olsrd.@Interface[$i].interface )"; do {
+               case "$( uci -q get olsrd.@Interface[$i].ignore )" in
+                       1|on|true|enabled|yes)
+                               # is disabled
+                       ;;
+                       *)
+                               echo "$interface"
+                       ;;
+               esac
+
+               i=$(( $i + 1 ))
+       } done
+}
+
+olsrd_interface_needs_adding()
+{
+       local interface="$1"    # e.g. wlanadhocRADIO1
+       local device="$2"       # e.g. wlan1-1
+       local myif
+       local config="/var/etc/olsrd.conf"
+
+       for myif in $(olsrd_list_configured_interfaces); do {
+               [ "$myif" = "$interface" ] && {
+                       if grep -s ^'Interface ' "$config" | grep -q "\"$device\""; then
+                               logger -t olsrd_hotplug -p daemon.debug "[OK] already_active: $INTERFACE => $DEVICE"
+                               return 1
+                       else
+                               logger -t olsrd_hotplug -p daemon.info "[OK] ifup: $INTERFACE => $DEVICE"
+                               return 0
+                       fi
+               }
+       } done
+
+       logger -t olsrd_hotplug -p daemon.debug "[OK] interface $INTERFACE not used for olsrd"
+       return 1
+}
+
+olsrd_interface_needs_adding "$INTERFACE" "$DEVICE" && {
+       /etc/init.d/olsrd restart
+}