Reboot if required after update
authorCameron Ball <c.ball1729@gmail.com>
Tue, 14 Apr 2015 16:09:45 +0000 (16:09 +0000)
committerCameron Ball <c.ball1729@gmail.com>
Tue, 14 Apr 2015 16:09:45 +0000 (16:09 +0000)
make-dist.sh
update.sh

index 698ae32..9dd65a8 100644 (file)
@@ -2,6 +2,7 @@
 \r
 mkdir -p tmp/hdmi-switcher\r
 mkdir dist\r
+make clean\r
 make\r
 cp hdmi-switcher tmp/hdmi-switcher\r
 cp start.sh tmp/hdmi-switcher\r
@@ -17,4 +18,4 @@ then
     openssl dgst -sha256 -sign private.pem -out dist/update.sig dist/update.zip\r
 else\r
     echo "Warning: Unable to sign file. Private key not found."\r
-fi
\ No newline at end of file
+fi\r
index 836b1cd..ea8eeea 100755 (executable)
--- 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