developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 3 | create_hostapdConf() { |
| 4 | devidx=0 |
| 5 | |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 6 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 7 | for _dev in /sys/class/ieee80211/*; do |
| 8 | [ -e "$_dev" ] || continue |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 9 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 10 | dev="${_dev##*/}" |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 11 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 12 | 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)" |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 17 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 18 | if [ "$(uci get wireless.radio${devidx}.disabled)" == "1" ]; then |
| 19 | devidx=$(($devidx + 1)) |
| 20 | continue |
| 21 | fi |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 22 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 23 | 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 |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 33 | |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 34 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 35 | if [ "$band" == "2g" ]; then |
| 36 | cp -f /etc/hostapd-2G.conf /nvram/hostapd"$devidx".conf |
| 37 | fi |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 38 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 39 | if [ "$band" == "5g" ]; then |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 40 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 41 | 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 |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 49 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 50 | if [ "$band" == "6g" ]; then |
| 51 | cp -f /etc/hostapd-6G.conf /nvram/hostapd"$devidx".conf |
| 52 | fi |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 53 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 54 | 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 | } |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 65 | echo -e "wifi0=1\nwifi1=1\nwifi2=0\nwifi3=0\nwifi4=0\nwifi5=0\nwifi6=0\nwifi7=0" >/tmp/vap-status |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 66 | #Creating files for tracking AssociatedDevices |
| 67 | touch /tmp/AllAssociated_Devices_2G.txt |
| 68 | touch /tmp/AllAssociated_Devices_5G.txt |
| 69 | |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 70 | #Create wps pin request log file |
| 71 | touch /var/run/hostapd_wps_pin_requests.log |
| 72 | |
developer | faf1ea2 | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 73 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 74 | create_hostapdConf |
developer | 880c829 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 75 | |
developer | 42af00d | 2022-08-29 18:59:45 +0800 | [diff] [blame^] | 76 | exit 0 |