]> git.ipfire.org Git - people/ms/firmware-update.git/commitdiff
Add message to get consent from user 20190329
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Mar 2019 11:22:39 +0000 (12:22 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Mar 2019 11:22:39 +0000 (12:22 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/firmware-update.in

index 6e1f75a34d9ac8d1996a1ee994ce4d9b175999c7..08c74b26b5b3576eac83dd025c11416b0420d129 100644 (file)
@@ -26,6 +26,39 @@ PACKAGE_VERSION="@PACKAGE_VERSION@"
 
 FIRMWARE_DIR="@firmwaredir@"
 
+get_consent() {
+       local firmware="${1}"
+
+       cat <<EOF
+
+You are going to flash the firmware on device. This is a dangerous operation
+that might potentially damage your device.
+
+Please do NOT TURN OFF the system while the update is in progress and do
+not abort the process.
+
+  Firmware file: ${firmware}
+
+EOF
+
+       local answer
+       while [ -t 0 -a -t 1 -a -t 2 ]; do
+               # Wait for user to type y
+               printf "Do you want to proceed? [y/n] "
+               read -r answer
+
+               case "${answer}" in
+                       y|Y)
+                               return 0
+                               ;;
+                       n|N)
+                               echo "Aborting."
+                               return 1
+                               ;;
+               esac
+       done
+}
+
 read_dmi() {
        local what="${1}"
 
@@ -141,8 +174,12 @@ update_pcengines_apu() {
                return 1
        fi
 
+       echo "New firmware version available: ${new_version}"
+
        # Perform update
-       do_flashrom -p "internal" -w "${firmware}"
+       if get_consent "${firmware}"; then
+               do_flashrom -p "internal" -w "${firmware}"
+       fi
 }
 
 do_update() {