Skip to content

Commit

Permalink
Update create_latest_candle.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Aug 29, 2022
1 parent ee8d49b commit e962b51
Showing 1 changed file with 53 additions and 21 deletions.
74 changes: 53 additions & 21 deletions create_latest_candle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ cat /etc/os-release
echo
echo

echo "/boot/cmdline.txt before:"
cat /boot/cmdline.txt
echo

# Wait for IP address for at most 30 seconds
echo "Waiting for IP address..." >> /dev/kmsg
Expand Down Expand Up @@ -605,13 +608,17 @@ then
#rm -rf /home/pi/.webthings # too dangerous

if [ -f /boot/candle_cutting_edge.txt ]; then
echo "Candle: Starting download of cutting edge controller install script"
echo "Candle: Starting download of cutting edge controller install script" >> /dev/kmsg
echo "Candle: Starting download of cutting edge controller install script" >> /boot/candle_log.txt
echo
wget https://raw.githubusercontent.com/createcandle/install-scripts/main/install_candle_controller.sh -O ./install_candle_controller.sh

else
echo "Candle: Starting download of stable controller install script"
echo "Candle: Starting download of stable controller install script" >> /dev/kmsg
echo "Candle: Starting download of stable controller install script" >> /boot/candle_log.txt
echo
curl -s https://api.github.com/repos/createcandle/install-scripts/releases/latest \
| grep "tarball_url" \
| cut -d : -f 2,3 \
Expand Down Expand Up @@ -755,9 +762,6 @@ echo "modifying /etc/apt/sources.list - allowing apt access to source code"
sed -i 's/#deb-src/deb-src/' /etc/apt/sources.list





if [ "$SKIP_APT_UPGRADE" = no ] || [[ -z "${SKIP_APT_UPGRADE}" ]];
then
echo
Expand Down Expand Up @@ -800,16 +804,13 @@ then
echo ""


#rm -rf /opt/vc/lib

apt-get update -y
DEBIAN_FRONTEND=noninteractive apt full-upgrade -y &
wait
apt --fix-broken install -y
sed -i 's|/usr/lib/dhcpcd5/dhcpcd|/usr/sbin/dhcpcd|g' /etc/systemd/system/dhcpcd.service.d/wait.conf # Fix potential issue with dhcpdp on Bullseye
echo ""


apt-get update -y
DEBIAN_FRONTEND=noninteractive apt upgrade -y &
wait
Expand Down Expand Up @@ -866,6 +867,11 @@ then
echo ""
fi


if [ -d /opt/vc/lib ]; then
echo "removing /opt/vc/lib"
rm -rf /opt/vc/lib
fi

fi

Expand Down Expand Up @@ -1027,7 +1033,7 @@ then
echo "Candle: installing support packages" >> /dev/kmsg
echo "Candle: installing support packages" >> /boot/candle_log.txt
echo
for i in arping autoconf ffmpeg libtool mosquitto policykit-1 sqlite3 libolm3 libffi6 nbtscan ufw iptables; do
for i in arping autoconf ffmpeg libtool mosquitto policykit-1 sqlite3 libolm3 libffi6 nbtscan ufw iptables liblivemedia-dev; do
echo "$i"
echo "Candle: installing $i" >> /dev/kmsg
echo "Candle: installing $i" >> /boot/candle_log.txt
Expand Down Expand Up @@ -1129,6 +1135,8 @@ then
done


#

for i in \
chromium-browser git \
autoconf build-essential curl libbluetooth-dev libboost-python-dev libboost-thread-dev libffi-dev \
Expand Down Expand Up @@ -1379,7 +1387,9 @@ then
cd seeed-voicecard

if [ ! -f /home/pi/candle/installed_respeaker_version.txt ]; then
touch /home/pi/candle/installed_respeaker_version.txt
mkdir -p /home/pi/candle
#touch /home/pi/candle/installed_respeaker_version.txt
cp ./dkms.conf /home/pi/candle/installed_respeaker_version.txt
fi

if [ -d "/etc/voicecard" ] && [ -f /bin/seeed-voicecard ];
Expand Down Expand Up @@ -1966,7 +1976,9 @@ if [ "$SKIP_RO" = no ] || [[ -z "${SKIP_RO}" ]]; then
if [ $(cat /boot/cmdline.txt | grep -c "init=/bin/ro-root.sh") -eq 0 ]
then
echo "- Modifying cmdline.txt for read-only file system"
echo "- - before: $(cat /boot/cmdline.txt)"
sed -i ' 1 s|.*|& init=/bin/ro-root.sh|' /boot/cmdline.txt
echo "- - after : $(cat /boot/cmdline.txt)"
echo "Candle: read-only mode is now enabled" >> /dev/kmsg
echo "Candle: read-only mode is now enabled" >> /boot/candle_log.txt
else
Expand Down Expand Up @@ -2108,13 +2120,21 @@ fi
echo "Clearing /tmp"
rm -rf /tmp/*

rm /home/pi/.wget-hsts
rm -rf /home/pi/.config/chromium
if [ -f /home/pi/.wget-hsts ]; then
rm /home/pi/.wget-hsts
fi

# TODO: is deleting this a good idea? Won't chromium just recreate it, this time without any modifications?
if [ -d /home/pi/.config/chromium ]; then
rm -rf /home/pi/.config/chromium
fi

echo '{"optOut": true,"lastUpdateCheck": 0}' > /home/pi/.config/configstore/update-notifier-npm.json
chown pi:pi /home/pi/.config/configstore/update-notifier-npm.json

# Remove files left over by Windows or MacOS
rm -rf /boot/.Spotlight*

if [ -f /boot/._cmdline.txt ]; then
rm /boot/._cmdline.txt
fi
Expand Down Expand Up @@ -2160,6 +2180,10 @@ fi
if [ -f /boot/fstab3.bak ] \
&& [ -f /boot/fstab4.bak ]; then
echo "/boot/fstab3.bak and /boot/fstab4.bak exist"
else
echo "ERROR, /boot/fstab3.bak and /boot/fstab4.bak do not exist"
echo "WARNING, /boot/fstab3.bak and /boot/fstab4.bak do not exist" >> /dev/kmsg
echo "ERROR, /boot/fstab3.bak and /boot/fstab4.bak do not exist" >> /boot/candle_log.txt
fi

if [ -d /home/pi/.webthings/etc/wpa_supplicant ] \
Expand Down Expand Up @@ -2193,18 +2217,24 @@ then
echo "Candle: copying 3 partition version of fstab" >> /boot/candle_log.txt

if ! diff -q /home/pi/configuration-files/boot/fstab3.bak /etc/fstab &>/dev/null; then
echo "fstab file is different, copying it"
echo "3 partition fstab file is different, copying it"
echo "Candle: 3 partition fstab file is different, copying it" >> /dev/kmsg
cp --verbose /home/pi/configuration-files/boot/fstab3.bak /etc/fstab
else
echo "new fstab file is same as the old one, not copying it."
echo "Candle: new fstab file is same as the old one, not copying it." >> /dev/kmsg
echo "new 3 partition fstab file is same as the old one, not copying it." >> /boot/candle_log.txt
fi

fi


else
echo
echo "ERROR, SOME VITAL FSTAB MOUNTPOINTS DO NOT EXIST"
echo "ERROR, SOME VITAL FSTAB MOUNTPOINTS DO NOT EXIST!"
# The only reason this is a warning and not an error (which would stop the process in de UI), is that the process is nearly done anyway.
echo "Candle: WARNING, SOME VITAL MOUNTPOINTS DO NOT EXIST, NOT CHANGING FSTAB" >> /dev/kmsg
echo "Candle: ERROR, SOME VITAL MOUNTPOINTS DO NOT EXIST, NOT CHANGING FSTAB" >> /boot/candle_log.txt
echo

ls /home/pi/.webthings/etc/wpa_supplicant
ls /home/pi/.webthings/var/lib/bluetooth
Expand All @@ -2214,8 +2244,6 @@ else
ls /home/pi/.webthings/arduino/.arduino15
ls /home/pi/.webthings/arduino/Arduino

echo "Candle: WARNING, SOME VITAL MOUNTPOINTS DO NOT EXIST, NOT CHANGING FSTAB" >> /dev/kmsg
echo "Candle: WARNING, SOME VITAL MOUNTPOINTS DO NOT EXIST, NOT CHANGING FSTAB" >> /boot/candle_log.txt
echo

fi
Expand All @@ -2229,7 +2257,7 @@ rm -rf /home/pi/configuration-files


# if this is not a cutting edge build, then use the cmdline.txt and config.txt from the configuration files
if [ ! -f /boot/candle_cutting_edge.txt ]; then
if [ ! -f /boot/candle_cutting_edge.txt ]; then # || [ ! -f /boot/candle_first_run_complete.txt ]; then

# Copy the Candle cmdline over the old one. This one is disk UUID agnostic.
if [ -f /boot/cmdline-candle.txt ]; then
Expand Down Expand Up @@ -2485,13 +2513,17 @@ then
echo "ALMOST DONE, RUNNING DEBUG SCRIPT"
echo

/home/pi/candle/debug.sh > /boot/debug.txt
if [ -f /boot/candle_first_run_complete.txt ]; then
/home/pi/candle/debug.sh > /boot/debug.txt

echo "" >> /boot/debug.txt
echo "THIS OUTPUT WAS CREATED BY THE SYSTEM UPDATE PROCESS" >> /boot/debug.txt
cat /boot/debug.txt
echo "" >> /boot/debug.txt
echo "THIS OUTPUT WAS CREATED BY THE SYSTEM UPDATE PROCESS" >> /boot/debug.txt
cat /boot/debug.txt
echo "Candle: DONE. Debug output placed in /boot/debug.txt" >> /dev/kmsg
else
/home/pi/candle/debug.sh
fi

echo "Candle: DONE. Debug output placed in /boot/debug.txt" >> /dev/kmsg
echo
echo

Expand Down

0 comments on commit e962b51

Please sign in to comment.