Skip to content

Instantly share code, notes, and snippets.

@stephanschuler
Created May 17, 2017 16:07
Show Gist options
  • Save stephanschuler/74a6dcdb80c72490ea4cc7f9de65e372 to your computer and use it in GitHub Desktop.
Save stephanschuler/74a6dcdb80c72490ea4cc7f9de65e372 to your computer and use it in GitHub Desktop.
#!/bin/sh
################################################################
# Individual channel setting per distinct AP
case `uci get system.@system[0].hostname` in
"ap1")
CHANNELS="36 1"
;;
"ap2")
CHANNELS="5"
;;
"ap3")
CHANNELS="5 44"
;;
"ap4")
CHANNELS="60 9"
;;
"ap5")
CHANNELS="52 13"
;;
*)
echo "Not a known host"
exit
esac
################################################################
# Start with fresh wifi setting
rm -f /etc/config/wireless
wifi config
uci commit wireless
################################################################
# Delete existing SSIDs
uci show wireless | grep =wifi-iface | awk -F= '{ print $1 }' | while read -r IFACE ; do
uci delete wireless.@wifi-iface[0]
done
################################################################
# Add a couple of SSIDs
add_iface() {
uci add wireless wifi-iface > /dev/null
uci set wireless.@wifi-iface[-1].device="$1"
uci set wireless.@wifi-iface[-1].mode='ap'
uci set wireless.@wifi-iface[-1].ssid="$3"
uci set wireless.@wifi-iface[-1].encryption="psk-mixed"
uci set wireless.@wifi-iface[-1].key="$4"
uci set wireless.@wifi-iface[-1].network="$2"
uci set wireless.@wifi-iface[-1].wpa_group_rekey='0'
uci set wireless.@wifi-iface[-1].hidden="$5"
}
uci show wireless | grep \\.radio.= | awk -F. '{ print $2}' | awk -F= '{ print $1 }' | while read -r DEVICE ; do
uci set wireless.$DEVICE.disabled=0
# add_iface "$DEVICE" NETWORK SSID PASSWORD HIDDEN
add_iface "$DEVICE" "lan" "my-lan" "pw-for-lan" "1"
add_iface "$DEVICE" "guest" "my-guest" "pw-for-guest" "0"
add_iface "$DEVICE" "roommate" "my-roommate" "pw-for-roommate" "1"
add_iface "$DEVICE" "dmz" "my-dmz" "pw-for-dmz" "1"
done
################################################################
# Some tweaking
COUNTER=0
for CHANNEL in $CHANNELS ; do
uci set wireless.radio$COUNTER.channel=$CHANNEL
uci set wireless.radio$COUNTER.country="DE"
uci set wireless.radio$COUNTER.doth='1'
uci set wireless.radio$COUNTER.wwm='1'
uci set wireless.radio$COUNTER.ff='1'
uci set wireless.radio$COUNTER.bursting='1'
uci set wireless.radio$COUNTER.compression='1'
if [ "$CHANNEL" -lt "20" ]
then
uci set wireless.radio$COUNTER.distance='20'
uci set wireless.radio$COUNTER.beacon_int='300'
else
uci set wireless.radio$COUNTER.beacon_int='100'
fi
COUNTER=$((COUNTER+1))
done
################################################################
# Commit
uci commit wireless
/etc/init.d/network restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment