#2642 add citadel as migration option

This commit is contained in:
rootzoll 2021-11-30 18:27:04 +01:00
parent 18a7ed9c3d
commit 3a4aae8ed7
3 changed files with 108 additions and 3 deletions

View File

@ -284,11 +284,14 @@ if [ "$1" = "status" ]; then
if [ "${hddFormat}" = "ext4" ]; then
# check for other node implementations
isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json')
isCitadelHDD=$(sudo ls /mnt/storage/citadel/info.json 2>/dev/null | grep -c '.json')
isMyNodeHDD=$(sudo ls /mnt/storage/mynode/bitcoin/bitcoin.conf 2>/dev/null | grep -c '.conf')
if [ ${isUmbrelHDD} -gt 0 ]; then
hddGotMigrationData="umbrel"
elif [ ${isMyNodeHDD} -gt 0 ]; then
hddGotMigrationData="mynode"
elif [ ${isCitadelHDD} -gt 0 ]; then
hddGotMigrationData="citadel"
fi
else
echo "# not an ext4 drive - all known fullnode packages use ext4 at the moment"

View File

@ -2,7 +2,7 @@
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# managing the RaspiBlitz data - import, export, backup."
echo "# blitz.migration.sh [export|import|export-gui|migration-umbrel|migration-mynode]"
echo "# blitz.migration.sh [export|import|export-gui|migration-umbrel|migration-mynode|migration-citadel]"
echo "error='missing parameters'"
exit 1
fi
@ -182,6 +182,81 @@ if [ "$1" = "migration-umbrel" ]; then
exit 0
fi
########################
# MIGRATION from Citadel
########################
if [ "$1" = "migration-citadel" ]; then
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
# make sure data drive is mounted
if [ "${isMounted}" != "1" ]; then
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
fi
if [ "${isMounted}" == "1" ]; then
echo "# mounted ${hddPartitionCandidate} to /mnt/hdd"
else
echo "err='failed temp mounting disk'"
exit 1
fi
# checking basic data disk layout
if [ -f /mnt/hdd/citadel/bitcoin/bitcoin.conf ] && [ -f /mnt/hdd/citadel/lnd/lnd.conf ]; then
echo "# found bitcoin & lnd data"
else
echo "err='citadel data layout changed'"
exit 1
fi
echo "# starting to rearrange the data drive for raspiblitz .."
# determine version
version=$(sudo cat /mnt/hdd/citadel/info.json | jq -r '.version')
if [ "${version}" == "" ]; then
echo "err='not able to get version'"
exit 1
fi
versionMajor=$(echo "${version}" | cut -d "." -f1)
versionMiner=$(echo "${version}" | cut -d "." -f2)
versionPatch=$(echo "${version}" | cut -d "." -f3)
if [ "${versionMajor}" == "" ] || [ "${versionMiner}" == "" ] || [ "${versionPatch}" == "" ]; then
echo "err='not able processing version'"
exit 1
fi
# set flag with standard password to be changed on final recovery setup
sudo touch /mnt/hdd/passwordc.flag
sudo chmod 777 /mnt/hdd/passwordc.flag
echo "moneyprintergobrrr" >> /mnt/hdd/passwordc.flag
sudo chown admin:admin /mnt/hdd/passwordc.flag
# extract detailed data
nameNode=$(sudo jq -r '.name' /mnt/hdd/citadel/db/user.json)
# move bitcoin/blockchain & call function to migrate config
sudo mv /mnt/hdd/bitcoin /mnt/hdd/backup_bitcoin 2>/dev/null
sudo mv /mnt/hdd/citadel/bitcoin /mnt/hdd/
sudo rm /mnt/hdd/bitcoin/.walletlock 2>/dev/null
sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin
migrate_btc_conf
# move lnd & call function to migrate config
sudo mv /mnt/hdd/lnd /mnt/hdd/backup_lnd 2>/dev/null
sudo mv /mnt/hdd/citadel/lnd /mnt/hdd/
sudo chown bitcoin:bitcoin -R /mnt/hdd/lnd
migrate_lnd_conf ${nameNode}
# backup & rename the rest of the data
sudo mv /mnt/hdd/citadel /mnt/hdd/backup_migration
# call function for final migration
migrate_raspiblitz_conf ${nameNode}
echo "# OK ... data disk converted to RaspiBlitz"
exit 0
fi
########################
# MIGRATION from myNode
# see manual steps: https://btc21.de/bitcoin/raspiblitz-migration/

View File

@ -16,7 +16,7 @@ source $SETUPFILE
# this is useful for testing the dialog outside of the setup process
# normally migrationOS & migrationVersion are provided by raspiblitz.info or raspiblitz.setup
# 1st PARAMATER (optional): [raspiblitz|mynode|umbrel]
# 1st PARAMATER (optional): [raspiblitz|mynode|umbrel|citadel]
if [ "${migrationOS}" == "" ]; then
migrationOS="$1"
fi
@ -27,7 +27,7 @@ if [ "${migrationVersion}" == "" ]; then
fi
# check parameter values
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ]; then
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ] && [ "${migrationOS}" != "citadel" ]; then
echo "# FAIL: the given migrationOS '${migrationOS}' is not supported yet"
exit 1
fi
@ -131,6 +131,33 @@ Do you want to start migration to RaspiBlitz now?
fi
####################################################
# CITADEL
# migrating from Citadel to RaspiBlitz
####################################################
if [ "${migrationOS}" == "citadel" ]; then
# infodialog
whiptail --title " CITADEL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from CITADEL
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
Please make sure to have your CITADEL seed words & static channel backup file (just in case). Also any data of additional apps you had installed on CITADEL might get lost.
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ "$?" != "0" ]; then
# user cancel - signal by exit code
exit 1
fi
# signal that user wants to proceed with migration
exit 0
fi
####################################################
# MYNODE
# migrating from myNode to RaspiBlitz