-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathservice-runner-update.sh
executable file
·148 lines (123 loc) · 3.61 KB
/
service-runner-update.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# emonPi update for use with service-runner add following entry to crontab:
# * * * * * /home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1
echo "#############################################################"
# Clear log update file
cat /dev/null > /home/pi/data/emonpiupdate.log
echo "Starting emonPi Update >"
echo "via service-runner-update.sh"
echo "Service Runner update script V1.1.1"
echo "EUID: $EUID"
argument=$1
echo "Argument: "$argument
# Date and time
date
echo "#############################################################"
echo
# Check emonSD base image is minimum required release date, else don't update
image_version=$(ls /boot | grep emonSD)
echo "emonSD version: $image_version"
echo
if [ "$image_version" == "emonSD-07Nov16" ] || [ "$image_version" == "emonSD-03May16" ] || [ "$image_version" == "emonSD-26Oct17" ] || [ "$image_version" == "emonSD-13Jun18" ] || [ "$image_version" == "emonSD-30Oct18" ]; then
echo "emonSD base image check passed...continue update"
else
echo "ERROR: emonSD base image old or undefined...update will not continue"
echo "See latest verson: https://github.com/openenergymonitor/emonpi/wiki/emonSD-pre-built-SD-card-Download-&-Change-Log"
echo "Stopping update"
exit
fi
echo
echo "#############################################################"
# Stop emonPi LCD servcice
sudo service emonPiLCD stop
# Display update message on LCD
sudo /home/pi/emonpi/lcd/./emonPiLCD_update.py
# make file system read-write
if [ -f /usr/bin/rpi-rw ]; then
rpi-rw
fi
echo "git pull /home/pi/emonpi"
cd /home/pi/emonpi
sudo rm -rf hardware/emonpi/emonpi2c/
git branch
git status
git pull
echo "git pull /home/pi/RFM2Pi"
cd /home/pi/RFM2Pi
git branch
git status
sudo chown -R pi:pi .git
git pull
echo "git pull /home/pi/emonhub"
cd /home/pi/emonhub
git branch
git status
git pull
if [ -d /home/pi/oem_openHab ]; then
echo "git pull /home/pi/oem_openHab"
cd /home/pi/oem_openHab
git branch
git status
git pull
fi
if [ -d /home/pi/oem_node ]; then
echo "git pull /home/pi/oem_node-red"
cd /home/pi/oem_node-red
git branch
git status
git pull
fi
if [ -d /home/pi/usefulscripts ]; then
echo "git pull /home/pi/usefulscripts"
cd /home/pi/usefulscripts
sudo chown -R pi:pi .git
git branch
git status
git pull
fi
if [ -d /home/pi/huawei-hilink-status ]; then
echo "git pull /home/pi/huawei-hilink-status"
cd /home/pi/huawei-hilink-status
git branch
git status
git pull
fi
echo
# if passed argument from Emoncms admin is rfm69pi then run rfm69pi update instead of emonPi
if [ "$argument" == "rfm69pi" ]; then
echo "Running RFM69Pi firmware update:"
/home/pi/emonpi/rfm69piupdate.sh
echo
else
echo "Start emonPi Atmega328 firmware update:"
# Run emonPi update script to update firmware on Atmega328 on emonPi Shield using avrdude
/home/pi/emonpi/emonpiupdate
echo
fi
echo
echo "Start emonhub update script:"
# Run emonHub update script to update emonhub.conf nodes
/home/pi/emonpi/emonhubupdate
echo
echo "Start emoncms update:"
# Run emoncms update script to pull in latest emoncms & emonhub updates
/home/pi/emonpi/emoncmsupdate
echo
echo
# Wait for update to finish
echo "Starting emonPi LCD service.."
sleep 5
sudo service emonPiLCD restart
echo
if [ -f /usr/bin/rpi-ro ]; then
rpi-ro
fi
date
echo
printf "\n...................\n"
printf "emonPi update done\n" # this text string is used by service runner to stop the log window polling, DO NOT CHANGE!
printf "restarting service-runner\n"
# old service runner
killall service-runner
# new service runner
sudo systemctl restart service-runner.service