formatting dialog

This commit is contained in:
rootzoll
2021-05-22 12:31:43 -05:00
parent be9310d9ff
commit 87ff5494f0
2 changed files with 105 additions and 80 deletions

View File

@@ -1,44 +1,57 @@
#!/bin/bash #!/bin/bash
if [ "$1" == "format" ]; then # 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
keepBlockchain=0
if [ ${blockchainName} != "" ]; then
whiptail --title " BLOCKCHAIN DATA FOUND " --yes-button "USE BLOCKCHAIN" --no-button "DELETE" --yesno "We found ${blockchainName} blockchain data on your HDD/SSD.
Using existing blockchain data can reduce your setup/sync time. But if you didnt validated that blockchain yourself there is a level of trust involved.
Do you want to use that blockchain data and run ${blockchainName}?
" 10 65
if [ "$?" == "0" ]; then
# 0 --> use blockchain & delete all other data
keepBlockchain=1
fi
fi
# 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
if [ "${keepBlockchain}" == "1" ]; then
# 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.
Are you sure to DELETE ALL OTHER DATA on the HDD/SSD?
" 12 65
if [ "$?" == "0" ]; then
# 0 --> keep blockchain + delete all other data
exit 2
else
# 1 --> cancel / stop
exit 0
fi
else
# normal formatting data drive security question
whiptail --title " FORMATTING DATA DRVE " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "Your data drive will now be 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. whiptail --title " FORMATTING DATA DRVE " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "Your data drive will now be 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.
Are you sure to format the HDD/SSD and DELETE ALL DATA on it? Are you sure to format the HDD/SSD and DELETE ALL DATA on it?
" 12 65 " 12 65
if [ "$?" == "0" ]; then if [ "$?" == "0" ]; then
# 0 --> delete data # 0 --> format drive
exit 0 exit 1
else else
# 1 --> cancel # 1 --> cancel / stop
exit 1
fi
fi
if [ "$1" == "keepblockchain" ]; then
blockchainName=$2
if [ "${blockchainName}" == "" ]; then
blockchainName="BITCOIN"
fi
whiptail --title " BLOCKCHAIN DATA FOUND " --yes-button "KEEP BLOCKCHAIN" --no-button "NO" --yesno "We found on the data drive ${blockchainName} blockchain data.
This can reduce your setup/sync time but if you didnt validated that blockchain yourself there is a level of trust involved.
Do you want to use that blockchain & its data and DELETE ALL OTHER DATA?
" 10 65
if [ "$?" == "0" ]; then
# 0 --> use blockchain & delete all other data
exit 0 exit 0
else
# 1 --> cancel
exit 1
fi fi
fi fi
echo "err='unkown parameter'"
exit 1

View File

@@ -94,33 +94,34 @@ if [ "${setupPhase}" == "setup" ]; then
exit 0 exit 0
fi fi
# uplaod and setup from migration backup ###############################################
if [ "${menuresult}" == "1" ]; then # FORMAT DRIVE on NEW SETUP or MIGRATION UPLOAD
/home/admin/setup.scripts/dialogMigration.sh raspiblitz if [ "${menuresult}" == "0" ] || [ "${menuresult}" == "1" ]; then
if [ "$?" == "1" ]; then
# upload did not worked .. exit with 0 to restart process from outside loop
exit 0
fi
# user needs to reset password A
echo "setPasswordA=1" >> $SETUPFILE
fi
############################################
# FRESH SETUP
if [ "${menuresult}" == "0" ]; then
############################################
# Format HDD/SSD - Keep Blockchain
formatNeeded=1
# check if there is a blockchain to use (so HDD is already formatted) # check if there is a blockchain to use (so HDD is already formatted)
# thats also true if the node is coming from another nodeOS # thats also true if the node is coming from another nodeOS
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddBlocksLitecoin}" == "1" ] || [ "${hddGotMigrationData}" != "" ]; then existingBlockchain=""
/home/admin/setup.scripts/dialogDeleteData.sh keepblockchain if [ "${hddBlocksLitecoin}" == "1" ]; then
if [ "$?" == "1" ]; then existingBlockchain="LITECOIN"
fi
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddGotMigrationData}" != "" ]; then
existingBlockchain="BITCOIN"
fi
# dont format HDD later - reuse data and clean up # ask user about possible existing blockchain and formatting HDD
formatNeeded=0 /home/admin/setup.scripts/dialogDeleteData.sh "${existingBlockchain}"
userChoice=$?
if [ "${userChoice}" == "1" ]; then
# FORMAT DATA DRIVE
echo "TODO: Format HDD/SSD"
# DEBUG EXIT
exit 1
if [ "${userChoice}" == "2" ]; then
# KEEP BLOCKCHAIN + DLETE ALL THE REST
# when blockchain comes from another node migrate data first # when blockchain comes from another node migrate data first
if [ "${hddGotMigrationData}" != "" ]; then if [ "${hddGotMigrationData}" != "" ]; then
@@ -137,25 +138,36 @@ if [ "${setupPhase}" == "setup" ]; then
echo "network=bitcoin" >> $SETUPFILE echo "network=bitcoin" >> $SETUPFILE
fi fi
# exit with 0 to restart process from outside loop # DEBUG EXIT
exit 1 exit 1
fi
else
# STOP SETUP - loop back to setup menu start
exit 0
fi fi
# if other data is on HDD/SSD from migration/recover warn on formatting drive fi
if [ "${formatNeeded}" == "1" ]; then
/home/admin/setup.scripts/dialogDeleteData.sh ############################################
# UPLOAD MIGRATION
if [ "${menuresult}" == "1" ]; then
/home/admin/setup.scripts/dialogMigration.sh raspiblitz
if [ "$?" == "1" ]; then if [ "$?" == "1" ]; then
# exit with 0 to restart process from outside loop # upload did not worked .. exit with 0 to restart process from outside loop
echo "Upload failed ... return to menu"
sleep 2
exit 0 exit 0
fi fi
# user needs to reset password A
# delete everything but blockchain echo "setPasswordA=1" >> $SETUPFILE
echo "TODO: Format HDD/SSD"
exit 1
fi fi
############################################
# FRESH SETUP
if [ "${menuresult}" == "0" ]; then
############################################ ############################################
# Choosing Blockchain & Lightning # Choosing Blockchain & Lightning