-
Notifications
You must be signed in to change notification settings - Fork 113
/
firstbootupdate
executable file
·36 lines (28 loc) · 1.2 KB
/
firstbootupdate
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
#!/bin/bash
# NOT USED ANYMORE REPLACED BY: https://github.com/openenergymonitor/EmonScripts/blob/master/update/firstbootupdate
# 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 or LCD push button (GPIO 23) is pressed (high when pressed)
# To rc.local before exit 0 add:
# su pi -c '/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 internet connectivity..,\n"
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
/home/pi/emonpi/service-runner-update.sh 2>&1 >> /home/pi/data/emonpiupdate.log 2>&1
# set permissions on newly created logfile so emonpiupdate script an write to it
sudo chmod 666 /home/pi/data/emonpiupdate.log
fi
else
echo "Not first boot"
exit
fi
exit