Merge branch '1126-provision' into pre-1.7.1

This commit is contained in:
rootzoll 2021-06-24 19:54:10 +02:00
commit 85b9ca618a
54 changed files with 771 additions and 2682 deletions

6
FAQ.md
View File

@ -541,7 +541,7 @@ Work notes for the process of producing a new SD card image release:
* Run the following command BUT REPLACE `[BRANCH]` with the branch-string of your latest version
* `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false true rootzoll [BRANCH] lcd true true`
* Monitor/Check outputs for warnings/errors - install LCD
* Login new with `ssh admin@[IP-OF-RASPIBLITZ]` (pw: raspiblitz) and run `./XXprepareRelease.sh`
* Login new with `ssh admin@[IP-OF-RASPIBLITZ]` (pw: raspiblitz) and run `release`
* Disconnect WiFi/LAN on build laptop (hardware switch off) and shutdown
* Remove `Ubuntu LIVE` USB stick and cut power from the RaspberryPi
* Connect USB stick with latest `TAILS` (make it stay offline)
@ -840,12 +840,12 @@ https://seravo.fi/2015/using-raid-btrfs-recovering-broken-disks
When the LCD display is telling you to do a config check:
- go to the RaspiBlitz terminal (X on main menu) and run './XXsyncScripts.sh'
- start reboot with command: './XXshutdown.sh reboot'
- start reboot with command: 'restart'
- go to the RaspiBlitz terminal run the command: 'check'
- now edit the RaspiBlitz config and get rid of the errors: 'nano /mnt/hdd/raspiblitz.conf'
- save config with: CTRL+o
- exit nano editor with: CTRL+x
- start reboot with command: './XXshutdown.sh reboot'
- start reboot with command: 'restart'
## How to fix my upside down LCD after update?

View File

@ -1108,7 +1108,7 @@ Now you are ready to start the SD card build script (check the code to see if th
As you can see from the URL, you can find the build script in this Git repo under `build_sdcard.sh`. You can check what gets installed and configured in detail. Feel free to post improvements as pull requests.
The whole build process takes a while. At the end the LCD drivers get installed and a reboot is needed. A user `admin` is created during the process. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use admin: `ssh admin@[IP-OF-YOUR-RASPI]`. The install dialog of the RaspiBlitz schould automatically start. If you do not want to continue with the installation at this moment and use this sd card as a template for setting up multiple RaspiBlitzes, click `Cancel` and run `/home/admin/XXprepareRelease.sh`. Once you see the LCD going white and the activity LED of the pi starts going dark, you can unplug power and remove the SD card. You have now built your own RaspiBlitz SD card image.
The whole build process takes a while. At the end the LCD drivers get installed and a reboot is needed. A user `admin` is created during the process. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use admin: `ssh admin@[IP-OF-YOUR-RASPI]`. The install dialog of the RaspiBlitz schould automatically start. If you do not want to continue with the installation at this moment and use this sd card as a template for setting up multiple RaspiBlitzes, click `Cancel` and run `release`. Once you see the LCD going white and the activity LED of the pi starts going dark, you can unplug power and remove the SD card. You have now built your own RaspiBlitz SD card image.
*Note: If you plan to use your self-build sd card as a MASTER copy and distribute it: Use a smaller 8GB card for that. This way it's ensured that it will fit on every 16 GB card recommended for RaspiBlitz later on.*

View File

@ -1073,7 +1073,7 @@ echo "Take the chance & look thru the output above if you can spot any errors or
echo ""
echo "IMPORTANT IF WANT TO MAKE A RELEASE IMAGE FROM THIS BUILD:"
echo "1. login fresh --> user:admin password:raspiblitz"
echo "2. run --> ./XXprepareRelease.sh"
echo "2. run --> release"
echo ""
# (do last - because might trigger reboot)

View File

@ -96,7 +96,7 @@ while :
alias lightningcli_alias="$lightningcli_alias"
fi
if [ "${setupPhase}" != "done" ]; then
if [ "${setupPhase}" != "done" ] || [ "${state}" == "copytarget" ] || [ "${state}" == "copysource" ] || [ "${state}" == "copystation" ]; then
# show status info during boot & setup & repair on LCD
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}" lcd
@ -109,7 +109,7 @@ while :
# if LND is syncing or scanning
lndSynced=$($lncli_alias 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/controlScanInfo.sh
sleep 20
continue
fi

View File

@ -360,7 +360,7 @@ case $CHOICE in
if [ $confirmationReboot -eq 0 ]; then
clear
echo ""
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 1
fi
;;
@ -371,13 +371,13 @@ case $CHOICE in
if [ $confirmationShutdown -eq 0 ]; then
clear
echo ""
sudo /home/admin/XXshutdown.sh
sudo /home/admin/config.scripts/blitz.shutdown.sh
exit 1
fi
;;
DELETE)
sudo /home/admin/XXcleanHDD.sh
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 1
;;
*)

View File

@ -1,11 +0,0 @@
#!/bin/bash
# TODO: ON BASIC BITCOIN CONFIG
###### 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

View File

@ -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.copychain.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
@ -80,7 +114,7 @@ do
# when is needed & bootstrap process signals that it waits for user dialog
if [ "${setupPhase}" != "done" ] && [ "${state}" == "waitsetup" ]; then
# push user to main menu
/home/admin/setup.scripts/setupDialogControl.sh
/home/admin/setup.scripts/controlSetupDialog.sh
# use the exit code from setup menu as signal if menu loop should exited
# 0 = continue loop / everything else = break loop and exit to terminal
exitMenuLoop=$?
@ -94,7 +128,7 @@ do
# when is needed & bootstrap process signals that it waits for user dialog
if [ "${setupPhase}" != "done" ] && [ "${state}" == "waitfinal" ]; then
# push to final setup gui dialogs
/home/admin/setup.scripts/finalDialogControl.sh
/home/admin/setup.scripts/controlFinalDialog.sh
continue
fi
@ -195,396 +229,3 @@ 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}
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
shopt -s expand_aliases
alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias"
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
bitcoincli_alias 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=$($lncli_alias 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=$($lncli_alias 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

View File

@ -436,5 +436,5 @@ if [ ${needsReboot} -eq 1 ]; then
# stop bitcoind
sudo -u bitcoin ${network}-cli stop
sleep 4
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi

View File

@ -499,5 +499,5 @@ if [ ${needsReboot} -eq 1 ]; then
# stop bitcoind
sudo -u bitcoin ${network}-cli stop
sleep 4
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,52 +0,0 @@
#!/bin/bash
echo ""
# TODO: should be good to be deleted - it now done in _provision.setup.sh and setup dialogs
# load setup config
source /home/admin/raspiblitz.info
# in case the config already exists
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# load version
source /home/admin/_version.info
# show info to user
sudo sed -i "s/^state=.*/state=reboot/g" /home/admin/raspiblitz.info
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
After reboot RaspiBlitz
needs to be unlocked and
sync with the network.
Press OK for a final reboot.
" 10 42
# let update script do the rest
/home/admin/_bootstrap.update.sh
# copy logfile to analyse setup
cp $logFile /home/admin/raspiblitz.setup.log
# set the name of the node
echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh ${hostname}
# expanding the root of the sd card
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
sudo raspi-config --expand-rootfs
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info
elif [ "${baseimage}" = "armbian" ]; then
sudo /usr/lib/armbian/armbian-resize-filesystem start
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info
fi
# mark setup is done
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
clear
echo "Setup done. Rebooting now."
sudo -u bitcoin ${network}-cli stop
sleep 3
sudo /home/admin/XXshutdown.sh reboot

View File

@ -26,7 +26,7 @@ elif [ "${CHOICE}" = "RESYNC" ]; then
dialog --pause "OK. System will reboot to activate changes." 8 58 8
clear
echo "rebooting .. (please wait)"
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
elif [ "${CHOICE}" = "REINDEX" ]; then
echo "Starting REINDEX ..."

View File

@ -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)" \
@ -193,7 +76,7 @@ case $CHOICE in
echo
echo "Press ENTER when your backup download is done to shutdown."
read key
/home/admin/XXshutdown.sh
/home/admin/config.scripts/blitz.shutdown.sh
;;
MIGRATION)
sudo /home/admin/config.scripts/blitz.migration.sh "export-gui"
@ -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

View File

@ -58,7 +58,7 @@ case $CHOICE in
RESET)
sudo /home/admin/config.scripts/lnd.credentials.sh reset
sudo /home/admin/config.scripts/lnd.credentials.sh sync
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0;;
SYNC)
sudo /home/admin/config.scripts/lnd.credentials.sh sync

View File

@ -126,7 +126,7 @@ patch()
if [ $? -eq 0 ]; then
clear
echo "REBOOT .."
/home/admin/XXshutdown.sh reboot
/home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8
else
echo "SKIP REBOOT .."
@ -238,7 +238,7 @@ Do you really want to update LND now?
if [ "${loop}" == "on" ]; then
sudo -u admin /home/admin/config.scripts/bonus.loop.sh on
fi
/home/admin/XXshutdown.sh reboot
/home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8
fi
;;
@ -262,7 +262,7 @@ Do you really want to update LND now?
if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30
else
/home/admin/XXshutdown.sh reboot
/home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8
fi
;;

View File

@ -1,35 +0,0 @@
#!/bin/bash
# load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi
clear
echo ""
echo "****************************************************************************"
echo "Unlock LND Wallet --> lncli --chain=${network} unlock"
echo "****************************************************************************"
echo "HELP: Enter your PASSWORD C"
echo "You may wait some seconds until you get asked for password."
echo "****************************************************************************"
while :
do
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -eq 0 ]; then
break
fi
echo ""
echo "network(${network}) chain(${chain})"
sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log
echo "Wallet still locked - please try again or"
echo "Cancel with CTRL+C - back to setup with command: raspiblitz"
done

View File

@ -522,7 +522,7 @@ class AppWindow(QMainWindow):
process = QProcess(self)
process.start('uxterm', ['-fa', 'Terminus', '-fs', '9', '-fn', 'fixed', '-into', str(int(self.ui.widget.winId())),
'+sb', '-hold', '-e', 'bash -c \"sudo /home/admin/XXshutdown.sh\"'])
'+sb', '-hold', '-e', 'bash -c \"sudo /home/admin/config.scripts/blitz.shutdown.sh\"'])
def b4_restart(self):
log.info("restart")
@ -532,7 +532,7 @@ class AppWindow(QMainWindow):
process = QProcess(self)
process.start('uxterm', ['-fa', 'Terminus', '-fs', '9', '-fn', 'fixed', '-into', str(int(self.ui.widget.winId())),
'+sb', '-hold', '-e', 'bash -c \"sudo /home/admin/XXshutdown.sh reboot\"'])
'+sb', '-hold', '-e', 'bash -c \"sudo /home/admin/config.scripts/blitz.shutdown.sh reboot\"'])
def create_new_invoice(self, memo="Pay to RaspiBlitz", amt=0):
if IS_DEV_ENV:

View File

@ -39,6 +39,10 @@ echo "chainnetwork: ${network} / ${chain}"
uptime
echo ""
echo "*** BACKGROUNDSERVICE ***"
echo "to monitor Background service call: sudo journalctl -f -u background"
echo ""
echo "*** BLOCKCHAIN SYSTEMD STATUS ***"
sudo systemctl status ${network}d -n2 --no-pager
echo ""

View File

@ -57,7 +57,7 @@ do
# https://github.com/rootzoll/raspiblitz/issues/160
####################################################
if [ "${state}" == "" ] || [ "${state}" == "copysource" ]; then
if [ "${state}" == "" ] || [ "${state}" == "copysource" ] || [ "${state}" == "copytarget" ]; then
echo "skipping background loop (${counter}) - state(${state})"
sleep 1
continue
@ -100,7 +100,7 @@ do
# detect a missing DHCP config
if [ "${localip:0:4}" = "169." ]; then
echo "Missing DHCP detected ... trying emergency reboot"
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
else
echo "DHCP OK"
fi

View File

@ -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
@ -93,6 +97,8 @@ sudo chmod 777 ${infoFile}
# when the provision did not ran thru without error (ask user for fresh sd card)
provisionFlagExists=$(sudo ls /home/admin/provision.flag | grep -c 'provision.flag')
if [ "${provisionFlagExists}" == "1" ]; then
sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop lnd 2>/dev/null
sed -i "s/^state=.*/state=inconsistentsystem/g" ${infoFile}
sed -i "s/^message=.*/message='provision did not ran thru'/g" ${infoFile}
echo "FAIL: 'provision did not ran thru - need fresh sd card!" >> ${logFile}
@ -389,6 +395,7 @@ echo "HDD already part of system: $isMounted" >> $logFile
if [ ${isMounted} -eq 0 ]; then
# write data needed for setup process into raspiblitz.info
echo "hddCandidate='${hddCandidate}'" >> ${infoFile}
echo "hddBlocksBitcoin=${hddBlocksBitcoin}" >> ${infoFile}
echo "hddBlocksLitecoin=${hddBlocksLitecoin}" >> ${infoFile}
echo "hddGotMigrationData=${hddGotMigrationData}" >> ${infoFile}
@ -484,7 +491,7 @@ if [ ${isMounted} -eq 0 ]; then
# if setup - run provision setup first
if [ "${setupPhase}" == "setup" ]; then
echo "Calling _bootstrap.setup.sh for basic setup tasks .." >> $logFile
echo "Calling _provision.setup.sh for basic setup tasks .." >> $logFile
sudo /home/admin/_provision.setup.sh
if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
@ -493,20 +500,9 @@ if [ ${isMounted} -eq 0 ]; then
fi
fi
# if update - run provision update migration first
if [ "${setupPhase}" == "update" ]; then
echo "Calling _bootstrap.update.sh for possible update migrations .." >> $logFile
sudo /home/admin/_provision.update.sh
if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
echo "This can also happen if _provision.update.sh has syntax errros" >> $logFile
exit 1
fi
fi
# if update - run provision update migration first
# if migration - run the migration provision first
if [ "${setupPhase}" == "migration" ]; then
echo "Calling _bootstrap.migration.sh for possible update migrations .." >> $logFile
echo "Calling _provision.migration.sh for possible migrations .." >> $logFile
sudo /home/admin/_provision.migration.sh
if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
@ -515,6 +511,17 @@ if [ ${isMounted} -eq 0 ]; then
fi
fi
# if update/recovery/migration
if [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then
echo "Calling _provision.update.sh .." >> $logFile
sudo /home/admin/_provision.update.sh
if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
echo "This can also happen if _provision.update.sh has syntax errros" >> $logFile
exit 1
fi
fi
echo "Calling _bootstrap.provision.sh for general system provisioning (${setupPhase}) .." >> $logFile
sudo /home/admin/_provision_.sh
if [ "$?" != "0" ]; then

View File

@ -35,14 +35,12 @@ function repair() {
# command: restart
function restart() {
cd /home/admin
./XXshutdown.sh reboot
/home/admin/config.scripts/blitz.shutdown.sh reboot
}
# command: sourcemode
function sourcemode() {
cd /home/admin
./98repairMenu.sh sourcemode
/home/admin/config.scripts/blitz.copychain.sh source
}
# command: check
@ -50,6 +48,11 @@ function check() {
/home/admin/config.scripts/blitz.configcheck.py
}
# command: release
function release() {
/home/admin/config.scripts/blitz.preparerelease.sh
}
# command: debug
function debug() {
cd /home/admin
@ -65,8 +68,7 @@ function patch() {
# command: off
function off() {
cd /home/admin
./XXshutdown.sh
/home/admin/config.scripts/blitz.shutdown.sh
}
# command: github

View File

@ -22,20 +22,6 @@ echo "# _provision.setup.sh" >> ${logFile}
echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provision Setup'/g" ${infoFile}
###################################
# Set Password A
if [ "${passwordA}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='config: missing passwordA'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing passwordA in (${setupFile})!" >> ${logFile}
exit 1
fi
echo "SETTING PASSWORD A" >> ${logFile}
sudo /home/admin/config.scripts/blitz.setpassword.sh a "${passwordA}" >> ${logFile}
###################################
# Preserve SSH keys
# just copy dont link anymore

View File

@ -9,8 +9,8 @@ infoFile="/home/admin/raspiblitz.info"
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# SETUPFILE - configuration of RaspiBlitz
setupFile="/mnt/hdd/raspiblitz.conf"
# SETUPFILE - - setup data of RaspiBlitz
setupFile="/var/cache/raspiblitz/temp/raspiblitz.setup"
# log header
echo "" >> ${logFile}
@ -60,6 +60,20 @@ fi
echo "prechecks OK" >> ${logFile}
###################################
# Set Password A
if [ "${passwordA}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='config: missing passwordA'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing passwordA in (${setupFile})!" >> ${logFile}
exit 1
fi
echo "SETTING PASSWORD A" >> ${logFile}
sudo /home/admin/config.scripts/blitz.setpassword.sh a "${passwordA}" >> ${logFile}
# MIGRATION - DATA CONVERSION when updating config
# this is the place if on a future version change
# a conversion of config data or app data is needed
@ -219,6 +233,22 @@ else
echo "OK - version of config data is up to date" >> ${logFile}
fi
# start network service
echo ""
echo "*** Start ${network} ***" >> ${logFile}
sudo sed -i "s/^message=.*/message='Blockchain Testrun'/g" ${infoFile}
echo "- This can take a while .." >> ${logFile}
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 >> ${logFile}
sudo systemctl enable ${network}d.service >> ${logFile}
sudo systemctl start ${network}d.service >> ${logFile}
# start lightning service
echo "Starting LND Service ..." >> ${logFile}
sudo systemctl enable lnd >> ${logFile}
sudo systemctl start lnd >> ${logFile}
echo "END Migration/Init" >> ${logFile}
exit 0

View File

@ -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
@ -651,6 +724,11 @@ else
sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${datadisk} >> ${logFile}
fi
# MAKE SURE SERVICES ARE RUNNING
echo "Make sure main services are running .." >> ${logFile}
sudo systemctl start ${network}d
sudo systemctl start lnd
echo "DONE - Give raspi some cool off time after hard building .... 5 secs sleep" >> ${logFile}
sleep 5

View File

@ -1,57 +0,0 @@
#!/bin/bash
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# managing the copy of blockchain data over LAN"
echo "# blitz.copyblockchain.sh [status]"
echo "error='missing parameters'"
exit 1
fi
# 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
# if no other
echo "error='unknown command'"
exit 1

View File

@ -0,0 +1,397 @@
#!/bin/bash
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
# 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.copychain.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)
clear
case $CHOICE in
MACOS) echo "Steve";;
LINUX) echo "Linus";;
WINDOWS) echo "Bill";;
BLITZ) echo "Satoshi";;
*) exit 1;;
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
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
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
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 "*********************************************"
# 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
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
exit 1
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"
exit 1
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"
exit 1
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
exit 1
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"
exit 1
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 one sync loop done ... will test in next loop 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=ready/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

View File

@ -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)

View File

@ -377,7 +377,7 @@ if [ "$1" = "export-gui" ]; then
read key
echo "Shutting down ...."
sleep 4
/home/admin/XXshutdown.sh
/home/admin/config.scripts/blitz.shutdown.sh
exit 0
fi

View File

@ -144,15 +144,15 @@ if [ "$1" = "send" ]; then
# now parse settings from config and use to send the message
if [ "${notifyMethod}" = "ext" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py ext ${notifyExtCmd} "$2"
/usr/bin/python3 /home/admin/config.scripts/blitz.sendnotification.py ext ${notifyExtCmd} "$2"
elif [ "${notifyMethod}" = "mail" ]; then
if [ "${notifyMailEncrypt}" = "on" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" --cert "${notifyMailToCert}" --encrypt ${notifyMailTo} "${@:3}" "$2"
/usr/bin/python3 /home/admin/config.scripts/blitz.sendnotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" --cert "${notifyMailToCert}" --encrypt ${notifyMailTo} "${@:3}" "$2"
else
/usr/bin/python3 /home/admin/XXsendNotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" "${notifyMailTo}" "${@:3}" "$2"
/usr/bin/python3 /home/admin/config.scripts/blitz.sendnotification.py mail --from-address "${notifyMailFromAddress}" --from-name "${notifyMailFromName}" "${notifyMailTo}" "${@:3}" "$2"
fi
elif [ "${notifyMethod}" = "slack" ]; then
/usr/bin/python3 /home/admin/XXsendNotification.py slack -h "$2"
/usr/bin/python3 /home/admin/config.scripts/blitz.sendnotification.py slack -h "$2"
else
echo "unknown notification method - check /mnt/hdd/raspiblitz.conf"
fi

View File

@ -453,7 +453,7 @@ fi
# when started with menu ... reboot when done
if [ "${reboot}" == "1" ]; then
echo "Now rebooting to activate changes ..."
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
else
echo "..."
fi

View File

@ -1,5 +1,5 @@
#!/bin/bash
# for reboot call: sudo /home/admin/XXshutdown.sh reboot
# for reboot call: sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
# use this script instead of dirct shutdown command to:
# 1) give UI the info that a reboot/shutdown is now happening

View File

@ -44,7 +44,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# some APC UPS were not running stable below 90% Battery - so start shutdown at 95% remaining
sudo sed -i "s/^BATTERYLEVEL.*/BATTERYLEVEL 95/g" /etc/apcupsd/apcupsd.conf
sudo sed -i "s/^ISCONFIGURED=.*/ISCONFIGURED=yes/g" /etc/default/apcupsd
sudo sed -i "s/^SHUTDOWN=.*/SHUTDOWN=\/home\/admin\/XXshutdown.sh/g" /etc/apcupsd/apccontrol
sudo sed -i "s/^SHUTDOWN=.*/SHUTDOWN=\/home\/admin\/config.scripts\/blitz.shutdown.sh/g" /etc/apcupsd/apccontrol
sudo sed -i "s/^WALL=.*/#WALL=wall/g" /etc/apcupsd/apccontrol
sudo systemctl enable apcupsd
sudo systemctl start apcupsd

View File

@ -86,7 +86,7 @@ configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null|
#############################################
# check for internet connection
online=0
if [ ${#dnsServer} -gt 0 ]; then
if [ "${dnsServer}" != "" ]; then
# re-test with user set dns server
online=$(ping ${dnsServer} -c 1 -W 2 | grep -c '1 received')
fi

View File

@ -100,4 +100,4 @@ sleep 4
# clean logs (to prevent a false reindex detection)
sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null
# reboot
sudo /home/admin/XXshutdown.sh reboot
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot

View File

@ -1,51 +0,0 @@
#!/bin/bash
# this is more a todo list of things that got removed from oter parts of the old setup/login and need to find a new place/home
############# SCB activation
# check if there is a channel.backup to activate
gotSCB=$(ls /home/admin/channel.backup 2>/dev/null | grep -c 'channel.backup')
if [ ${gotSCB} -eq 1 ]; then
echo "*** channel.backup Recovery ***"
lncli --chain=${network} restorechanbackup --multi_file=/home/admin/channel.backup 2>/home/admin/.error.tmp
error=`cat /home/admin/.error.tmp`
rm /home/admin/.error.tmp 2>/dev/null
if [ ${#error} -gt 0 ]; then
# output error message
echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo "${error}"
# check if its possible to give background info on the error
notMachtingSeed=$(echo $error | grep -c 'unable to unpack chan backup')
if [ ${notMachtingSeed} -gt 0 ]; then
echo "--> ERROR BACKGROUND:"
echo "The WORD SEED is not matching the channel.backup file."
echo "Either there was an error in the word seed list or"
echo "or the channel.backup file is from another RaspiBlitz."
echo
fi
# basic info on error
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
echo "You can try after full setup to restore channel.backup file again with:"
echo "lncli --chain=${network} restorechanbackup --multi_file=/home/admin/channel.backup"
echo
echo "Press ENTER to continue for now ..."
read key
else
mv /home/admin/channel.backup /home/admin/channel.backup.done
dialog --title " OK channel.backup IMPORT " --msgbox "
LND accepted the channel.backup file you uploaded.
It will now take around a hour until you can see,
if LND was able to recover funds from your channels.
" 9 56
fi
fi

View File

@ -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

View File

@ -0,0 +1,124 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup"
source ${SETUPFILE}
############################################
# SHOW SEED WORDS AFTER SETUP
if [ "${setupPhase}" == "setup" ] && [ "${seedwords6x4NEW}" != "" ]; then
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${seedwords6x4NEW}" 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
fi
############################################
# BLOCKCHAIN INFO & OPTIONS
if [ "${syncProgress}" != "" ] && [ "${network}" == "bitcoin" ] && [ ${syncProgress} -lt 75 ]; then
# offer choice to copy blockchain over LAN
OPTIONS=()
OPTIONS+=(VALIDATE "Run full self sync/validation (takes long)")
OPTIONS+=(COPY "Copy from Computer/RaspiBlitz over LAN (±6h)")
CHOICESUB=$(dialog --backtitle "RaspiBlitz" --clear --title " Blockchain Sync/Validation " --menu "\nYour Blockchain sync is just at ${syncProgress}%\nThe full validation might take multiple days to finish.\n\nHow do you want to proceed:" 13 63 7 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICESUB}" == "COPY" ]; then
/home/admin/config.scripts/blitz.copychain.sh target
fi
exit 1
fi
############# SCB activation
# check if there is a channel.backup to activate
gotSCB=$(ls /home/admin/channel.backup 2>/dev/null | grep -c 'channel.backup')
if [ ${gotSCB} -eq 1 ]; then
echo "*** channel.backup Recovery ***"
lncli --chain=${network} restorechanbackup --multi_file=/home/admin/channel.backup 2>/home/admin/.error.tmp
error=`cat /home/admin/.error.tmp`
rm /home/admin/.error.tmp 2>/dev/null
if [ ${#error} -gt 0 ]; then
# output error message
echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo "${error}"
# check if its possible to give background info on the error
notMachtingSeed=$(echo $error | grep -c 'unable to unpack chan backup')
if [ ${notMachtingSeed} -gt 0 ]; then
echo "--> ERROR BACKGROUND:"
echo "The WORD SEED is not matching the channel.backup file."
echo "Either there was an error in the word seed list or"
echo "or the channel.backup file is from another RaspiBlitz."
echo
fi
# basic info on error
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
echo "You can try after full setup to restore channel.backup file again with:"
echo "lncli --chain=${network} restorechanbackup --multi_file=/home/admin/channel.backup"
echo
echo "Press ENTER to continue for now ..."
read key
else
mv /home/admin/channel.backup /home/admin/channel.backup.done
dialog --title " OK channel.backup IMPORT " --msgbox "
LND accepted the channel.backup file you uploaded.
It will now take around a hour until you can see,
if LND was able to recover funds from your channels.
" 9 56
fi
fi
############################################
# SETUP DONE CONFIRMATION (Konfetti Moment)
# when coming from fresh setup
if [ "${setupPhase}" == "setup" ]; then
clear
whiptail --title " SetUp Done " --msgbox "\
Your RaspiBlitz Setup is done. Welcome new node operator! :D\n
There might now be some waiting time until your Blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
Its safe to logout during sync and return later.\n
" 12 65
# when coming from migration from other node
elif [ "${setupPhase}" == "migration" ]; then
clear
whiptail --title " Migration Done " --msgbox "\
Your running now RaspiBlitz. Welcome to the family! :D\n
There might now be some waiting time until your Blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
Its safe to logout during sync and return later.\n
" 12 65
# just in case then from another phase
else
clear
echo "Missing Final Done Dialog for: ${setupPhase}"
echo "PRESS ENTER"
read key
fi
echo "Starting ... (please wait)"
# signal to backend that all is good and it can continue
sudo sed -i "s/^state=.*/state='finalready'/g" /home/admin/raspiblitz.info

View File

@ -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
@ -128,6 +134,7 @@ if [ "${setupPhase}" == "setup" ]; then
fi
# run formatting
echo "Running Format: (${filesystem}) (${hddCandidate})"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${filesystem} ${hddCandidate})
if [ "${error}" != "" ]; then
echo "FAIL ON FORMATTING THE DRIVE:"
@ -136,10 +143,6 @@ if [ "${setupPhase}" == "setup" ]; then
exit 1
fi
# DEBUG EXIT
echo "OK Format done"
exit 1
elif [ "${userChoice}" == "2" ]; then
# KEEP BLOCKCHAIN + DLETE ALL THE REST

View File

@ -5,7 +5,7 @@
blockchainName=$1
keepBlockchain=0
if [ ${blockchainName} != "" ]; then
if [ "${blockchainName}" != "" ]; then
whiptail --title " BLOCKCHAIN DATA FOUND " --yes-button "USE BLOCKCHAIN" --no-button "DELETE" --yesno "We found ${blockchainName} blockchain data on your HDD/SSD.

View File

@ -38,7 +38,7 @@ backtitle="RaspiBlitz ${codeVersion} / ${localip} / ${eventID}"
# 1) WELL DEFINED EVENTS
################################################
if [ "${eventID}" == "starting" ] || [ "${eventID}" == "system-init" ]; then
if [ "${eventID}" == "starting" ] || [ "${eventID}" == "system-init" ] || [ "${eventID}" == "ready" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Starting RaspiBlitz
@ -77,7 +77,7 @@ elif [ "${eventID}" == "provision" ] || [ "${eventID}" == "recovering" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Upgrade/Recover/Provision
---> ${contentString}
Please keep running until reboot.
Please keep running until done.
" 7 40
elif [ "${eventID}" == "repair" ] && [ "${mode}" == "lcd" ]; then
@ -88,6 +88,30 @@ ssh admin@${localip}
Use your Password A
" 7 41
elif [ "${eventID}" == "copysource" ] && [ "${mode}" == "lcd" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Repair-Mode - Providing Blockchain
ssh admin@${localip}
Use your Password A
" 7 41
elif [ "${eventID}" == "copystation" ] && [ "${mode}" == "lcd" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Copy-Station Mode
ssh admin@${localip}
Use your Password A
" 7 41
elif [ "${eventID}" == "copytarget" ] && [ "${mode}" == "lcd" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Receiving Blockchain over LAN
ssh admin@${localip}
Use your Password A
" 7 41
elif [ "${eventID}" == "inconsistentsystem" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
@ -144,7 +168,7 @@ Use password: raspiblitz
" 8 41
fi
elif [ "${eventID}" == "waitfinal" ]; then
elif [ "${eventID}" == "waitfinal" ] || [ "${eventID}" == "finalready" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Setup-Done - Login for Details:
@ -201,14 +225,6 @@ Local Network seems OK but no Internet.
Is your router still online?
" 7 43
elif [ "${eventID}" = "noInternet" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for Internet ...
Local Network seems OK but no Internet.
Is your router still online?
" 7 43
elif [ "${eventID}" == "inspect-hdd" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "

View File

@ -1,66 +0,0 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup"
source ${SETUPFILE}
############################################
# SHOW SEED WORDS AFTER SETUP
if [ "${setupPhase}" == "setup" ]; then
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${seedwords6x4NEW}" 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
fi
############################################
# BLOCKCHAIN INFO & OPTIONS
if [ ${syncProgress} -lt 75 ]; then
clear
echo "Your Blockchain is at ${syncProgress}% - this might take multiple days to validate."
echo "TODO: Option COPY OVER LAN IF BITCOIN"
echo "TODO: MAKE SURE THAT background.service is running from beginng!"
echo "PRESS ENTER"
read key
fi
############################################
# SETUP DONE CONFIRMATION (Konfetti Moment)
# when coming from fresh setup
if [ "${setupPhase}" == "setup" ]; then
clear
echo "Hooray :) Everything is Setup!"
echo "PRESS ENTER"
read key
# when coming from migration from other node
elif [ "${setupPhase}" == "migration" ]; then
clear
echo "Hooray :) Your Migration to RaspiBlitz is Done!"
echo "PRESS ENTER"
read key
# just in case then from another phase
else
clear
echo "Missing Final Done Dialog for: ${setupPhase}"
echo "PRESS ENTER"
read key
fi
echo "Starting ..."
# signal to backend that all is good and it can continue
sudo sed -i "s/^state=.*/state='finalready'/g" /home/admin/raspiblitz.info