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
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.
Are you sure to format the HDD/SSD and DELETE ALL DATA on it?
" 12 65
if [ "$?" == "0" ]; then
# 0 --> delete data
exit 0
else
# 1 --> cancel
# 0 --> format drive
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
else
# 1 --> cancel
exit 1
# 1 --> cancel / stop
exit 0
fi
fi
echo "err='unkown parameter'"
exit 1
fi

View File

@@ -94,11 +94,70 @@ if [ "${setupPhase}" == "setup" ]; then
exit 0
fi
# uplaod and setup from migration backup
###############################################
# FORMAT DRIVE on NEW SETUP or MIGRATION UPLOAD
if [ "${menuresult}" == "0" ] || [ "${menuresult}" == "1" ]; then
# check if there is a blockchain to use (so HDD is already formatted)
# thats also true if the node is coming from another nodeOS
existingBlockchain=""
if [ "${hddBlocksLitecoin}" == "1" ]; then
existingBlockchain="LITECOIN"
fi
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddGotMigrationData}" != "" ]; then
existingBlockchain="BITCOIN"
fi
# ask user about possible existing blockchain and formatting HDD
/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
if [ "${hddGotMigrationData}" != "" ]; then
echo "TODO: Migrate data from '{hddGotMigrationData}'"
fi
# delete everything but blockchain
echo "TODO: Delete everything but blockchain"
# by keeping that blockchain - user choosed already the blockchain type
if [ "${hddBlocksLitecoin}" == "1" ]; then
echo "network=litecoin" >> $SETUPFILE
else
echo "network=bitcoin" >> $SETUPFILE
fi
# DEBUG EXIT
exit 1
else
# STOP SETUP - loop back to setup menu start
exit 0
fi
fi
############################################
# UPLOAD MIGRATION
if [ "${menuresult}" == "1" ]; then
/home/admin/setup.scripts/dialogMigration.sh raspiblitz
if [ "$?" == "1" ]; then
# upload did not worked .. exit with 0 to restart process from outside loop
echo "Upload failed ... return to menu"
sleep 2
exit 0
fi
# user needs to reset password A
@@ -109,53 +168,6 @@ if [ "${setupPhase}" == "setup" ]; then
# 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)
# thats also true if the node is coming from another nodeOS
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddBlocksLitecoin}" == "1" ] || [ "${hddGotMigrationData}" != "" ]; then
/home/admin/setup.scripts/dialogDeleteData.sh keepblockchain
if [ "$?" == "1" ]; then
# dont format HDD later - reuse data and clean up
formatNeeded=0
# when blockchain comes from another node migrate data first
if [ "${hddGotMigrationData}" != "" ]; then
echo "TODO: Migrate data from '{hddGotMigrationData}'"
fi
# delete everything but blockchain
echo "TODO: Delete everything but blockchain"
# by keeping that blockchain - user choosed already the blockchain type
if [ "${hddBlocksLitecoin}" == "1" ]; then
echo "network=litecoin" >> $SETUPFILE
else
echo "network=bitcoin" >> $SETUPFILE
fi
# exit with 0 to restart process from outside loop
exit 1
fi
fi
# if other data is on HDD/SSD from migration/recover warn on formatting drive
if [ "${formatNeeded}" == "1" ]; then
/home/admin/setup.scripts/dialogDeleteData.sh
if [ "$?" == "1" ]; then
# exit with 0 to restart process from outside loop
exit 0
fi
# delete everything but blockchain
echo "TODO: Format HDD/SSD"
exit 1
fi
############################################
# Choosing Blockchain & Lightning