blob: fd5532da9fe4592bc577d7af6ee843f375be0da3 [file] [log] [blame]
developer15a43312022-04-12 11:23:23 +08001# If not stated otherwise in this file or this component's LICENSE
2# file the following copyright and licenses apply:
3#
4#Copyright [2019] [RDK Management]
5#
6#Licensed under the Apache License, Version 2.0 (the "License");
7#you may not use this file except in compliance with the License.
8#You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12#Unless required by applicable law or agreed to in writing, software
13#distributed under the License is distributed on an "AS IS" BASIS,
14#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15#See the License for the specific language governing permissions and
16#limitations under the License.
17
18#!/bin/sh
19
20device_type=`cat /version.txt | grep imagename | cut -d':' -f2 | cut -d'-' -f3`
21echo "device_type: $device_type"
22if [ $device_type == "extender" ];
23then
24#Workaround: allowing devices initialization
25sleep 5;
26fi
27
28nvram_mounted=`mount | grep nvram -wc`
29if [ $nvram_mounted == 0 ]; then
30 mkdir -p /nvram
31 if [ -b /dev/mmcblk0p6 ]; then
32 #for Older Turris Omnia
33 mount /dev/mmcblk0p6 /nvram
34 else
35 #for Omnia2019 and Omnia2020
36 mount /dev/mmcblk0p5 /nvram
37 fi
38fi
39
40WIFI0_MAC=`cat /sys/class/net/wlan0/address`
41WIFI1_MAC=`cat /sys/class/net/wlan1/address`
42echo "2.4GHz Radio MAC: $WIFI0_MAC"
43echo "5GHz Radio MAC: $WIFI1_MAC"
44
45if [ ! -f /nvram/hostapd0.conf ]
46then
47 cp /etc/hostapd-2G.conf /nvram/hostapd0.conf
48 #Set bssid for wifi0
49 NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
50 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd0.conf
51 echo "wpa_psk_file=/tmp/hostapd0.psk" >> /nvram/hostapd0.conf
52fi
53
54if [ ! -f /nvram/hostapd1.conf ]
55then
56 cp /etc/hostapd-5G.conf /nvram/hostapd1.conf
57 #Set bssid for wifi1
58 NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+2, $2, $3, $4 ,$5, $6}')
59 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd1.conf
60 echo "wpa_psk_file=/tmp/hostapd1.psk" >> /nvram/hostapd1.conf
61fi
62
63if [ ! -f /nvram/hostapd2.conf ]
64then
65 cp /etc/hostapd-bhaul2G.conf /nvram/hostapd2.conf
66 #Set bssid for wifi2
67 NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+4, $2, $3, $4 ,$5, $6}')
68 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd2.conf
69 echo "wpa_psk_file=/tmp/hostapd2.psk" >> /nvram/hostapd2.conf
70fi
71
72if [ ! -f /nvram/hostapd3.conf ]
73then
74 cp /etc/hostapd-bhaul5G.conf /nvram/hostapd3.conf
75 #Set bssid for wifi3
76 NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+4, $2, $3, $4 ,$5, $6}')
77 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd3.conf
78 echo "wpa_psk_file=/tmp/hostapd3.psk" >> /nvram/hostapd3.conf
79fi
80
81if [ ! -f /nvram/hostapd4.conf ]
82then
83 cp /etc/hostapd-bhaul2G.conf /nvram/hostapd4.conf
84 #Set bssid for wifi4
85 NEW_MAC=$(echo 0x$WIFI0_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+6, $2, $3, $4 ,$5, $6}')
86 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd4.conf
87 sed -i "/^interface=/c\interface=wifi4" /nvram/hostapd4.conf
88 sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl4" /nvram/hostapd4.conf
89 echo "wpa_psk_file=/tmp/hostapd4.psk" >> /nvram/hostapd4.conf
90fi
91
92if [ ! -f /nvram/hostapd5.conf ]
93then
94 cp /etc/hostapd-bhaul5G.conf /nvram/hostapd5.conf
95 #Set bssid for wifi5
96 NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+6, $2, $3, $4 ,$5, $6}')
97 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd5.conf
98 sed -i "/^interface=/c\interface=wifi5" /nvram/hostapd5.conf
99 sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl5" /nvram/hostapd5.conf
100 echo "wpa_psk_file=/tmp/hostapd5.psk" >> /nvram/hostapd5.conf
101fi
102
103if [ ! -f /nvram/hostapd6.conf ]
104then
105 cp /etc/hostapd-bhaul2G.conf /nvram/hostapd6.conf
106 #Set bssid for wifi6
107 NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+8, $2, $3, $4 ,$5, $6}')
108 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd6.conf
109 sed -i "/^interface=/c\interface=wifi6" /nvram/hostapd6.conf
110 sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl6" /nvram/hostapd6.conf
111 echo "wpa_psk_file=/tmp/hostapd6.psk" >> /nvram/hostapd6.conf
112fi
113
114if [ ! -f /nvram/hostapd7.conf ]
115then
116 cp /etc/hostapd-bhaul5G.conf /nvram/hostapd7.conf
117 #Set bssid for wifi7
118 NEW_MAC=$(echo 0x$WIFI1_MAC| awk -F: '{printf "%02x:%s:%s:%s:%s:%s", strtonum($1)+8, $2, $3, $4 ,$5, $6}')
119 sed -i "/^bssid=/c\bssid=$NEW_MAC" /nvram/hostapd7.conf
120 sed -i "/^interface=/c\interface=wifi7" /nvram/hostapd7.conf
121 sed -i "/^accept_mac/c\accept_mac_file=/tmp/hostapd-acl7" /nvram/hostapd7.conf
122 echo "wpa_psk_file=/tmp/hostapd7.psk" >> /nvram/hostapd7.conf
123fi
124
125#Setting up VAP status file
126echo -e "wifi0=1\nwifi1=1\nwifi2=0\nwifi3=0\nwifi4=0\nwifi5=0\nwifi6=0\nwifi7=0" >/tmp/vap-status
127
128#Creating files for tracking AssociatedDevices
129touch /tmp/AllAssociated_Devices_2G.txt
130touch /tmp/AllAssociated_Devices_5G.txt
131
132if [ $device_type == "extender" ];
133then
134 ifconfig wlan0 down
135 ifconfig wlan1 down
136 exit 0;
137fi
138
139#Creating virtual interfaces wifi0 and wifi1 for Home APs
140iw dev wlan0 interface add wifi0 type __ap
141iw dev wlan1 interface add wifi1 type __ap
142
143#2.4GHz Virtual Access Points for backhaul connection
144iw dev wlan0 interface add wifi2 type __ap
145ip addr add 169.254.0.1/25 dev wifi2
146ifconfig wifi2 mtu 1600
147
148#5GHz Virtual Access Points for backhaul connection
149iw dev wlan1 interface add wifi3 type __ap
150ip addr add 169.254.1.1/25 dev wifi3
151ifconfig wifi3 mtu 1600
152
153#Creating virtual interfaces wifi4 and wifi5 for Guest APs
154iw dev wlan0 interface add wifi4 type __ap
155iw dev wlan1 interface add wifi5 type __ap
156
157#2.4GHz Virtual Access Points for Secure Onboard connection
158iw dev wlan0 interface add wifi6 type __ap
159ip addr add 169.254.0.129/25 dev wifi6
160ifconfig wifi6 mtu 1600
161
162#5GHz Virtual Access Points for onboard connection
163iw dev wlan1 interface add wifi7 type __ap
164ip addr add 169.254.1.129/25 dev wifi7
165ifconfig wifi7 mtu 1600
166
167#Creating virtual interfaces wifi8 and wifi9 for Service APs
168iw dev wlan0 interface add wifi8 type __ap
169iw dev wlan1 interface add wifi9 type __ap
170
171#Create empty acl list for hostapd
172touch /tmp/hostapd-acl0
173touch /tmp/hostapd-acl1
174touch /tmp/hostapd-acl2
175touch /tmp/hostapd-acl3
176touch /tmp/hostapd-acl4
177touch /tmp/hostapd-acl5
178touch /tmp/hostapd-acl6
179touch /tmp/hostapd-acl7
180touch /tmp/hostapd-acl8
181touch /tmp/hostapd-acl9
182
183#create empty psk files
184touch /tmp/hostapd0.psk
185touch /tmp/hostapd1.psk
186touch /tmp/hostapd2.psk
187touch /tmp/hostapd3.psk
188touch /tmp/hostapd6.psk
189touch /tmp/hostapd7.psk
190touch /tmp/hostapd8.psk
191touch /tmp/hostapd9.psk
192
193#Create wps pin request log file
194touch /var/run/hostapd_wps_pin_requests.log
195
196#Setting brlan0 bridge
197if [ ! -f /sys/class/net/brlan0 ]
198then
199 brctl addbr brlan0
200 ip link set brlan0 address `cat /sys/class/net/eth1/address`
201 ifconfig brlan0 10.0.0.1 netmask 255.255.255.0 up
202fi
203
204#Work around for Ethernet connected clients
205brctl addif brlan0 lan0
206brctl addif brlan0 lan1
207brctl addif brlan0 lan2
208brctl addif brlan0 lan3
209brctl addif brlan0 lan4
210
211ifconfig eth1 up
212ifconfig lan0 up
213ifconfig lan1 up
214ifconfig lan2 up
215ifconfig lan3 up
216ifconfig lan4 up
217
218#workaround: creating /opt/secure folder for ssh service
219mkdir /opt/secure
220
221exit 0
222