From 6bdbd50aaf0344c1c17deabb5393a8f8f622af4f Mon Sep 17 00:00:00 2001 From: Bastian Bittorf Date: Wed, 25 Sep 2013 14:35:25 +0200 Subject: [PATCH] olsrd: added hotplug script, which is needed for openwrt >= r38023 - otherwise it can happen that several interfaces are not known to olsrd at boottime --- olsrd/Makefile | 2 ++ olsrd/files/olsrd.hotplug.sh | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 olsrd/files/olsrd.hotplug.sh diff --git a/olsrd/Makefile b/olsrd/Makefile index 364dea5..10bbf0c 100644 --- a/olsrd/Makefile +++ b/olsrd/Makefile @@ -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 index 0000000..467156f --- /dev/null +++ b/olsrd/files/olsrd.hotplug.sh @@ -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 +} -- 2.30.2