Support uplink network management when two wlan devices are available
[infodrom/musiikki-web.git] / bin / musiikki-essid
1 #! /bin/sh
2
3 uplink=$(grep ^uplink= /etc/musiikki.conf|sed 's/.*=\(.*\)/\1/')
4
5 if [ -z "$uplink" ]
6 then
7     exit
8 fi
9
10 read name
11 read essid
12 read password
13
14 logger -t musiikki "New ESSID $essid"
15
16 ifdown ${uplink} > /dev/null 2>&1
17
18 rm -f /etc/network/interfaces.d/uplink.conf
19
20 cat <<EOS > /etc/network/interfaces.d/upstream_${name}.conf
21 auto ${uplink}
22 iface ${uplink} inet dhcp
23    wpa-driver wext
24    wpa-scan-ssid 1
25    wpa-proto WPA RSN
26    wpa-key-mgmt WPA-PSK
27    wpa-pairwise CCMP TKIP
28    wpa-group CCMP TKIP
29    wpa-ssid ${essid}
30    wpa-psk ${psk}
31    up iptables-restore < /srv/musiikki/iptables_nat.conf
32 EOS
33
34 cd /etc/network/interfaces.d
35 ln -s upstream_${name}.conf uplink.conf
36 ifup ${uplink} > /dev/null 2>&1