diff --git a/home.admin/setup.scripts/dialogBlockchainLightning.sh b/home.admin/setup.scripts/dialogBlockchainLightning.sh index f91b64f03..7656fe9fd 100644 --- a/home.admin/setup.scripts/dialogBlockchainLightning.sh +++ b/home.admin/setup.scripts/dialogBlockchainLightning.sh @@ -9,23 +9,25 @@ source /home/admin/raspiblitz.info SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup" source $SETUPFILE -# values to determine by dialogs -network="" -lightning="" -# chose blockchain -OPTIONS=() -OPTIONS+=(BITCOIN "Setup BITCOIN Blockchain (BitcoinCore)") -OPTIONS+=(LITECOIN "Setup LITECOIN Blockchain (experimental)") -CHOICE=$(dialog --clear \ +################################# +# SELECT BLOCKCHAIN +# when not already set by setupfile + +if [ "${network}" == "" ]; then + + OPTIONS=() + OPTIONS+=(BITCOIN "Setup BITCOIN Blockchain (BitcoinCore)") + OPTIONS+=(LITECOIN "Setup LITECOIN Blockchain (experimental)") + CHOICE=$(dialog --clear \ --backtitle "RaspiBlitz ${codeVersion} - Setup" \ --title "⚡ Blockchain ⚡" \ --menu "\nChoose which Blockchain to run: \n " \ 11 64 5 \ "${OPTIONS[@]}" \ 2>&1 >/dev/tty) -clear -case $CHOICE in + clear + case $CHOICE in BITCOIN) # bitcoin core network="bitcoin" @@ -40,7 +42,13 @@ case $CHOICE in clear echo "User Cancel" exit 1 -esac + esac +fi + + +################################# +# SELECT LIGHTNING +# only possible when network is bitcoin if [ "${network}" == "bitcoin" ]; then diff --git a/home.admin/setup.scripts/dialogDeleteData.sh b/home.admin/setup.scripts/dialogDeleteData.sh index 528c49987..cc0acd91d 100644 --- a/home.admin/setup.scripts/dialogDeleteData.sh +++ b/home.admin/setup.scripts/dialogDeleteData.sh @@ -5,7 +5,7 @@ if [ "$1" == "format" ]; then 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? - " 14 65 + " 12 65 if [ "$?" == "0" ]; then # 0 --> delete data diff --git a/home.admin/setup.scripts/setupDialogControl.sh b/home.admin/setup.scripts/setupDialogControl.sh index 1faf9a2e4..587a538d3 100755 --- a/home.admin/setup.scripts/setupDialogControl.sh +++ b/home.admin/setup.scripts/setupDialogControl.sh @@ -109,13 +109,51 @@ 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 [ "${orgSetupPhase}" != "${setupPhase}" ]; then + 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 ############################################