@@ -181,13 +181,13 @@ sudo setcap cap_net_raw+eip $(eval readlink -f `which python3`)
181181# Download Candle controller from Github and install it
182182
183183echo
184- echo " DOWNLOADING AND INSTALLING CANDLE CONTROLLER"
185- echo " Do not worry about the errors you will see with optipng and jpegtran "
184+ echo " INSTALLING CANDLE CONTROLLER"
185+
186186echo
187187
188188
189- # Create a backup first
190189
190+ # Create a backup first
191191
192192availMem=$( df -P " /dev/mmcblk0p2" | awk ' END{print $4}' )
193193if [ -f /home/pi/latest_stable_controller.tar ]; then
@@ -200,8 +200,8 @@ if [ -f /home/pi/latest_stable_controller.tar ]; then
200200 && [ -d /home/pi/webthings/gateway/build/static/bundle ];
201201 then
202202 echo " Detected old webthings directory! Creating fresh backup"
203- echo " Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /dev/kmsg
204- echo " Candle: Detected old webthings directory. Creating additional backup" | sudo tee -a /boot/candle_log.txt
203+ echo " Candle: Detected old webthings directory. Creating fresh backup" | sudo tee -a /dev/kmsg
204+ echo " Candle: Detected old webthings directory. Creating fresh backup" | sudo tee -a /boot/candle_log.txt
205205 # mv /home/pi/webthings /home/pi/webthings-old
206206 tar -czf ./controller_backup_fresh.tar ./webthings
207207 fi
211211
212212# rm -rf /home/pi/webthings
213213
214- echo " Candle: Starting controller source code download" | sudo tee -a /dev/kmsg
215- echo " Candle: Starting controller source code download" | sudo tee -a /boot/candle_log.txt
216- mkdir -p /home/pi/webthings
217- chown pi:pi /home/pi/webthings
218- cd /home/pi/webthings
219-
220214if [ -d ./candle-controller ]; then
221215 echo " spotted candle-controller directory. Must be left over from interupted install"
222216 rm -rf candle-controller
228222# DOWNLOAD CANDLE CONTROLLER FROM GITHUB
229223
230224if [ -f /boot/candle_cutting_edge.txt ]; then
225+
226+ echo " Candle: Starting controller source code download" | sudo tee -a /dev/kmsg
227+ echo " Candle: Starting controller source code download" | sudo tee -a /boot/candle_log.txt
228+ mkdir -p /home/pi/webthings
229+ chown pi:pi /home/pi/webthings
230+ cd /home/pi/webthings
231+
231232 git clone --depth 1 https://github.com/createcandle/candle-controller.git
232233 if [ -d ./candle-controller ]; then
233234 echo " Cutting edge controller download succeeded" | sudo tee -a /dev/kmsg
254255
255256 if [ -f /home/pi/latest_stable_controller.tar ]; then
256257
258+ echo " Will extract latest_stable_controller.tar"
259+
257260 cd /home/pi
258261
259262 if [ -d /home/pi/webthings/gateway2 ]; then
@@ -263,21 +266,35 @@ else
263266 availMem=$( df -P " /dev/mmcblk0p2" | awk ' END{print $4}' )
264267 if [ " $availMem " -gt " 1000000" ];
265268 then
269+ echo " Candle: Doing safe unpack of latest_stable_controller.tar"
266270 echo " Candle: Doing safe unpack of latest_stable_controller.tar" | sudo tee -a /dev/kmsg
267271 echo " Doing safe unpack of latest_stable_controller.tar" | sudo tee -a /boot/candle_log.txt
268272 mkdir -p /home/pi/downloaded_controller
269273 rm -rf /home/pi/downloaded_controller/*
270- tar -xf latest_stable_controller.tar -O /home/pi/downloaded_controller/
274+ echo " extracting"
275+ tar -xf latest_stable_controller.tar -C /home/pi/downloaded_controller
276+
277+ ls /home/pi/downloaded_controller
271278
272279 if [ -f /home/pi/downloaded_controller/webthings/gateway/.post_upgrade_complete ]; then
280+ echo " extraction worked fine"
273281 if [ -d /home/pi/webthings/gateway ]; then
274282 rm -rf /home/pi/webthings/gateway
275283 fi
284+ echo " moving extracted gateway dir into place"
276285 mv /home/pi/downloaded_controller/webthings/gateway /home/pi/webthings/gateway
286+ else
287+ echo " extraction did not go as planned"
277288 fi
289+
290+ echo " removing extracted files"
278291 rm -rf /home/pi/downloaded_controller
292+
279293 else
280294 # more risky move because of low disk space
295+ echo " Candle: Low disk space, doing direct unpack of latest_stable_controller.tar" | sudo tee -a /dev/kmsg
296+ echo " Low disk space, doing direct unpack of latest_stable_controller.tar" | sudo tee -a /boot/candle_log.txt
297+
281298 if [ -d /home/pi/webthings ]; then
282299 sudo rm -rf /home/pi/webthings
283300 fi
286303
287304 else
288305
306+ mkdir -p /home/pi/webthings
307+ chown pi:pi /home/pi/webthings
289308 cd /home/pi/webthings
290309
291310 curl -s https://api.github.com/repos/createcandle/candle-controller/releases/latest \
@@ -366,6 +385,9 @@ if [ -d /home/pi/webthings/gateway2 ]; then
366385 # npm install
367386 echo " Candle: Installing Node modules (takes a while)" | sudo tee -a /dev/kmsg
368387 echo " Candle: Installing Node modules (takes a while)" | sudo tee -a /boot/candle_log.txt
388+
389+ echo " Do not worry about the errors you will see with optipng and jpegtran"
390+
369391 CPPFLAGS=" -DPNG_ARM_NEON_OPT=0" npm ci
370392
371393 # echo "Does node_modules exist now?: $(ls /home/pi/webthings/gateway)" | sudo tee -a /dev/kmsg
0 commit comments