raspiblitz/home.admin/setup.scripts/dialogDeleteData.sh

57 lines
2.1 KiB
Bash
Raw Normal View History

2021-05-21 21:18:37 -05:00
#!/bin/bash
2021-05-22 12:31:43 -05:00
# FIRST PARAMETER can be the name of the blockchain data that is available in the HDD/SS
# if set the user will be given to option to DELETE ALL DATA but KEEP BLOCKCHAIN
blockchainName=$1
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
keepBlockchain=0
if [ ${blockchainName} != "" ]; then
2021-05-21 21:18:37 -05:00
2021-05-22 12:31:43 -05:00
whiptail --title " BLOCKCHAIN DATA FOUND " --yes-button "USE BLOCKCHAIN" --no-button "DELETE" --yesno "We found ${blockchainName} blockchain data on your HDD/SSD.
2021-05-22 12:56:13 -05:00
Using existing blockchain data can reduce the setup/sync time. But if you didnt validated the blockchain yourself there is a level of trust involved.
2021-05-22 12:31:43 -05:00
Do you want to use that blockchain data and run ${blockchainName}?
2021-05-22 12:56:13 -05:00
" 14 68
2021-05-21 21:18:37 -05:00
2021-05-22 10:40:19 -05:00
if [ "$?" == "0" ]; then
2021-05-22 12:31:43 -05:00
# 0 --> use blockchain & delete all other data
keepBlockchain=1
2021-05-22 10:40:19 -05:00
fi
2021-05-22 10:48:45 -05:00
fi
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
# normally when the the HDD will get formatted and the user will get asked about that
# if before the user decided to keep the blockchain instead if formatting just "ALL OTHER DATA" wil get deleted
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
if [ "${keepBlockchain}" == "1" ]; then
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
# deleting all data around blockchain security question
whiptail --title " DELETING ALL OTHER DATA " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "OK we will keep the blockchain data - but all other data on your HDD/SSD will get deleted on setup. Make sure that there is no important data or old funds on that data drive.
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
Are you sure to DELETE ALL OTHER DATA on the HDD/SSD?
2021-05-22 12:56:13 -05:00
" 11 65
2021-05-22 10:40:19 -05:00
if [ "$?" == "0" ]; then
2021-05-22 12:31:43 -05:00
# 0 --> keep blockchain + delete all other data
exit 2
2021-05-22 10:40:19 -05:00
else
2021-05-22 12:31:43 -05:00
# 1 --> cancel / stop
exit 0
2021-05-22 10:40:19 -05:00
fi
2021-05-22 12:31:43 -05:00
else
# normal formatting data drive security question
2021-05-22 12:56:13 -05:00
whiptail --title " FORMATTING DATA DRVE " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "Your data drive will now get formatted. This will delete all data on your connected HDD/SSD. Make sure that there is no important data or old funds on that data drive.
2021-05-22 12:31:43 -05:00
Are you sure to format the HDD/SSD and DELETE ALL DATA on it?
2021-05-22 12:56:13 -05:00
" 11 65
2021-05-22 10:40:19 -05:00
2021-05-22 12:31:43 -05:00
if [ "$?" == "0" ]; then
# 0 --> format drive
exit 1
else
# 1 --> cancel / stop
exit 0
fi
fi