3 if [[ ! -e
"/dev/sda1" ]]; then
9 umount
/dev
/sda1
> /dev
/null
2>&1
10 mount
/dev
/sda1
> /dev
/null
2>&1 ||
{ printf "Mount failure\n"; exit 1; }
12 printf "\t\tMount OK\n"
14 if [[ -e
"/mnt/usb-update/config.ini" ]]; then
15 printf "Found config.ini... "
16 (cp /mnt
/usb-update
/config.ini
/home
/pi
/hdmi-switcher
> /dev
/null
2>&1 && printf "\tCopy OK\n") ||
printf "\tCopy failure\n"
19 if [[ -e
"/mnt/usb-update/video.mp4" ]]; then
20 printf "Found video.mp4... "
21 (cp /mnt
/usb-update
/video.mp4
/home
/pi
/hdmi-switcher
> /dev
/null
2>&1 && printf "\tCopy OK\n") ||
printf "\tCopy failure\n"
24 if [[ -e
"/mnt/usb-update/update.zip" ]] && [[ -e
"/mnt/usb-update/update.sig" ]]; then
25 current_version
=$
(/home
/pi
/hdmi-switcher
/hdmi-switcher version
)
26 printf "Updating software... "
27 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
29 (unzip -o
/mnt
/usb-update
/update.
zip -d
/home
/pi
> /dev
/null
2>&1 && printf "\tOK\n") ||
printf "\tExtract failure\n"
30 chmod +x
/home
/pi
/hdmi-switcher
/start.sh
31 chmod +x
/home
/pi
/hdmi-switcher
/update.sh
32 chmod +x
/home
/pi
/hdmi-switcher
/hdmi-switcher
33 new_version
=$
(/home
/pi
/hdmi-switcher
/hdmi-switcher version
)
34 if [[ "$current_version" != "$new_version" ]]; then
35 printf "Restart required...\n"
39 printf "\tSignature failure\n"
43 umount
/dev
/sda1
> /dev
/null
2>&1