Improving Migration from Umbrel/Citadel (#2881)

This commit is contained in:
/rootzoll 2022-01-12 14:03:18 +01:00 committed by GitHub
parent 46ecc66d5b
commit 75478fa726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 28 deletions

View File

@ -420,6 +420,7 @@ if [ ${isMounted} -eq 0 ]; then
/home/admin/_cache.sh set hddBlocksBitcoin "${hddBlocksBitcoin}"
/home/admin/_cache.sh set hddBlocksLitecoin "${hddBlocksLitecoin}"
/home/admin/_cache.sh set hddGotMigrationData "${hddGotMigrationData}"
/home/admin/_cache.sh set hddVersionLND "${hddVersionLND}"
echo ""
echo "HDD is there but not AutoMounted yet - Waiting for user Setup/Update" >> $logFile

View File

@ -16,6 +16,9 @@ source ${infoFile}
# SETUPFILE - data from setup process
source /var/cache/raspiblitz/temp/raspiblitz.setup
# CACHEDATA - import needed data from cache
source <(/home/admin/_cache.sh get hddGotMigrationData hddVersionLND)
# log header
echo "" > ${logFile}
sudo chmod 640 ${logFile}
@ -24,8 +27,6 @@ echo "# _provision.migration.sh" >> ${logFile}
echo "###################################" >> ${logFile}
/home/admin/_cache.sh set message "Provision Migration"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${hddGotMigrationData}" == "" ]; then
/home/admin/config.scripts/blitz.error.sh _provision.migration.sh "missing-hostnamemigrationdata" "missing hddGotMigrationData" "" ${logFile}
exit 2

View File

@ -303,6 +303,7 @@ if [ "$1" = "status" ]; then
# check if its another fullnode implementation data disk
hddGotMigrationData=""
hddGotMigrationDataExtra=""
if [ "${hddFormat}" = "ext4" ]; then
# check for other node implementations
isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json')
@ -310,10 +311,14 @@ if [ "$1" = "status" ]; then
isMyNodeHDD=$(sudo ls /mnt/storage/mynode/bitcoin/bitcoin.conf 2>/dev/null | grep -c '.conf')
if [ ${isUmbrelHDD} -gt 0 ]; then
hddGotMigrationData="umbrel"
lndVersion=$(grep "lightninglabs/lnd" /mnt/storage/umbrel/docker-compose.yml 2>/dev/null | sed 's/.*lnd://' | sed 's/@.*//')
echo "hddVersionLND='${lndVersion}'"
elif [ ${isMyNodeHDD} -gt 0 ]; then
hddGotMigrationData="mynode"
elif [ ${isCitadelHDD} -gt 0 ]; then
hddGotMigrationData="citadel"
lndVersion=$(grep "lightninglabs/lnd" /mnt/storage/citadel/docker-compose.yml 2>/dev/null | sed 's/.*lnd://' | sed 's/@.*//')
echo "hddVersionLND='${lndVersion}'"
fi
else
echo "# not an ext4 drive - all known fullnode packages use ext4 at the moment"

View File

@ -39,16 +39,21 @@ sudo systemctl stop tlightningd 2>/dev/null
sudo systemctl stop slnd 2>/dev/null
sudo systemctl stop slightningd 2>/dev/null
# stopping bitcoin (thru cli)
echo "stop ${network}d (1) - please wait .."
timeout 10 sudo -u bitcoin ${network}-cli stop 2>/dev/null
if [ "${network}" != "" ]; then
# stopping bitcoind (thru systemd)
echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop t${network}d 2>/dev/null
sudo systemctl stop s${network}d 2>/dev/null
sleep 3
# stopping bitcoin (thru cli)
echo "stop ${network}d (1) - please wait .."
timeout 10 sudo -u bitcoin ${network}-cli stop 2>/dev/null
# stopping bitcoind (thru systemd)
echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop t${network}d 2>/dev/null
sudo systemctl stop s${network}d 2>/dev/null
sleep 3
else
echo "skipping stopping layer1 (network=='' in cache)"
fi
# make sure drives are synced before shutdown
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)

View File

@ -26,6 +26,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
echo
echo "Install or remove LND services on parallel chains"
echo "lnd.install.sh install - called by the build_sdcard.sh"
echo "lnd.install.sh info [?compareVersion]"
echo "lnd.install.sh on [mainnet|testnet|signet] [?initwallet]"
echo "lnd.install.sh off [mainnet|testnet|signet]"
echo "lnd.install.sh display-seed [mainnet|testnet|signet] [?delete]"
@ -38,6 +39,47 @@ if [ "${network}" == "" ]; then
network="bitcoin"
fi
if [ "$1" = "info" ] ; then
# the version that this script installs by default
echo "lndDefaultInstallVersion='${lndVersion}'"
# the version that is installed
lndInstalledVersion=$(sudo -u admin lnd --version 2>/dev/null | cut -d " " -f3)
echo "lndInstalledVersion='${lndInstalledVersion}'"
# if a version string is given as second optional parameter - check update compatibility
# assumption: if the available version is one miner version lower then asked data is not compatible
compareVersion=$2
if [ "${compareVersion}" != "" ]; then
# use version thats either installed or can be installed
availableVersion="${lndInstalledVersion}"
if [ "${availableVersion}" == "" ]; then
availableVersion="${lndVersion}"
fi
# check major & miner version value
availableMajor=$(echo ${availableVersion} | cut -d "." -f1 | grep -o '[[:digit:]]*' | tail -n 1)
compareMajor=$(echo ${compareVersion} | cut -d "." -f1 | grep -o '[[:digit:]]*' | tail -n 1)
availableMiner=$(echo ${availableVersion} | cut -d "." -f2 | grep -o '[[:digit:]]*' | tail -n 1)
compareMiner=$(echo ${compareVersion} | cut -d "." -f2 | grep -o '[[:digit:]]*' | tail -n 1)
#echo "# ${availableMajor} ${compareMajor} ${availableMiner} ${compareMiner}"
if [ "${compareMajor}" != "" ] && [ "${compareMiner}" != "" ]; then
# check major
if [ ${availableMajor} -lt ${compareMajor} ]; then
echo "compatible=0"
else
if [ ${availableMiner} -lt ${compareMiner} ]; then
echo "compatible=0"
else
echo "compatible=1"
fi
fi
fi
fi
exit 0
fi
if [ "$1" = "install" ] ; then
echo "# *** INSTALL LND ${lndVersion} BINARY ***"

View File

@ -63,9 +63,23 @@ fi
############################################
# QuickOption: Migration from other node
if [ "${setupPhase}" == "migration" ]; then
source <(/home/admin/_cache.sh get hddGotMigrationData hddVersionLND)
# show recovery dialog
echo "# Starting migration dialog (${hddGotMigrationData}) ..."
/home/admin/setup.scripts/dialogMigration.sh ${hddGotMigrationData}
# check if lightning is outdated
migrationMode="normal"
if [ "${lndVersion}" != "" ]; then
# get local lnd version & check compatibility
source <(/home/admin/config.scripts/lnd.install.sh info "${lndVersion}")
if [ "${compatible}" != "1" ]; then
migrationMode="outdatedLightning"
fi
fi
/home/admin/setup.scripts/dialogMigration.sh ${hddGotMigrationData} ${migrationMode}
if [ "$?" == "0" ]; then
# mark migration to happen on provision
echo "migrationOS='${hddGotMigrationData}'" >> $SETUPFILE
@ -77,6 +91,7 @@ if [ "${setupPhase}" == "migration" ]; then
# on cancel - default to normal setup
/home/admin/_cache.sh set setupPhase "setup"
echo "# you refused node migration option - defaulting to normal setup"
/home/admin/00raspiblitz.sh
exit 1
fi

View File

@ -13,24 +13,23 @@ source $SETUPFILE
#########################
# Parameters
# 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|citadel]
if [ "${migrationOS}" == "" ]; then
migrationOS="$1"
fi
# 2nd PARAMATER (optional): the version of the former fullnode OS if available
if [ "${migrationVersion}" == "" ]; then
migrationVersion="$2"
fi
# check parameter values
# 1st PARAMATER migrationOS: [raspiblitz|mynode|umbrel|citadel]
migrationOS="$1"
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ] && [ "${migrationOS}" != "citadel" ]; then
echo "# FAIL: the given migrationOS '${migrationOS}' is not supported yet"
exit 1
fi
# 2nd PARAMATER migrationMode (optional): [normal|outdatedLightning]
migrationMode="$2"
if [ "${migrationMode}" = "" ]; then
migrationMode="normal"
fi
if [ "${migrationMode}" != "normal" ] && [ "${migrationMode}" != "outdatedLightning" ]; then
echo "# FAIL: the given migrationMode '${migrationMode}' is not supported yet"
exit 1
fi
####################################################
# RASPIBLITZ
@ -104,6 +103,32 @@ if [ "${migrationOS}" == "raspiblitz" ]; then
fi
####################################################
# WARNING: OUTDATED LIGHTNING
# in case lightning version of RaspiBlitz is too old
####################################################
# outdated warning
if [ "${migrationMode}" == "outdatedLightning" ]; then
whiptail --title " MIGRATION WARNING " --yes-button "Stop Migration" --no-button "Try Anyway" --yesno "
RaspiBlitz might run an TOO OLD of an lightning version to migrate your nodes channel data automatically.
You have now two options:
1) Stop Migration, shutdown, keep your old node system
until RaspiBlitz offers an updated version
2) Ignore this warning and try your luck (not recommended)
" 16 62
result=$?
echo "${result}"
if [ "$?result" != "1" ]; then
# user cancel - signal by exit code
exit 1
fi
fi
####################################################
# UMBREL
# migrating from Umbrel to RaspiBlitz
@ -112,7 +137,7 @@ fi
if [ "${migrationOS}" == "umbrel" ]; then
# infodialog
whiptail --title " UMBREL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from UMBREL
whiptail --title " UMBREL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Cancel Migration" --yesno "RaspiBlitz found data from UMBREL
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
@ -139,7 +164,7 @@ fi
if [ "${migrationOS}" == "citadel" ]; then
# infodialog
whiptail --title " CITADEL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from CITADEL
whiptail --title " CITADEL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Cancel Migration" --yesno "RaspiBlitz found data from CITADEL
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
@ -166,7 +191,7 @@ fi
if [ "${migrationOS}" == "mynode" ]; then
# infodialog
whiptail --title " MYNODE --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from MYNODE
whiptail --title " MYNODE --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Cancel Migration" --yesno "RaspiBlitz found data from MYNODE
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.