@@ -58,21 +58,21 @@ if [ -f /proc/mounts ];
5858then
5959 # Detect is read-only mode is active
6060 if [ -n " $( grep " [[:space:]]ro[[:space:],]" /proc/mounts | grep ' /ro ' ) " ]; then
61- echo
62- echo " Detected read-only mode. Create /boot/candle_rw_once.txt, reboot, and then try again."
63- echo " Candle: detected read-only mode. Aborting." >> /dev/kmsg
64- echo " Candle: detected read-only mode. Aborting." >> /boot/candle_log.txt
61+ echo
62+ echo " Detected read-only mode. Create /boot/candle_rw_once.txt, reboot, and then try again."
63+ echo " Candle: detected read-only mode. Aborting." >> /dev/kmsg
64+ echo " Candle: detected read-only mode. Aborting." >> /boot/candle_log.txt
6565
66- # Show error image
67- if [ " $scriptname " = " bootup_actions.sh" ] || [ " $scriptname " = " bootup_actions_failed.sh" ] || [ " $scriptname " = " post_bootup_actions.sh" ] || [ " $scriptname " = " post_bootup_actions_failed.sh" ];
68- then
69- if [ -e " /bin/ply-image" ] && [ -e /dev/fb0 ] && [ -f /boot/error.png ]; then
70- /bin/ply-image /boot/error.png
71- # sleep 7200
72- fi
73- fi
66+ # Show error image
67+ if [ " $scriptname " = " bootup_actions.sh" ] || [ " $scriptname " = " bootup_actions_failed.sh" ] || [ " $scriptname " = " post_bootup_actions.sh" ] || [ " $scriptname " = " post_bootup_actions_failed.sh" ];
68+ then
69+ if [ -e " /bin/ply-image" ] && [ -e /dev/fb0 ] && [ -f /boot/error.png ]; then
70+ /bin/ply-image /boot/error.png
71+ # sleep 7200
72+ fi
73+ fi
7474
75- exit 1
75+ exit 1
7676 fi
7777fi
7878
@@ -98,6 +98,8 @@ if [ -f /boot/cmdline.txt ]; then
9898 exit 1
9999 fi
100100fi
101+
102+
101103echo
102104
103105# Detect if a kernel or bootloader update has just occured. If so, the system must be rebooted first.
@@ -188,35 +190,45 @@ echo "USER : $(whoami)"
188190echo " SCRIPT NAME : $scriptname "
189191
190192if [ -f /boot/candle_cutting_edge.txt ]; then
193+ echo " CUTTING EDGE : yes"
191194 echo " CUTTING EDGE : yes" >> /dev/kmsg
192195 echo " CUTTING EDGE : yes" >> /boot/candle_log.txt
193196else
197+ echo " CUTTING EDGE : no"
194198 echo " CUTTING EDGE : no" >> /dev/kmsg
195199 echo " CUTTING EDGE : no" >> /boot/candle_log.txt
196200fi
197201
202+
203+ if [ " $CHROOTED " = no ] || [[ -z " ${CHROOTED} " ]]; then
204+ echo " CHROOT : Not in chroot"
205+ echo " CHROOT : Not in chroot" >> /boot/candle_log.txt
206+ else
207+ echo " CHROOT : Inside chroot"
208+ fi
209+
210+
198211if [[ -z " ${APT_REINSTALL} " ]] || [ " $APT_REINSTALL " = no ] ; then
212+ echo " APT REINSTALL: no"
199213 echo " APT REINSTALL: no" >> /dev/kmsg
200214else
201215 reinstall=" --reinstall"
216+ echo " APT REINSTALL: yes"
202217 echo " APT REINSTALL: yes" >> /dev/kmsg
203218 echo " APT REINSTALL: yes" >> /boot/candle_log.txt
219+ echo
220+ echo " reinstall flag: $reinstall "
204221fi
205222
206- if [ " $CHROOTED " = no ] || [[ -z " ${CHROOTED} " ]]; then
207- echo " CHROOT : Not in chroot"
208- echo " CHROOT : Not in chroot" >> /boot/candle_log.txt
209- else
210- echo " CHROOT : INSIDE CHROOT (boot partition is not mounted)"
211- fi
212223
213- echo
214- echo " reinstall flag: $reinstall "
224+
215225
226+ echo
216227echo
217228echo " Current version of Raspbery Pi OS:"
218229cat /etc/os-release
219230echo
231+ echo
220232
221233
222234# Wait for IP address for at most 30 seconds
335347sleep 3
336348cd /home/pi
337349
350+
338351# Make sure there is a current time
339352if [ -f /boot/candle_hardware_clock.txt ]; then
340353 rm /boot/candle_hardware_clock.txt
349362
350363
351364
352-
353365# Download error image first
354366if [ -f /boot/cmdline.txt ]; then
355367 wget https://www.candlesmarthome.com/tools/error.png -O /boot/error.png
362374
363375
364376
377+ # Quickly install Git if it hasn't been already
365378if [ -z " $( which git) " ]; then
366379 echo
367380 echo " installing git"
373386
374387
375388
376-
377389# PLYMOUTH LITE
378390if [ ! -f /bin/ply-image ];
379391then
@@ -404,7 +416,6 @@ if [ -f /boot/cmdline.txt ]; then
404416 wget https://www.candlesmarthome.com/tools/splash_updating.png -O /boot/splash_updating.png
405417 wget https://www.candlesmarthome.com/tools/splash_updating180.png -O /boot/splash_updating180.png
406418
407-
408419 if [ " $scriptname " = " bootup_actions.sh" ] || [ " $scriptname " = " bootup_actions_failed.sh" ] || [ " $scriptname " = " post_bootup_actions.sh" ] || [ " $scriptname " = " post_bootup_actions_failed.sh" ];
409420 then
410421 if [ -e " /bin/ply-image" ] && [ -e /dev/fb0 ] && [ -f " /boot/splash_updating.png" ]; then
447458
448459
449460echo
450- echo " DOWNLOADING AND COPYING CONFIGURATION FILES FROM GITHUB"
461+ echo " PRE- DOWNLOADING CONFIGURATION FILES FROM GITHUB"
451462echo
452463
453464
657668 # rm -rf /home/pi/webthings
658669 # rm -rf /home/pi/.webthings # too dangerous
659670
660-
661-
662671 if [ -f /boot/candle_cutting_edge.txt ]; then
663672 echo " Candle: Starting download of cutting edge controller install script" >> /dev/kmsg
664673 wget https://raw.githubusercontent.com/createcandle/install-scripts/main/install_candle_controller.sh -O ./install_candle_controller.sh
697706 wget https://www.candlesmarthome.com/img/controller/latest_stable_controller.tar.txt -O /home/pi/latest_stable_controller.tar.txt
698707
699708 if [ -f /home/pi/latest_stable_controller.tar ] && [ -f /home/pi/latest_stable_controller.tar.txt ]; then
709+
700710 echo " controller tar & md5 downloaded OK"
701711
702712 if [ " $( md5sum latest_stable_controller.tar | awk ' {print $1}' ) " = " $( cat /home/pi/latest_stable_controller.tar.txt) " ]; then
@@ -1103,7 +1113,7 @@ then
11031113 echo " $i "
11041114 echo " Candle: installing $i " >> /dev/kmsg
11051115 echo " Candle: installing $i " >> /boot/candle_log.txt
1106- apt -y install " $i " --print-uris " $reinstall "
1116+ apt -y install " $i " --print-uris " $reinstall "
11071117 echo
11081118 done
11091119
@@ -1113,11 +1123,7 @@ then
11131123 echo " Candle: WARNING, mosquitto failed to install the first time" >> /boot/candle_log.txt
11141124 apt -y --reinstall install mosquitto
11151125 fi
1116-
11171126
1118- # removed from above list:
1119- # libnanomsg-dev \
1120- # libnanomsg5 \
11211127
11221128 # additional programs for Candle kiosk mode:
11231129 echo
@@ -1195,7 +1201,7 @@ then
11951201 echo " $i "
11961202 echo " Candle: installing $i " >> /dev/kmsg
11971203 echo " Candle: installing $i " >> /boot/candle_log.txt
1198- apt -y install " $i " --print-uris " $reinstall "
1204+ apt -y install " $i " --print-uris " $reinstall "
11991205 echo
12001206 done
12011207
@@ -1204,12 +1210,12 @@ then
12041210 echo " Candle: installing hostapd and dnsmasq" >> /dev/kmsg
12051211 echo " Candle: installing hostapd and dnsmasq" >> /boot/candle_log.txt
12061212
1207- apt -y install dnsmasq --print-uris " $reinstall "
1213+ apt -y install dnsmasq --print-uris " $reinstall "
12081214 systemctl disable dnsmasq.service
12091215 systemctl stop dnsmasq.service
12101216
12111217 echo
1212- apt -y install hostapd --print-uris " $reinstall "
1218+ apt -y install hostapd --print-uris " $reinstall "
12131219 systemctl disable hostapd.service
12141220 systemctl stop hostapd.service
12151221
@@ -1222,9 +1228,6 @@ then
12221228 apt autoremove -y
12231229
12241230
1225-
1226-
1227-
12281231 # Check if the binaries eactually exist
12291232 for i in \
12301233 hostapd \
@@ -2652,7 +2655,9 @@ else
26522655 echo " Candle: Rebooting in 10 seconds" >> /dev/kmsg
26532656 echo
26542657 sleep 10
2655- rm /boot/candle_rw_once.txt
2658+ if [ -f /boot/candle_rw_once.txt ]; then
2659+ rm /boot/candle_rw_once.txt
2660+ fi
26562661 reboot
26572662fi
26582663
0 commit comments