developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 3 | create_hostapdConf() { |
| 4 | devidx=0 |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 5 | phyidx=0 |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 6 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 7 | for _dev in /sys/class/ieee80211/*; do |
| 8 | [ -e "$_dev" ] || continue |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 9 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 10 | dev="${_dev##*/}" |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 11 | |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 12 | band="$(uci get wireless.radio${phyidx}.band)" |
| 13 | channel="$(uci get wireless.radio${phyidx}.channel)" |
| 14 | MAC="$(cat /sys/class/net/wlan${phyidx}/address)" |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 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 | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 17 | |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 18 | if [ "$(uci get wireless.radio${phyidx}.disabled)" == "1" ]; then |
| 19 | phyidx=$(($phyidx + 1)) |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 20 | continue |
| 21 | fi |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 22 | |
developer | 0858735 | 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 |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 26 | iw dev wlan$phyidx interface add wifi$devidx type __ap |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 27 | touch /tmp/hostapd-acl$devidx |
| 28 | touch /tmp/hostapd$devidx.psk |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 29 | touch /tmp/hostapd-deny$devidx |
| 30 | touch /tmp/$dev-wifi$devidx |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 31 | hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf |
| 32 | devidx=$(($devidx + 1)) |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 33 | phyidx=$(($phyidx + 1)) |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 34 | continue |
| 35 | fi |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 36 | |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 37 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 38 | if [ "$band" == "2g" ]; then |
| 39 | cp -f /etc/hostapd-2G.conf /nvram/hostapd"$devidx".conf |
| 40 | fi |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 41 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 42 | if [ "$band" == "5g" ]; then |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 43 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 44 | if [ $chip == "0x7906" ]; then |
| 45 | cp -f /etc/hostapd-5G-7916.conf /nvram/hostapd"$devidx".conf |
| 46 | elif [ $chip == "0x7915" ]; then |
| 47 | cp -f /etc/hostapd-5G-7915.conf /nvram/hostapd"$devidx".conf |
| 48 | else |
| 49 | cp -f /etc/hostapd-5G.conf /nvram/hostapd"$devidx".conf |
| 50 | fi |
| 51 | fi |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 52 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 53 | if [ "$band" == "6g" ]; then |
| 54 | cp -f /etc/hostapd-6G.conf /nvram/hostapd"$devidx".conf |
| 55 | fi |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 56 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 57 | sed -i "/^interface=.*/c\interface=wifi$devidx" /nvram/hostapd"$devidx".conf |
| 58 | sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd"$devidx".conf |
| 59 | echo "wpa_psk_file=/tmp/hostapd$devidx.psk" >> /nvram/hostapd"$devidx".conf |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 60 | iw dev wlan$phyidx interface add wifi$devidx type __ap |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 61 | touch /tmp/hostapd-acl$devidx |
| 62 | touch /tmp/hostapd$devidx.psk |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 63 | touch /tmp/hostapd-deny$devidx |
| 64 | touch /tmp/$dev-wifi$devidx |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 65 | hostapd_cli -i global raw ADD bss_config=$dev:/nvram/hostapd"$devidx".conf |
developer | ba026b6 | 2022-10-18 10:04:07 +0800 | [diff] [blame^] | 66 | devidx=$(($devidx + 1)) |
| 67 | phyidx=$(($phyidx + 1)) |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 68 | |
| 69 | done |
| 70 | } |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 71 | echo -e "wifi0=1\nwifi1=1\nwifi2=0\nwifi3=0\nwifi4=0\nwifi5=0\nwifi6=0\nwifi7=0" >/tmp/vap-status |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 72 | #Creating files for tracking AssociatedDevices |
| 73 | touch /tmp/AllAssociated_Devices_2G.txt |
| 74 | touch /tmp/AllAssociated_Devices_5G.txt |
| 75 | |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 76 | #Create wps pin request log file |
| 77 | touch /var/run/hostapd_wps_pin_requests.log |
| 78 | |
developer | 7b43f2d | 2022-04-29 17:53:25 +0800 | [diff] [blame] | 79 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 80 | create_hostapdConf |
developer | 21ea813 | 2022-07-11 11:52:59 +0800 | [diff] [blame] | 81 | |
developer | 0858735 | 2022-08-29 18:59:45 +0800 | [diff] [blame] | 82 | exit 0 |