From b8a2472df0f7b5e49f684387c6d7439ede29ee67 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 18 Jun 2019 00:37:38 +0200 Subject: [PATCH] #606 add delete blockchain --- home.admin/00raspiblitz.sh | 48 ++++---------------------------- home.admin/XXcleanHDD.sh | 25 +++++++++++++++++ home.admin/XXrepairBlockchain.sh | 37 ++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 43 deletions(-) create mode 100755 home.admin/XXrepairBlockchain.sh diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index ff64bbf40..8b2eecd2c 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -191,7 +191,8 @@ waitUntilChainNetworkIsReady() fi fi if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then - echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options." + + echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options." sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info sleep 3 @@ -206,48 +207,9 @@ To run a BACKUP of funds & channels first is recommended. " 13 65 clear - # Basic Options - OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \ - COPY "Copy from another Computer (SKILLED)" \ - REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \ - BACKUP "Run Backup LND data first (optional)" - ) - - CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) - - clear - if [ "${CHOICE}" = "TORRENT" ]; then - echo "Starting TORRENT ..." - sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info - /home/admin/50torrentHDD.sh - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - /home/admin/00raspiblitz.sh - exit - - elif [ "${CHOICE}" = "COPY" ]; then - echo "Starting COPY ..." - sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info - /home/admin/50copyHDD.sh - sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info - /home/admin/00raspiblitz.sh - exit - - elif [ "${CHOICE}" = "REINDEX" ]; then - echo "Starting REINDEX ..." - sudo /home/admin/config.scripts/network.reindex.sh - exit - - elif [ "${CHOICE}" = "BACKUP" ]; then - sudo /home/admin/config.scripts/lnd.rescue.sh backup - echo "PRESS ENTER to return to menu." - read key - /home/admin/00raspiblitz.sh - exit - - else - echo "CANCEL" - exit - fi + /home/admin/XXrepairBlockchain.sh + /home/admin/00raspiblitz.sh + exit fi diff --git a/home.admin/XXcleanHDD.sh b/home.admin/XXcleanHDD.sh index 95c017c81..a520db683 100755 --- a/home.admin/XXcleanHDD.sh +++ b/home.admin/XXcleanHDD.sh @@ -22,6 +22,31 @@ if [ "${extraParameter}" = "-all" ]; then echo "cleaning HDD ... (please wait)" sudo rm -rfv /mnt/hdd/* +elif [ "${extraParameter}" = "-blockchain" ]; then + + echo "!!!! This will DELETE JUST your blockchain from the HDD." + echo "--> It will keep your LND data and other setups." + echo "Press ENTER to really continue - CTRL+c to CANCEL (last chance)" + read key + + echo "stopping services ... (please wait)" + echo "- swap" + sudo dphys-swapfile swapoff + echo "- background" + sudo systemctl stop background 2>/dev/null + echo "- lnd" + sudo systemctl stop lnd.service 2>/dev/null + echo "- blockchain" + sudo systemctl stop bitcoind.service 2>/dev/null + sudo systemctl stop litecoind.service 2>/dev/null + + echo "DELETING ..." + sudo rm -f -r /mnt/hdd/bitcoin 2>/dev/null + sudo rm -f -r /mnt/hdd/litecoin 2>/dev/null + + echo "Starting Repair Options ..." + /home/admin/XXrepairBlockchain.sh + else echo "!!!! This will DELETE your personal data & POSSIBLE FUNDS from the HDD !!!!" diff --git a/home.admin/XXrepairBlockchain.sh b/home.admin/XXrepairBlockchain.sh new file mode 100755 index 000000000..57cd286c1 --- /dev/null +++ b/home.admin/XXrepairBlockchain.sh @@ -0,0 +1,37 @@ +#!/bin/bash +echo "" + +# Basic Options +OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \ + COPY "Copy from another Computer (SKILLED)" \ + REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \ + BACKUP "Run Backup LND data first (optional)" +) + +CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) + +clear +if [ "${CHOICE}" = "TORRENT" ]; then + echo "Starting TORRENT ..." + sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info + /home/admin/50torrentHDD.sh + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + +elif [ "${CHOICE}" = "COPY" ]; then + echo "Starting COPY ..." + sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info + /home/admin/50copyHDD.sh + sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info + +elif [ "${CHOICE}" = "REINDEX" ]; then + echo "Starting REINDEX ..." + sudo /home/admin/config.scripts/network.reindex.sh + +elif [ "${CHOICE}" = "BACKUP" ]; then + sudo /home/admin/config.scripts/lnd.rescue.sh backup + echo "PRESS ENTER to continue." + read key + +else + echo "CANCEL" +fi \ No newline at end of file