Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59d88d95 authored by Rohit Sekhar's avatar Rohit Sekhar
Browse files

flash_FP4_factory.sh: Be friendly to an user who's upgrading

parent 8f231c82
Loading
Loading
Loading
Loading
+25 −13
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
set -e
set -u

CLEAN_FLASH="true" # Control data wipe behavior. Default is "true".
CLEAN_FLASH="true" # Control data wipe behavior. "true" -> Prompts user if upgrade and if he agrees to wipe

# Target device info
PRODUCT="Fairphone 4"
@@ -182,25 +182,37 @@ reboot_device() {
# Warn about data wipe, and ask for confirmation
data_wipe_check() {
  if [ "${CLEAN_FLASH}" = "true" ]
  then
    local is_upgrade
    local is_wipe

    echo ""
    echo "Q: Are you upgrading from a previous installation of /e/ OS ?"
    read -rp " Type \"Yes\" and press enter to confirm upgrading. ELSE, just press Enter: " is_upgrade
    if [ "${is_upgrade,,}" != "yes" ]
    then
       echo ""
    echo "WARNING: Flashing this image wipes all user data and settings on the phone."
    echo " Are you sure you want to wipe data and continue?"
       echo "WARNING: You did NOT type \"Yes\", assuming you are NOT upgrading from an installation of /e/ OS"
       echo "WARNING: Flashing this image requires wiping all user data and settings on the phone."
       echo "Q: Are you sure you want to wipe data and continue?"
       echo ""
       # Read user's input
    read -rp " Type \"Yes\" (case sensitive) and press enter to wipe data and continue. Else, just press enter: " a
       read -rp " Type \"Yes\" and press enter to wipe data and continue. ELSE, just press enter: " is_wipe
       echo ""
    if [ "_${a:-"No"}" != '_Yes' ]
      # NOTE: $a is being set by the read command above,
      #   so the check for a to be set is mostly redundant
       if [ "${is_wipe,,}" != 'yes' ]
       then
         echo "WARNING: You DID NOT type \"Yes\", proceeding without data wipe."
         echo "WARNING: You DID NOT type \"Yes\", cannot proceed without data wipe for a new installation"
         echo ""
         CLEAN_FLASH="false"
         exit 1
       else
         echo "WARNING: You typed \"Yes\", proceeding with data wipe."
         CLEAN_FLASH="true"
       fi
    else
       echo "WARNING: You typed \"Yes\", assuming you are upgrading from an installation of /e/ OS"
       echo "WARNING: Proceeding without data wipe!"
       CLEAN_FLASH="false"
    fi
  fi
}