raspiblitz/home.admin/98repairMenu.sh

215 lines
7.1 KiB
Bash
Raw Normal View History

2019-06-19 00:06:05 +02:00
#!/bin/bash
# get raspiblitz config
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
2019-06-27 22:20:31 +02:00
askBackupCopy()
{
whiptail --title "LND Data Backup" --yes-button "Backup" --no-button "Skip" --yesno "
Before deleting your data, do you want
to make a backup of all your LND Data
and download that file to your laptop?
2019-06-19 00:06:05 +02:00
2019-06-27 22:20:31 +02:00
Download LND Data Backup now?
" 12 44
2019-06-19 00:55:16 +02:00
if [ $? -eq 0 ]; then
clear
echo "*************************************"
echo "* PREPARING LND BACKUP DOWNLOAD"
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup
echo
echo "PRESS ENTER to continue once you are done downloading."
2019-06-19 00:55:16 +02:00
read key
else
clear
echo "*************************************"
2019-08-07 13:13:48 +02:00
echo "* JUST MAKING BACKUP TO SD CARD"
2019-06-19 00:55:16 +02:00
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup no-download
fi
2019-06-27 22:20:31 +02:00
}
infoResetSDCard()
{
whiptail --title "RESET DONE" --msgbox "
OK Reset of HDD is done.
System will now shutdown.
To start fresh please write a fresh
RaspiBlitz image to your SD card.
" 12 40
}
2020-03-29 21:56:25 +02:00
copyHost()
{
clear
2020-06-17 20:30:06 +02:00
echo
echo "# *** Copy Blockchain Source Modus ***"
2020-06-17 22:20:06 +02:00
2020-06-17 20:30:06 +02:00
echo "# get IP of RaspiBlitz to copy to ..."
targetIP=$(whiptail --inputbox "\nPlease enter the LOCAL IP of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title " Target IP " --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
2020-06-17 22:20:06 +02:00
targetIP=$(echo "${targetIP[0]}")
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
2020-06-17 22:23:01 +02:00
if [ ${#targetIP} -eq 0 ]; then
return
fi
2020-06-17 22:20:06 +02:00
if [ "${localIP}" == "${targetIP}" ]; then
whiptail --msgbox "Dont type in the local IP of this RaspiBlitz,\nthe LOCAL IP of the other RaspiBlitz is needed." 8 54 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
canPingIP=$(ping ${targetIP} -c 1 | grep -c "1 received")
if [ ${canPingIP} -eq 0 ]; then
whiptail --msgbox "Was not able to contact/ping: ${targetIP}\n\n- check if IP of target RaspiBlitz is correct.\n- check to be on the same local network.\n- try again ..." 11 58 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
2020-06-17 22:52:43 +02:00
echo "# install dependencies ..."
sudo apt-get install -y sshpass
2020-06-17 22:20:06 +02:00
echo "# get Password of RaspiBlitz to copy to ..."
2020-06-17 20:30:06 +02:00
targetPassword=$(whiptail --passwordbox "\nPlease enter the PASSWORD A of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title "Target Password" --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
2020-06-17 22:23:01 +02:00
if [ ${#targetPassword} -eq 0 ]; then
return
fi
canLogin=$(sudo sshpass -p "${targetPassword}" ssh -t bitcoin@${targetIP} "echo 'working'" 2>/dev/null | grep -c 'working')
if [ ${canLogin} -eq 0 ]; then
2020-06-17 22:20:06 +02:00
whiptail --msgbox "Password was not working for IP: ${targetIP}\n\n- check thats the correct IP for correct RaspiBlitz\n- check that you used PASSWORD A and had no typo\n- If you tried too often, wait 1h try again" 11 58 "" --title " Testing Target Password " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
2020-06-17 22:52:43 +02:00
echo "# stopping servives ..."
sudo systemctl stop lnd
sudo systemctl stop ${network}d
sudo systemctl disable ${network}d
2020-06-18 00:53:28 +02:00
sleep 5
sudo systemctl stop bitcoind 2>/dev/null
2020-06-17 22:33:45 +02:00
clear
echo
2020-06-17 22:52:43 +02:00
echo "# Starting copy over LAN (around 4-6 hours) ..."
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
2020-06-18 00:53:28 +02:00
cd /mnt/hdd/${network}
2020-06-17 22:28:57 +02:00
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
2020-06-17 22:52:43 +02:00
sed -i "s/^state=.*/state=/g" /home/admin/raspiblitz.info
2020-06-17 22:20:06 +02:00
echo "# start servives again ..."
sudo systemctl enable ${network}d
sudo systemctl start ${network}d
sudo systemctl start lnd
echo "# show final message"
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"
2020-06-17 20:30:06 +02:00
2020-03-29 21:56:25 +02:00
}
2019-06-27 22:20:31 +02:00
# Basic Options
OPTIONS=(HARDWARE "Run Hardwaretest" \
SOFTWARE "Run Softwaretest (DebugReport)" \
2020-02-14 13:12:57 +01:00
BACKUP-LND "Backup your LND data (Rescue-File)" \
2020-02-14 15:04:04 +01:00
MIGRATION "Migrate Blitz Data to new Hardware" \
2020-03-29 21:56:25 +02:00
COPY-SOURCE "Copy Blockchain Source Modus" \
2019-06-27 22:20:31 +02:00
RESET-CHAIN "Delete Blockchain & Re-Download" \
RESET-LND "Delete LND & start new node/wallet" \
RESET-HDD "Delete HDD Data but keep Blockchain" \
RESET-ALL "Delete HDD completly to start fresh" \
DELETE-ELEC "Delete Electrum Index" \
DELETE-INDEX "Delete Bitcoin Transaction-Index"
2019-06-27 22:20:31 +02:00
)
2019-06-19 00:55:16 +02:00
2020-05-02 21:30:06 +02:00
CHOICE=$(whiptail --clear --title "Repair Options" --menu "" 18 62 11 "${OPTIONS[@]}" 2>&1 >/dev/tty)
2019-06-27 22:20:31 +02:00
clear
case $CHOICE in
HARDWARE)
sudo /home/admin/05hardwareTest.sh
/home/admin/00mainMenu.sh
;;
SOFTWARE)
sudo /home/admin/XXdebugLogs.sh
echo "Press ENTER to return to main menu."
read key
/home/admin/00mainMenu.sh
;;
2020-02-14 13:12:57 +01:00
BACKUP-LND)
2019-07-02 11:37:00 +02:00
sudo /home/admin/config.scripts/lnd.rescue.sh backup
2020-02-18 14:19:26 +01:00
echo
2020-02-18 14:21:30 +01:00
echo "Press ENTER when your backup download is done to shutdown."
2019-07-02 11:37:00 +02:00
read key
2020-02-18 14:21:30 +01:00
/home/admin/XXshutdown.sh
2019-07-02 11:37:00 +02:00
;;
2020-02-14 15:04:04 +01:00
MIGRATION)
2020-02-14 14:35:11 +01:00
sudo /home/admin/config.scripts/blitz.migration.sh "export-gui"
2020-02-14 13:12:57 +01:00
echo "Press ENTER to return to main menu."
read key
/home/admin/00mainMenu.sh
;;
2019-06-27 22:20:31 +02:00
RESET-CHAIN)
/home/admin/XXcleanHDD.sh -blockchain
/home/admin/98repairBlockchain.sh
echo "For reboot type: sudo shutdown -r now"
exit 1;
;;
RESET-LND)
askBackupCopy
# ask for a new name so that network analysis has harder time to connect new node id with old
result=""
while [ ${#result} -eq 0 ]
do
2019-08-07 13:10:59 +02:00
_temp="/home/admin/download/dialog.$$"
l1="Please enter the new name of your LND node:\n"
l2="different name is better for a fresh identity\n"
l3="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2$l3" 13 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred -u $_temp
echo "processing ..."
sleep 3
done
2020-04-18 01:23:36 +02:00
# make sure host is named like in the raspiblitz config
echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh ${result}
2020-04-18 01:24:07 +02:00
sudo sed -i "s/^hostname=.*/hostname=${result}/g" /mnt/hdd/raspiblitz.conf
2020-04-18 01:23:36 +02:00
echo "stopping lnd ..."
2019-06-27 22:20:31 +02:00
sudo systemctl stop lnd
sudo rm -r /mnt/hdd/lnd
/home/admin/70initLND.sh
2020-04-17 19:28:32 +02:00
# go back to main menu (and show)
/home/admin/00raspiblitz.sh
2019-06-27 22:20:31 +02:00
exit 1;
;;
RESET-HDD)
askBackupCopy
2019-06-19 00:55:16 +02:00
/home/admin/XXcleanHDD.sh
2019-06-27 22:20:31 +02:00
infoResetSDCard
sudo shutdown now
exit 1;
;;
RESET-ALL)
askBackupCopy
/home/admin/XXcleanHDD.sh -all
infoResetSDCard
sudo shutdown now
2019-06-19 00:06:05 +02:00
exit 1;
;;
DELETE-ELEC)
2020-05-02 21:33:39 +02:00
/home/admin/config.scripts/bonus.electrs.sh off deleteindex
exit 1;
;;
DELETE-INDEX)
2020-05-02 21:33:39 +02:00
/home/admin/config.scripts/network.txindex.sh delete
exit 1;
;;
2020-03-29 21:56:25 +02:00
COPY-SOURCE)
copyHost
;;
2019-06-19 00:06:05 +02:00
esac