mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-20 21:28:54 +02:00
move and delete scripts
This commit is contained in:
@@ -100,7 +100,7 @@ while :
|
||||
# if LND is syncing or scanning
|
||||
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
|
||||
/home/admin/setup.scripts/scanInfoController.sh
|
||||
sleep 20
|
||||
continue
|
||||
fi
|
||||
|
@@ -33,6 +33,40 @@ if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# special state: copysource
|
||||
if [ "${state}" = "copysource" ]; then
|
||||
echo "***********************************************************"
|
||||
echo "INFO: You lost connection during copying the blockchain"
|
||||
echo "You have the following options:"
|
||||
echo "a) continue/check progress with command: sourcemode"
|
||||
echo "b) return to normal mode with command: restart"
|
||||
echo "***********************************************************"
|
||||
exit
|
||||
fi
|
||||
|
||||
# special state: copytarget
|
||||
source <(/home/admin/config.scripts/blitz.copyblockchain.sh status)
|
||||
if [ "${copyInProgress}" = "1" ]; then
|
||||
echo "Detected interrupted COPY blochain process ..."
|
||||
/home/admin/config.scripts/blitz.copychain.sh target
|
||||
exit
|
||||
fi
|
||||
|
||||
# special state: reindex was triggered
|
||||
if [ "${state}" = "reindex" ]; then
|
||||
echo "Re-Index in progress ... start monitoring:"
|
||||
/home/admin/config.scripts/network.reindex.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
# special state: copystation
|
||||
if [ "${state}" = "copystation" ]; then
|
||||
echo "Copy Station is Runnning ..."
|
||||
echo "reboot to return to normal"
|
||||
sudo /home/admin/XXcopyStation.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
# prepare status file
|
||||
# TODO: this is to be replaced and unified together with raspiblitz.info
|
||||
# when we move to a background monitoring thread & redis for WebUI with v1.8
|
||||
@@ -194,392 +228,4 @@ else
|
||||
fi
|
||||
echo "Back to menus use command: raspiblitz"
|
||||
echo
|
||||
exit 0
|
||||
|
||||
################# TODO: MOVE PARTS BELOW TO APROPIATE NEW PLACE
|
||||
|
||||
# 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
|
||||
echo "***********************************************************"
|
||||
echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
|
||||
echo "***********************************************************"
|
||||
exit
|
||||
fi
|
||||
|
||||
# load the data from the info file (will get produced on every startup)
|
||||
source ${infoFile}
|
||||
|
||||
if [ "${state}" = "recovering" ]; then
|
||||
echo "***********************************************************"
|
||||
echo "WARNING: bootstrap still updating - close SSH, login later"
|
||||
echo "To monitor progress --> tail -n1000 -f raspiblitz.log"
|
||||
echo "***********************************************************"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "${state}" = "copysource" ]; then
|
||||
echo "***********************************************************"
|
||||
echo "INFO: You lost connection during copying the blockchain"
|
||||
echo "You have the following options:"
|
||||
echo "a) continue/check progress with command: sourcemode"
|
||||
echo "b) return to normal mode with command: restart"
|
||||
echo "***********************************************************"
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if copy blockchain over LAN to this RaspiBlitz was running
|
||||
source <(/home/admin/config.scripts/blitz.copyblockchain.sh status)
|
||||
if [ "${copyInProgress}" = "1" ]; then
|
||||
echo "Detected interrupted COPY blochain process ..."
|
||||
/home/admin/50copyHDD.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
# signal that after bootstrap recover user dialog is needed
|
||||
recoveredInfoExists=$(sudo ls /home/admin/recover.flag 2>/dev/null | grep -c '.flag')
|
||||
if [ ${recoveredInfoExists} -gt 0 ]; then
|
||||
echo "System recovered - needs final user settings"
|
||||
/home/admin/20recoverDialog.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# signal that a reindex was triggered
|
||||
if [ "${state}" = "reindex" ]; then
|
||||
echo "Re-Index in progress ... start monitoring:"
|
||||
/home/admin/config.scripts/network.reindex.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# singal that copstation is running
|
||||
if [ "${state}" = "copystation" ]; then
|
||||
echo "Copy Station is Runnning ..."
|
||||
echo "reboot to return to normal"
|
||||
sudo /home/admin/XXcopyStation.sh
|
||||
exit
|
||||
fi
|
||||
|
||||
# if state=ready -> setup is done or started
|
||||
if [ "${state}" = "ready" ]; then
|
||||
configExists=$(ls ${configFile} | grep -c '.conf')
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
echo "loading config data"
|
||||
source ${configFile}
|
||||
else
|
||||
echo "setup still in progress - setupStep(${setupStep})"
|
||||
fi
|
||||
fi
|
||||
|
||||
## default menu settings
|
||||
# to fit the main menu without scrolling:
|
||||
HEIGHT=13
|
||||
WIDTH=64
|
||||
CHOICE_HEIGHT=6
|
||||
BACKTITLE="RaspiBlitz"
|
||||
TITLE=""
|
||||
MENU="Choose one of the following options:"
|
||||
OPTIONS=()
|
||||
|
||||
# check if RTL web interface is installed
|
||||
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
||||
|
||||
# function to use later
|
||||
waitUntilChainNetworkIsReady()
|
||||
{
|
||||
source ${configFile}
|
||||
echo "checking ${network}d - please wait .."
|
||||
echo "can take longer if device was off or first time"
|
||||
|
||||
# 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
|
||||
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})"
|
||||
echo "Missing Blockchain Data (<${minSize}) ..."
|
||||
clienterror="missing blockchain"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${#clienterror} -gt 0 ]; then
|
||||
#echo "clienterror(${clienterror})"
|
||||
|
||||
# analyse LOGS for possible reindex
|
||||
reindex=$(sudo cat /mnt/hdd/${network}/debug.log 2>/dev/null | grep -c 'Please restart with -reindex or -reindex-chainstate to recover')
|
||||
if [ ${reindex} -gt 0 ]; then
|
||||
# dismiss if its just a date thing
|
||||
futureBlock=$(sudo tail /mnt/hdd/${network}/debug.log 2>/dev/null | grep "Please restart with -reindex or -reindex-chainstate to recover" | grep -c "block database contains a block which appears to be from the future")
|
||||
if [ ${futureBlock} -gt 0 ]; then
|
||||
blockchainBroken=0
|
||||
echo "-> Ignore reindex - its just a future block"
|
||||
fi
|
||||
if [ ${isSyncing} -gt 0 ]; then
|
||||
reindex=0
|
||||
fi
|
||||
fi
|
||||
if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then
|
||||
|
||||
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 "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
|
||||
|
||||
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?
|
||||
" 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
|
||||
exit
|
||||
else
|
||||
# ignore - just delete blockchain logfile
|
||||
clear
|
||||
echo "***********************************************************"
|
||||
echo "CONTINUE SYNC blockchain ..."
|
||||
echo "***********************************************************"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# let 80scanLND script to the info to use
|
||||
/home/admin/80scanLND.sh
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "${network} error: ${clienterror}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
sleep 1
|
||||
else
|
||||
# check how many times LND was restarted
|
||||
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
|
||||
if [ ${startcountLightning} -lt 4 ]; then
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
echo "Starting up Wallet ... (10sec)"
|
||||
sleep 5
|
||||
sleep 5
|
||||
echo "please wait ... update to next screen can be slow"
|
||||
else
|
||||
/home/admin/80scanLND.sh lightning-error
|
||||
sudo rm /home/admin/systemd.lightning.log
|
||||
echo "(exit after too much restarts/unlocks - restart to try again)"
|
||||
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
|
||||
/home/admin/80scanLND.sh
|
||||
if [ $? -gt 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# everything is ready - return from loop
|
||||
return
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
if [ ${#setupStep} -eq 0 ]; then
|
||||
echo "WARN: no setup step found in raspiblitz.info"
|
||||
setupStep=0
|
||||
fi
|
||||
if [ ${setupStep} -eq 0 ]; then
|
||||
|
||||
|
||||
# start setup
|
||||
BACKTITLE="RaspiBlitz - Setup"
|
||||
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
|
||||
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
|
||||
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
|
||||
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" \
|
||||
MIGRATION "Upload a Migration File from old RaspiBlitz" )
|
||||
HEIGHT=12
|
||||
|
||||
elif [ ${setupStep} -lt 100 ]; then
|
||||
|
||||
# continue setup
|
||||
BACKTITLE="${hostname} / ${network} / ${chain}"
|
||||
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
|
||||
MENU="\nThe setup process is not finished yet: \n "
|
||||
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
|
||||
HEIGHT=10
|
||||
|
||||
else
|
||||
|
||||
# check if LND needs re-setup
|
||||
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
if [ "${wallet}" == "0" ] || [ "${macaroon}" == "0" ] || [ "${config}" == "0" ] || [ "${tls}" == "0" ]; then
|
||||
echo "WARN: LND needs re-setup"
|
||||
/home/admin/70initLND.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# wait all is synced and ready
|
||||
waitUntilChainNetworkIsReady
|
||||
|
||||
|
||||
|
||||
# check if DNS is working (if not it will trigger dialog)
|
||||
sudo /home/admin/config.scripts/internet.dns.sh test
|
||||
|
||||
#forward to main menu
|
||||
/home/admin/00mainMenu.sh
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "$BACKTITLE" \
|
||||
--title "$TITLE" \
|
||||
--menu "$MENU" \
|
||||
$HEIGHT $WIDTH $CHOICE_HEIGHT \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
|
||||
clear
|
||||
case $CHOICE in
|
||||
CLOSE)
|
||||
exit 1;
|
||||
;;
|
||||
BITCOIN)
|
||||
# set network info
|
||||
sed -i "s/^network=.*/network=bitcoin/g" ${infoFile}
|
||||
sed -i "s/^chain=.*/chain=main/g" ${infoFile}
|
||||
###### OPTIMIZE IF RAM >1GB
|
||||
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
|
||||
if [ ${kbSizeRAM} -gt 1500000 ]; then
|
||||
echo "Detected RAM >1GB --> optimizing ${network}.conf"
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /home/admin/assets/bitcoin.conf
|
||||
sudo sed -i "s/^maxmempool=.*/maxmempool=300/g" /home/admin/assets/bitcoin.conf
|
||||
fi
|
||||
/home/admin/10setupBlitz.sh
|
||||
exit 1;
|
||||
;;
|
||||
LITECOIN)
|
||||
/home/admin/config.scripts/blitz.litecoin.sh on
|
||||
/home/admin/10setupBlitz.sh
|
||||
exit 1;
|
||||
;;
|
||||
MANUAL)
|
||||
echo "************************************************************************************"
|
||||
echo "PLEASE go to RaspiBlitz FAQ:"
|
||||
echo "https://github.com/rootzoll/raspiblitz"
|
||||
echo "And check: How can I recover my coins from a failing RaspiBlitz?"
|
||||
echo "************************************************************************************"
|
||||
exit 0
|
||||
;;
|
||||
MIGRATION)
|
||||
sudo /home/admin/config.scripts/blitz.migration.sh "import-gui"
|
||||
# on error clean & repeat
|
||||
if [ "$?" = "1" ]; then
|
||||
echo
|
||||
echo "# clean and unmount for next try"
|
||||
sudo umount /mnt/hdd 2>/dev/null
|
||||
sudo umount /mnt/storage 2>/dev/null
|
||||
sudo umount /mnt/temp 2>/dev/null
|
||||
sleep 2
|
||||
/home/admin/00raspiblitz.sh
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
CONTINUE)
|
||||
/home/admin/10setupBlitz.sh
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
exit 0
|
@@ -1,267 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# CHECK WHAT IS ALREADY WORKING
|
||||
# check list from top down - so ./10setupBlitz.sh
|
||||
# and re-enters the setup process at the correct spot
|
||||
# in case it got interrupted
|
||||
echo "checking setup script"
|
||||
|
||||
# INFOFILE on SD - state data from bootstrap & setup
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
source ${infoFile}
|
||||
|
||||
echo "network(${network})"
|
||||
echo "chain(${chain})"
|
||||
echo "setupStep(${setupStep})"
|
||||
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "FAIL: Something is wrong. There is no value for network in ${infoFile}."
|
||||
echo "Should be at least default value. EXIT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if no setup step in info file init with 0
|
||||
if [ ${#setupStep} -eq 0 ];then
|
||||
echo "Init setupStep=0"
|
||||
echo "setupStep=0" >> ${infoFile}
|
||||
setupStep=0
|
||||
fi
|
||||
|
||||
# check if LND needs re-setup
|
||||
if [ ${setupStep} -gt 79 ];then
|
||||
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
if [ ${wallet} -eq 0 ] || [ ${macaroon} -eq 0 ] || [ ${config} -eq 0 ] || [ ${tls} -eq 0 ]; then
|
||||
echo "WARN: LND needs re-setup"
|
||||
sudo /home/admin/70initLND.sh
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# if setup if ready --> REBOOT
|
||||
if [ ${setupStep} -gt 89 ];then
|
||||
echo "FINISH by setupstep(${setupStep})"
|
||||
sleep 3
|
||||
sudo /home/admin/90finishSetup.sh
|
||||
sudo /home/admin/95finalSetup.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# check if lightning is running
|
||||
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
|
||||
if [ ${lndRunning} -eq 1 ]; then
|
||||
|
||||
echo "LND is running ..."
|
||||
sleep 1
|
||||
|
||||
# check if LND wallet exists and if locked
|
||||
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
|
||||
walletLocked=0
|
||||
# only when a wallet exists - it can be locked
|
||||
if [ ${walletExists} -eq 1 ];then
|
||||
echo "lnd wallet exists ... checking if locked"
|
||||
sleep 2
|
||||
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>&1 | grep -c unlock)
|
||||
fi
|
||||
if [ ${walletLocked} -gt 0 ]; then
|
||||
# LND wallet is locked
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
/home/admin/10setupBlitz.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# check if blockchain still syncing (during sync sometimes CLI returns with error at this point)
|
||||
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
|
||||
chainSyncing=1
|
||||
if [ ${#chainInfo} -gt 0 ];then
|
||||
echo "check chaininfo"
|
||||
chainSyncing=$(echo "${chainInfo}" | grep "true" -c)
|
||||
else
|
||||
echo "chaininfo is zero"
|
||||
fi
|
||||
if [ ${chainSyncing} -eq 1 ]; then
|
||||
echo "Sync Chain ..."
|
||||
sleep 3
|
||||
/home/admin/70initLND.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# check if lnd is scanning blockchain
|
||||
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | grep "synced_to_chain")
|
||||
lndSyncing=1
|
||||
if [ ${#lndInfo} -gt 0 ];then
|
||||
lndSyncing=$(echo "${chainInfo}" | grep "false" -c)
|
||||
fi
|
||||
if [ ${lndSyncing} -eq 1 ]; then
|
||||
echo "Sync LND ..."
|
||||
sleep 3
|
||||
/home/admin/70initLND.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup
|
||||
echo "FINSIH ... "
|
||||
sleep 3
|
||||
sudo /home/admin/90finishSetup.sh
|
||||
sudo /home/admin/95finalSetup.sh
|
||||
exit 0
|
||||
|
||||
fi #end - when lighting is running
|
||||
|
||||
# check if bitcoin is running
|
||||
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
|
||||
if [ ${bitcoinRunning} -eq 0 ]; then
|
||||
# double check
|
||||
seconds=120
|
||||
if [ ${setupStep} -lt 60 ]; then
|
||||
seconds=10
|
||||
fi
|
||||
dialog --pause " Double checking for ${network}d - please wait .." 8 58 ${seconds}
|
||||
clear
|
||||
bitcoinRunning=$(${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
|
||||
else
|
||||
echo "${network} is running"
|
||||
fi
|
||||
if [ ${bitcoinRunning} -eq 1 ]; then
|
||||
echo "OK - ${network}d is running"
|
||||
echo "Next step run Lightning"
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
else
|
||||
echo "${network} still not running"
|
||||
fi #end - when bitcoin is running
|
||||
|
||||
# --- so neither bitcoin or lnd or running yet --> find the earlier step in the setup process:
|
||||
|
||||
# use blitz.datadrive.sh to analyse HDD situation
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "# FAIL blitz.datadrive.sh status --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if HDD is auto-mounted
|
||||
if [ ${isMounted} -eq 1 ]; then
|
||||
|
||||
# FAILSAFE: check if raspiblitz.conf is available
|
||||
configExists=$(ls /mnt/hdd/raspiblitz.conf | grep -c '.conf')
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
echo ""
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "FAIL: /mnt/hdd/raspiblitz.conf should exists at this point, but not found!"
|
||||
echo "Please report to: https://github.com/rootzoll/raspiblitz/issues/293"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Press ENTER to EXIT."
|
||||
read key
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# are there any signs of blockchain data and activity
|
||||
# setup running with admin user, but has no permission to read /mnt/hdd/bitcoin/blocks/, sudo needed
|
||||
blockchainDataExists=$(sudo ls /mnt/hdd/${network}/blocks 2>/dev/null | grep -c '.dat')
|
||||
configExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c '.conf')
|
||||
|
||||
if [ ${blockchainDataExists} -gt 0 ]; then
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
/home/admin/XXdebugLogs.sh
|
||||
echo "UNKOWN STATE - there is blockain data config, but blockchain service is not running"
|
||||
echo "It seems that something went wrong during sync/download/copy of the blockchain."
|
||||
echo "Or something with the config is not correct."
|
||||
echo "Sometimes a reboot helps - use command: restart"
|
||||
echo "Or try to repair blockchain - use command: repair"
|
||||
exit 1
|
||||
else
|
||||
echo "Got mounted blockchain, but no config and running service yet --> finish HDD"
|
||||
/home/admin/60finishHDD.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# HDD is empty - get Blockchain
|
||||
|
||||
# detect hardware version of RaspberryPi
|
||||
# https://www.unixtutorial.org/command-to-confirm-raspberry-pi-model
|
||||
raspberryPi=$(cat /proc/device-tree/model | cut -d " " -f 3 | sed 's/[^0-9]*//g')
|
||||
if [ ${#raspberryPi} -eq 0 ]; then
|
||||
raspberryPi=0
|
||||
fi
|
||||
|
||||
# Bitcoin on older/weak RaspberryPi3 (LEGACY)
|
||||
if [ ${network} = "bitcoin" ] && [ ${raspberryPi} -eq 3 ]; then
|
||||
echo "Bitcoin-RP3 Options"
|
||||
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
|
||||
--menu "You need a copy of the Bitcoin Blockchain - choose method:" 13 75 5 \
|
||||
C "COPY --> Copy from laptop/node over LAN (±6hours)" \
|
||||
S "SYNC --> Selfvalidate all Blocks (VERY SLOW ±2month)" 2>&1 >/dev/tty)
|
||||
|
||||
# Bitcoin on stronger RaspberryPi4 (new DEFAULT)
|
||||
elif [ ${network} = "bitcoin" ]; then
|
||||
echo "Bitcoin-RP4 Options"
|
||||
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
|
||||
--menu "You need a copy of the Bitcoin Blockchain - choose method:" 13 75 5 \
|
||||
S "SYNC --> Selfvalidate all Blocks (DEFAULT ±2days)" \
|
||||
C "COPY --> Copy from laptop/node over LAN (±6hours)" 2>&1 >/dev/tty)
|
||||
|
||||
# Litecoin
|
||||
elif [ ${network} = "litecoin" ]; then
|
||||
echo "Litecoin Options"
|
||||
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
|
||||
--menu "You need a copy of the Litecoin Blockchain:" 13 75 4 \
|
||||
S "SYNC --> Selfvalidate all Blocks (±1day)" 2>&1 >/dev/tty)
|
||||
|
||||
# error
|
||||
else
|
||||
echo "FAIL Unkown network(${network})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=50/g" ${infoFile}
|
||||
|
||||
clear
|
||||
case $menuitem in
|
||||
C)
|
||||
/home/admin/50copyHDD.sh
|
||||
;;
|
||||
S)
|
||||
/home/admin/50syncHDD.sh
|
||||
/home/admin/10setupBlitz.sh
|
||||
;;
|
||||
*)
|
||||
echo "Use 'raspiblitz' command to return to setup ..."
|
||||
;;
|
||||
esac
|
||||
exit 1
|
||||
|
||||
fi # end HDD is already auto-mountes
|
||||
|
||||
|
||||
# --- the HDD is not auto-mounted --> very early stage of setup
|
||||
|
||||
# if the script is called for the first time
|
||||
if [ ${setupStep} -eq 0 ]; then
|
||||
# run initial user dialog
|
||||
/home/admin/20setupDialog.sh
|
||||
fi
|
||||
|
||||
# if the script is called for the first time
|
||||
if [ ${setupStep} -eq 20 ]; then
|
||||
# run initial user dialog
|
||||
/home/admin/30initHDD.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# the HDD is already ext4 formated and cointains blockchain data
|
||||
if [ "${hddFormat}" = "ext4" ] || [ "${hddFormat}" = "btrfs" ]; then
|
||||
if [ ${hddGotBlockchain} -eq 1 ]; then
|
||||
echo "HDD was already initialized/prepared"
|
||||
echo "Now needs to be mounted"
|
||||
/home/admin/40addHDD.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# the HDD had no init yet
|
||||
echo "init HDD ..."
|
||||
/home/admin/30initHDD.sh
|
||||
exit 1
|
@@ -1,127 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# show password info dialog
|
||||
resetAlsoPasswordB=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null | grep -c "rpcpassword=passwordB")
|
||||
resetAlsoPasswordC=$(sudo ls /mnt/hdd/passwordc.flag 2>/dev/null | grep -c ".flag")
|
||||
|
||||
if [ ${resetAlsoPasswordC} -gt 0 ]; then
|
||||
|
||||
# password A + B + C
|
||||
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
|
||||
|
||||
You need to set a new Password A, B & C:
|
||||
A) Main User Password (SSH, WebUI, ..)
|
||||
B) RPC & APP Password (Additional Apps, ..)
|
||||
C) Lightning Wallet Unlock Password
|
||||
|
||||
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
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
|
||||
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh b
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
|
||||
|
||||
oldPasswordC=$(sudo cat /mnt/hdd/passwordc.flag)
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh c $oldPasswordC
|
||||
if [ "$?" != "0" ]; then
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "Please write down your Password C:\n${oldPasswordC}" 10 52
|
||||
else
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password C was set\nuse it to unlock your Lightning Wallet after restarts." 8 52
|
||||
fi
|
||||
|
||||
elif [ ${resetAlsoPasswordB} -gt 0 ]; then
|
||||
|
||||
# password A + B
|
||||
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
|
||||
|
||||
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
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
|
||||
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh b
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
|
||||
|
||||
else
|
||||
|
||||
# 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 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
|
||||
|
||||
# sucess info dialog
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
|
||||
|
||||
fi
|
||||
|
||||
# activate lnd & bitcoin service
|
||||
echo "Enabling Services"
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable lnd.service
|
||||
sudo systemctl enable ${network}d.service
|
||||
if [ "${rtlWebinterface}" = "on" ]; then
|
||||
sudo systemctl enable RTL
|
||||
fi
|
||||
if [ "${loop}" = "on" ]; then
|
||||
sudo systemctl enable loopd
|
||||
fi
|
||||
if [ "${BTCRPCexplorer}" = "on" ]; then
|
||||
sudo systemctl enable btc-rpc-explorer
|
||||
fi
|
||||
if [ "${ElectRS}" = "on" ]; then
|
||||
sudo systemctl enable electrs
|
||||
fi
|
||||
|
||||
# remove flag that freshly recovered
|
||||
sudo rm /home/admin/recover.flag
|
||||
|
||||
# when auto-unlock is activated then Password C is needed to be restored on SD card
|
||||
if [ "${autoUnlock}" = "on" ]; then
|
||||
|
||||
# reset auto-unlock feature
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "You had the Auto-Unlock feature enabled.
|
||||
|
||||
In the next dialog you need to re-enter your
|
||||
ACTUAL/OLD Password C to re-activate the
|
||||
Auto-Unlock feature. Enter a empty password
|
||||
to deactivate the Auto-Unlock feature.
|
||||
" 10 52
|
||||
echo "Activating Auto-Unlock (please wait) .."
|
||||
sudo /home/admin/config.scripts/lnd.autounlock.sh on
|
||||
dialog --backtitle "RaspiBlitz" --pause " FINAL REBOOT IS NEEDED." 8 52 5
|
||||
|
||||
else
|
||||
dialog --backtitle "RaspiBlitz" --pause " OK - Passwords set.\n FINAL REBOOT IS NEEDED." 9 52 5
|
||||
fi
|
||||
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
@@ -1,90 +0,0 @@
|
||||
#!/bin/bash
|
||||
_temp=$(mktemp -p /dev/shm/)
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info 2>/dev/null
|
||||
|
||||
###################
|
||||
# CHECK IF DNS NEEDS SETTING DURING SETUP
|
||||
# https://github.com/rootzoll/raspiblitz/issues/787
|
||||
###################
|
||||
sudo /home/admin/config.scripts/internet.dns.sh test
|
||||
|
||||
###################
|
||||
# ENTER NAME
|
||||
###################
|
||||
|
||||
# welcome and ask for name of RaspiBlitz
|
||||
result=""
|
||||
while [ ${#result} -eq 0 ]
|
||||
do
|
||||
l1="Please enter the name of your new RaspiBlitz:\n"
|
||||
l2="one word, keep characters basic & not too long"
|
||||
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2" 11 52 2>$_temp
|
||||
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
|
||||
shred -u $_temp
|
||||
echo "processing ..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
# set lightning alias
|
||||
sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
|
||||
|
||||
# store hostname for later - to be set right before the next reboot
|
||||
# work around - because without a reboot the hostname seems not updates in the whole system
|
||||
valueExistsInInfoFile=$(sudo cat /home/admin/raspiblitz.info | grep -c "hostname=")
|
||||
if [ ${valueExistsInInfoFile} -eq 0 ]; then
|
||||
# add
|
||||
echo "hostname=${result}" >> /home/admin/raspiblitz.info
|
||||
else
|
||||
# update
|
||||
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
|
||||
fi
|
||||
|
||||
###################
|
||||
# ENTER PASSWORDS
|
||||
###################
|
||||
|
||||
# show password info dialog
|
||||
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "RaspiBlitz uses 4 different passwords.
|
||||
Referenced as password A, B, C and D.
|
||||
|
||||
A) Master User Password
|
||||
B) Blockchain RPC Password
|
||||
C) LND Wallet Password
|
||||
D) LND Seed Password
|
||||
|
||||
Choose now 4 new passwords - all min 8 chars,
|
||||
no spaces and only special characters - or .
|
||||
Write them down & store them in a safe place.
|
||||
" 15 52
|
||||
|
||||
# call set password a script
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh a
|
||||
|
||||
# sucess info dialog
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
|
||||
|
||||
# call set password b script
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh b
|
||||
|
||||
# success info dialog
|
||||
dialog --backtitle "RaspiBlitz" --msgbox "OK - RPC password changed \n\nNow starting the Setup of your RaspiBlitz." 7 52
|
||||
|
||||
###################
|
||||
# TOR BY DEFAULT
|
||||
# https://github.com/rootzoll/raspiblitz/issues/592
|
||||
#
|
||||
###################
|
||||
echo "runBehindTor=on" >> /home/admin/raspiblitz.info
|
||||
#whiptail --title ' Privacy Level - How do you want to run your node? ' --yes-button='Public IP' --no-button='TOR NETWORK' --yesno "Running your Lightning node with your Public IP is common and faster, but might reveal your personal identity and location.\n
|
||||
#You can better protect your privacy with running your lightning node as a TOR Hidden Service from the start, but it can make it harder to connect with other non-TOR nodes and remote mobile apps later on.
|
||||
# " 12 75
|
||||
#if [ $? -eq 1 ]; then
|
||||
# echo "runBehindTor=on" >> /home/admin/raspiblitz.info
|
||||
#fi
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=20/g" /home/admin/raspiblitz.info
|
||||
|
||||
clear
|
@@ -1,138 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - its now done in bootstrap and setupcontroller
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
clear
|
||||
echo ""
|
||||
echo "# *** 30initHDD.sh ***"
|
||||
echo
|
||||
echo "# --> Checking HDD/SSD status..."
|
||||
|
||||
# use blitz.datadrive.sh to analyse HDD situation
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "# FAIL blitz.datadrive.sh status --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if HDD is mounted (secure against formatting a mounted disk with data)
|
||||
echo "isMounted=${isMounted}"
|
||||
if [ ${isMounted} -eq 1 ]; then
|
||||
echo "# FAIL HDD/SSD is mounted - please unmount and call ./30initHDD.sh again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if HDD contains old RaspiBlitz data (secure against wrongly formatting)
|
||||
echo "hddRaspiData=${hddRaspiData}"
|
||||
if [ ${hddRaspiData} -eq 1 ]; then
|
||||
echo "# FAIL HDD/SSD contains old data - please delete manual and call ./30initHDD.sh again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if there is a HDD connectecd to use as data drive
|
||||
echo "hddCandidate=${hddCandidate}"
|
||||
if [ ${#hddCandidate} -eq 0 ]; then
|
||||
echo "# FAIL please connect a HDD and call ./30initHDD.sh again"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK"
|
||||
|
||||
# check minimal size of data drive needed
|
||||
echo
|
||||
echo "# --> Check HDD/SSD for Size ..."
|
||||
# bitcoin: 400 GB
|
||||
# litecoin: 120 GB
|
||||
minSize=400
|
||||
if [ "${network}" = "litecoin" ]; then
|
||||
minSize=120
|
||||
fi
|
||||
if [ ${hddGigaBytes} -lt ${minSize} ]; then
|
||||
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "# WARNING: HDD is too small"
|
||||
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo ""
|
||||
echo "# HDD was detected with the size of ${hddGigaBytes} GB"
|
||||
echo "# For ${network} at least ${minSize} GB is needed"
|
||||
echo ""
|
||||
echo "# If you want to change to a bigger HDD:"
|
||||
echo "# * Unplug power of RaspiBlitz"
|
||||
echo "# * Make a fresh SD card again"
|
||||
echo "# * Start again with bigger HDD"
|
||||
exit 1
|
||||
fi
|
||||
echo " OK"
|
||||
|
||||
# format drive if it does not have any blockchain or blitz data on it
|
||||
# to be sure that HDD has no faulty partions, etc.
|
||||
echo
|
||||
echo "# --> Check HDD/SSD for Blockchain ..."
|
||||
echo "# hddGotBlockchain=${hddGotBlockchain}"
|
||||
raidSizeGB=$(echo "${raidCandidate[0]}" | cut -d " " -f 2)
|
||||
echo "# raidCandidates=${raidCandidates}"
|
||||
echo "# raidSizeGB=${raidSizeGB}"
|
||||
if [ "${hddGotBlockchain}" == "" ] || [ ${hddGotBlockchain} -eq 0 ]; then
|
||||
|
||||
format="ext4"
|
||||
|
||||
# test feature: if there is a USB stick as a raid connected, then format in BTRFS an not in EXT4
|
||||
if [ ${raidCandidates} -eq 1 ] && [ ${raidSizeGB} -gt 14 ]; then
|
||||
|
||||
echo
|
||||
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "# EXPERIMENTAL FEATURE: BTRFS + RAID"
|
||||
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "# You connected an extra USB thumb drive to your RaspiBlitz."
|
||||
echo "# This activates the exterimental feature of running BTRFS"
|
||||
echo "# instead of EXT4 and is still unstable but needs testing."
|
||||
echo "# PRESS ENTER to continue with BTRFS+RAID setup or press"
|
||||
echo "# CTRL+C, remove device & call ./30initHDD.sh again."
|
||||
read key
|
||||
format="btrfs"
|
||||
|
||||
# check that raid cadidate is big enough
|
||||
# a 32GB drive gets shown with 28GB in mby tests
|
||||
if [ ${raidSizeGB} -lt 27 ]; then
|
||||
echo "# FAIL the raid device needs to be at least a 32GB thumb drive."
|
||||
echo "# Please remove or replace and call ./30initHDD.sh again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [ ${raidCandidates} -gt 1 ]; then
|
||||
echo "# FAIL more then one USB raid drive candidate connected."
|
||||
echo "# Please max one extra usb drive and the call ./30initHDD.sh again"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# now partition/format HDD
|
||||
echo
|
||||
if (whiptail --title "FORMAT HDD/SSD" --yesno "The connected hard drive needs to get formatted.\nIMPORTANT: This will delete all data on that drive." 8 56); then
|
||||
clear
|
||||
echo "# --> Formatting HDD/SSD ..."
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${format} ${hddCandidate})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "# FAIL blitz.datadrive.sh format --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
clear
|
||||
echo "# Not formatting the HDD/SSD - Setup Process stopped."
|
||||
echo "# Rearrange your hardware and restart with a fresh sd card again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
echo "# OK"
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info
|
||||
|
||||
# automatically now add the HDD to the system
|
||||
./40addHDD.sh
|
||||
|
||||
|
@@ -1,168 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh or _provision_.sh
|
||||
# ---> the experimental "adding RAID drive" section for BRTFS gets dropped here
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
echo ""
|
||||
echo "# *** 40addHDD.sh ***"
|
||||
|
||||
# use blitz.datadrive.sh to analyse HDD situation
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh status --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# temp mount
|
||||
if [ "$hddFormat" == "btrfs" ]; then
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddCandidate})
|
||||
else
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
|
||||
fi
|
||||
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh tempmount --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# linking drives/directories
|
||||
echo
|
||||
echo "# --> Linking drives/directories"
|
||||
echo "# hddCandidate='${hddCandidate}'"
|
||||
echo "# hddPartitionCandidate='${hddPartitionCandidate}'"
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh link)
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh link --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# adding drives to fstab for permanent mount
|
||||
echo
|
||||
echo "# --> Adding the data drive to OS ..."
|
||||
echo "# hddCandidate='${hddCandidate}'"
|
||||
echo "# hddPartitionCandidate='${hddPartitionCandidate}'"
|
||||
echo "# hddFormat='${hddFormat}'"
|
||||
if [ "$hddFormat" == "btrfs" ]; then
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddCandidate})
|
||||
else
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddPartitionCandidate})
|
||||
fi
|
||||
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL blitz.datadrive.sh fstab --> ${error}"
|
||||
echo "Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# adding RAID drive
|
||||
echo "# isBTRFS=${isBTRFS}"
|
||||
echo "# raidCandidates=${raidCandidates}"
|
||||
if [ ${isBTRFS} -eq 1 ] && [ ${raidCandidates} -eq 1 ]; then
|
||||
|
||||
# example string: 'sdb 28 GB SanDisk'
|
||||
raidDevice=$(echo "${raidCandidate[0]}" | cut -d " " -f 1)
|
||||
raidSizeGB=$(echo "${raidCandidate[0]}" | cut -d " " -f 2)
|
||||
|
||||
echo
|
||||
echo "# --> Adding Raid Drive ..."
|
||||
echo "# raidDevice='${raidDevice}'"
|
||||
echo "# raidSizeGB=${raidSizeGB}"
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh raid on ${raidDevice})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "# FAIL blitz.datadrive.sh raid on --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# init the RASPIBLITZ Config
|
||||
echo
|
||||
echo "# --> Init raspiblitz.conf ..."
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf')
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
|
||||
# config exists - nothing much to do
|
||||
echo "# config file already exists on HDD/SSD"
|
||||
sudo chmod 777 ${configFile}
|
||||
|
||||
else
|
||||
|
||||
# create file and use init values from raspiblitz.info
|
||||
echo "# CREATING new ${configFile}"
|
||||
source /home/admin/_version.info
|
||||
echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf
|
||||
echo "raspiBlitzVersion='${codeVersion}'" >> /home/admin/raspiblitz.conf
|
||||
echo "network=${network}" >> /home/admin/raspiblitz.conf
|
||||
echo "chain=${chain}" >> /home/admin/raspiblitz.conf
|
||||
echo "hostname=${hostname}" >> /home/admin/raspiblitz.conf
|
||||
echo "displayClass=${displayClass}" >> /home/admin/raspiblitz.conf
|
||||
echo "displayType=${displayType}" >> /home/admin/raspiblitz.conf
|
||||
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
|
||||
|
||||
sudo mv /home/admin/raspiblitz.conf $configFile
|
||||
sudo chown root:root ${configFile}
|
||||
sudo chmod 777 ${configFile}
|
||||
sleep 3
|
||||
|
||||
# try to determine publicIP and make sure its in raspiblitz.conf
|
||||
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
|
||||
/home/admin/config.scripts/internet.sh update-publicip
|
||||
|
||||
fi
|
||||
|
||||
# link ssh directory from SD card to HDD
|
||||
echo "# --> SSH key settings"
|
||||
echo "# copying SSH pub keys to HDD"
|
||||
sudo cp -r /etc/ssh /mnt/hdd/ssh
|
||||
# just copy dont link anymore
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/1798
|
||||
#sudo rm -rf /etc/ssh
|
||||
#sudo ln -s /mnt/hdd/ssh /etc/ssh
|
||||
#sudo /home/admin/config.scripts/blitz.systemd.sh update-sshd
|
||||
echo "# OK"
|
||||
echo ""
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
|
||||
|
||||
# check if HDD contains a blockchain to work with
|
||||
echo "hddGotBlockchain=${hddGotBlockchain}"
|
||||
if [ ${hddGotBlockchain} -eq 1 ]; then
|
||||
|
||||
echo "# Looks like the HDD is prepared with the Blockchain."
|
||||
|
||||
# ask user if prepared blockchain is to use or self-validate
|
||||
whiptail --title ' Use Blockchain from HDD/SSD? ' --yes-button='Continue' --no-button='DELETE' --yesno "
|
||||
On the HDD/SSD Blockchain data was found.\n
|
||||
Continue if you trust that data to be valid.\n
|
||||
If you dont trust that data you can now choose to delete it - but keep in mind that this can add multiple days of waiting time to your setup process to regain or self-validate the initial blockchain data.
|
||||
" 14 75
|
||||
if [ $? -eq 1 ]; then
|
||||
# DELETE
|
||||
echo "# Deleting old blockchain data .."
|
||||
sudo rm -R /mnt/hdd/bitcoin 2>/dev/null
|
||||
sudo rm -R /mnt/hdd/litecoin 2>/dev/null
|
||||
# HDD is now empty - let setupBlitz - display next options
|
||||
echo "# HDD now empty --> follow further setup"
|
||||
./10setupBlitz.sh
|
||||
else
|
||||
# CONTINUE
|
||||
echo "# Continuing with finishing the system setup ..."
|
||||
./60finishHDD.sh
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# HDD is empty - let setupBlitz - display next options
|
||||
echo "# HDD empty --> follow further setup"
|
||||
./10setupBlitz.sh
|
||||
|
||||
fi
|
@@ -1,256 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
# get local ip
|
||||
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
|
||||
# Basic Options
|
||||
OPTIONS=(WINDOWS "Windows" \
|
||||
MACOS "Apple MacOSX" \
|
||||
LINUX "Linux" \
|
||||
BLITZ "RaspiBlitz"
|
||||
)
|
||||
|
||||
CHOICE=$(dialog --clear --title " Copy Blockchain from another laptop/node over LAN " --menu "\nWhich system is running on the other laptop/node you want to copy the blockchain from?\n " 14 60 9 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
clear
|
||||
case $CHOICE in
|
||||
MACOS) echo "Steve";;
|
||||
LINUX) echo "Linus";;
|
||||
WINDOWS) echo "Bill";;
|
||||
BLITZ) echo "Satoshi";;
|
||||
*) exit 1;;
|
||||
esac
|
||||
|
||||
# additional prep if this is used to replace corrupted blockchain
|
||||
if [ "${setupStep}" = "100" ]; then
|
||||
# make sure services are not running
|
||||
echo "stopping services ..."
|
||||
sudo systemctl stop background
|
||||
sudo systemctl stop lnd
|
||||
sudo systemctl stop bitcoind
|
||||
sudo cp -f /mnt/hdd/bitcoin/bitcoin.conf /home/admin/assets/bitcoin.conf
|
||||
else
|
||||
# make sure bitcoind is not running
|
||||
sudo systemctl stop background <2 /dev/null
|
||||
sudo systemctl stop bitcoind <2 /dev/null
|
||||
fi
|
||||
|
||||
# check if old blockchain data exists
|
||||
hasOldBlockchainData=0
|
||||
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
|
||||
if [ ${hasOldBlockchainData} -eq 1 ] && [ "$1" != "stop-after-script" ]; then
|
||||
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
if [ "${response}" = "1" ]; then
|
||||
echo "OK - keep old blockchain - just try to repair by copying over it"
|
||||
sleep 3
|
||||
else
|
||||
echo "OK - delete old blockchain"
|
||||
sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null
|
||||
sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# make sure /mnt/hdd/bitcoin exists
|
||||
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
|
||||
|
||||
# allow all users write to it
|
||||
sudo chmod 777 /mnt/hdd/bitcoin
|
||||
|
||||
echo
|
||||
clear
|
||||
if [ "${CHOICE}" = "WINDOWS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a WINDOWS computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR WINDOWS COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Windows computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Windows computer & change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Windows thats: C:\Users\YourUserName\Appdata\Roaming\Bitcoin"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:"
|
||||
echo "scp -r ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "If asked for a password use PASSWORD A (or 'raspiblitz')."
|
||||
fi
|
||||
if [ "${CHOICE}" = "MACOS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a MacOSX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR MacOSX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your MacOSX computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your MacOSX computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on MacOSX thats: cd ~/Library/Application Support/Bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your MacOSX terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your MacOSX"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "LINUX" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a LINUX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR LINUX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Linux computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Linux computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Linux thats: cd ~/.bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Linux terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your Linux"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "BLITZ" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another RaspiBlitz"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "The other RaspiBlitz needs a minimum version of 1.6 (if lower, update first)."
|
||||
echo "Make sure that the other RaspiBlitz is on the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal and login per SSH into that other RaspiBlitz."
|
||||
echo "Once in the main menu go: MAINMENU > REPAIR > COPY-SOURCE"
|
||||
echo "Follow the given instructions ..."
|
||||
echo ""
|
||||
echo "The LOCAL IP of this target RaspiBlitz is: ${localip}"
|
||||
fi
|
||||
echo ""
|
||||
echo "It can take multiple hours until transfer is complete - be patient."
|
||||
echo "****************************************************************************"
|
||||
echo "PRESS ENTER if transfers is done OR if you want to choose another option."
|
||||
sleep 2
|
||||
read key
|
||||
|
||||
# make quick check if data is there
|
||||
anyDataAtAll=0
|
||||
quickCheckOK=1
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.dat -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/blocks"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 300 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 300 .dat files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.ldb -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/chainstate"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 700 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 700 .ldb files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
|
||||
echo "*********************************************"
|
||||
echo "QUICK CHECK RESULT"
|
||||
echo "*********************************************"
|
||||
|
||||
# just if any data transferred ..
|
||||
if [ ${anyDataAtAll} -eq 1 ]; then
|
||||
|
||||
# data was invalid - ask user to keep?
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
|
||||
echo "FAIL -> DATA seems incomplete."
|
||||
|
||||
else
|
||||
|
||||
echo "OK -> DATA LOOKS GOOD :D"
|
||||
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
echo "CANCEL -> NO DATA was copied."
|
||||
quickCheckOK=0
|
||||
|
||||
fi
|
||||
echo "*********************************************"
|
||||
|
||||
# if started with parameter "stop-after-script" - quit here
|
||||
if [ "$1" == "stop-after-script" ]; then
|
||||
echo "DONE Copy"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# if started after intial setup - quit here
|
||||
if [ "${setupStep}" = "100" ]; then
|
||||
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
|
||||
sudo systemctl enable bitcoind
|
||||
echo "DONE - rebooting: sudo shutdown -r now"
|
||||
sudo shutdown -r now
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# REACT ON QUICK CHECK DURING INITAL SETUP
|
||||
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
|
||||
echo "*********************************************"
|
||||
echo "There seems to be an invalid transfer."
|
||||
|
||||
echo "Wait 5 secs ..."
|
||||
sleep 5
|
||||
|
||||
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
if [ "${response}" == "0" ]; then
|
||||
/home/admin/50copyHDD.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data?" 8 60
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
case $response in
|
||||
1) quickCheckOK=1 ;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo "Deleting invalid Data ... "
|
||||
sudo rm -rf /mnt/hdd/bitcoin
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
# setup script will decide the next logical step
|
||||
/home/admin/10setupBlitz.sh
|
@@ -1,101 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh
|
||||
# --- BUT check how its used in repair script
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
# only show warning when bitcoin
|
||||
if [ "$network" = "bitcoin" ]; then
|
||||
|
||||
# detect hardware version of RaspberryPi
|
||||
# https://www.unixtutorial.org/command-to-confirm-raspberry-pi-model
|
||||
raspberryPi=$(cat /proc/device-tree/model | cut -d " " -f 3 | sed 's/[^0-9]*//g')
|
||||
if [ ${#raspberryPi} -eq 0 ]; then
|
||||
raspberryPi=0
|
||||
fi
|
||||
echo "RaspberryPi Model Version: ${raspberryPi}"
|
||||
if [ ${raspberryPi} -lt 4 ]; then
|
||||
# raspberryPi 3 and lower
|
||||
msg=" This old RaspberryPi has very limited CPU power.\n"
|
||||
msg="$msg To sync & validate the complete blockchain\n"
|
||||
msg="$msg can take multiple days - even weeks\n"
|
||||
msg="$msg Its recommended to use another option.\n"
|
||||
msg="$msg \n"
|
||||
msg="$msg So do you really want start syncing now?"
|
||||
dialog --title " WARNING " --yesno "${msg}" 11 57
|
||||
response=$?
|
||||
case $response in
|
||||
0) echo "--> OK";;
|
||||
1) exit 1;;
|
||||
255) exit 1;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
# ask if really sync behind TOR
|
||||
# if [ "${runBehindTor}" = "on" ]; then
|
||||
# whiptail --title ' Sync Blockchain from behind TOR? ' --yes-button='Public-Sync' --no-button='TOR-Sync' --yesno "You decided to run your node behind TOR and validate the blockchain with your RaspiBlitz - thats good. But downloading the complete blockchain thru TOR can add some extra time (maybe a day) to the process and adds a heavy load on the TOR network.\n
|
||||
#Your RaspiBlitz can just run the initial blockchain download with your public IP (Public-Sync) but keep your Lighting node safe behind TOR.
|
||||
#It would speed up the self-validation while not revealing your Lightning node identity. But for most privacy choose (TOR-Sync).
|
||||
# " 15 76
|
||||
# if [ $? -eq 0 ]; then
|
||||
# # set flag to not run bitcoin behind TOR during IDB
|
||||
# echo "ibdBehindTor=off" >> /home/admin/raspiblitz.info
|
||||
# fi
|
||||
#fi
|
||||
|
||||
echo "**********************************"
|
||||
echo "Dont Trust, verify - starting sync"
|
||||
echo "**********************************"
|
||||
echo ""
|
||||
sleep 3
|
||||
|
||||
|
||||
echo "*** Optimizing RAM for Sync ***"
|
||||
|
||||
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
|
||||
echo "dont forget to reduce dbcache once IBD is done" > "/home/admin/selfsync.flag"
|
||||
# RP4 4GB
|
||||
if [ ${kbSizeRAM} -gt 3500000 ]; then
|
||||
echo "Detected RAM >=4GB --> optimizing ${network}.conf"
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=3072/g" /home/admin/assets/${network}.conf
|
||||
# RP4 2GB
|
||||
elif [ ${kbSizeRAM} -gt 1500000 ]; then
|
||||
echo "Detected RAM >=2GB --> optimizing ${network}.conf"
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=1536/g" /home/admin/assets/${network}.conf
|
||||
# RP3/4 1GB
|
||||
else
|
||||
echo "Detected RAM <=1GB --> optimizing ${network}.conf"
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /home/admin/assets/${network}.conf
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "*** Activating Blockain Sync ***"
|
||||
|
||||
sudo mkdir /mnt/hdd/${network} 2>/dev/null
|
||||
sudo /home/admin/XXcleanHDD.sh -blockchain -force
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/blocks 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/chainstate 2>/dev/null
|
||||
|
||||
# set so that 10raspiblitz.sh has a flag to see that resync is running
|
||||
sudo touch /mnt/hdd/${network}/blocks/.selfsync
|
||||
sudo sed -i "s/^state=.*/state=sync/g" /home/admin/raspiblitz.info
|
||||
|
||||
echo "OK - sync is activated"
|
||||
|
||||
if [ "${setupStep}" = "100" ]; then
|
||||
|
||||
# start servives
|
||||
echo "reboot needed: shutdown -r now"
|
||||
|
||||
else
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=50/g" /home/admin/raspiblitz.info
|
||||
|
||||
# continue setup
|
||||
./60finishHDD.sh
|
||||
|
||||
fi
|
@@ -1,91 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
echo ""
|
||||
echo "*** 60finishHDD.sh ***"
|
||||
|
||||
# use blitz.datadrive.sh to analyse HDD situation
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "# FAIL blitz.datadrive.sh status --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check that data drive is mounted
|
||||
if [ ${isMounted} -eq 0 ]; then
|
||||
echo "# FAIL - HDD is not mounted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###### COPY BASIC NETWORK CONFIG
|
||||
|
||||
echo ""
|
||||
echo "*** Prepare ${network} ***"
|
||||
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
|
||||
sudo mkdir /home/admin/.${network} 2>/dev/null
|
||||
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
|
||||
|
||||
# make sure all files are linked correct
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh link
|
||||
|
||||
# BLITZ WEB SERVICE
|
||||
/home/admin/config.scripts/blitz.web.sh on
|
||||
|
||||
###### ACTIVATE TOR IF SET DURING SETUP
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
|
||||
echo "runBehindTor --> ON"
|
||||
sudo /home/admin/config.scripts/internet.tor.sh on
|
||||
|
||||
# but if IBD is allowed to be public switch off TOR just fro bitcoin
|
||||
# until IBD is done. background service will after that switch TOR on
|
||||
if [ "${ibdBehindTor}" = "off" ]; then
|
||||
echo "ibdBehindTor --> OFF"
|
||||
sudo /home/admin/config.scripts/internet.tor.sh btcconf-off
|
||||
else
|
||||
echo "ibdBehindTor --> ON"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "runBehindTor --> OFF"
|
||||
fi
|
||||
|
||||
###### START NETWORK SERVICE
|
||||
echo ""
|
||||
echo "*** Start ${network} ***"
|
||||
echo "- This can take a while .."
|
||||
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
|
||||
#sudo chmod +x /etc/systemd/system/${network}d.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ${network}d.service
|
||||
sudo systemctl start ${network}d.service
|
||||
|
||||
# check if bitcoin has started
|
||||
bitcoinRunning=0
|
||||
loopcount=0
|
||||
while [ ${bitcoinRunning} -eq 0 ]
|
||||
do
|
||||
>&2 echo "# (${loopcount}/200) checking if ${network}d is running ... "
|
||||
bitcoinRunning=$(${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
|
||||
sleep 2
|
||||
sync
|
||||
loopcount=$(($loopcount +1))
|
||||
if [ ${loopcount} -gt 200 ]; then
|
||||
/home/admin/XXdebugLogs.sh
|
||||
echo "***********************************"
|
||||
echo "FAIL: ${network} failed to start :("
|
||||
echo "Get support or try again the command: raspiblitz"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info
|
||||
|
||||
./10setupBlitz.sh
|
@@ -1,481 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh and setup dialogs
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
echo ""
|
||||
echo "*** 70initLND.sh ***"
|
||||
|
||||
# CHECK #########
|
||||
|
||||
echo "*** Check Basic Config ***"
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "FAIL - missing: network"
|
||||
exit 1
|
||||
fi
|
||||
if [ ${#chain} -eq 0 ]; then
|
||||
echo "FAIL - missing: chain"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHECK #########
|
||||
|
||||
echo "*** Check ${network} Running ***"
|
||||
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
|
||||
if [ ${bitcoinRunning} -eq 0 ]; then
|
||||
bitcoinRunning=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | grep -c verificationprogress)
|
||||
fi
|
||||
if [ ${bitcoinRunning} -eq 0 ]; then
|
||||
whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "Service ${network}d is not running." 8 50
|
||||
if [ $? -eq 0 ]; then
|
||||
/home/admin/70initLND.sh
|
||||
else
|
||||
/home/admin/XXdebugLogs.sh
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CHECK #########
|
||||
|
||||
echo "*** Check ${network} Responding *** (can take a while)"
|
||||
chainIsReady=0
|
||||
loopCount=0
|
||||
while [ ${chainIsReady} -eq 0 ]
|
||||
do
|
||||
loopCount=$(($loopCount +1))
|
||||
result=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>error.out)
|
||||
error=$(cat error.out)
|
||||
rm error.out
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
if [ ${loopCount} -gt 33 ]; then
|
||||
echo "*** TAKES LONGER THEN EXCEPTED ***"
|
||||
date +%s
|
||||
echo "result(${result})"
|
||||
echo "error(${error})"
|
||||
testnetAdd=""
|
||||
if [ "${chain}" = "test" ]; then
|
||||
testnetAdd="testnet3/"
|
||||
fi
|
||||
sudo tail -n 5 /mnt/hdd/${network}/${testnetAdd}debug.log
|
||||
echo "If you see an error -28 relax, just give it some time."
|
||||
echo "Waiting 1 minute and then trying again ..."
|
||||
sleep 60
|
||||
else
|
||||
echo "(${loopCount}/33) still waiting .."
|
||||
sleep 10
|
||||
fi
|
||||
else
|
||||
echo "OK - chainnetwork is working"
|
||||
echo ""
|
||||
chainIsReady=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# CHECK #########
|
||||
|
||||
echo "*** Check LND Config ***"
|
||||
configExists=$( sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c lnd.conf )
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
|
||||
else
|
||||
echo "OK - exists"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
###### Init LND service & start
|
||||
|
||||
echo "*** Init LND Service & Start ***"
|
||||
lndRunning=$(sudo systemctl status lnd.service 2>/dev/null | grep -c running)
|
||||
if [ ${lndRunning} -eq 0 ]; then
|
||||
|
||||
echo "stopping lnd .."
|
||||
sudo systemctl stop lnd 2>/dev/null
|
||||
sudo systemctl disable lnd 2>/dev/null
|
||||
|
||||
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service
|
||||
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service
|
||||
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
|
||||
#sudo chmod +x /etc/systemd/system/lnd.service
|
||||
|
||||
###### ACTIVATE TOR IF SET DURING SETUP
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
echo "TOR was selected"
|
||||
sudo /home/admin/config.scripts/internet.tor.sh lndconf-on
|
||||
else
|
||||
echo "TOR was not selected"
|
||||
fi
|
||||
|
||||
echo "Starting LND Service ..."
|
||||
sudo systemctl enable lnd
|
||||
sudo systemctl start lnd
|
||||
|
||||
echo ""
|
||||
echo "waiting ."
|
||||
sleep 10
|
||||
echo "waiting .."
|
||||
sleep 10
|
||||
echo "waiting ..."
|
||||
sleep 10
|
||||
dialog --pause " Starting LND - please wait .." 8 58 90
|
||||
fi
|
||||
|
||||
###### Check LND starting
|
||||
|
||||
while [ ${lndRunning} -eq 0 ]
|
||||
do
|
||||
lndRunning=$(sudo systemctl status lnd.service | grep -c running)
|
||||
if [ ${lndRunning} -eq 0 ]; then
|
||||
date +%s
|
||||
echo "LND not ready yet ... waiting another 60 seconds."
|
||||
echo "If this takes too long (more then 10min total) --> CTRL+c and report Problem"
|
||||
sleep 60
|
||||
fi
|
||||
done
|
||||
echo "OK - LND is running"
|
||||
echo ""
|
||||
|
||||
###### Check LND health/fails (to be extended)
|
||||
fail=""
|
||||
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert")
|
||||
if [ ${tlsExists} -eq 0 ]; then
|
||||
fail="LND was starting, but missing /mnt/hdd/lnd/tls.cert"
|
||||
fi
|
||||
if [ ${#fail} -gt 0 ]; then
|
||||
whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "${fail}" 8 50
|
||||
if [ $? -eq 0 ]; then
|
||||
/home/admin/70initLND.sh
|
||||
else
|
||||
/home/admin/XXdebugLogs.sh
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###### Instructions on Creating/Restoring LND Wallet
|
||||
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
|
||||
echo "walletExists(${walletExists})"
|
||||
sleep 2
|
||||
if [ ${walletExists} -eq 0 ]; then
|
||||
|
||||
# UI: Ask if user wants NEW wallet or RECOVER a wallet
|
||||
OPTIONS=(NEW "Setup a brand new Lightning Node (DEFAULT)" \
|
||||
OLD "I had an old Node I want to recover/restore")
|
||||
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
echo "choice($CHOICE)"
|
||||
|
||||
if [ "${CHOICE}" == "NEW" ]; then
|
||||
|
||||
############################
|
||||
# NEW WALLET
|
||||
############################
|
||||
|
||||
# let user enter password c
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
sudo touch /var/cache/raspiblitz/.pass.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /var/cache/raspiblitz/.pass.tmp
|
||||
passwordC=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
|
||||
# make sure passwordC is set
|
||||
if [ ${#passwordC} -eq 0 ]; then
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# generate wallet with seed and set passwordC
|
||||
clear
|
||||
echo "Generating new Wallet ...."
|
||||
sudo touch /var/cache/raspiblitz/.seed.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.seed.tmp
|
||||
python3 /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /var/cache/raspiblitz/.seed.tmp
|
||||
source /var/cache/raspiblitz/.seed.tmp
|
||||
sudo shred -u /var/cache/raspiblitz/.seed.tmp 2>/dev/null
|
||||
|
||||
# in case of error - retry
|
||||
if [ ${#err} -gt 0 ]; then
|
||||
whiptail --title "lnd.initwallet.py - ERROR" --msgbox "${err}" 8 50
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
else
|
||||
if [ ${#seedwords} -eq 0 ]; then
|
||||
echo "FAIL!! -> MISSING seedwords data - but also no err data ?!?"
|
||||
echo "CHECK output data above - PRESS ENTER to restart 70initLND.sh"
|
||||
read key
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${#seedwords6x4} -eq 0 ]; then
|
||||
seedwords6x4="${seedwords}"
|
||||
fi
|
||||
|
||||
ack=0
|
||||
while [ ${ack} -eq 0 ]
|
||||
do
|
||||
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n\n${seedwords6x4}" 12 76
|
||||
whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55
|
||||
if [ $? -eq 1 ]; then
|
||||
ack=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${setupStep} -lt 100 ]; then
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=65/g" /home/admin/raspiblitz.info
|
||||
fi
|
||||
|
||||
echo "waiting ."
|
||||
sleep 10
|
||||
|
||||
else
|
||||
|
||||
############################
|
||||
# RECOVER OLD WALLET
|
||||
############################
|
||||
|
||||
OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \
|
||||
SEED+SCB "Seed & channel.backup file (OK)" \
|
||||
ONLYSEED "Only Seed Word List (FALLBACK)")
|
||||
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
# LND RESCUE
|
||||
if [ "${CHOICE}" == "LNDRESCUE" ]; then
|
||||
sudo /home/admin/config.scripts/lnd.rescue.sh restore
|
||||
echo ""
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# WARNING ON ONLY SEED
|
||||
if [ "${CHOICE}" == "ONLYSEED" ]; then
|
||||
|
||||
# let people know about the difference between SEED & SEED+SCB
|
||||
whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno "
|
||||
Using JUST SEED WORDS will only recover your on-chain funds.
|
||||
To also try to recover the open channel funds you need the
|
||||
channel.backup file (since RaspiBlitz v1.2 / LND 0.6-beta)
|
||||
or having a complete LND rescue-backup from your old node.
|
||||
" 11 65
|
||||
if [ $? -eq 1 ]; then
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# IF SEED and SCB - make user upload channel.backup file now
|
||||
# and it will get automated activated after syns are ready
|
||||
# TODO: later activate directly with call to lnd.iniwallet.py
|
||||
if [ "${CHOICE}" == "SEED+SCB" ]; then
|
||||
|
||||
# let lnd.rescue script do the upload process
|
||||
/home/admin/config.scripts/lnd.rescue.sh scb-up
|
||||
|
||||
# check exit code of script
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "USER CANCEL --> back to menu"
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
else
|
||||
clear
|
||||
echo "channel.backup will get checked/activated after blockchain/lightning is synced"
|
||||
sleep 2
|
||||
echo "NEXT --> Set password for new LND wallet"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
|
||||
clear
|
||||
|
||||
# let user enter password c
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
sudo touch /var/cache/raspiblitz/.pass.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /var/cache/raspiblitz/.pass.tmp
|
||||
passwordC=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
|
||||
# get seed word list
|
||||
if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then
|
||||
|
||||
wordsCorrect=0
|
||||
while [ ${wordsCorrect} -eq 0 ]
|
||||
do
|
||||
# dialog to enter
|
||||
sudo touch /var/cache/raspiblitz/.seed.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.seed.tmp
|
||||
dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by spaces, in correct order as numbered)" 9 78 2>/var/cache/raspiblitz/.seed.tmp
|
||||
wordstring=$( cat /var/cache/raspiblitz/.seed.tmp | sed 's/[^a-zA-Z0-9 ]//g' )
|
||||
shred -u /var/cache/raspiblitz/.seed.tmp
|
||||
echo "processing ... ${wordstring}"
|
||||
|
||||
# check correct number of words
|
||||
wordcount=$(echo "${wordstring}" | wc -w)
|
||||
if [ ${wordcount} -eq 24 ]; then
|
||||
echo "OK - 24 words"
|
||||
wordsCorrect=1
|
||||
else
|
||||
whiptail --title " WARNING " \
|
||||
--yes-button "Try Again" \
|
||||
--no-button "Cancel" \
|
||||
--yesno "
|
||||
The word list has ${wordcount} words. But it must be 24.
|
||||
Please check your list and try again.
|
||||
|
||||
Best is to write words in external editor
|
||||
and then copy and paste them into dialog.
|
||||
|
||||
The Word list should look like this:
|
||||
wordone wordtweo wordthree ...
|
||||
|
||||
" 16 52
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# ask if seed was protected by password D
|
||||
passwordD=""
|
||||
dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno "
|
||||
Are your seed words protected by an extra password?
|
||||
|
||||
During wallet creation LND offers to set an extra password
|
||||
to protect the seed words. Most users did not set this.
|
||||
" 11 65
|
||||
if [ $? -eq 1 ]; then
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
sudo touch /var/cache/raspiblitz/.pass.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Enter extra Password D" /var/cache/raspiblitz/.pass.tmp empty-allowed
|
||||
passwordD=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
|
||||
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# FOR NOW: let channel.backup file get activated by lncli after syncs
|
||||
# LATER: make different call to lnd.initwallet.py
|
||||
if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then
|
||||
|
||||
# trigger wallet recovery
|
||||
source <(python3 /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${wordstring}" ${passwordD} 2>/dev/null)
|
||||
|
||||
# check if wallet was created for real
|
||||
if [ ${#err} -eq 0 ]; then
|
||||
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
|
||||
if [ ${walletExists} -eq 0 ]; then
|
||||
err="Was not able to create wallet (unknown error)."
|
||||
fi
|
||||
fi
|
||||
|
||||
# set fundRecovery=1 in raspiblitz.info
|
||||
sed -i "s/^fundRecovery=.*/fundRecovery=1/g" /home/admin/raspiblitz.info
|
||||
|
||||
# user feedback
|
||||
if [ ${#err} -eq 0 ]; then
|
||||
dialog --title " SUCCESS " --msgbox "
|
||||
Looks good :) LND was able to recover the wallet.
|
||||
|
||||
IMPORTANT: LND needs now to scan the blockchain
|
||||
for your funds - this can take some extra time.
|
||||
" 10 60
|
||||
clear
|
||||
|
||||
else
|
||||
whiptail --title " FAIL " --msgbox "
|
||||
Something went wrong - see info below:
|
||||
|
||||
${err}
|
||||
${errMore}
|
||||
" 13 72
|
||||
clear
|
||||
echo "Restarting LND Wallet Setup .."
|
||||
sleep 2
|
||||
echo
|
||||
/home/admin/70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
fi # END OLD WALLET
|
||||
|
||||
else
|
||||
echo "OK - LND wallet already exists."
|
||||
fi
|
||||
|
||||
|
||||
echo "waiting .."
|
||||
sleep 10
|
||||
dialog --pause " Waiting for LND - please wait .." 8 58 45
|
||||
|
||||
############################
|
||||
# Copy LND macaroons to admin
|
||||
############################
|
||||
|
||||
clear
|
||||
echo ""
|
||||
echo "*** Copy LND Macaroons to user admin ***"
|
||||
|
||||
# check if macaroon exists and if not try to unlock LND wallet first
|
||||
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
|
||||
if [ ${macaroonExists} -eq 0 ]; then
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# check if macaroon exists now - if not fail
|
||||
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
|
||||
if [ ${macaroonExists} -eq 0 ]; then
|
||||
sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon
|
||||
echo ""
|
||||
echo "FAIL - LND Macaroons not created"
|
||||
echo "Please check the following LND issue:"
|
||||
echo "https://github.com/lightningnetwork/lnd/issues/890"
|
||||
echo "You may want try again with starting ./70initLND.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy macaroons to all needed users
|
||||
sudo /home/admin/config.scripts/lnd.credentials.sh sync
|
||||
echo "OK - LND Macaroons created and copied"
|
||||
echo ""
|
||||
|
||||
###### Unlock Wallet (if needed)
|
||||
echo "*** Check Wallet Lock ***"
|
||||
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
|
||||
if [ ${locked} -gt 0 ]; then
|
||||
echo "OK - Wallet is locked ... starting unlocking dialog"
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
else
|
||||
echo "OK - Wallet is already unlocked"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
if [ ${setupStep} -lt 100 ]; then
|
||||
|
||||
# set SetupState (scan is done - so its 80%)
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
|
||||
|
||||
###### finishSetup
|
||||
sudo /home/admin/90finishSetup.sh
|
||||
sudo /home/admin/95finalSetup.sh
|
||||
|
||||
else
|
||||
|
||||
# its important that RaspiBlitz dont get rebooted
|
||||
# before LND rescan is finished
|
||||
whiptail --title "RESET DONE" --msgbox "
|
||||
OK LND Reset is done.
|
||||
You may now give it
|
||||
extra time to rescan.
|
||||
" 10 25
|
||||
|
||||
fi
|
@@ -1,67 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
|
||||
# TODO: COPY OVER COMPLETLY INTO _provison_.sh
|
||||
|
||||
# add bonus scripts (auto install deactivated to reduce third party repos)
|
||||
/home/admin/91addBonus.sh
|
||||
|
||||
###### SWAP File
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
if [ ${isSwapExternal} -eq 0 ]; then
|
||||
|
||||
echo "No external SWAP found - creating ... "
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh swap on
|
||||
|
||||
else
|
||||
echo "SWAP already OK"
|
||||
fi
|
||||
|
||||
####### FIREWALL - just install (not configure)
|
||||
echo ""
|
||||
echo "*** Setting and Activating Firewall ***"
|
||||
echo "deny incoming connection on other ports"
|
||||
sudo ufw default deny incoming
|
||||
echo "allow outgoing connections"
|
||||
sudo ufw default allow outgoing
|
||||
echo "allow: ssh"
|
||||
sudo ufw allow ssh
|
||||
echo "allow: bitcoin testnet"
|
||||
sudo ufw allow 18333 comment 'bitcoin testnet'
|
||||
echo "allow: bitcoin mainnet"
|
||||
sudo ufw allow 8333 comment 'bitcoin mainnet'
|
||||
echo "allow: litecoin mainnet"
|
||||
sudo ufw allow 9333 comment 'litecoin mainnet'
|
||||
echo 'allow: lightning testnet'
|
||||
sudo ufw allow 19735 comment 'lightning testnet'
|
||||
echo "allow: lightning mainnet"
|
||||
sudo ufw allow 9735 comment 'lightning mainnet'
|
||||
echo "allow: lightning gRPC"
|
||||
sudo ufw allow 10009 comment 'lightning gRPC'
|
||||
echo "allow: lightning REST API"
|
||||
sudo ufw allow 8080 comment 'lightning REST API'
|
||||
echo "allow: transmission"
|
||||
sudo ufw allow 49200:49250/tcp comment 'rtorrent'
|
||||
echo "allow: public web HTTP"
|
||||
sudo ufw allow from any to any port 80 comment 'allow public web HTTP'
|
||||
echo "allow: local web admin HTTPS"
|
||||
sudo ufw allow from 10.0.0.0/8 to any port 443 comment 'allow local LAN HTTPS'
|
||||
sudo ufw allow from 172.16.0.0/12 to any port 443 comment 'allow local LAN HTTPS'
|
||||
sudo ufw allow from 192.168.0.0/16 to any port 443 comment 'allow local LAN HTTPS'
|
||||
echo "open firewall for auto nat discover (see issue #129)"
|
||||
sudo ufw allow proto udp from 10.0.0.0/8 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
sudo ufw allow proto udp from 172.16.0.0/12 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
sudo ufw allow proto udp from 192.168.0.0/16 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
echo "enable lazy firewall"
|
||||
sudo ufw --force enable
|
||||
echo ""
|
||||
|
||||
# update system
|
||||
echo ""
|
||||
echo "*** Update System ***"
|
||||
sudo apt-mark hold raspberrypi-bootloader
|
||||
sudo apt-get update -y
|
||||
echo "OK - System is now up to date"
|
||||
|
||||
# mark setup is done
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
|
@@ -1,14 +0,0 @@
|
||||
|
||||
# TODO: COPY OVER COMPLETLY INTO _provison_.sh
|
||||
|
||||
mkdir /home/admin/tmpScriptDL
|
||||
cd /home/admin/tmpScriptDL
|
||||
echo "installing bash completion for bitcoin-cli and lncli"
|
||||
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
|
||||
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
|
||||
sudo cp *.bash-completion /etc/bash_completion.d/
|
||||
echo "OK - bash completion available after next login"
|
||||
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
|
||||
rm -r /home/admin/tmpScriptDL
|
||||
|
||||
cd
|
@@ -46,123 +46,6 @@ RaspiBlitz image to your SD card.
|
||||
" 12 40
|
||||
}
|
||||
|
||||
copyHost()
|
||||
{
|
||||
clear
|
||||
echo
|
||||
echo "# *** Copy Blockchain Source Modus ***"
|
||||
|
||||
echo "# get IP of RaspiBlitz to copy to ..."
|
||||
targetIP=$(whiptail --inputbox "\nPlease enter the LOCAL IP of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title " Target IP " --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
|
||||
targetIP=$(echo "${targetIP[0]}")
|
||||
localIP=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
if [ ${#targetIP} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
if [ "${localIP}" == "${targetIP}" ]; then
|
||||
whiptail --msgbox "Dont type in the local IP of this RaspiBlitz,\nthe LOCAL IP of the other RaspiBlitz is needed." 8 54 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
canPingIP=$(ping ${targetIP} -c 1 | grep -c "1 received")
|
||||
if [ ${canPingIP} -eq 0 ]; then
|
||||
whiptail --msgbox "Was not able to contact/ping: ${targetIP}\n\n- check if IP of target RaspiBlitz is correct.\n- check to be on the same local network.\n- try again ..." 11 58 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "# get Password of RaspiBlitz to copy to ..."
|
||||
targetPassword=$(whiptail --passwordbox "\nPlease enter the PASSWORD A of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title "Target Password" --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
|
||||
if [ ${#targetPassword} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
sudo rm /root/.ssh/known_hosts 2>/dev/null
|
||||
canLogin=$(sudo sshpass -p "${targetPassword}" ssh -t -o StrictHostKeyChecking=no bitcoin@${targetIP} "echo 'working'" 2>/dev/null | grep -c 'working')
|
||||
if [ ${canLogin} -eq 0 ]; then
|
||||
whiptail --msgbox "Password was not working for IP: ${targetIP}\n\n- check thats the correct IP for correct RaspiBlitz\n- check that you used PASSWORD A and had no typo\n- If you tried too often, wait 1h try again" 11 58 "" --title " Testing Target Password " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "# stopping services ..."
|
||||
sudo systemctl stop background
|
||||
sudo systemctl stop lnd
|
||||
sudo systemctl stop ${network}d
|
||||
sudo systemctl disable ${network}d
|
||||
sleep 5
|
||||
sudo systemctl stop bitcoind 2>/dev/null
|
||||
|
||||
clear
|
||||
echo
|
||||
echo "# Starting copy over LAN (around 4-6 hours) ..."
|
||||
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
|
||||
cd /mnt/hdd/${network}
|
||||
|
||||
# transfere beginning flag
|
||||
date +%s > /home/admin/copy_begin.time
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_begin.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
sudo rm -f /home/admin/copy_begin.time
|
||||
|
||||
# repeat the syncing of directories until
|
||||
# a) there are no files left to transfere (be robust against failing connections, etc)
|
||||
# b) the user hits a key to break loop after report
|
||||
|
||||
|
||||
while :
|
||||
do
|
||||
|
||||
# transfere blockchain data
|
||||
rm -f ./transferred.rsync
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 --log-file=./transferred.rsync ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
|
||||
# check result
|
||||
# the idea is even after successfull transfer the loop will run a second time
|
||||
# but on the second time there will be no files transfered (log lines are below 4)
|
||||
# thats the signal that its done
|
||||
linesInLogFile=$(wc -l ./transferred.rsync | cut -d " " -f 1)
|
||||
if [ ${linesInLogFile} -lt 4 ]; then
|
||||
echo ""
|
||||
echo "OK all files transfered. DONE"
|
||||
sleep 2
|
||||
break
|
||||
fi
|
||||
|
||||
# wait 20 seconds for user exiting loop
|
||||
echo ""
|
||||
echo -en "OK on sync loop done ... will test in another if all was transferred."
|
||||
echo -en "PRESS X TO MANUALLY FINISH SYNCING"
|
||||
read -n 1 -t 6 keyPressed
|
||||
if [ "${keyPressed}" = "x" ]; then
|
||||
echo ""
|
||||
echo "Ending Sync ..."
|
||||
sleep 2
|
||||
break
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# transfere end flag
|
||||
sed -i "s/^state=.*/state=/g" /home/admin/raspiblitz.info
|
||||
date +%s > /home/admin/copy_end.time
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_end.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
sudo rm -f /home/admin/copy_end.time
|
||||
|
||||
echo "# start services again ..."
|
||||
sudo systemctl enable ${network}d
|
||||
sudo systemctl start ${network}d
|
||||
sudo systemctl start lnd
|
||||
sudo systemctl start background
|
||||
|
||||
echo "# show final message"
|
||||
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
|
||||
}
|
||||
|
||||
# when called with parameter "sourcemode"
|
||||
if [ "$1" == "sourcemode" ]; then
|
||||
copyHost
|
||||
raspiblitz
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Basic Options
|
||||
#OPTIONS=(HARDWARE "Run Hardwaretest" \
|
||||
OPTIONS=(SOFTWARE "Run Softwaretest (DebugReport)" \
|
||||
@@ -260,7 +143,7 @@ case $CHOICE in
|
||||
exit 1;
|
||||
;;
|
||||
COPY-SOURCE)
|
||||
copyHost
|
||||
/home/admin/config.scripts/blitz.copychain.sh source
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
;;
|
||||
esac
|
||||
|
@@ -62,7 +62,10 @@ source ${configFile} 2>/dev/null
|
||||
source <(/home/admin/config.scripts/internet.sh status)
|
||||
|
||||
# get basic hardware info
|
||||
source <(/home/admin/config.scripts/internet.sh status)
|
||||
source <(/home/admin/config.scripts/.sh status)
|
||||
|
||||
# get basic dns info
|
||||
source <(sudo /home/admin/config.scripts/internet.dns.sh test nodialog)
|
||||
|
||||
# resetting info file
|
||||
echo "Resetting the InfoFile: ${infoFile}"
|
||||
@@ -76,6 +79,7 @@ echo "network=${network}" >> $infoFile
|
||||
echo "chain=${chain}" >> $infoFile
|
||||
echo "localip='${localip}'" >> $infoFile
|
||||
echo "online='${online}'" >> $infoFile
|
||||
echo "dnsworking=${dnsworking}" >> $infoFile
|
||||
echo "fsexpanded=${fsexpanded}" >> $infoFile
|
||||
echo "displayClass=${displayClass}" >> $infoFile
|
||||
echo "displayType=${displayType}" >> $infoFile
|
||||
|
@@ -38,8 +38,7 @@ function restart() {
|
||||
|
||||
# command: sourcemode
|
||||
function sourcemode() {
|
||||
cd /home/admin
|
||||
./98repairMenu.sh sourcemode
|
||||
/home/admin/config.scripts/blitz.copychain.sh source
|
||||
}
|
||||
|
||||
# command: check
|
||||
|
@@ -172,9 +172,82 @@ else
|
||||
fi
|
||||
echo "" >> ${logFile}
|
||||
|
||||
##########################
|
||||
# FINISH SETUP
|
||||
##########################
|
||||
|
||||
# finish setup (SWAP, Benus, Firewall, Update, ..)
|
||||
sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile}
|
||||
/home/admin/90finishSetup.sh >> ${logFile} 2>&1
|
||||
|
||||
# add bonus scripts (auto install deactivated to reduce third party repos)
|
||||
mkdir /home/admin/tmpScriptDL
|
||||
cd /home/admin/tmpScriptDL
|
||||
echo "installing bash completion for bitcoin-cli and lncli"
|
||||
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
|
||||
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
|
||||
sudo cp *.bash-completion /etc/bash_completion.d/
|
||||
echo "OK - bash completion available after next login"
|
||||
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
|
||||
rm -r /home/admin/tmpScriptDL
|
||||
cd
|
||||
|
||||
###### SWAP File
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
if [ ${isSwapExternal} -eq 0 ]; then
|
||||
echo "No external SWAP found - creating ... "
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh swap on
|
||||
else
|
||||
echo "SWAP already OK"
|
||||
fi
|
||||
|
||||
####### FIREWALL - just install (not configure)
|
||||
echo ""
|
||||
echo "*** Setting and Activating Firewall ***"
|
||||
echo "deny incoming connection on other ports"
|
||||
sudo ufw default deny incoming
|
||||
echo "allow outgoing connections"
|
||||
sudo ufw default allow outgoing
|
||||
echo "allow: ssh"
|
||||
sudo ufw allow ssh
|
||||
echo "allow: bitcoin testnet"
|
||||
sudo ufw allow 18333 comment 'bitcoin testnet'
|
||||
echo "allow: bitcoin mainnet"
|
||||
sudo ufw allow 8333 comment 'bitcoin mainnet'
|
||||
echo "allow: litecoin mainnet"
|
||||
sudo ufw allow 9333 comment 'litecoin mainnet'
|
||||
echo 'allow: lightning testnet'
|
||||
sudo ufw allow 19735 comment 'lightning testnet'
|
||||
echo "allow: lightning mainnet"
|
||||
sudo ufw allow 9735 comment 'lightning mainnet'
|
||||
echo "allow: lightning gRPC"
|
||||
sudo ufw allow 10009 comment 'lightning gRPC'
|
||||
echo "allow: lightning REST API"
|
||||
sudo ufw allow 8080 comment 'lightning REST API'
|
||||
echo "allow: transmission"
|
||||
sudo ufw allow 49200:49250/tcp comment 'rtorrent'
|
||||
echo "allow: public web HTTP"
|
||||
sudo ufw allow from any to any port 80 comment 'allow public web HTTP'
|
||||
echo "allow: local web admin HTTPS"
|
||||
sudo ufw allow from 10.0.0.0/8 to any port 443 comment 'allow local LAN HTTPS'
|
||||
sudo ufw allow from 172.16.0.0/12 to any port 443 comment 'allow local LAN HTTPS'
|
||||
sudo ufw allow from 192.168.0.0/16 to any port 443 comment 'allow local LAN HTTPS'
|
||||
echo "open firewall for auto nat discover (see issue #129)"
|
||||
sudo ufw allow proto udp from 10.0.0.0/8 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
sudo ufw allow proto udp from 172.16.0.0/12 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
sudo ufw allow proto udp from 192.168.0.0/16 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
|
||||
echo "enable lazy firewall"
|
||||
sudo ufw --force enable
|
||||
echo ""
|
||||
|
||||
# update system
|
||||
echo ""
|
||||
echo "*** Update System ***"
|
||||
sudo apt-mark hold raspberrypi-bootloader
|
||||
sudo apt-get update -y
|
||||
echo "OK - System is now up to date"
|
||||
|
||||
# mark setup is done
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
|
||||
|
||||
##########################
|
||||
# PROVISIONING SERVICES
|
||||
|
@@ -1,234 +1,397 @@
|
||||
#!/bin/bash
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
# only works for bitcoin for now
|
||||
if [ "${network}" != "bitcoin" ]; then
|
||||
echo "err='only works for bitcoin'"
|
||||
exit 1
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# managing the copy of blockchain data over LAN"
|
||||
echo "# blitz.copychain.sh [status|target|source]"
|
||||
echo "error='missing parameters'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Basic Options
|
||||
OPTIONS=(WINDOWS "Windows" \
|
||||
# load basic system settings
|
||||
source /home/admin/raspiblitz.info 2>/dev/null
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
|
||||
# check that blockchain is set & supported
|
||||
if [ "${network}" != "bitcoin" ] && [ "${network}" != "litecoin" ]; then
|
||||
echo "blockchain='{$network}'"
|
||||
echo "error='blockchain type missing or not supported'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check that HDD is available
|
||||
isMounted=$(sudo df | grep -c /mnt/hdd)
|
||||
if [ "${isMounted}" != "1" ]; then
|
||||
echo "error='no datadrive is mounted'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###################
|
||||
# STATUS
|
||||
###################
|
||||
|
||||
# check if copy is in progress
|
||||
copyBeginTime=$(cat /mnt/hdd/${network}/copy_begin.time 2>/dev/null | tr -cd '[[:digit:]]')
|
||||
if [ ${#copyBeginTime} -eq 0 ]; then
|
||||
copyBeginTime=0
|
||||
fi
|
||||
copyEndTime=$(cat /mnt/hdd/${network}/copy_end.time 2>/dev/null | tr -cd '[[:digit:]]')
|
||||
if [ ${#copyEndTime} -eq 0 ]; then
|
||||
copyEndTime=0
|
||||
fi
|
||||
copyInProgress=0
|
||||
if [ ${copyBeginTime} -gt ${copyEndTime} ]; then
|
||||
copyInProgress=1
|
||||
fi
|
||||
|
||||
# output status data & exit
|
||||
if [ "$1" = "status" ]; then
|
||||
echo "# blitz.copyblockchain.sh"
|
||||
echo "copyInProgress=${copyInProgress}"
|
||||
echo "copyBeginTime=${copyBeginTime}"
|
||||
echo "copyEndTime=${copyEndTime}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###################
|
||||
# COPYTARGET
|
||||
###################
|
||||
|
||||
# output status data & exit
|
||||
if [ "$1" = "target" ]; then
|
||||
|
||||
# Basic Options
|
||||
OPTIONS=(WINDOWS "Windows" \
|
||||
MACOS "Apple MacOSX" \
|
||||
LINUX "Linux" \
|
||||
BLITZ "RaspiBlitz"
|
||||
)
|
||||
CHOICE=$(dialog --clear --title " Copy Blockchain from another laptop/node over LAN " --menu "\nWhich system is running on the other laptop/node you want to copy the blockchain from?\n " 14 60 9 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
CHOICE=$(dialog --clear --title " Copy Blockchain from another laptop/node over LAN " --menu "\nWhich system is running on the other laptop/node you want to copy the blockchain from?\n " 14 60 9 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
clear
|
||||
case $CHOICE in
|
||||
clear
|
||||
case $CHOICE in
|
||||
MACOS) echo "Steve";;
|
||||
LINUX) echo "Linus";;
|
||||
WINDOWS) echo "Bill";;
|
||||
BLITZ) echo "Satoshi";;
|
||||
*) exit 1;;
|
||||
esac
|
||||
esac
|
||||
|
||||
# setting copy state
|
||||
sed -i "s/^state=.*/state=copytarget/g" /home/admin/raspiblitz.info
|
||||
sed -i "s/^message=.*/message='Receiving Blockchain over LAN'/g" /home/admin/raspiblitz.info
|
||||
# setting copy state
|
||||
sed -i "s/^state=.*/state=copytarget/g" /home/admin/raspiblitz.info
|
||||
sed -i "s/^message=.*/message='Receiving Blockchain over LAN'/g" /home/admin/raspiblitz.info
|
||||
|
||||
echo "stopping services ..."
|
||||
sudo systemctl stop bitcoind <2 /dev/null
|
||||
echo "stopping services ..."
|
||||
sudo systemctl stop bitcoind <2 /dev/null
|
||||
|
||||
# check if old blockchain data exists
|
||||
hasOldBlockchainData=0
|
||||
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
# check if old blockchain data exists
|
||||
hasOldBlockchainData=0
|
||||
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]')
|
||||
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
|
||||
hasOldBlockchainData=1
|
||||
fi
|
||||
|
||||
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
|
||||
response=$?
|
||||
clear
|
||||
echo "response(${response})"
|
||||
if [ "${response}" = "1" ]; then
|
||||
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
|
||||
response=$?
|
||||
clear
|
||||
echo "response(${response})"
|
||||
if [ "${response}" = "1" ]; then
|
||||
echo "OK - keep old blockchain - just try to repair by copying over it"
|
||||
sleep 3
|
||||
else
|
||||
else
|
||||
echo "OK - delete old blockchain"
|
||||
sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null
|
||||
sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# make sure /mnt/hdd/bitcoin exists
|
||||
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
|
||||
|
||||
# allow all users write to it
|
||||
sudo chmod 777 /mnt/hdd/bitcoin
|
||||
|
||||
echo
|
||||
clear
|
||||
if [ "${CHOICE}" = "WINDOWS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a WINDOWS computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR WINDOWS COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Windows computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Windows computer & change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Windows thats: C:\Users\YourUserName\Appdata\Roaming\Bitcoin"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:"
|
||||
echo "scp -r ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "If asked for a password use PASSWORD A (or 'raspiblitz')."
|
||||
fi
|
||||
if [ "${CHOICE}" = "MACOS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a MacOSX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR MacOSX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your MacOSX computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your MacOSX computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on MacOSX thats: cd ~/Library/Application Support/Bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your MacOSX terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your MacOSX"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "LINUX" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a LINUX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR LINUX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Linux computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Linux computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Linux thats: cd ~/.bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Linux terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your Linux"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "BLITZ" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another RaspiBlitz"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "The other RaspiBlitz needs a minimum version of 1.6 (if lower, update first)."
|
||||
echo "Make sure that the other RaspiBlitz is on the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal and login per SSH into that other RaspiBlitz."
|
||||
echo "Once in the main menu go: MAINMENU > REPAIR > COPY-SOURCE"
|
||||
echo "Follow the given instructions ..."
|
||||
echo ""
|
||||
echo "The LOCAL IP of this target RaspiBlitz is: ${localip}"
|
||||
fi
|
||||
echo ""
|
||||
echo "It can take multiple hours until transfer is complete - be patient."
|
||||
echo "****************************************************************************"
|
||||
echo "PRESS ENTER if transfers is done OR if you want to choose another option."
|
||||
sleep 2
|
||||
read key
|
||||
|
||||
# make quick check if data is there
|
||||
anyDataAtAll=0
|
||||
quickCheckOK=1
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.dat -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/blocks"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 300 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 300 .dat files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.ldb -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/chainstate"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 700 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 700 .ldb files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
|
||||
echo "*********************************************"
|
||||
echo "QUICK CHECK RESULT"
|
||||
echo "*********************************************"
|
||||
|
||||
# just if any data transferred ..
|
||||
if [ ${anyDataAtAll} -eq 1 ]; then
|
||||
|
||||
# data was invalid - ask user to keep?
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo "FAIL -> DATA seems incomplete."
|
||||
else
|
||||
echo "OK -> DATA LOOKS GOOD :D"
|
||||
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
|
||||
fi
|
||||
|
||||
else
|
||||
echo "CANCEL -> NO DATA was copied."
|
||||
quickCheckOK=0
|
||||
fi
|
||||
echo "*********************************************"
|
||||
# make sure /mnt/hdd/bitcoin exists
|
||||
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
|
||||
|
||||
# allow all users write to it
|
||||
sudo chmod 777 /mnt/hdd/bitcoin
|
||||
|
||||
# REACT ON QUICK CHECK DURING INITAL SETUP
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo
|
||||
clear
|
||||
if [ "${CHOICE}" = "WINDOWS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a WINDOWS computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR WINDOWS COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Windows computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Windows computer & change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Windows thats: C:\Users\YourUserName\Appdata\Roaming\Bitcoin"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:"
|
||||
echo "scp -r ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "If asked for a password use PASSWORD A (or 'raspiblitz')."
|
||||
fi
|
||||
if [ "${CHOICE}" = "MACOS" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a MacOSX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR MacOSX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your MacOSX computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your MacOSX computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on MacOSX thats: cd ~/Library/Application Support/Bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your MacOSX terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your MacOSX"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "LINUX" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a LINUX computer"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "ON YOUR LINUX COMPUTER download and validate the blockchain with the Bitcoin"
|
||||
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
|
||||
echo "If the Bitcoin Blockchain is synced up - make sure that your Linux computer &"
|
||||
echo "your RaspiBlitz are in the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal on your Linux computer and change into the directory that"
|
||||
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
|
||||
echo "there. Normally on Linux thats: cd ~/.bitcoin/"
|
||||
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
|
||||
echo ""
|
||||
echo "COPY, PASTE & EXECUTE the following command on your Linux terminal:"
|
||||
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
|
||||
echo ""
|
||||
echo "You will be asked for passwords. First can be the user password of your Linux"
|
||||
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
|
||||
fi
|
||||
if [ "${CHOICE}" = "BLITZ" ]; then
|
||||
echo "****************************************************************************"
|
||||
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another RaspiBlitz"
|
||||
echo "****************************************************************************"
|
||||
echo ""
|
||||
echo "The other RaspiBlitz needs a minimum version of 1.6 (if lower, update first)."
|
||||
echo "Make sure that the other RaspiBlitz is on the same local network."
|
||||
echo ""
|
||||
echo "Open a fresh terminal and login per SSH into that other RaspiBlitz."
|
||||
echo "Once in the main menu go: MAINMENU > REPAIR > COPY-SOURCE"
|
||||
echo "Follow the given instructions ..."
|
||||
echo ""
|
||||
echo "The LOCAL IP of this target RaspiBlitz is: ${localip}"
|
||||
fi
|
||||
echo ""
|
||||
echo "It can take multiple hours until transfer is complete - be patient."
|
||||
echo "****************************************************************************"
|
||||
echo "PRESS ENTER if transfers is done OR if you want to choose another option."
|
||||
sleep 2
|
||||
read key
|
||||
|
||||
# make quick check if data is there
|
||||
anyDataAtAll=0
|
||||
quickCheckOK=1
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.dat -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/blocks"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 300 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 300 .dat files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.ldb -type f | wc -l)
|
||||
if [ ${count} -gt 0 ]; then
|
||||
echo "Found data in /mnt/hdd/bitcoin/chainstate"
|
||||
anyDataAtAll=1
|
||||
fi
|
||||
if [ ${count} -lt 700 ]; then
|
||||
echo "FAIL: transfer seems invalid - less then 700 .ldb files (${count})"
|
||||
quickCheckOK=0
|
||||
fi
|
||||
|
||||
echo "*********************************************"
|
||||
echo "There seems to be an invalid transfer."
|
||||
echo "QUICK CHECK RESULT"
|
||||
echo "*********************************************"
|
||||
|
||||
echo "Wait 5 secs ..."
|
||||
sleep 5
|
||||
# just if any data transferred ..
|
||||
if [ ${anyDataAtAll} -eq 1 ]; then
|
||||
|
||||
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
if [ "${response}" == "0" ]; then
|
||||
/home/admin/config.scripts/blitz.copychain.sh
|
||||
exit 0
|
||||
# data was invalid - ask user to keep?
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo "FAIL -> DATA seems incomplete."
|
||||
else
|
||||
echo "OK -> DATA LOOKS GOOD :D"
|
||||
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
|
||||
fi
|
||||
|
||||
else
|
||||
echo "CANCEL -> NO DATA was copied."
|
||||
quickCheckOK=0
|
||||
fi
|
||||
echo "*********************************************"
|
||||
|
||||
|
||||
# REACT ON QUICK CHECK DURING INITAL SETUP
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
|
||||
echo "*********************************************"
|
||||
echo "There seems to be an invalid transfer."
|
||||
|
||||
echo "Wait 5 secs ..."
|
||||
sleep 5
|
||||
|
||||
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
if [ "${response}" == "0" ]; then
|
||||
/home/admin/config.scripts/blitz.copychain.sh
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data?" 8 60
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
case $response in
|
||||
1) quickCheckOK=1 ;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data?" 8 60
|
||||
response=$?
|
||||
echo "response(${response})"
|
||||
case $response in
|
||||
1) quickCheckOK=1 ;;
|
||||
esac
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo "Deleting invalid Data ... "
|
||||
sudo rm -rf /mnt/hdd/bitcoin
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
echo "restarting services ... (please wait)"
|
||||
sudo systemctl start bitcoind
|
||||
sleep 10
|
||||
|
||||
# setting copy state
|
||||
sed -i "s/^state=.*/state=ready/g" /home/admin/raspiblitz.info
|
||||
sed -i "s/^message=.*/message='Node Running'/g" /home/admin/raspiblitz.info
|
||||
fi
|
||||
|
||||
###################
|
||||
# COPYSOURCE
|
||||
###################
|
||||
|
||||
if [ "$1" = "source" ]; then
|
||||
|
||||
clear
|
||||
echo
|
||||
echo "# *** Copy Blockchain Source Modus ***"
|
||||
|
||||
echo "# get IP of RaspiBlitz to copy to ..."
|
||||
targetIP=$(whiptail --inputbox "\nPlease enter the LOCAL IP of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title " Target IP " --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
|
||||
targetIP=$(echo "${targetIP[0]}")
|
||||
localIP=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
if [ ${#targetIP} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
if [ "${localIP}" == "${targetIP}" ]; then
|
||||
whiptail --msgbox "Dont type in the local IP of this RaspiBlitz,\nthe LOCAL IP of the other RaspiBlitz is needed." 8 54 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
canPingIP=$(ping ${targetIP} -c 1 | grep -c "1 received")
|
||||
if [ ${canPingIP} -eq 0 ]; then
|
||||
whiptail --msgbox "Was not able to contact/ping: ${targetIP}\n\n- check if IP of target RaspiBlitz is correct.\n- check to be on the same local network.\n- try again ..." 11 58 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
|
||||
fi
|
||||
echo "# get Password of RaspiBlitz to copy to ..."
|
||||
targetPassword=$(whiptail --passwordbox "\nPlease enter the PASSWORD A of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title "Target Password" --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
|
||||
if [ ${#targetPassword} -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ${quickCheckOK} -eq 0 ]; then
|
||||
echo "Deleting invalid Data ... "
|
||||
sudo rm -rf /mnt/hdd/bitcoin
|
||||
sleep 2
|
||||
fi
|
||||
sudo rm /root/.ssh/known_hosts 2>/dev/null
|
||||
canLogin=$(sudo sshpass -p "${targetPassword}" ssh -t -o StrictHostKeyChecking=no bitcoin@${targetIP} "echo 'working'" 2>/dev/null | grep -c 'working')
|
||||
if [ ${canLogin} -eq 0 ]; then
|
||||
whiptail --msgbox "Password was not working for IP: ${targetIP}\n\n- check thats the correct IP for correct RaspiBlitz\n- check that you used PASSWORD A and had no typo\n- If you tried too often, wait 1h try again" 11 58 "" --title " Testing Target Password " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "restarting services ... (please wait)"
|
||||
sudo systemctl start bitcoind
|
||||
sleep 10
|
||||
echo "# stopping services ..."
|
||||
sudo systemctl stop background
|
||||
sudo systemctl stop lnd
|
||||
sudo systemctl stop ${network}d
|
||||
sudo systemctl disable ${network}d
|
||||
sleep 5
|
||||
sudo systemctl stop bitcoind 2>/dev/null
|
||||
|
||||
clear
|
||||
echo
|
||||
echo "# Starting copy over LAN (around 4-6 hours) ..."
|
||||
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
|
||||
cd /mnt/hdd/${network}
|
||||
|
||||
# setting copy state
|
||||
sed -i "s/^state=.*/state=ready/g" /home/admin/raspiblitz.info
|
||||
sed -i "s/^message=.*/message='Node Running'/g" /home/admin/raspiblitz.info
|
||||
# transfere beginning flag
|
||||
date +%s > /home/admin/copy_begin.time
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_begin.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
sudo rm -f /home/admin/copy_begin.time
|
||||
|
||||
# repeat the syncing of directories until
|
||||
# a) there are no files left to transfere (be robust against failing connections, etc)
|
||||
# b) the user hits a key to break loop after report
|
||||
while :
|
||||
do
|
||||
|
||||
# transfere blockchain data
|
||||
rm -f ./transferred.rsync
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 --log-file=./transferred.rsync ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
|
||||
# check result
|
||||
# the idea is even after successfull transfer the loop will run a second time
|
||||
# but on the second time there will be no files transfered (log lines are below 4)
|
||||
# thats the signal that its done
|
||||
linesInLogFile=$(wc -l ./transferred.rsync | cut -d " " -f 1)
|
||||
if [ ${linesInLogFile} -lt 4 ]; then
|
||||
echo ""
|
||||
echo "OK all files transfered. DONE"
|
||||
sleep 2
|
||||
break
|
||||
fi
|
||||
|
||||
# wait 20 seconds for user exiting loop
|
||||
echo ""
|
||||
echo -en "OK on sync loop done ... will test in another if all was transferred."
|
||||
echo -en "PRESS X TO MANUALLY FINISH SYNCING"
|
||||
read -n 1 -t 6 keyPressed
|
||||
if [ "${keyPressed}" = "x" ]; then
|
||||
echo ""
|
||||
echo "Ending Sync ..."
|
||||
sleep 2
|
||||
break
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# transfere end flag
|
||||
sed -i "s/^state=.*/state=/g" /home/admin/raspiblitz.info
|
||||
date +%s > /home/admin/copy_end.time
|
||||
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_end.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
|
||||
sudo rm -f /home/admin/copy_end.time
|
||||
|
||||
echo "# start services again ..."
|
||||
sudo systemctl enable ${network}d
|
||||
sudo systemctl start ${network}d
|
||||
sudo systemctl start lnd
|
||||
sudo systemctl start background
|
||||
|
||||
echo "# show final message"
|
||||
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"
|
||||
|
||||
fi
|
@@ -203,7 +203,7 @@ if [ "$1" = "status" ]; then
|
||||
else
|
||||
|
||||
#####################################
|
||||
# Pre-Setup Invetigation of DATA-PART
|
||||
# Pre-Setup Investigation of DATA-PART
|
||||
|
||||
# check for recoverable RaspiBlitz data (if config file exists) and raid
|
||||
hddRaspiData=$(sudo ls -l /mnt/hdd${subVolumeDir} 2>/dev/null | grep -c raspiblitz.conf)
|
||||
|
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: if DNS is not working --> ask in system-loop
|
||||
# TODO: get size of sd card & free space on sd card
|
||||
|
||||
##################
|
||||
# CHECK IF DNS NEEDS SETTING DURING SETUP
|
||||
# https://github.com/rootzoll/raspiblitz/issues/787
|
||||
###################
|
||||
sudo /home/admin/config.scripts/internet.dns.sh test
|
@@ -19,6 +19,12 @@ echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE
|
||||
sudo chown admin:admin $SETUPFILE
|
||||
sudo chmod 777 $SETUPFILE
|
||||
|
||||
############################################
|
||||
# PRESETUP: SET DNS (just if needed)
|
||||
if [ "${dnsworking}" == "0" ]; then
|
||||
sudo /home/admin/config.scripts/internet.dns.sh test
|
||||
fi
|
||||
|
||||
############################################
|
||||
# QuickOption: Update
|
||||
if [ "${setupPhase}" == "update" ]; then
|
||||
|
Reference in New Issue
Block a user