#!/bin/sh set_default_config() { local cfg="$1" config_get type "$cfg" "type" case $type in atheros) uci -q batch <<-EOF set freifunk.wifi_device.channel=1 set freifunk.wifi_device.diversity=0 set freifunk.wifi_device.txantenna=1 set freifunk.wifi_device.rxantenna=1 set freifunk.wifi_device.disabled=0 set freifunk.wifi_device.txpower="" set freifunk.wifi_device.hwmode=11g set freifunk.wifi_device.distance=1000 set freifunk.wifi_iface=defaults set freifunk.wifi_iface.mode=adhoc set freifunk.wifi_iface.bssid="02:CA:FF:EE:BA:BE" set freifunk.wifi_iface.sw_merge=1 set freifunk.wifi_iface.mcast_rate=5500 set freifunk.wifi_iface.probereq=1 commit freifunk EOF ;; mac80211) uci -q batch <<-EOF set freifunk.wifi_device.channel=1 set freifunk.wifi_device.diversity="" set freifunk.wifi_device.disabled=0 set freifunk.wifi_device.txpower="" set freifunk.wifi_device.distance=1000 set freifunk.wifi_device.htmode='HT40-' set freifunk.wifi_device.hwmode=11ng set freifunk.wifi_iface=defaults set freifunk.wifi_iface.mode=adhoc set freifunk.wifi_iface.bssid="02:CA:FF:EE:BA:BE" set freifunk.wifi_iface.sw_merge="" commit freifunk EOF ;; broadcom) uci -q batch <<-EOF set freifunk.wifi_device.channel=1 set freifunk.wifi_device.diversity="" set freifunk.wifi_device.disabled=0 set freifunk.wifi_device.txpower="" set freifunk.wifi_device.txantenna=0 set freifunk.wifi_device.rxantenna=0 set freifunk.wifi_device.hwmode=11g set freifunk.wifi_device.distance=1000 set freifunk.wifi_iface=defaults set freifunk.wifi_iface.encryption=none set freifunk.wifi_iface.mode=adhoc set freifunk.wifi_iface.bssid="02:CA:FF:EE:BA:BE" set freifunk.wifi_iface.sw_merge="" commit freifunk EOF ;; esac } ( while true ; do sleep 30 wifie=0 config_load wireless && wifie=1 if [ $wifie -eq 1 ] ; then config_foreach set_default_config wifi-device uci set freifunk.interface.dns="88.198.178.18 141.54.1.1 212.204.49.83 8.8.8.8 8.8.4.4" uci commit freifunk exit 0 fi done ) >/dev/null &