2021-05-01 00:23:49 +02:00
#!/bin/bash
# TODO: also the migration might need to be adapted to work with an already mounted HDD later
# command info
if [ $# -eq 0 ] || [ " $1 " = "-h" ] || [ " $1 " = "-help" ] ; then
echo "# dialog to get all data needed for migration-setup"
echo "# 00migrationDialog.sh [raspiblitz|mynode|umbrel]"
exit 1
fi
## get basic info
source /home/admin/raspiblitz.info
# tempfile for result of dialogs
_temp = $( mktemp -p /dev/shm/)
# prepare the setup file (that constains info just needed for the rest of setup process)
2021-05-01 01:06:55 +02:00
SETUPFILE = "/home/admin/raspiblitz.setup"
2021-05-01 00:23:49 +02:00
rm $SETUPFILE 2>/dev/null
echo "# RASPIBLITZ SETUP FILE" > $SETUPFILE
# flags of what passwords are to set by user
setPasswordA = 1
setPasswordB = 0
setPasswordC = 0
# 1st PARAMATER: [raspiblitz|mynode|umbrel]
migrationOS = " $1 "
2021-05-01 01:08:59 +02:00
if [ " ${ migrationOS } " != "raspiblitz" ] && [ " ${ migrationOS } " != "mynode" ] && [ " ${ migrationOS } " != "umbrel" ] ; then
2021-05-01 00:23:49 +02:00
echo " parameter1( ${ migrationOS } ) "
echo "error='not supported'"
exit 1
fi
# 2nd PARAMATER (optional): the version of the former fullnode OS if available
migrationVersion = " $2 "
####################################################
# RASPIBLITZ
# migrating from other hardware with migration file
####################################################
if [ " ${ migrationOS } " = = "raspiblitz" ] ; then
2021-05-01 01:22:38 +02:00
# write migration info
echo " migrationOS=' ${ migrationOS } ' " >> $SETUPFILE
echo " migrationVersion=' ${ migrationVersion } ' " >> $SETUPFILE
2021-05-01 00:23:49 +02:00
# get defaultZipPath, localIP, etc
source <( sudo /home/admin/config.scripts/blitz.migration.sh status)
# make sure that temp directory exists and can be written by admin
sudo mkdir -p ${ defaultZipPath }
sudo chmod 777 -R ${ defaultZipPath }
# scp upload info
clear
echo
echo "*****************************"
echo "* UPLOAD THE MIGRATION FILE *"
echo "*****************************"
echo "If you have a migration file on your laptop you can now"
echo "upload it and restore on the new HDD/SSD."
echo
echo "ON YOUR LAPTOP open a new terminal and change into"
echo "the directory where your migration file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
echo " scp -r ./raspiblitz-*.tar.gz admin@ ${ localip } : ${ defaultZipPath } "
echo ""
echo "Use password 'raspiblitz' to authenticate file transfer."
echo "PRESS ENTER when upload is done."
read key
countZips = $( sudo ls ${ defaultZipPath } /raspiblitz-*.tar.gz 2>/dev/null | grep -c 'raspiblitz-' )
# in case no upload found
if [ ${ countZips } -eq 0 ] ; then
echo
echo " FAIL: Was not able to detect uploaded file in ${ defaultZipPath } "
echo "Shutting down ... please make fesh sd card & try again."
sleep 3
echo "shutdown=1" >> $SETUPFILE
exit 1
fi
# in case of multiple files
if [ ${ countZips } -gt 1 ] ; then
echo
echo " # FAIL: Multiple possible files detected in ${ defaultZipPath } "
echo "Shutting down ... please make fesh sd card & try again."
sleep 3
echo "shutdown=1" >> $SETUPFILE
exit 1
fi
# further checks and unpacking will be done when migration is processed (not part of dialog)
echo
echo "OK: Migration data was imported - will now try to recover/restore RaspiBlitz with this data"
echo "PRESS ENTER TO CONTINUE"
read key
# user needs to reset password A
setPasswordA = 1
fi
####################################################
# UMBREL
# migrating from Umbrel to RaspiBlitz
####################################################
if [ " ${ migrationOS } " = = "umbrel" ] ; then
# infodialog
2021-05-01 00:36:12 +02:00
whiptail --title " UMBREL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Shutdown" --yesno " RaspiBlitz found data from UMBREL
2021-05-01 00:23:49 +02:00
You can migrate your blockchain & LND data ( funds & channels) over to RaspiBlitz.
Please make sure to have your UMBREL seed words & static channel backup file ( just in case ) . Also any data of additional apps you had installed on UMBREL might get lost.
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ $? -eq 0 ] ; then
# write migration info
echo "migrationOS='umbrel'" >> $SETUPFILE
echo " migrationVersion=' ${ migrationVersion } ' " >> $SETUPFILE
else
# user cancel - request shutdown
echo "shutdown=1" >> $SETUPFILE
exit 1
fi
# user needs to reset password A
setPasswordA = 1
setPasswordB = 1
setPasswordC = 1
fi
####################################################
# MYNODE
# migrating from myNode to RaspiBlitz
####################################################
if [ " ${ migrationOS } " = = "mynode" ] ; then
# infodialog
2021-05-01 00:36:12 +02:00
whiptail --title " MYNODE --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Shutdown" --yesno " RaspiBlitz found data from MYNODE
2021-05-01 00:23:49 +02:00
You can migrate your blockchain & LND data ( funds & channels) over to RaspiBlitz.
Please make sure to have your MYNODE seed words & static channel backup file ( just in case ) . Also any data of additional apps you had installed on MYNODE might get lost.
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ $? -eq 0 ] ; then
# write migration info
echo "migrationOS='mynode'" >> $SETUPFILE
echo " migrationVersion=' ${ migrationVersion } ' " >> $SETUPFILE
else
# user cancel - request shutdown
echo "shutdown=1" >> $SETUPFILE
exit 1
fi
# user needs to reset password A
setPasswordA = 1
setPasswordB = 1
setPasswordC = 1
fi
####################################################
# INPUT PASSWORDS (based on flags above set)
# dynamic info string on what passwords need to be changed
passwordinfo = "A" # always so far
if [ ${ setPasswordB } -eq 1 ] ; then
passwordinfo = " ${ passwordinfo } , B "
fi
if [ ${ setPasswordC } -eq 1 ] ; then
passwordinfo = " ${ passwordinfo } , C "
fi
# basic information in RaspiBlitz passwords
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox " You will need to set new passwords.
2021-05-01 00:39:18 +02:00
RaspiBlitz works with 3 different passwords:
2021-05-01 00:23:49 +02:00
PASSWORD A) Main User Password ( SSH & WebUI, sudo)
PASSWORD B) APP Password ( RPC & Additional Apps)
2021-05-01 00:52:31 +02:00
PASSWORD C) Lightning Wallet Password for Unlock
2021-05-01 00:23:49 +02:00
You will need to set Password: ${ passwordinfo }
( other passwords might stay like on your old node)
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
2021-05-01 00:39:18 +02:00
" 17 64
2021-05-01 00:23:49 +02:00
if [ ${ setPasswordA } -eq 1 ] ; then
2021-05-01 00:52:31 +02:00
clear
2021-05-01 00:23:49 +02:00
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
password = $( sudo cat $_temp )
echo " passwordA=' ${ password } ' " >> $SETUPFILE
2021-05-01 00:46:09 +02:00
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password A set" 7 20
2021-05-01 00:23:49 +02:00
fi
if [ ${ setPasswordB } -eq 1 ] ; then
2021-05-01 00:52:31 +02:00
clear
2021-05-01 00:23:49 +02:00
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
password = $( sudo cat $_temp )
echo " passwordB=' ${ password } ' " >> $SETUPFILE
2021-05-01 00:46:09 +02:00
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password B set" 7 20
2021-05-01 00:23:49 +02:00
fi
if [ ${ setPasswordC } -eq 1 ] ; then
2021-05-01 00:52:31 +02:00
clear
2021-05-01 00:23:49 +02:00
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
password = $( sudo cat $_temp )
echo " passwordC=' ${ password } ' " >> $SETUPFILE
2021-05-01 00:46:09 +02:00
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password C set" 7 20
2021-05-01 01:06:55 +02:00
fi
clear
echo "# data from dialogs stored in to be further processed:"
echo " ${ SETUPFILE } "
exit 0