Browse Source

lnd.rescue handling SCB up and down

master
Christian Rotzoll 6 years ago
parent
commit
6455934bfc
  1. 55
      home.admin/70initLND.sh
  2. 78
      home.admin/config.scripts/lnd.rescue.sh

55
home.admin/70initLND.sh

@ -227,7 +227,7 @@ if [ ${walletExists} -eq 0 ]; then
exit 1 exit 1
fi fi
# WRNING ON ONLY SEED # WARNING ON ONLY SEED
if [ "${CHOICE}" == "ONLYSEED" ]; then if [ "${CHOICE}" == "ONLYSEED" ]; then
whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno " whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno "
Using JUST SEED WORDS will only recover your on-chain funds. Using JUST SEED WORDS will only recover your on-chain funds.
@ -325,50 +325,17 @@ or having a complete LND rescue-backup from your old node.
# fi # fi
if [ "${CHOICE}" == "SEED+SCB" ]; then if [ "${CHOICE}" == "SEED+SCB" ]; then
# get the channel.backup file # let lnd.rescue script do the upload process
gotFile=-1 /home/admin/config.scripts/lnd.rescue.sh scb-up
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
while [ ${gotFile} -lt 1 ]
do
# show info
clear
sleep 1
echo "**********************************"
echo "* UPLOAD THE channel.backup FILE *"
echo "**********************************"
echo
if [ ${gotFile} -eq -1 ]; then
echo "If you have the channel.backup file on your laptop or on"
echo "another server you can now upload it to the RaspiBlitz."
elif [ ${gotFile} -eq 0 ]; then
echo "NO channel.backup FOUND IN /home/admin"
echo "Please try upload again."
fi
echo
echo "To make upload open a new terminal and change,"
echo "into the directory where your lnd-rescue file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
echo "scp ./channel.backup admin@${localip}:/home/admin/"
echo ""
echo "Use password A to authenticate file transfere."
echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel."
# wait user interaction
echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel."
read key
if [ "${key}" == "x" ]; then
/home/admin/70initLND.sh
exit 1
fi
# test upload
gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup')
done
clear # check exit code of script
echo "OK - channel.backup file found." if [ $? -eq 1 ]; then
echo "USER CANCEL --> back to menu"
/home/admin/70initLND.sh
exit 1
else
echo "FILE UPLOADED --> will ne checked/activated after wallet restore from seed"
fi
fi fi
##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS ##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS

78
home.admin/config.scripts/lnd.rescue.sh

@ -4,8 +4,15 @@ source /mnt/hdd/raspiblitz.conf
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small rescue script to to backup or restore" echo "# small rescue script to to backup or restore LND data"
echo "lnd.rescue.sh [backup|restore] [?no-download]" echo "# -> backup all LND data in a tar.gz file for download:"
echo "# lnd.rescue.sh backup [?no-download]"
echo "# -> upload a LND data tar.gz file to replace LND data:"
echo "# lnd.rescue.sh restore"
echo "# -> download the LND channel.backup file from SD card:"
echo "# lnd.rescue.sh scb-down"
echo "# -> upload the LND channel.backup to recover wallet:"
echo "# lnd.rescue.sh scb-up"
exit 1 exit 1
fi fi
@ -67,10 +74,10 @@ elif [ ${mode} = "restore" ]; then
# RESTORE # RESTORE
################################ ################################
echo "*** LND.RESCUE --> RESTORE" echo "# LND.RESCUE --> RESTORE"
echo "" echo ""
# delete old backups # delete old backups
rm /home/admin/lnd-rescue-*.tar.gz rm /home/admin/lnd-rescue-*.tar.gz
filename="" filename=""
@ -169,6 +176,69 @@ elif [ ${mode} = "restore" ]; then
echo "Keep in mind that some channels maybe forced closed in the meanwhile." echo "Keep in mind that some channels maybe forced closed in the meanwhile."
echo echo
elif [ ${mode} = "scb-down" ]; then
echo
echo "****************************"
echo "* DOWNLOAD THE BACKUP FILE *"
echo "****************************"
echo
echo "RUN THE FOLLOWING COMMAND ON YOUR LAPTOP IN NEW TERMINAL:"
echo "scp -r admin@${localip}:/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ./"
echo ""
echo "Use password A to authenticate file transfere."
echo
echo "NOTE: Use this file when setting up a fresh RaspiBlitz by choosing"
echo "option OLD WALLET and then SCB+SEED -> Seed & channel.backup file"
echo "Will just recover on-chain & channel-funds, but closing all channels"
elif [ ${mode} = "scb-up" ]; then
gotFile=-1
while [ ${gotFile} -lt 1 ]
do
# show info
clear
sleep 1
echo "**********************************"
echo "* UPLOAD THE channel.backup FILE *"
echo "**********************************"
echo
if [ ${gotFile} -eq -1 ]; then
echo "If you have the channel.backup file on your laptop or on"
echo "another server you can now upload it to the RaspiBlitz."
elif [ ${gotFile} -eq 0 ]; then
echo "NO channel.backup FOUND IN /home/admin"
echo "Please try upload again."
fi
echo
echo "To make upload open a new terminal and change,"
echo "into the directory where your lnd-rescue file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
echo "scp ./channel.backup admin@${localip}:/home/admin/"
echo ""
echo "Use password A to authenticate file transfere."
echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel."
# wait user interaction
echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel."
read key
if [ "${key}" == "x" ]; then
# EXIT with CODE 1 --> USER CANCEL
echo "# CANCEL upload"
exit 1
fi
# test upload
gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup')
done
# EXIT with CODE 1 --> FILE UPLOADED
echo "# OK channel.backup uploaded"
exit 0
else else
echo "unknown parameter '${mode}' - exit" echo "unknown parameter '${mode}' - exit"
fi fi
Loading…
Cancel
Save