mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-02 08:58:15 +02:00
parent
4cdc3b2027
commit
413867a4b6
@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "For debug logs CTRL+C and: tail -n1000 -f raspiblitz.log"
|
||||
echo "or call the command 'debug' to see bigger report."
|
||||
echo "Starting the main menu ..."
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
@ -37,6 +39,54 @@ if [ ${isMounted} -eq 0 ] && [ ${#hddCandidate} -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if HDD is from another fullnode OS and offer migration
|
||||
if [ "${hddGotMigrationData}" != "" ] && [ "${hddGotMigrationData}" != "none" ]; then
|
||||
nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]")
|
||||
whiptail --title " ${nodenameUpperCase} --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Ignore" --yesno "RaspiBlitz found data from ${nodenameUpperCase}
|
||||
|
||||
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
|
||||
|
||||
Please make sure to have your ${nodenameUpperCase} seed words & static channel backup file (just in case). Also any data of additional apps you had installed on ${nodenameUpperCase} might get lost.
|
||||
|
||||
Do you want to start migration to RaspiBlitz now?
|
||||
" 16 58
|
||||
if [ $? -eq 0 ]; then
|
||||
err=""
|
||||
echo "**************************************************"
|
||||
echo "MIGRATION FROM ${nodenameUpperCase} TO RASPIBLITZ"
|
||||
echo "**************************************************"
|
||||
echo "- started ..."
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
|
||||
if [ "${err}" != "" ]; then
|
||||
echo "MIGRATION FAILED: ${err}"
|
||||
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if free space is lower than 100GB (100000000) delete backup files
|
||||
if [ "${hddDataFreeKB}" != "" ] && [ ${hddDataFreeKB} -lt 407051412 ]; then
|
||||
echo "- free space of data disk is low ... deleting 'backup_migration'"
|
||||
sudo rm -R /mnt/hdd/backup_migration
|
||||
else
|
||||
echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'"
|
||||
fi
|
||||
sleep 3
|
||||
|
||||
# kick into reboot
|
||||
echo "******************************************************"
|
||||
echo "OK MIGRATION --> will now reboot and update/recover"
|
||||
echo "******************************************************"
|
||||
#sudo shutdown -h -r now
|
||||
#sleep 100
|
||||
exit 0
|
||||
else
|
||||
echo "******************************************************"
|
||||
echo "MIGRATION SKIPPED ... starting fresh RaspiBlitz Setup"
|
||||
echo "******************************************************"
|
||||
sleep 6
|
||||
fi
|
||||
fi
|
||||
|
||||
# check data from _bootstrap.sh that was running on device setup
|
||||
bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
|
||||
if [ ${bootstrapInfoExists} -eq 0 ]; then
|
||||
@ -128,33 +178,31 @@ waitUntilChainNetworkIsReady()
|
||||
source ${configFile}
|
||||
echo "checking ${network}d - please wait .."
|
||||
echo "can take longer if device was off or first time"
|
||||
while :
|
||||
do
|
||||
|
||||
# check for error on network
|
||||
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
|
||||
clienterror=`cat error.tmp`
|
||||
rm error.tmp
|
||||
|
||||
# check for missing blockchain data
|
||||
if [ "${network}" = "bitcoin" ]; then
|
||||
if [ "${chain}" = "main" ]; then
|
||||
# check for error on network
|
||||
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
|
||||
clienterror=`cat error.tmp`
|
||||
rm error.tmp
|
||||
|
||||
# check for missing blockchain data
|
||||
if [ "${network}" = "bitcoin" ]; then
|
||||
if [ "${chain}" = "main" ]; then
|
||||
minSize=210000000000
|
||||
else
|
||||
minSize=27000000000
|
||||
fi
|
||||
elif [ "${network}" = "litecoin" ]; then
|
||||
if [ "${chain}" = "main" ]; then
|
||||
minSize=20000000000
|
||||
else
|
||||
minSize=27000000000
|
||||
fi
|
||||
else
|
||||
minSize=210000000000000
|
||||
minSize=27000000000
|
||||
fi
|
||||
isSyncing=$(sudo ls -la /mnt/hdd/${network}/blocks/.selfsync 2>/dev/null | grep -c '.selfsync')
|
||||
blockchainsize=$(sudo du -shbc /mnt/hdd/${network}/ 2>/dev/null | head -n1 | awk '{print $1;}')
|
||||
if [ ${#blockchainsize} -gt 0 ]; then
|
||||
elif [ "${network}" = "litecoin" ]; then
|
||||
if [ "${chain}" = "main" ]; then
|
||||
minSize=20000000000
|
||||
else
|
||||
minSize=27000000000
|
||||
fi
|
||||
else
|
||||
minSize=210000000000000
|
||||
fi
|
||||
isSyncing=$(sudo ls -la /mnt/hdd/${network}/blocks/.selfsync 2>/dev/null | grep -c '.selfsync')
|
||||
blockchainsize=$(sudo du -shbc /mnt/hdd/${network}/ 2>/dev/null | head -n1 | awk '{print $1;}')
|
||||
if [ ${#blockchainsize} -gt 0 ]; then
|
||||
if [ ${blockchainsize} -lt ${minSize} ]; then
|
||||
if [ ${isSyncing} -eq 0 ]; then
|
||||
echo "blockchainsize(${blockchainsize})"
|
||||
@ -163,9 +211,9 @@ waitUntilChainNetworkIsReady()
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${#clienterror} -gt 0 ]; then
|
||||
if [ ${#clienterror} -gt 0 ]; then
|
||||
#echo "clienterror(${clienterror})"
|
||||
|
||||
# analyse LOGS for possible reindex
|
||||
@ -183,23 +231,29 @@ waitUntilChainNetworkIsReady()
|
||||
fi
|
||||
if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then
|
||||
|
||||
echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options."
|
||||
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
|
||||
sleep 3
|
||||
if [ ${reindex} -gt 0 ]; then
|
||||
echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options."
|
||||
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
whiptail --title "RaspiBlitz - Repair Script" --yes-button "DELETE+REPAIR" --no-button "Ignore" --yesno "Your blockchain data needs to be repaired.
|
||||
This can be due to power problems or a failing HDD.
|
||||
whiptail --title "Blockchain not Complete" --yes-button "DELETE+REPAIR" --no-button "Continue Sync" --yesno "Your blockchain data is not complete (yet).
|
||||
|
||||
You can try to sync the chain further but if your stuck
|
||||
this can be due to power problems or a failing HDD.
|
||||
For more info see: https://raspiblitz.org -> FAQ
|
||||
|
||||
Before RaspiBlitz can offer you repair options the old
|
||||
corrupted blockchain needs to be deleted while your LND
|
||||
funds and channel stay safe (just expect some off-time).
|
||||
If you choose to DELETE+REPAIR the old blockchain gets
|
||||
deleted but your Lightning funds & channel not be touched.
|
||||
|
||||
How do you want to continue?
|
||||
" 13 65
|
||||
" 15 65
|
||||
if [ $? -eq 0 ]; then
|
||||
#delete+repair
|
||||
clear
|
||||
echo "***********************************************************"
|
||||
echo "DELETE+REPAIR blockchain ..."
|
||||
echo "***********************************************************"
|
||||
/home/admin/XXcleanHDD.sh -blockchain -force
|
||||
/home/admin/98repairBlockchain.sh
|
||||
/home/admin/00raspiblitz.sh
|
||||
@ -207,6 +261,9 @@ How do you want to continue?
|
||||
else
|
||||
# ignore - just delete blockchain logfile
|
||||
clear
|
||||
echo "***********************************************************"
|
||||
echo "CONTINUE SYNC blockchain ..."
|
||||
echo "***********************************************************"
|
||||
fi
|
||||
|
||||
fi
|
||||
@ -217,10 +274,13 @@ How do you want to continue?
|
||||
echo "${network} error: ${clienterror}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
|
||||
if [ ${locked} -gt 0 ]; then
|
||||
while :
|
||||
do
|
||||
|
||||
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
|
||||
if [ ${locked} -gt 0 ]; then
|
||||
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
|
||||
if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 300 ]; then
|
||||
# give autounlock 5 min after startup to react
|
||||
@ -241,17 +301,16 @@ How do you want to continue?
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
if [ ${lndSynced} -eq 0 ]; then
|
||||
fi
|
||||
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
|
||||
if [ ${lndSynced} -eq 0 ]; then
|
||||
/home/admin/80scanLND.sh
|
||||
if [ $? -gt 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
else
|
||||
# everything is ready - return from loop
|
||||
return
|
||||
fi
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
@ -5,20 +5,44 @@ source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# show password info dialog
|
||||
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
|
||||
resetAlsoPasswordB=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep -c "rpcpassword=passwordB")
|
||||
if [ ${resetAlsoPasswordB} -eq 0 ]; then
|
||||
# just password A
|
||||
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
|
||||
|
||||
You need to set a new Password A:
|
||||
A) Master User Password
|
||||
|
||||
Passwords B, C & D stay as before.
|
||||
Passwords B & C stay as before.
|
||||
|
||||
Follow Password Rules: Minimal of 8 chars,
|
||||
no spaces and only special characters - or .
|
||||
Write them down & store them in a safe place.
|
||||
" 14 52
|
||||
|
||||
# call set password a script
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh a
|
||||
# call set password a script
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh a
|
||||
|
||||
else
|
||||
# password A + B
|
||||
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
|
||||
|
||||
You need to set a new Password A & B:
|
||||
A) Main User Password (SSH, WebUI, ..)
|
||||
B) RPC & APP Password (Additional Apps, ..)
|
||||
|
||||
Passwords C (for your Lightning wallet) stays to the password you set before.
|
||||
|
||||
Follow Password Rules: Minimal of 8 chars,
|
||||
no spaces and only special characters - or .
|
||||
Write them down & store them in a safe place.
|
||||
" 17 52
|
||||
|
||||
# call set password a script
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh a
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh b
|
||||
|
||||
fi
|
||||
|
||||
# sucess info dialog
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
|
||||
@ -60,7 +84,7 @@ to deactivate the Auto-Unlock feature.
|
||||
dialog --backtitle "RaspiBlitz" --pause " FINAL REBOOT IS NEEDED." 8 52 5
|
||||
|
||||
else
|
||||
dialog --backtitle "RaspiBlitz" --pause " OK - SSH password A set.\n FINAL REBOOT IS NEEDED." 9 52 5
|
||||
dialog --backtitle "RaspiBlitz" --pause " OK - Passwords set.\n FINAL REBOOT IS NEEDED." 9 52 5
|
||||
fi
|
||||
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
@ -183,20 +183,26 @@ elif [ ${walletLocked} -gt 0 ]; then
|
||||
title="Auto Unlock"
|
||||
infoStr=" Waiting for Wallet Auto-Unlock.\n Please wait up to 5min ..."
|
||||
else
|
||||
title="Action Required"
|
||||
infoStr=" LND WALLET IS LOCKED !!!\n"
|
||||
if [ "${rtlWebinterface}" = "on" ]; then
|
||||
|
||||
if [ "$USER" == "admin" ]; then
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
else
|
||||
title="Action Required"
|
||||
infoStr=" LND WALLET IS LOCKED !!!\n"
|
||||
if [ "${rtlWebinterface}" = "on" ]; then
|
||||
height=6
|
||||
infoStr="${infoStr} Browser: http://${localip}:3000\n PasswordB=login / PasswordC=unlock"
|
||||
else
|
||||
else
|
||||
infoStr="${infoStr} Please use SSH to unlock:"
|
||||
fi
|
||||
if [ ${startcountLightning} -gt 1 ]; then
|
||||
fi
|
||||
if [ ${startcountLightning} -gt 1 ]; then
|
||||
width=45
|
||||
height=$((height+3))
|
||||
infoStr=" LIGHTNING RESTARTED - login for details\n${infoStr}"
|
||||
adminStr="${adminStr}\n or choose 'INFO' in main menu\n or type 'raspiblitz' on terminal"
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
|
@ -176,7 +176,12 @@ echo "*** MOUNTED DRIVES ***"
|
||||
df -T -h
|
||||
echo ""
|
||||
|
||||
echo "*** NETWORK Info ***"
|
||||
echo ""
|
||||
echo "*** DATADRIVE ***"
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh status
|
||||
echo ""
|
||||
|
||||
echo "*** NETWORK ***"
|
||||
sudo /home/admin/config.scripts/internet.sh status | grep 'network_device\|localip\|dhcp'
|
||||
echo ""
|
||||
|
||||
|
@ -22,7 +22,7 @@ zmqpubrawtx=tcp://127.0.0.1:28333
|
||||
# Raspberry Pi optimizations
|
||||
dbcache=128
|
||||
maxorphantx=10
|
||||
maxmempool=64
|
||||
maxmempool=300
|
||||
maxconnections=40
|
||||
maxuploadtarget=5000
|
||||
|
||||
|
@ -227,12 +227,12 @@ if [ "$1" = "status" ]; then
|
||||
if [ ${isTempMounted} -eq 0 ]; then
|
||||
echo "hddError='storage mount failed'"
|
||||
else
|
||||
|
||||
# check for blockchain data on storage
|
||||
hddBlocksBitcoin=$(sudo ls /mnt/storage${subVolumeDir}/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
|
||||
echo "hddBlocksBitcoin=${hddBlocksBitcoin}"
|
||||
hddBlocksLitecoin=$(sudo ls /mnt/storage${subVolumeDir}/litecoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
|
||||
echo "hddBlocksLitecoin=${hddBlocksLitecoin}"
|
||||
sudo umount /mnt/storage
|
||||
if [ "${blockchainType}" = "bitcoin" ] && [ ${hddBlocksBitcoin} -eq 1 ]; then
|
||||
echo "hddGotBlockchain=1"
|
||||
elif [ "${blockchainType}" = "litecoin" ] && [ ${hddBlocksLitecoin} -eq 1 ]; then
|
||||
@ -240,6 +240,36 @@ if [ "$1" = "status" ]; then
|
||||
elif [ ${#blockchainType} -gt 0 ]; then
|
||||
echo "hddGotBlockchain=0"
|
||||
fi
|
||||
|
||||
# check free space on data drive
|
||||
if [ ${isBTRFS} -eq 0 ]; then
|
||||
# EXT4
|
||||
hdd_data_free1Kblocks=$(df -h -k /dev/${hddDataPartitionExt4} | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
|
||||
else
|
||||
# BRTS
|
||||
hdd_data_free1Kblocks=$(df -h -k /dev/${hdd}1 | grep "/dev/${hdd}1" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
|
||||
fi
|
||||
echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
|
||||
|
||||
# check if its another fullnode implementation data disk
|
||||
hddGotMigrationData="none"
|
||||
if [ "${hddFormat}" = "ext4" ]; then
|
||||
# check for umbrel
|
||||
isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json')
|
||||
if [ ${isUmbrelHDD} -gt 0 ]; then
|
||||
hddGotMigrationData="umbrel"
|
||||
fi
|
||||
isMyNodeHDD=$(sudo ls /mnt/storage/bitcoin/bitcoin.conf 2>/dev/null | grep -c '.conf')
|
||||
if [ ${isMyNodeHDD} -gt 0 ]; then
|
||||
hddGotMigrationData="mynode"
|
||||
fi
|
||||
else
|
||||
echo "# not an ext4 drive - all known fullnode packages use ext4 at the moment"
|
||||
fi
|
||||
echo "hddGotMigrationData='${hddGotMigrationData}'"
|
||||
|
||||
# unmount
|
||||
sudo umount /mnt/storage
|
||||
fi
|
||||
else
|
||||
# if not ext4 or btrfs - there is no usable data
|
||||
@ -299,6 +329,7 @@ if [ "$1" = "status" ]; then
|
||||
# EXT4 calculations
|
||||
hdd_used_space=$(df -h | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 3 2>/dev/null)
|
||||
hdd_used_ratio=$(df -h | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 5 | tr -dc '0-9' 2>/dev/null)
|
||||
hdd_data_free1Kblocks=$(df -h -k /dev/${hddDataPartitionExt4} | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
|
||||
hddUsedInfo="${hdd_used_space} (${hdd_used_ratio}%)"
|
||||
else
|
||||
# BRTS calculations
|
||||
@ -306,9 +337,11 @@ if [ "$1" = "status" ]; then
|
||||
# https://askubuntu.com/questions/170044/btrfs-and-missing-free-space
|
||||
datadrive=$(df -h | grep "/dev/${hdd}1" | sed -e's/ */ /g' | cut -d" " -f 5)
|
||||
storageDrive=$(df -h | grep "/dev/${hdd}2" | sed -e's/ */ /g' | cut -d" " -f 5)
|
||||
hdd_data_free1Kblocks=$(df -h -k /dev/${hdd}1 | grep "/dev/${hdd}1" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
|
||||
hddUsedInfo="${datadrive} & ${storageDrive}"
|
||||
fi
|
||||
echo "hddUsedInfo='${hddUsedInfo}'"
|
||||
echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
|
||||
|
||||
fi
|
||||
|
||||
@ -335,7 +368,7 @@ if [ "$1" = "status" ]; then
|
||||
# SupTronics 2.5" SATA HDD Shield X825 v1.5
|
||||
hddAdapterUSAP=1
|
||||
fi
|
||||
echo "hddAdapterUSAP='${hddAdapterUSAP}'"
|
||||
echo "hddAdapterUSAP=${hddAdapterUSAP}"
|
||||
fi
|
||||
|
||||
echo
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# managing the RaspiBlitz data - import, export, backup."
|
||||
echo "# blitz.migration.sh [status|export|import|export-gui|import-gui]"
|
||||
echo "# blitz.migration.sh [status|export|import|export-gui|import-gui|migration-umbrel|migration-mynode]"
|
||||
echo "error='missing parameters'"
|
||||
exit 1
|
||||
fi
|
||||
@ -48,6 +48,189 @@ if [ "$1" = "status" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
########################
|
||||
# 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
|
||||
|
||||
# keep old conf als backup
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
echo "raspiBlitzVersion='${codeVersion}'" >> /home/admin/raspiblitz.conf
|
||||
echo "network=bitcoin" >> /home/admin/raspiblitz.conf
|
||||
echo "chain=main" >> /home/admin/raspiblitz.conf
|
||||
echo "hostname=${nodename}" >> /home/admin/raspiblitz.conf
|
||||
echo "lcd2hdmi=on" >> /home/admin/raspiblitz.conf
|
||||
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
|
||||
echo "runBehindTor=on" >> /home/admin/raspiblitz.conf
|
||||
sudo mv /home/admin/raspiblitz.conf /mnt/hdd/raspiblitz.conf
|
||||
sudo chown root:root /mnt/hdd/raspiblitz.conf
|
||||
sudo chmod 777 /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# rename ext4 data drive
|
||||
sudo e2label /dev/sda1 BLOCKCHAIN
|
||||
}
|
||||
|
||||
########################
|
||||
# MIGRATION from Umbrel
|
||||
########################
|
||||
|
||||
if [ "$1" = "migration-umbrel" ]; then
|
||||
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
# can olny migrate unmonted data disks
|
||||
if [ "${isMounted}" == "1" ]; then
|
||||
echo "err='cannot migrate mounted drive'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if the HDD is an umbrel data disk
|
||||
if [ "${hddGotMigrationData}" == "umbrel" ]; then
|
||||
echo "# found UMBREL data disk at ${hddPartitionCandidate}"
|
||||
else
|
||||
echo "err='not an umbrel disk'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# temp mount the data drive
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
|
||||
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/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 .."
|
||||
|
||||
# extract data
|
||||
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}
|
||||
|
||||
echo "# OK ... data disk converted to RaspiBlitz - reboot with fresh sd card to recover"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
########################
|
||||
# MIGRATION from myNode
|
||||
########################
|
||||
|
||||
if [ "$1" = "migration-mynode" ]; then
|
||||
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
# can olny migrate unmonted data disks
|
||||
if [ "${isMounted}" == "1" ]; then
|
||||
echo "err='cannot migrate mounted drive'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if the HDD is an umbrel data disk
|
||||
if [ "${hddGotMigrationData}" == "mynode" ]; then
|
||||
echo "# found MYNODE data disk at ${hddPartitionCandidate}"
|
||||
else
|
||||
echo "err='not an mynode disk'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# temp mount the data drive
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
|
||||
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/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
|
||||
|
||||
# backup & rename the rest of the data
|
||||
sudo mv /mnt/hdd/mynode /mnt/hdd/backup_migration
|
||||
sudo rm
|
||||
|
||||
# call function for final migration
|
||||
migrate_raspiblitz_conf
|
||||
|
||||
echo "# OK ... data disk converted to RaspiBlitz"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#########################
|
||||
# EXPORT RaspiBlitz Data
|
||||
#########################
|
||||
|
Loading…
x
Reference in New Issue
Block a user