3 if [[ ! -e
"/dev/sda1" ]]; then
9 umount
/dev
/sda1
> /dev
/null
2>&1
10 # The {} does NOT spawn a new subshell, so the exit kills this script.
11 mount
/dev
/sda1
> /dev
/null
2>&1 ||
{ printf "Mount failure\n"; exit 1; }
13 printf "\t\tMount OK\n"
15 if [[ -e
"/mnt/usb-update/config.ini" ]]; then
16 printf "Found config.ini... "
17 (cp /mnt
/usb-update
/config.ini
/home
/pi
/hdmi-switcher
> /dev
/null
2>&1 && printf "\tCopy OK\n") ||
printf "\tCopy failure\n"
20 if [[ -e
"/mnt/usb-update/video.mp4" ]]; then
21 printf "Found video.mp4... "
22 (cp /mnt
/usb-update
/video.mp4
/home
/pi
/hdmi-switcher
> /dev
/null
2>&1 && printf "\tCopy OK\n") ||
printf "\tCopy failure\n"
25 if [[ -e
"/mnt/usb-update/update.zip" ]] && [[ -e
"/mnt/usb-update/update.sig" ]]; then
26 current_version
=$
(/home
/pi
/hdmi-switcher
/hdmi-switcher version
)
27 printf "Updating software... "
28 openssl dgst
-sha256
-verify
/home
/pi
/hdmi-switcher
/public.pem
-signature
/mnt
/usb-update
/update.sig
/mnt
/usb-update
/update.
zip > /dev
/null
2>&1
30 (unzip -o
/mnt
/usb-update
/update.
zip -d
/home
/pi
> /dev
/null
2>&1 && printf "\tOK\n") ||
printf "\tExtract failure\n"
31 chmod +x
/home
/pi
/hdmi-switcher
/start.sh
32 chmod +x
/home
/pi
/hdmi-switcher
/update.sh
33 chmod +x
/home
/pi
/hdmi-switcher
/hdmi-switcher
34 new_version
=$
(/home
/pi
/hdmi-switcher
/hdmi-switcher version
)
35 if [[ "$current_version" != "$new_version" ]]; then
36 printf "Restart required...\n"
40 printf "\tSignature failure\n"
44 umount
/dev
/sda1
> /dev
/null
2>&1