olsrd: hotplug script works for IPv4 and IPv6 30/head
authorAlessio Caiazza <nolith@abisso.org>
Wed, 28 May 2014 15:45:10 +0000 (17:45 +0200)
committerAlessio Caiazza <nolith@abisso.org>
Wed, 28 May 2014 15:45:10 +0000 (17:45 +0200)
This should fix issue #16

olsrd/files/olsrd.hotplug.sh

index 2094463fc1a8c512eb1e03bbb6006fd9fec87d93..9e5f0ca72cff5126dbeff80c1cb99ab92c0daaf3 100755 (executable)
@@ -5,8 +5,8 @@ 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
+       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
                        ;;
@@ -22,7 +22,7 @@ olsrd_list_configured_interfaces()
 olsrd_interface_already_in_config()
 {
        # e.g.: 'Interface "eth0.1" "eth0.2" "wlan0"'
-       if grep -s ^'Interface ' '/var/etc/olsrd.conf' | grep -q "\"$DEVICE\""; then
+       if grep -s ^'Interface ' '/var/etc/$OLSRD.conf' | grep -q "\"$DEVICE\""; then
                logger -t olsrd_hotplug -p daemon.debug "[OK] already_active: '$INTERFACE' => '$DEVICE'"
                return 0
        else
@@ -44,7 +44,7 @@ olsrd_interface_needs_adding()
                }
        } done
 
-       logger -t olsrd_hotplug -p daemon.debug "[OK] interface '$INTERFACE' => '$DEVICE' not used for olsrd"
+       logger -t olsrd_hotplug -p daemon.debug "[OK] interface '$INTERFACE' => '$DEVICE' not used for $OLSRD"
        return 1
 }
 
@@ -52,11 +52,19 @@ case "$ACTION" in
        ifup)
                # only work after the first normal startup
                # also: no need to test, if enabled
-               [ -e '/var/etc/olsrd.conf' ] && {
+               OLSRD=olsrd4
+               [ -e "/var/etc/$OLSRD.conf" ] && {
                        # INTERFACE = e.g. 'wlanadhocRADIO1' or 'cfg144d8f'
                        # DEVICE    = e.g. 'wlan1-1'
                        olsrd_interface_needs_adding && {
-                               . /etc/rc.common /etc/init.d/olsrd restart
+                               . /etc/rc.common /etc/init.d/$OLSRD restart
+                       }
+               }
+
+               OLSRD=olsrd6
+               [ -e "/var/etc/$OLSRD.conf" ] && {
+                       olsrd_interface_needs_adding && {
+                               . /etc/rc.common /etc/init.d/$OLSRD restart
                        }
                }
        ;;