olsrd: added hotplug script, which is needed for openwrt >= r38023 - otherwise it...
[feed/routing.git] / olsrd / files / olsrd.hotplug.sh
1 #!/bin/sh
2
3 [ "$ACTION" = ifup ] || exit 0
4 /etc/init.d/olsrd enabled || exit 0
5
6 olsrd_list_configured_interfaces()
7 {
8 local i=0
9 local interface
10
11 while interface="$( uci -q get olsrd.@Interface[$i].interface )"; do {
12 case "$( uci -q get olsrd.@Interface[$i].ignore )" in
13 1|on|true|enabled|yes)
14 # is disabled
15 ;;
16 *)
17 echo "$interface"
18 ;;
19 esac
20
21 i=$(( $i + 1 ))
22 } done
23 }
24
25 olsrd_interface_needs_adding()
26 {
27 local interface="$1" # e.g. wlanadhocRADIO1
28 local device="$2" # e.g. wlan1-1
29 local myif
30 local config="/var/etc/olsrd.conf"
31
32 for myif in $(olsrd_list_configured_interfaces); do {
33 [ "$myif" = "$interface" ] && {
34 if grep -s ^'Interface ' "$config" | grep -q "\"$device\""; then
35 logger -t olsrd_hotplug -p daemon.debug "[OK] already_active: $INTERFACE => $DEVICE"
36 return 1
37 else
38 logger -t olsrd_hotplug -p daemon.info "[OK] ifup: $INTERFACE => $DEVICE"
39 return 0
40 fi
41 }
42 } done
43
44 logger -t olsrd_hotplug -p daemon.debug "[OK] interface $INTERFACE not used for olsrd"
45 return 1
46 }
47
48 olsrd_interface_needs_adding "$INTERFACE" "$DEVICE" && {
49 /etc/init.d/olsrd restart
50 }