2019-12-10 20:48:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
|
|
|
echo "# managing the RaspiBlitz data - import, export, backup."
|
2021-11-30 18:27:04 +01:00
|
|
|
echo "# blitz.migration.sh [export|import|export-gui|migration-umbrel|migration-mynode|migration-citadel]"
|
2020-01-20 21:05:40 +01:00
|
|
|
echo "error='missing parameters'"
|
2019-12-10 20:48:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if started with sudo
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
2020-01-20 21:05:40 +01:00
|
|
|
echo "error='missing sudo'"
|
2019-12-10 20:48:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
###################
|
|
|
|
# STATUS
|
|
|
|
###################
|
|
|
|
|
2020-02-14 23:18:49 +01:00
|
|
|
# check if data drive is mounted - other wise cannot operate
|
|
|
|
isMounted=$(sudo df | grep -c /mnt/hdd)
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
# set place where zipped TAR file gets stored
|
2021-08-04 00:18:30 +02:00
|
|
|
defaultUploadPath="/mnt/hdd/temp/migration"
|
2019-12-10 20:48:28 +01:00
|
|
|
|
2020-11-01 13:42:03 +01:00
|
|
|
# get local ip
|
|
|
|
source <(/home/admin/config.scripts/internet.sh status local)
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
# SCP download and upload links
|
2021-08-04 00:18:30 +02:00
|
|
|
scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./"
|
|
|
|
scpDownloadWin="scp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ."
|
|
|
|
scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
|
|
|
|
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
|
2019-12-10 20:48:28 +01:00
|
|
|
|
|
|
|
# output status data & exit
|
|
|
|
if [ "$1" = "status" ]; then
|
|
|
|
echo "# RASPIBLITZ Data Import & Export"
|
2021-08-04 00:18:30 +02:00
|
|
|
echo "localip=\"${localip}\""
|
|
|
|
echo "defaultUploadPath=\"${defaultUploadPath}\""
|
2020-11-01 13:42:03 +01:00
|
|
|
echo "scpDownloadUnix=\"${scpDownloadUnix}\""
|
|
|
|
echo "scpUploadUnix=\"${scpUploadUnix}\""
|
|
|
|
echo "scpDownloadWin=\"${scpDownloadWin}\""
|
|
|
|
echo "scpUploadWin=\"${scpUploadWin}\""
|
2019-12-10 20:48:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-05 13:14:56 +02:00
|
|
|
########################
|
|
|
|
# MIGRATION BASICS
|
|
|
|
########################
|
|
|
|
|
|
|
|
migrate_btc_conf () {
|
|
|
|
# keep old conf als backup
|
|
|
|
sudo mv /mnt/hdd/bitcoin/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf.migration
|
|
|
|
# start from fresh configuration template
|
|
|
|
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
|
|
|
|
}
|
|
|
|
|
|
|
|
migrate_lnd_conf () {
|
|
|
|
|
|
|
|
# 1st parameter can be an alias to set
|
|
|
|
nodename=$1
|
|
|
|
if [ ${#nodename} -eq 0 ]; then
|
|
|
|
nodename="raspiblitz"
|
|
|
|
fi
|
|
|
|
|
2022-02-09 12:11:07 +01:00
|
|
|
# keep old conf as backup
|
2021-04-05 13:14:56 +02:00
|
|
|
sudo mv /mnt/hdd/lnd/lnd.conf /mnt/hdd/lnd/lnd.conf.migration
|
|
|
|
# start from fresh configuration template (user will set password B on recovery)
|
|
|
|
sudo cp /home/admin/assets/lnd.bitcoin.conf /mnt/hdd/lnd/lnd.conf
|
|
|
|
sudo sed -i "s/^alias=.*/alias=${nodename}/g" /mnt/hdd/lnd/lnd.conf
|
2021-10-07 14:32:07 +02:00
|
|
|
|
|
|
|
# make sure correct file permisions are set
|
|
|
|
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
|
|
|
|
sudo chmod 664 /mnt/hdd/lnd/lnd.conf
|
|
|
|
|
2021-04-05 13:14:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
migrate_raspiblitz_conf () {
|
|
|
|
|
|
|
|
# 1st parameter can be an nodename to set
|
|
|
|
nodename=$1
|
|
|
|
if [ ${#nodename} -eq 0 ]; then
|
|
|
|
nodename="raspiblitz"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# write default raspiblitz config
|
|
|
|
source /home/admin/_version.info
|
|
|
|
echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf
|
|
|
|
sudo mv /home/admin/raspiblitz.conf /mnt/hdd/raspiblitz.conf
|
2021-08-26 13:14:00 +02:00
|
|
|
sudo chown root:sudo /mnt/hdd/raspiblitz.conf
|
|
|
|
sudo chmod 664 /mnt/hdd/raspiblitz.conf
|
2021-04-05 13:14:56 +02:00
|
|
|
|
2021-12-14 23:34:35 +01:00
|
|
|
/home/admin/config.scripts/blitz.conf.sh set raspiBlitzVersion "${codeVersion}"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set network "bitcoin"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set chain "main"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set hostname "${nodename}"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set displayClass "lcd"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set lcdrotate "1"
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh set runBehindTor "on"
|
|
|
|
|
2021-04-05 13:14:56 +02:00
|
|
|
# rename ext4 data drive
|
|
|
|
sudo e2label /dev/sda1 BLOCKCHAIN
|
|
|
|
}
|
|
|
|
|
|
|
|
########################
|
|
|
|
# MIGRATION from Umbrel
|
|
|
|
########################
|
|
|
|
|
|
|
|
if [ "$1" = "migration-umbrel" ]; then
|
|
|
|
|
2021-08-26 12:03:45 +02:00
|
|
|
# make sure data drive is mounted
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
2021-08-26 12:03:45 +02:00
|
|
|
if [ "${isMounted}" != "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount)
|
2021-08-26 12:03:45 +02:00
|
|
|
fi
|
2021-04-05 13:14:56 +02:00
|
|
|
if [ "${isMounted}" == "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
echo "# mounted /mnt/hdd (hddFormat='${hddFormat}')"
|
2021-04-05 13:14:56 +02:00
|
|
|
else
|
|
|
|
echo "err='failed temp mounting disk'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# checking basic data disk layout
|
|
|
|
if [ -f /mnt/hdd/umbrel/bitcoin/bitcoin.conf ] && [ -f /mnt/hdd/umbrel/lnd/lnd.conf ]; then
|
|
|
|
echo "# found bitcoin & lnd data"
|
|
|
|
else
|
|
|
|
echo "err='umbrel data layout changed'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "# starting to rearrange the data drive for raspiblitz .."
|
|
|
|
|
2021-04-24 12:46:21 +02:00
|
|
|
# determine version
|
|
|
|
version=$(sudo cat /mnt/hdd/umbrel/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
|
|
|
|
|
|
|
|
# since 0.3.9 umbrel uses a fixed/default password for lnd wallet (before it was the user set one)
|
|
|
|
if [ ${versionMajor} -eq 0 ] && [ ${versionMiner} -lt 4 ] && [ ${versionPatch} -lt 9 ]; then
|
|
|
|
echo "# umbrel before 0.3.9 --> password c is old user set password"
|
|
|
|
else
|
|
|
|
echo "# umbrel 0.3.9 or higher --> password c is fixed 'moneyprintergobrrr'"
|
|
|
|
# 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
|
|
|
|
fi
|
|
|
|
|
|
|
|
# extract detailed data
|
2021-04-05 13:14:56 +02:00
|
|
|
nameNode=$(sudo jq -r '.name' /mnt/hdd/umbrel/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/umbrel/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/umbrel/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/umbrel /mnt/hdd/backup_migration
|
|
|
|
|
|
|
|
# call function for final migration
|
|
|
|
migrate_raspiblitz_conf ${nameNode}
|
|
|
|
|
2021-08-26 12:29:13 +02:00
|
|
|
echo "# OK ... data disk converted to RaspiBlitz"
|
2021-11-30 18:27:04 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
########################
|
|
|
|
# MIGRATION from Citadel
|
|
|
|
########################
|
|
|
|
|
|
|
|
if [ "$1" = "migration-citadel" ]; then
|
|
|
|
|
|
|
|
# make sure data drive is mounted
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
2021-11-30 18:27:04 +01:00
|
|
|
if [ "${isMounted}" != "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount)
|
2021-11-30 18:27:04 +01:00
|
|
|
fi
|
|
|
|
if [ "${isMounted}" == "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
echo "# mounted /mnt/hdd (hddFormat='${hddFormat}')"
|
2021-11-30 18:27:04 +01:00
|
|
|
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"
|
2021-04-05 13:14:56 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
########################
|
|
|
|
# MIGRATION from myNode
|
2021-04-08 00:02:57 +02:00
|
|
|
# see manual steps: https://btc21.de/bitcoin/raspiblitz-migration/
|
2021-04-05 13:14:56 +02:00
|
|
|
########################
|
|
|
|
|
|
|
|
if [ "$1" = "migration-mynode" ]; then
|
|
|
|
|
2021-08-26 12:03:45 +02:00
|
|
|
# make sure data drive is mounted
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
2021-08-26 12:03:45 +02:00
|
|
|
if [ "${isMounted}" != "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount)
|
2021-08-26 12:03:45 +02:00
|
|
|
fi
|
2021-04-05 13:14:56 +02:00
|
|
|
if [ "${isMounted}" == "1" ]; then
|
2022-01-17 11:32:07 +01:00
|
|
|
echo "# mounted /mnt/hdd (hddFormat='${hddFormat}')"
|
2021-04-05 13:14:56 +02:00
|
|
|
else
|
|
|
|
echo "err='failed temp mounting disk'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# checking basic data disk layout
|
|
|
|
if [ -f /mnt/hdd/mynode/bitcoin/bitcoin.conf ] && [ -f /mnt/hdd/mynode/lnd/lnd.conf ]; then
|
|
|
|
echo "# found bitcoin & lnd data"
|
|
|
|
else
|
|
|
|
echo "err='mynode data layout changed'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "# starting to rearrange the data drive for raspiblitz .."
|
|
|
|
|
|
|
|
# move bitcoin/blockchain & call function to migrate config
|
|
|
|
sudo mv /mnt/hdd/bitcoin /mnt/hdd/backup_bitcoin 2>/dev/null
|
|
|
|
sudo mv /mnt/hdd/mynode/bitcoin /mnt/hdd/
|
|
|
|
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/mynode/lnd /mnt/hdd/
|
|
|
|
sudo chown bitcoin:bitcoin -R /mnt/hdd/lnd
|
|
|
|
migrate_lnd_conf
|
|
|
|
|
2021-04-17 01:09:06 +02:00
|
|
|
# copy lnd wallet password - so that user can set own on final setup
|
|
|
|
sudo cp /mnt/hdd/mynode/settings/.lndpw /mnt/hdd/passwordc.flag
|
|
|
|
|
2021-04-05 13:14:56 +02:00
|
|
|
# backup & rename the rest of the data
|
|
|
|
sudo mv /mnt/hdd/mynode /mnt/hdd/backup_migration
|
|
|
|
|
|
|
|
# call function for final migration
|
|
|
|
migrate_raspiblitz_conf
|
|
|
|
|
|
|
|
echo "# OK ... data disk converted to RaspiBlitz"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
#########################
|
|
|
|
# EXPORT RaspiBlitz Data
|
|
|
|
#########################
|
|
|
|
|
|
|
|
if [ "$1" = "export" ]; then
|
|
|
|
|
|
|
|
echo "# RASPIBLITZ DATA --> EXPORT"
|
|
|
|
|
|
|
|
# collect files to exclude in export in temp file
|
|
|
|
echo "*.tar.gz" > ~/.exclude.temp
|
|
|
|
echo "/mnt/hdd/bitcoin" >> ~/.exclude.temp
|
2021-12-09 14:08:04 +01:00
|
|
|
echo "/mnt/hdd/litecoin" >> ~/.exclude.temp # keep for legacy reasons
|
2019-12-10 20:48:28 +01:00
|
|
|
echo "/mnt/hdd/swapfile" >> ~/.exclude.temp
|
2019-12-14 18:38:11 +01:00
|
|
|
echo "/mnt/hdd/temp" >> ~/.exclude.temp
|
|
|
|
echo "/mnt/hdd/lost+found" >> ~/.exclude.temp
|
2019-12-10 20:48:28 +01:00
|
|
|
echo "/mnt/hdd/snapshots" >> ~/.exclude.temp
|
2019-12-14 18:38:11 +01:00
|
|
|
echo "/mnt/hdd/torrent" >> ~/.exclude.temp
|
|
|
|
echo "/mnt/hdd/app-storage" >> ~/.exclude.temp
|
2019-12-10 20:48:28 +01:00
|
|
|
|
2019-12-15 12:30:00 +01:00
|
|
|
# copy bitcoin data files to backup dir (if bitcoin active)
|
|
|
|
if [ -f "/mnt/hdd/bitcoin/bitcoin.conf" ]; then
|
|
|
|
sudo mkdir -p /mnt/hdd/backup_bitcoin
|
|
|
|
sudo cp /mnt/hdd/bitcoin/bitcoin.conf /mnt/hdd/backup_bitcoin/bitcoin.conf
|
|
|
|
sudo cp /mnt/hdd/bitcoin/wallet.dat /mnt/hdd/backup_bitcoin/wallet.dat 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
# clean old backups from temp
|
2020-08-08 22:49:05 +02:00
|
|
|
rm -f /hdd/temp/raspiblitz-*.tar.gz 2>/dev/null
|
2019-12-10 20:48:28 +01:00
|
|
|
|
|
|
|
# get date stamp
|
|
|
|
datestamp=$(date "+%y-%m-%d-%H-%M")
|
|
|
|
echo "# datestamp=${datestamp}"
|
|
|
|
|
|
|
|
# get name of RaspiBlitz from config (optional if exists)
|
|
|
|
blitzname="-"
|
|
|
|
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
|
|
|
if [ ${#hostname} -gt 0 ]; then
|
2020-11-01 11:38:58 +01:00
|
|
|
blitzname="-${hostname}-"
|
2019-12-10 20:48:28 +01:00
|
|
|
fi
|
|
|
|
echo "# blitzname=${blitzname}"
|
|
|
|
|
|
|
|
# zip it
|
|
|
|
echo "# Building the Export File (this can take some time) .."
|
2021-09-08 21:04:55 +02:00
|
|
|
sudo mkdir -p ${defaultUploadPath}
|
2021-08-04 00:18:30 +02:00
|
|
|
sudo tar -zcvf ${defaultUploadPath}/raspiblitz-export-temp.tar.gz -X ~/.exclude.temp /mnt/hdd 1>~/.include.temp 2>/dev/null
|
2019-12-10 20:48:28 +01:00
|
|
|
|
|
|
|
# get md5 checksum
|
2022-02-09 12:11:07 +01:00
|
|
|
echo "# Building checksum (can take a while) ..."
|
2021-08-04 00:18:30 +02:00
|
|
|
md5checksum=$(md5sum ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | head -n1 | cut -d " " -f1)
|
2020-11-10 23:40:54 +01:00
|
|
|
echo "md5checksum=${md5checksum}"
|
2019-12-10 20:48:28 +01:00
|
|
|
|
2020-11-10 23:40:54 +01:00
|
|
|
# get byte size
|
2021-08-04 00:18:30 +02:00
|
|
|
bytesize=$(wc -c ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | cut -d " " -f 1)
|
2020-11-10 23:40:54 +01:00
|
|
|
echo "bytesize=${bytesize}"
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
# final renaming
|
|
|
|
name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz"
|
2021-08-04 00:18:30 +02:00
|
|
|
echo "exportpath='${defaultUploadPath}'"
|
2019-12-10 20:48:28 +01:00
|
|
|
echo "filename='${name}'"
|
2021-08-04 00:18:30 +02:00
|
|
|
sudo mv ${defaultUploadPath}/raspiblitz-export-temp.tar.gz ${defaultUploadPath}/${name}
|
|
|
|
sudo chown bitcoin:bitcoin ${defaultUploadPath}/${name}
|
2019-12-10 20:48:28 +01:00
|
|
|
|
|
|
|
# delete temp files
|
|
|
|
rm ~/.exclude.temp
|
|
|
|
rm ~/.include.temp
|
|
|
|
|
2020-11-01 13:42:03 +01:00
|
|
|
echo "scpDownloadUnix=\"${scpDownloadUnix}\""
|
|
|
|
echo "scpDownloadWin=\"${scpDownloadWin}\""
|
2019-12-10 20:48:28 +01:00
|
|
|
echo "# OK - Export done"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-02-14 14:35:11 +01:00
|
|
|
if [ "$1" = "export-gui" ]; then
|
|
|
|
|
|
|
|
# cleaning old migration files from blitz
|
2021-08-04 00:18:30 +02:00
|
|
|
sudo rm ${defaultUploadPath}/*.tar.gz 2>/dev/null
|
2020-02-14 14:35:11 +01:00
|
|
|
|
2020-02-14 15:00:43 +01:00
|
|
|
echo "--> stopping services ..."
|
2022-02-09 12:11:07 +01:00
|
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
# bitcoind
|
2020-02-14 15:00:43 +01:00
|
|
|
sudo systemctl stop bitcoind
|
2022-02-09 12:11:07 +01:00
|
|
|
if [ "${testnet}" == "on" ] || [ "${cl}" == "1" ]; then
|
|
|
|
sudo systemctl stop tbitcoind
|
|
|
|
fi
|
|
|
|
if [ "${signet}" == "on" ] || [ "${tcl}" == "1" ]; then
|
|
|
|
sudo systemctl stop sbitcoind
|
|
|
|
fi
|
|
|
|
# lnd
|
|
|
|
if [ "${lnd}" == "on" ] || [ "${lnd}" == "1" ]; then
|
|
|
|
sudo systemctl stop lnd
|
|
|
|
fi
|
|
|
|
if [ "${tlnd}" == "on" ] || [ "${tlnd}" == "1" ]; then
|
|
|
|
sudo systemctl stop tlnd
|
|
|
|
fi
|
|
|
|
if [ "${slnd}" == "on" ] || [ "${slnd}" == "1" ]; then
|
|
|
|
sudo systemctl stop slnd
|
|
|
|
fi
|
|
|
|
# lightningd
|
|
|
|
if [ "${cl}" == "on" ] || [ "${cl}" == "1" ]; then
|
|
|
|
sudo systemctl stop lightningd
|
|
|
|
fi
|
|
|
|
if [ "${tcl}" == "on" ] || [ "${tcl}" == "1" ]; then
|
|
|
|
sudo systemctl stop tlightningd
|
|
|
|
fi
|
|
|
|
if [ "${scl}" == "on" ] || [ "${scl}" == "1" ]; then
|
|
|
|
sudo systemctl stop slightningd
|
|
|
|
fi
|
2020-02-14 15:00:43 +01:00
|
|
|
|
2020-02-14 14:35:11 +01:00
|
|
|
# create new migration file
|
|
|
|
clear
|
|
|
|
echo "--> creating blitz migration file ... (please wait)"
|
2021-08-04 00:18:30 +02:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.migration.sh export)
|
2020-02-14 14:35:11 +01:00
|
|
|
if [ ${#filename} -eq 0 ]; then
|
|
|
|
echo "# FAIL: was not able to create migration file"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# show info for migration
|
2020-02-14 23:42:27 +01:00
|
|
|
clear
|
2020-02-14 14:35:11 +01:00
|
|
|
echo
|
|
|
|
echo "*******************************"
|
|
|
|
echo "* DOWNLOAD THE MIGRATION FILE *"
|
|
|
|
echo "*******************************"
|
|
|
|
echo
|
2021-08-27 09:59:21 +02:00
|
|
|
echo "On your Linux or MacOS Laptop - RUN IN NEW TERMINAL:"
|
2020-11-01 13:42:03 +01:00
|
|
|
echo "${scpDownloadUnix}"
|
|
|
|
echo "On Windows use command:"
|
|
|
|
echo "${scpDownloadWin}"
|
2020-02-14 14:35:11 +01:00
|
|
|
echo ""
|
2020-02-23 19:44:27 +01:00
|
|
|
echo "Use password A to authenticate file transfer."
|
2020-11-10 23:40:54 +01:00
|
|
|
echo
|
|
|
|
echo "To check if you downloaded the file correctly:"
|
|
|
|
echo "md5-checksum --> ${md5checksum}"
|
|
|
|
echo "byte-size --> ${bytesize}"
|
|
|
|
echo
|
2020-02-14 15:00:43 +01:00
|
|
|
echo "Your Lightning node is now stopped. After download press ENTER to shutdown your raspiblitz."
|
|
|
|
echo "To complete the data migration follow then instructions on the github FAQ."
|
|
|
|
echo
|
|
|
|
read key
|
2020-07-26 03:00:21 +02:00
|
|
|
echo "Shutting down ...."
|
|
|
|
sleep 4
|
2021-08-04 00:18:30 +02:00
|
|
|
/home/admin/config.scripts/blitz.shutdown.sh
|
2020-02-14 14:35:11 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
#########################
|
|
|
|
# IMPORT RaspiBlitz Data
|
|
|
|
#########################
|
|
|
|
|
|
|
|
if [ "$1" = "import" ]; then
|
|
|
|
|
2021-08-04 00:18:30 +02:00
|
|
|
# BACKGROUND:
|
|
|
|
# the migration import is only called during setup phase - assume a prepared but clean HDD
|
|
|
|
|
|
|
|
# 2nd PARAMETER: file to import (expect that the file was valid checked from calling script)
|
|
|
|
importFile=$2
|
|
|
|
if [ "${importFile}" == "" ]; then
|
|
|
|
echo "error='filename missing'"
|
2019-12-10 20:48:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-04 00:18:30 +02:00
|
|
|
fileExists=$(sudo ls ${importFile} 2>/dev/null | grep -c "${importFile}")
|
|
|
|
if [ "${fileExists}" != "1" ]; then
|
|
|
|
echo "error='filename not found'"
|
2019-12-10 20:48:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-04 00:18:30 +02:00
|
|
|
echo "importFile='${importFile}'"
|
2019-12-10 20:48:28 +01:00
|
|
|
|
|
|
|
echo "# Importing (overwrite) (can take some time) .."
|
|
|
|
sudo tar -xf ${importFile} -C /
|
2021-08-04 00:18:30 +02:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "error='non zero exit state of unzipping migration file'"
|
|
|
|
echo "# reboot system ... HDD will offer fresh formating"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-12-15 02:16:46 +01:00
|
|
|
|
2021-12-09 14:08:04 +01:00
|
|
|
# copy bitcoin data backups back to original places (if part of backup)
|
2019-12-15 12:30:00 +01:00
|
|
|
if [ -d "/mnt/hdd/backup_bitcoin" ]; then
|
|
|
|
echo "# Copying back bitcoin backup data .."
|
2022-01-25 12:07:11 +01:00
|
|
|
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
|
2019-12-15 12:30:00 +01:00
|
|
|
sudo cp /mnt/hdd/backup_bitcoin/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
|
|
|
|
sudo cp /mnt/hdd/backup_bitcoin/wallet.dat /mnt/hdd/bitcoin/wallet.dat 2>/dev/null
|
2020-02-16 00:46:06 +01:00
|
|
|
sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin
|
2020-11-30 14:14:49 +01:00
|
|
|
sudo chown bitcoin:bitcoin -R /mnt/storage/bitcoin 2>/dev/null
|
2019-12-15 12:30:00 +01:00
|
|
|
fi
|
|
|
|
|
2021-08-04 00:18:30 +02:00
|
|
|
# check migration
|
|
|
|
raspiblitzConfExists=$(sudo ls /mnt/hdd/raspiblitz.conf | grep -c "raspiblitz.conf")
|
|
|
|
if [ "${raspiblitzConfExists}" != "1" ]; then
|
|
|
|
echo "error='no raspiblitz.conf after unzip migration file'"
|
|
|
|
echo "# reboot system ... HDD will offer fresh formating"
|
2020-02-14 23:21:53 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-04 00:18:30 +02:00
|
|
|
# correcting all user rights on data will be done by provisioning process
|
|
|
|
echo "# OK import done - provisioning process needed"
|
2020-02-14 14:35:11 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-12-10 20:48:28 +01:00
|
|
|
echo "error='unkown command'"
|
2020-08-08 22:49:05 +02:00
|
|
|
exit 1
|