This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50-config-from-mac
executable file
·66 lines (57 loc) · 1.72 KB
/
50-config-from-mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
set -e
set -u
mac=$(cat /sys/class/ieee80211/phy0/macaddress)
hostname=
channel_11a=
channel_11g=
if [ "$mac" = 60:e3:27:b8:16:ec ]; then
hostname=cz-ap0
channel_11g=6
elif [ "$mac" = 60:e3:27:ed:86:9a ]; then
hostname=cz-ap1
channel_11g=11
elif [ "$mac" = 78:8a:20:82:d6:bd ]; then
hostname=cz-ap2
channel_11a=48
channel_11g=6
htmode_11a=VHT80
elif [ "$mac" = 60:e3:27:ed:9b:b0 ]; then
hostname=lz-ap0
channel_11g=1
fi
# disable root password login
sed -i 's/^root.*$/root:*:0:0:99999:7:::/' /etc/shadow
uci set system.@system[0].hostname=$hostname
uci commit system
echo $(uci get system.@system[0].hostname) > /proc/sys/kernel/hostname
uci set dropbear.@dropbear[0].PasswordAuth='off'
uci set dropbear.@dropbear[0].RootPasswordAuth='off'
uci commit dropbear
/etc/init.d/dropbear restart
#WIFI_IFACES=$(uci show wireless | sed -nr 's/^wireless\.([^=]+)=wifi-iface*$/\1/p')
WIFI_DEVICES=$(uci show wireless | sed -nr 's/^wireless\.([^=]+)=wifi-device*$/\1/p')
for radio in $WIFI_DEVICES; do
disabled=true
if [ $(uci get wireless.$radio.hwmode) = '11a' ]; then
# 5 GHz
if [ -n "$channel_11a" ]; then
uci set wireless.$radio.channel=$channel_11a
uci set wireless.$radio.htmode=${htmode_11a:-HT20}
disabled=false
fi
elif [ $(uci get wireless.$radio.hwmode) = '11g' ]; then
# 2.4 GHz
if [ -n "$channel_11g" ]; then
uci set wireless.$radio.channel=$channel_11g
disabled=false
fi
fi
if $disabled; then
uci set wireless.$radio.disabled=1
else
uci delete wireless.$radio.disabled || true
fi
uci set wireless.$radio.country=AT
done
uci commit wireless