blob: f65152b6d7b5018492c7cbbfe06ea6553f37fb30 [file] [log] [blame]
developer7b43f2d2022-04-29 17:53:25 +08001#!/bin/sh
2
developer08587352022-08-29 18:59:45 +08003create_hostapdConf() {
4 devidx=0
5
developer7b43f2d2022-04-29 17:53:25 +08006
developer08587352022-08-29 18:59:45 +08007 for _dev in /sys/class/ieee80211/*; do
8 [ -e "$_dev" ] || continue
developer7b43f2d2022-04-29 17:53:25 +08009
developer08587352022-08-29 18:59:45 +080010 dev="${_dev##*/}"
developer7b43f2d2022-04-29 17:53:25 +080011
developer08587352022-08-29 18:59:45 +080012 band="$(uci get wireless.radio${devidx}.band)"
13 channel="$(uci get wireless.radio${devidx}.channel)"
14 MAC="$(cat /sys/class/net/wlan${devidx}/address)"
15 NEW_MAC=$(echo 0x$MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
16 chip="$(cat /sys/class/ieee80211/"$dev"/device/device)"
developer7b43f2d2022-04-29 17:53:25 +080017
developer08587352022-08-29 18:59:45 +080018 if [ "$(uci get wireless.radio${devidx}.disabled)" == "1" ]; then
19 devidx=$(($devidx + 1))
20 continue
21 fi
developer7b43f2d2022-04-29 17:53:25 +080022
developer08587352022-08-29 18:59:45 +080023 if [ ! -f /nvram/hostapd"$devidx".conf ]; then
24 touch /nvram/hostapd"$devidx".conf
25 else
26 iw dev wlan$devidx interface add wifi$devidx type __ap
27 touch /tmp/hostapd-acl$devidx
28 touch /tmp/hostapd$devidx.psk
29 hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf
30 devidx=$(($devidx + 1))
31 continue
32 fi
developer7b43f2d2022-04-29 17:53:25 +080033
developer7b43f2d2022-04-29 17:53:25 +080034
developer08587352022-08-29 18:59:45 +080035 if [ "$band" == "2g" ]; then
36 cp -f /etc/hostapd-2G.conf /nvram/hostapd"$devidx".conf
37 fi
developer7b43f2d2022-04-29 17:53:25 +080038
developer08587352022-08-29 18:59:45 +080039 if [ "$band" == "5g" ]; then
developer7b43f2d2022-04-29 17:53:25 +080040
developer08587352022-08-29 18:59:45 +080041 if [ $chip == "0x7906" ]; then
42 cp -f /etc/hostapd-5G-7916.conf /nvram/hostapd"$devidx".conf
43 elif [ $chip == "0x7915" ]; then
44 cp -f /etc/hostapd-5G-7915.conf /nvram/hostapd"$devidx".conf
45 else
46 cp -f /etc/hostapd-5G.conf /nvram/hostapd"$devidx".conf
47 fi
48 fi
developer7b43f2d2022-04-29 17:53:25 +080049
developer08587352022-08-29 18:59:45 +080050 if [ "$band" == "6g" ]; then
51 cp -f /etc/hostapd-6G.conf /nvram/hostapd"$devidx".conf
52 fi
developer7b43f2d2022-04-29 17:53:25 +080053
developer08587352022-08-29 18:59:45 +080054 sed -i "/^interface=.*/c\interface=wifi$devidx" /nvram/hostapd"$devidx".conf
55 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd"$devidx".conf
56 echo "wpa_psk_file=/tmp/hostapd$devidx.psk" >> /nvram/hostapd"$devidx".conf
57 iw dev wlan$devidx interface add wifi$devidx type __ap
58 touch /tmp/hostapd-acl$devidx
59 touch /tmp/hostapd$devidx.psk
60 hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf
61 devidx=$(($devidx + 1))
62
63 done
64}
developer7b43f2d2022-04-29 17:53:25 +080065echo -e "wifi0=1\nwifi1=1\nwifi2=0\nwifi3=0\nwifi4=0\nwifi5=0\nwifi6=0\nwifi7=0" >/tmp/vap-status
developer7b43f2d2022-04-29 17:53:25 +080066#Creating files for tracking AssociatedDevices
67touch /tmp/AllAssociated_Devices_2G.txt
68touch /tmp/AllAssociated_Devices_5G.txt
69
developer7b43f2d2022-04-29 17:53:25 +080070#Create wps pin request log file
71touch /var/run/hostapd_wps_pin_requests.log
72
developer7b43f2d2022-04-29 17:53:25 +080073
developer08587352022-08-29 18:59:45 +080074create_hostapdConf
developer21ea8132022-07-11 11:52:59 +080075
developer08587352022-08-29 18:59:45 +080076exit 0