]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - scripts/setup_wireless_cape.sh
Updated TI Linux Sensor To Cloud to the latest TI 15.4-Stack v2.4, now with CC13x2...
[apps/tidep0084.git] / scripts / setup_wireless_cape.sh
1 #!/bin/bash
3 HERE=$PWD
5 echo "Do you want to configure the BeagleBone Black to use the Wireless cape? (y/n)"
6 read INPUT
7 while [ "${INPUT}" != "y" ] && [ "${INPUT}" != "n" ]
8 do
9   echo "Do you want to configure the BeagleBone Black to use the Wireless cape? (y/n)"
10   read INPUT
11 done
12 if [ "${INPUT}" == "n" ]
13 then
14   exit 0
15 fi
17 if [ ! -f "/boot/am335x-boneblack.dtb" ]
18 then
19   echo "Cannot find device tree file /boot/am335x-boneblack.dtb."
20   echo "Make sure to boot from the am335x processor SDK flashed onto an SD card."
21   echo "You can boot to the SD card by holding S1 on power-up."
22   exit 1
23 fi
26 if [ -f "../devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb" ]
27 then
28   cp ../devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb /boot/
29   cd /boot/
30   mv am335x-boneblack.dtb am335x-boneblack.dtb.backup
31   ln -s devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb am335x-boneblack.dtb
32   echo "wifi-cape device tree will be used on next boot. Execute the following command to revert to the stock device tree file:"
33   echo "ln -s devicetree-zImage-am335x-evm.dtb am335x-boneblack.dtb"
34 fi
36 if [ ! -d "/usr/sbin/wlconf" ]
37 then
38   cp -r /usr/bin/wlconf/ /usr/sbin
39   cd /usr/sbin/wlconf/
40 # echo "Enter the following to configure Wi-Fi cape:"
41 # echo "Using a TI module? -> yes"
42 # echo "Chip flavor -> 1837"
43 # echo "Japanese standards? -> no"
44 # echo "Number of 2.4 GHz antennas -> 2"
45 # echo "Number of 5 GHz antennas -> 1"
46   sh configure-device.sh << EOD
47 y
48 1837
49 n
50 2
51 1
52 EOD
53 fi
55 # change HOSTAPD_BIN_DIR form /usr/local/bin to /usr/bin
56 cd /usr/share/wl18xx/
57 sed -i -e 's/local\/bin/sbin/g' ap_start.sh
59 echo "This BeagleBone will now advertise a Wi-Fi network."
60 echo "Enter your desired network name. Press enter to skip."
61 read NET_NAME
62 if [ "x${NET_NAME}x" != "xx" ] ; then
63   echo "SSID is now ${NET_NAME}"
64   sed -i -e "/^ssid=/ s/=.*/=${NET_NAME}/" /usr/share/wl18xx/hostapd.conf
65 fi
67 echo "Please enter a password for this network (must be at least 8 characters)."
68 echo "Press enter to leave the network open."
69 read PASSWORD
70 echo "Please enter your password again."
71 read PASS2
72 if [ $PASSWORD == $PASS2 ]
73 then
74   if [ "x${PASSWORD}x" == 'xx' ]
75   then
76     echo "${NET_NAME} is now an open network."
77     sed -i "/wpa=1/s/^/#/" /usr/share/wl18xx/hostapd.conf
78     # sed -i -e "/wpa_passphrase/ s/=.*/=${PASSWORD}/" /usr/share/wl18xx/hostapd.conf
79     sed -i "/wpa_passphrase=/s/^/#/" /usr/share/wl18xx/hostapd.conf
80     sed -i "/wpa_key_mgmt=/s/^/#/" /usr/share/wl18xx/hostapd.conf
81   else
82     echo "Success. Password is '${PASSWORD}'"
83     sed -i "/wpa=1/s/^#//" /usr/share/wl18xx/hostapd.conf
84     sed -i -e "/wpa_passphrase/ s/=.*/=${PASSWORD}/" /usr/share/wl18xx/hostapd.conf
85     sed -i "/wpa_passphrase=/s/^#//" /usr/share/wl18xx/hostapd.conf
86     sed -i "/wpa_key_mgmt=/s/^#//" /usr/share/wl18xx/hostapd.conf
87     sed -i -e "/wpa_key_mgmt/ s/=.*/=WPA-PSK/" /usr/share/wl18xx/hostapd.conf
88   fi
89 else
90   echo "Passwords do not match. Password not changed. Please run script again to change password."
91   exit 1
92 fi
94 echo "Reboot required for changes to take effect. Reboot now? (y/n)"
95 read INPUT
96 while [ "${INPUT}" != "y" ] && [ "${INPUT}" != "n" ]
97 do
98   echo "Reboot required for changes to take effect. Reboot now? (y/n)"
99   read INPUT
100 done
102 if [ "${INPUT}" == "y" ]
103 then
104   reboot
105 fi
107 exit 0