From 1e3bb6f7b4eea8e0ea50d1d45404e0ad05e28717 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Tue, 14 Apr 2015 16:09:45 +0000 Subject: [PATCH] Reboot if required after update --- make-dist.sh | 3 ++- update.sh | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/make-dist.sh b/make-dist.sh index 698ae32..9dd65a8 100644 --- a/make-dist.sh +++ b/make-dist.sh @@ -2,6 +2,7 @@ mkdir -p tmp/hdmi-switcher mkdir dist +make clean make cp hdmi-switcher tmp/hdmi-switcher cp start.sh tmp/hdmi-switcher @@ -17,4 +18,4 @@ then openssl dgst -sha256 -sign private.pem -out dist/update.sig dist/update.zip else echo "Warning: Unable to sign file. Private key not found." -fi \ No newline at end of file +fi diff --git a/update.sh b/update.sh index 836b1cd..ea8eeea 100755 --- a/update.sh +++ b/update.sh @@ -12,22 +12,28 @@ printf "\t\tMount OK\n" if [[ -e "/mnt/usb-update/config.ini" ]]; then printf "Found config.ini... " - (cp /mnt/usb-update/config.ini ./ > /dev/null 2>&1 && printf "\tCopy OK\n") || printf "\tCopy failure\n" + (cp /mnt/usb-update/config.ini /home/pi > /dev/null 2>&1 && printf "\tCopy OK\n") || printf "\tCopy failure\n" fi if [[ -e "/mnt/usb-update/video.mp4" ]]; then printf "Found video.mp4... " - (cp /mnt/usb-update/video.mp4 ./ > /dev/null 2>&1 && printf "\tCopy OK\n") || printf "\tCopy failure\n" + (cp /mnt/usb-update/video.mp4 /home/pi > /dev/null 2>&1 && printf "\tCopy OK\n") || printf "\tCopy failure\n" fi if [[ -e "/mnt/usb-update/update.zip" ]] && [[ -e "/mnt/usb-update/update.sig" ]]; then + current_version=$(/home/pi/hdmi-switcher/hdmi-switcher version) printf "Updating software... " openssl dgst -sha256 -verify public.pem -signature /mnt/usb-update/update.sig /mnt/usb-update/update.zip > /dev/null 2>&1 if [[ $? = 0 ]]; then (unzip -o /mnt/usb-update/update.zip -d /home/pi > /dev/null 2>&1 && printf "\tOK\n") || printf "\tExtract failure\n" - chmod +x start.sh - chmod +x update.sh - chmod +x hdmi-switcher + chmod +x /home/pi/hdmi-switcher/start.sh + chmod +x /home/pi/hdmi-switcher/update.sh + chmod +x /home/pi/hdmi-switcher/hdmi-switcher + new_version=$(/home/pi/hdmi-switcher/hdmi-switcher version) + if [[ "$current_version" != "$new_version" ]]; then + printf "Restart required...\n" + #reboot + fi else printf "\tSignature failure\n" fi -- 2.11.0