forked from openenergymonitor/emonpi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstbootupdate
More file actions
executable file
·34 lines (29 loc) · 1.05 KB
/
firstbootupdate
File metadata and controls
executable file
·34 lines (29 loc) · 1.05 KB
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
#!/bin/bash
# Script to update new emonPi's to latest firmware and software the fist time they are booted up in the factory
# Looks to see if /home/pi/data/emonpiupdate.log exists, if it does not then run update script
# To rc.local before exit 0 add:
# /home/pi/emonpi/./firstbootupdate
# Check if update log file is empty if so then proceed to update
if [ ! -s /home/pi/data/emonpiupdate.log ]; then
echo "First Boot Update.."
printf "Checking interent connectivity...wait 5s\n"
sleep 30
WGET="/usr/bin/wget"
$WGET -q --tries=20 --timeout=5 http://www.google.com -O /tmp/google.idx &> /dev/null
if [ ! -s /tmp/google.idx ]; then
echo "No Internet connection :-("
else
echo "Internet connection detected running update.."
connected=true
fi
if [ "$connected" = true ]; then
touch /tmp/emonpiupdate
/home/pi/emonpi/update 2>&1 >> /home/pi/data/emonpiupdate.log 2>&1
fi
else
echo "Not first boot"
exit
fi
# set permissions on newly created logfile so emonpiupdate script an write to it
sudo chmod 666 /home/pi/data/emonpiupdate.log
exit