/
checkForUpdate.sh
executable file
·41 lines (32 loc) · 1.21 KB
/
checkForUpdate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# /home/pi/HotspotUpdates/checkForUpdates.sh
# 5 Nov 2016 version 1.1
# Script to check for updates
echo "** `date` ** Checking for updates" >>/home/pi/HotspotUpdates/log
sudo rm -r /home/pi/HotspotUpdates/new
#turn the wifi back on
sudo airmon-ng stop mon0
sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode managed
sudo ifconfig wlan0 up
sleep 60
# Attempt to download Hotspot repository from github
git clone https://github.com/Thingitude/Hotspot /home/pi/HotspotUpdates/new
if [ -f /home/pi/HotspotUpdates/new/Version ]; then
version=`sudo python /home/pi/HotspotUpdates/checkForUpdate.py`
if [ $version -eq 1 ]; then
echo "No update received. Rebooting..." >>/home/pi/HotspotUpdates/log
else
echo "Updating..." >>/home/pi/HotspotUpdates/log
sudo rm -r /home/pi/HotspotUpdates/old
sudo mv /home/pi/Hotspot /home/pi/HotspotUpdates/old
sudo cp -r /home/pi/HotspotUpdates/new /home/pi/Hotspot
sudo chown -R pi:pi /home/pi/Hotspot
newver=`cat /home/pi/Hotspot/Version`
sudo /home/pi/Hotspot/update.sh
echo "Success! Updated to version $newver." >>/home/pi/HotspotUpdates/log
fi
else
echo "Failed. Could not clone repository." >>/home/pi/HotspotUpdates/log
fi
sudo reboot