1 #!/bin/bash
3 HERE=$PWD
5 if [ ! -f "/boot/am335x-boneblack.dtb" ]
6 then
7 echo "Cannot find device tree file /boot/am335x-boneblack.dtb."
8 echo "Make sure to boot from the am335x processor SD card by holding S1 on power-up."
9 exit 1
10 fi
13 if [ -f "devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb" ] && [ ! -f "/boot/devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb" ]
14 then
15 cp devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb /boot/
16 cd /boot/
17 mv am335x-boneblack.dtb am335x-boneblack.dtb.backup
18 ln -s devicetree-zImage-am335x-boneblack-wifi-cape-e14.dtb am335x-boneblack.dtb
19 fi
21 if [ ! -d "/usr/sbin/wlconf" ]
22 then
23 cp -r /usr/bin/wlconf/ /usr/sbin
24 cd /usr/sbin/wlconf/
25 # echo "Enter the following to configure Wi-Fi cape:"
26 # echo "Using a TI module? -> yes"
27 # echo "Chip flavor -> 1837"
28 # echo "Japanese standards? -> no"
29 # echo "Number of 2.4 GHz antennas -> 2"
30 # echo "Number of 5 GHz antennas -> 1"
31 sh configure-device.sh << EOD
32 y
33 1837
34 n
35 2
36 1
37 EOD
38 fi
40 # change HOSTAPD_BIN_DIR form /usr/local/bin to /usr/bin
41 cd /usr/share/wl18xx/
42 sed -i -e 's/local\/bin/sbin/g' ap_start.sh
44 if [ ! -f "/etc/systemd/system/autostart.service" ]
45 then
46 echo "Installing autostart service to run at start-up"
47 cd $HERE/example/commissioner/
48 cp autostart.service /etc/systemd/system/
49 systemctl daemon-reload
50 systemctl enable autostart.service
51 fi
53 echo "This BeagleBone will now advertise a Wi-Fi network. Please enter desired network name."
54 read NET_NAME
55 if [ "x${NET_NAME}x" != "xx" ] ; then
56 echo "SSID is now ${NET_NAME}"
57 sed -i -e "/^ssid=/ s/=.*/=${NET_NAME}/" /usr/share/wl18xx/hostapd.conf
58 fi
60 echo "Please enter a password for this network (must be at least 8 characters)."
61 read PASSWORD
62 echo "Please enter your password again."
63 read PASS2
64 if [ $PASSWORD == $PASS2 ]
65 then
66 if [ "x${PASSWORD}x" == 'xx' ]
67 then
68 echo "SitaraAP is now an open network."
69 sed -i "/wpa=1/s/^/#/" /usr/share/wl18xx/hostapd.conf
70 # sed -i -e "/wpa_passphrase/ s/=.*/=${PASSWORD}/" /usr/share/wl18xx/hostapd.conf
71 sed -i "/wpa_passphrase=/s/^/#/" /usr/share/wl18xx/hostapd.conf
72 sed -i "/wpa_key_mgmt=/s/^/#/" /usr/share/wl18xx/hostapd.conf
73 else
74 echo "Success. Password is '${PASSWORD}'"
75 sed -i "/wpa=1/s/^#//" /usr/share/wl18xx/hostapd.conf
76 sed -i -e "/wpa_passphrase/ s/=.*/=${PASSWORD}/" /usr/share/wl18xx/hostapd.conf
77 sed -i "/wpa_passphrase=/s/^#//" /usr/share/wl18xx/hostapd.conf
78 sed -i "/wpa_key_mgmt=/s/^#//" /usr/share/wl18xx/hostapd.conf
79 sed -i -e "/wpa_key_mgmt/ s/=.*/=WPA-PSK/" /usr/share/wl18xx/hostapd.conf
80 fi
81 else
82 echo "Passwords do not match. Password not changed. Please run script again to change password."
83 exit 1
84 fi
86 echo "SensorToCloud" > /etc/hostname
88 echo "Checking node_modules dependencies..."
89 if [ ! -d "${HERE}/example/commissioner/webserver/uploads" ]
90 then
91 cd ${HERE}/example/commissioner/webserver/
92 mkdir uploads
93 fi
94 if [ -d "${HERE}/example/iot-gateway/node_modules" ]
95 then
96 echo "node_modules found for iot-gateway!"
97 else
98 npm config set proxy http://webproxy.ext.ti.com:80
99 npm config set registry http://registry.npmjs.org/
100 cd ${HERE}/example/iot-gateway/
101 echo "Installing node_modules for iot-gateway"
102 npm install
103 fi
105 if [ -d "${HERE}/example/commissioner/node_modules" ]
106 then
107 echo "node_modules found for commisioner!"
108 else
109 echo "Installing node_modules for commissioner"
110 cd ${HERE}/example/commissioner/
111 npm install
112 fi
114 echo "Reboot system for changes to take effect"
116 exit 0