mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-11 21:29:29 +02:00
Merge branch 'pre-1.7.1' into cblitz-merge
This commit is contained in:
commit
afa6854df7
20
FAQ.md
20
FAQ.md
@ -56,6 +56,7 @@
|
||||
- [Why is my node not routing?](#why-is-my-node-not-routing)
|
||||
- [How can I update LND or bitcoind even before the next RaspiBlitz update?](#how-can-i-update-lnd-or-bitcoind-even-before-the-next-raspiblitz-update)
|
||||
- [I cannot connect per SSH to my RaspiBlitz. What can I do?](#i-cannot-connect-per-ssh-to-my-raspiblitz-what-to-do)
|
||||
- [How to SSH over Tor?](#how-to-ssh-over-tor)
|
||||
- [How do I setup port-forwarding with a SSH tunnel?](#how-to-setup-port-forwarding-with-a-ssh-tunnel)
|
||||
- [How do I setup just a port-forwarding user on my public server?](#how-to-setup-just-a-port-forwarding-user-on-my-public-server)
|
||||
- [How do I connect a UPS to the RaspiBlitz?](#how-to-connect-a-ups-to-the-raspiblitz)
|
||||
@ -234,7 +235,7 @@ If you still can SSH in and HDD is readable, we can try to rescue/export your LN
|
||||
To rescue/export your Lightning data from a RaspiBlitz (since v1.1):
|
||||
|
||||
* SSH into your RaspiBlitz and EXIT to terminal from the menu.
|
||||
* then run: `/home/admin/config.scripts/lnd.rescue.sh backup`
|
||||
* then run: `/home/admin/config.scripts/lnd.backup.sh lnd-export-gui`
|
||||
* follow the instructions of the script.
|
||||
|
||||
This will create a lnd-rescue file (ends on gz.tar) that contains all the data from the LND. The script offers you a command to transfer the lnd-rescue file to your laptop. If the transfer was successful you can now setup a fresh RaspiBlitz. Do all the setup until you have a clean new Lightning node running - just without any funding or channels.
|
||||
@ -242,7 +243,7 @@ This will create a lnd-rescue file (ends on gz.tar) that contains all the data f
|
||||
Then to restore your old LND data and to recover your funds and channels:
|
||||
|
||||
* SSH into your new RaspiBlitz and EXIT to terminal from the menu.
|
||||
* then run: `/home/admin/config.scripts/lnd.rescue.sh restore`
|
||||
* then run: `/home/admin/config.scripts/lnd.backup.sh lnd-import-gui`
|
||||
* follow the instructions of the script.
|
||||
|
||||
This script will offer you a way to transfer the lnd-rescue file from your laptop to the new RaspiBlitz and will restore the old data. LND then gets restarted for you, and after some time it should show you the status screen again with your old funds and channels.
|
||||
@ -713,6 +714,21 @@ If that doesn't work, try to ping the IP of the RaspiBlitz with `ping [IP-of-Ras
|
||||
|
||||
If you've checked those and SSH is still not working: Join the conversation on [GitHub Issue #420](https://github.com/rootzoll/raspiblitz/issues/420).
|
||||
|
||||
## How to SSH over Tor?
|
||||
|
||||
SSH is already encrypted, why would I want to use it with Tor?
|
||||
* Remote access when away from LAN.
|
||||
* Anonymized access - Someone sniffing the traffic don't know where the server you are establishing a connection is, not the server side knows where the client is.
|
||||
|
||||
Create Hidden Service:
|
||||
`bash /home/admin/config.scripts/internet.hiddenservice.sh ssh 22 22`
|
||||
|
||||
SSH over Tor:
|
||||
`torsocks ssh admin@HiddenServiceAddress.onion`
|
||||
|
||||
Get the address:
|
||||
`sudo cat /mnt/hdd/tor/ssh/hostname`
|
||||
|
||||
## How to setup port-forwarding with a SSH tunnel?
|
||||
|
||||
To use a public server for port-forwarding thru a SSH tunnel you can use the following experimental script on the RaspiBlitz (since v1.2):
|
||||
|
30
README.md
30
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
*Build your own Lightning Node on a RaspberryPi with a nice Display.*
|
||||
|
||||
`Version 1.7.0 with lnd 0.12.1 and bitcoin 0.21.0 (or litecoin 0.18.1)`
|
||||
`Version 1.7.0 with lnd 0.12.1 (or c-lightning 0.10.0) and bitcoin 0.21.0 (or litecoin 0.18.1)`
|
||||
|
||||

|
||||
|
||||
@ -19,7 +19,7 @@ There are further Services that can be switched on:
|
||||
* **BTCPayServer** (Cryptocurrency Payment Processor) [details](https://btcpayserver.org)
|
||||
* **BTC-RPC-Explorer** (Bitcoin Blockchain Explorer) [details](https://github.com/janoside/btc-rpc-explorer)
|
||||
* **LNbits** (Lightning wallet/accounts System) [details](https://twitter.com/lnbits/status/1253700293440741377?s=20)
|
||||
* **SpecterDesktop** (Multisig Trezor, Ledger, COLDCARDwallet & Specter-DIY) [details](https://github.com/cryptoadvance/specter-desktop)
|
||||
* **SpecterDesktop** (Multisig Trezor, Ledger, COLDCARDwallet & Specter-DIY) [details](https://github.com/cryptoadvance/specter-desktop) [app connection guide](https://d11n.net/connect-specter-desktor-with-raspiblitz.html)
|
||||
* **Lightning Terminal (Loop, Pool & Faraday)** (Manage Channel Liquidity) [details](https://github.com/lightninglabs/lightning-terminal#lightning-terminal-lit)
|
||||
* **JoinMarket** (CoinJoin Service) [details](https://github.com/JoinMarket-Org/joinmarket-clientserver)
|
||||
* **ThunderHub** (Lightning Node Manager WebUI) [details](https://www.thunderhub.io/)
|
||||
@ -103,7 +103,6 @@ In the end your RaspiBlitz should look like this:
|
||||
|
||||
## Downloading the Software
|
||||
|
||||
There are two ways how you can install the RaspiBlitz software on your RaspberryPi:
|
||||
|
||||
|Method|Install the image|Build the sd card|
|
||||
|------|-----------------|-----------------|
|
||||
@ -111,12 +110,17 @@ There are two ways how you can install the RaspiBlitz software on your Raspberry
|
||||
|Difficulty level|Easy|Medium|
|
||||
|Pros|Make Blitz accessible to everyone|You don't need to trust us, build from your own forked repository|
|
||||
|Cons|You have to trust the mantainer image binaries|You need to read the build_sdcard.sh parameters in order for the customization to suit your needs|
|
||||
|Instructions|[Download image](https://raspiblitz.fulmo.org/images/raspiblitz-v1.7.0-2021-04-25.img.gz) and [Flash the sd card](https://github.com/rootzoll/raspiblitz/tree/master#write-the-sd-card-image-to-your-sd-card)|[Build your own sd card image](#build-the-sd-card-image)|
|
||||
|Verify what?|SHA-256 (below) and/or [Signature](https://raspiblitz.fulmo.org/images/raspiblitz-v1.7.0-2021-04-25.img.gz.sig)|All of the code, don't trust, verify|
|
||||
|Instructions|[Download image](https://raspiblitz.fulmo.org/images/raspiblitz-v1.7.0-2021-04-25.img.gz) and [Flash the sd card](README.md#write-the-sd-card-image-to-your-sd-card)|[Build your own sd card image](#build-the-sd-card-image)|
|
||||
|Verify what?|[Signature file](https://raspiblitz.fulmo.org/images/raspiblitz-v1.7.0-2021-04-25.img.gz.sig) and [verify the Sig](FAQ.md#how-to-verify-the-sd-card-image-after-download) OR SHA-256 (below)|All of the code, don't trust, verify|
|
||||
|
||||
If downloading the mantainer sd card image, the shasum is:
|
||||
If downloading the mantainer sd card image:
|
||||
* GPG 64-bit: 1C73 060C 7C17 6461
|
||||
* SHA-256: e6d70ac1662af3e90e57bee8c50e9a7925239431892e1916c2be80e519befc3f
|
||||
|
||||
Which verification method should I used: Hash or Signature?
|
||||
* Signed file prove to you that the SD card image was actually built by the lead developer of the RaspiBlitz project. (Safest)
|
||||
* Hash function checks file integrity. (Secure)
|
||||
|
||||
The mantainer sd card image can also be downloaded via torrent:
|
||||
* [assets/raspiblitz-v1.7.0-2021-04-25.img.gz.torrent](https://github.com/rootzoll/raspiblitz/raw/v1.7/home.admin/assets/raspiblitz-v1.7.0-2021-04-25.img.gz.torrent)
|
||||
|
||||
@ -661,8 +665,6 @@ The goal of SpecterDesktop is to make a convenient and user-friendly GUI around
|
||||
|
||||
After install, you will see a new `SPECTER` option in the SSH main menu - it will give you all the information you need to start using it.
|
||||
|
||||
As an alternative to runninf Specter on directly on the RaspiBlitz, there is a Specter Desktop version that runs on your laptop. Here is a [guide to connect the specter laptop app] (https://d11n.net/connect-specter-desktor-with-raspiblitz.html) to your RaspiBlitz Bitcoin fullnode.
|
||||
|
||||
##### Mempool Explorer
|
||||
|
||||

|
||||
@ -774,7 +776,7 @@ Opens an ad-hoc webserver so that you can download the files in your local netwo
|
||||
|
||||
*This is the least secure way to transfer those files - everybody in your local network has access to those file during download. Remember with the Admin-Macaroon somebody could takeover your node and spend all your funds. Just use as last fallback.*
|
||||
|
||||
###### Hex-String
|
||||
####### Hex-String
|
||||
|
||||
The Macaroons and TLS.cert files can be copy+pasted as Hex-Strings from RaspiBlitz to any other app that supports that format. If you choose this option, RaspiBlitz will print all the files for you as Hex-String to do so.
|
||||
|
||||
@ -827,12 +829,6 @@ The `REPAIR` menu gives you options to check and reset your RaspiBlitz.
|
||||
|
||||
The options are explained in detail below:
|
||||
|
||||
##### HARDWARE: Run Hardware Test
|
||||
|
||||
This will start the hardware test to identify if your RaspiBlitz is in good shape and can provide a stable service.
|
||||
|
||||
Use this option if you see under-voltage reports on your LCD display or you think your RaspiBlitz gets very hot.
|
||||
|
||||
##### SOFTWARE: Run Software Tests (DebugReport)
|
||||
|
||||
This will print out a lot of information that can be used to find software problems.
|
||||
@ -970,7 +966,7 @@ Before you start migration:
|
||||
* if you have on-chain funds on your old node - make sure to have the backup seed words
|
||||
* if you have lightning channels open on your old node - make sure to have downloaded the latest Static Channel Backup file to your laptop
|
||||
|
||||
Also be aware that at the moment RaspiBlitz can only transfere your blockchain and LND wallet data (including channels) over to RaspiBlitz. Any data/pairing of additional apps cannot be transfered and may get lost.
|
||||
Also be aware that at the moment RaspiBlitz can only transfer your blockchain and LND wallet data (including channels) over to RaspiBlitz. Any data/pairing of additional apps cannot be transfered and may get lost.
|
||||
|
||||
Instructions for Migration:
|
||||
* shutdown your old node
|
||||
@ -986,7 +982,7 @@ Now RaspiBlitz should show you that old data from your node was detected and off
|
||||
* Login per SSH as before and reset the passwords (`FINAL RECOVERY LOGIN` on LCD). Then a final reboot will happen.
|
||||
* Login per SSH with your new password A & unlock LND wallet with password C. Now blockchain needs to catch up and then your RaspiBlitz should be ready and show you (under INFO) your on-chain & channel balance.
|
||||
|
||||
If you dont have an LCD or HDMI monitor connectec it might be a bit difficult to see what state your RaspiBlitz is in. Just (re-)try to login per SSH again after the reboots (might always take some time until it reacts).
|
||||
If you dont have an LCD or HDMI monitor connected it might be a bit difficult to see what state your RaspiBlitz is in. Just (re-)try to login per SSH again after the reboots (might always take some time until it reacts).
|
||||
|
||||
## Interface / APIs
|
||||
|
||||
|
@ -20,6 +20,8 @@ function usage() {
|
||||
verbose=0
|
||||
pause=12
|
||||
|
||||
# this is used by touchscreen and command 'satus'
|
||||
# TODO: remove on v1.8
|
||||
while [[ "$1" == -* ]]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
@ -82,222 +84,28 @@ while :
|
||||
# CHECK BASIC DATA
|
||||
###########################
|
||||
|
||||
# get the local network IP to be displayed on the lCD
|
||||
source <(sudo /home/admin/config.scripts/internet.sh status)
|
||||
|
||||
# waiting for IP in general
|
||||
if [ ${#localip} -eq 0 ]; then
|
||||
l1="Waiting for Network ...\n"
|
||||
l2="Not able to get local IP.\n"
|
||||
l3="LAN cable connected? WIFI lost?\n"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion}" --infobox "$l1$l2$l3" 5 40
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
# waiting for Internet connection
|
||||
if [ ${online} -eq 0 ]; then
|
||||
l1="Waiting for Internet ...\n"
|
||||
l2="Local Network seems OK but no Internet.\n"
|
||||
l3="Is router still online?\n"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2$l3" 5 45
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
# get config info if already available (with state value)
|
||||
source ${infoFile}
|
||||
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
|
||||
if [ ${configExists} -eq 1 ]; then
|
||||
source ${configFile}
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars)
|
||||
shopt -s expand_aliases
|
||||
alias bitcoincli_alias="$bitcoincli_alias"
|
||||
alias lncli_alias="$lncli_alias"
|
||||
alias lightningcli_alias="$lightningcli_alias"
|
||||
fi
|
||||
|
||||
# reboot info
|
||||
if [ "${state}" = "reboot" ]; then
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion}" --infobox "Waiting for Reboot ..." 3 30
|
||||
sleep 20
|
||||
continue
|
||||
fi
|
||||
if [ "${setupPhase}" != "done" ]; then
|
||||
|
||||
# shutdown info
|
||||
if [ "${state}" = "shutdown" ]; then
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion}" --infobox "Waiting for Shutdown ..." 3 30
|
||||
sleep 20
|
||||
continue
|
||||
fi
|
||||
|
||||
# waiting for DHCP in general
|
||||
if [ "${state}" = "noDHCP" ]; then
|
||||
l1="Waiting for DHCP ...\n"
|
||||
l2="Not able to get local IP.\n"
|
||||
l3="Check you router if constant.\n"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip})" --infobox "$l1$l2$l3" 5 40
|
||||
# show status info during boot & setup & repair on LCD
|
||||
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}" lcd
|
||||
sleep 1
|
||||
continue
|
||||
|
||||
fi
|
||||
|
||||
# if no information available from files - set default
|
||||
if [ ${#setupStep} -eq 0 ]; then
|
||||
setupStep=0
|
||||
fi
|
||||
|
||||
# before setup even started
|
||||
if [ ${setupStep} -eq 0 ]; then
|
||||
|
||||
# check for internet connection
|
||||
online=$(ping 1.0.0.1 -c 1 -W 2 | grep -c '1 received')
|
||||
if [ ${online} -eq 0 ]; then
|
||||
# re-test with other server
|
||||
online=$(ping 8.8.8.8 -c 1 -W 2 | grep -c '1 received')
|
||||
fi
|
||||
if [ ${online} -eq 0 ]; then
|
||||
# re-test with other server
|
||||
online=$(ping 208.67.222.222 -c 1 -W 2 | grep -c '1 received')
|
||||
fi
|
||||
|
||||
if [ ${online} -eq 0 ]; then
|
||||
message="no internet connection"
|
||||
|
||||
# when in presync - get more info on progress
|
||||
elif [ "${state}" = "presync" ]; then
|
||||
blockchaininfo="$(sudo -u root bitcoin-cli --conf=/home/admin/assets/bitcoin.conf getblockchaininfo 2>/dev/null)"
|
||||
message="starting"
|
||||
if [ ${#blockchaininfo} -gt 0 ]; then
|
||||
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
|
||||
message=$(echo $message | awk '{printf( "%.2f%%", 100 * $1)}')
|
||||
fi
|
||||
|
||||
# when old data - improve message
|
||||
elif [ "${state}" = "sdtoosmall" ]; then
|
||||
message="SDCARD TOO SMALL - min 16GB"
|
||||
|
||||
# when no HDD - improve message
|
||||
elif [ "${state}" = "noHDD" ]; then
|
||||
message="Connect external HDD/SSD"
|
||||
fi
|
||||
|
||||
# setup process has not started yet
|
||||
l1="Login to your RaspiBlitz with:\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: raspiblitz\n"
|
||||
|
||||
if [ "${state}" = "recovering" ]; then
|
||||
l1="Recovering please wait ..\n"
|
||||
fi
|
||||
|
||||
boxwidth=$((${#localip} + 24))
|
||||
sleep 3
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) - ${message}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
|
||||
# check if recovering/upgrade is running
|
||||
if [ "${state}" = "recovering" ]; then
|
||||
if [ ${#message} -eq 0 ]; then
|
||||
message="Setup in Progress"
|
||||
fi
|
||||
l1="Upgrade/Recover/Provision\n"
|
||||
l2="---> ${message}\n"
|
||||
l3="Please keep running until reboot."
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${setupStep} ${localip}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
# if freshly recovered
|
||||
recoveredInfoExists=$(sudo ls /home/admin/recover.flag 2>/dev/null | grep -c '.flag')
|
||||
if [ ${recoveredInfoExists} -gt 0 ]; then
|
||||
l1="FINAL RECOVER LOGIN NEEDED:\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: raspiblitz\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state})" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
# if re-indexing
|
||||
if [ "${state}" = "reindex" ]; then
|
||||
l1="REINDEXING BLOCKCHAIN\n"
|
||||
l2="To monitor & detect finish:\n"
|
||||
l3="ssh admin@${localip}\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state})" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
# when setup is in progress - password has been changed
|
||||
if [ ${setupStep} -lt 100 ]; then
|
||||
l1="Login to your RaspiBlitz with:\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use your Password A\n"
|
||||
boxwidth=$((${#localip} + 24))
|
||||
sleep 3
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} ${localip} - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 7
|
||||
continue
|
||||
fi
|
||||
|
||||
###########################
|
||||
# DISPLAY AFTER SETUP
|
||||
###########################
|
||||
|
||||
if [ "${state}" = "repair" ]; then
|
||||
l1="Repair Mode\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: PasswordA\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${setupStep} ${localip}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${state}" = "reboot" ]; then
|
||||
l1="Reboot needed.\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: PasswordA\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${setupStep} ${localip}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${state}" = "retorrent" ]; then
|
||||
l1="Repair Mode- TORRENT\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: PasswordA\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${setupStep} ${localip}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${state}" = "recopy" ]; then
|
||||
l1="Repair Mode - COPY\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="Use password: PasswordA\n"
|
||||
boxwidth=$((${#localip} + 28))
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${setupStep} ${localip}" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${state}" = "copystation" ]; then
|
||||
l1="COPY STATION MODE\n"
|
||||
l2="${message}"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2" 6 56
|
||||
sleep 2
|
||||
continue
|
||||
fi
|
||||
|
||||
# TODO: ALSO SEPERATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
|
||||
# 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
|
||||
@ -306,23 +114,6 @@ while :
|
||||
continue
|
||||
fi
|
||||
|
||||
# perform config check
|
||||
configCheck=$(/home/admin/config.scripts/blitz.configcheck.py)
|
||||
if [ $? -eq 0 ]; then
|
||||
configValid=1
|
||||
# echo "Config Valid!"
|
||||
else
|
||||
configValid=0
|
||||
# echo "Config Not Valid!"
|
||||
l1="POTENTIAL CONFIG ERROR FOUND\n"
|
||||
l2="ssh admin@${localip}\n"
|
||||
l3="use Password A\n"
|
||||
l4="Run on Terminal command: check"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} cfg-err ${localip}" --infobox "$l1$l2$l3$l4" 6 50
|
||||
sleep 20
|
||||
continue
|
||||
fi
|
||||
|
||||
# no special case - show status display
|
||||
/home/admin/00infoBlitz.sh
|
||||
sleep 5
|
||||
|
@ -346,9 +346,6 @@ case $CHOICE in
|
||||
;;
|
||||
REPAIR)
|
||||
/home/admin/98repairMenu.sh
|
||||
if [ $? -eq 99 ]; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
PASSWORD)
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh
|
||||
@ -357,44 +354,41 @@ case $CHOICE in
|
||||
/home/admin/99updateMenu.sh
|
||||
;;
|
||||
REBOOT)
|
||||
clear
|
||||
confirmation "Are you sure?" "Reboot" "Cancel" true 7 40
|
||||
confirmationReboot=$?
|
||||
if [ $confirmationReboot -eq 0 ]; then
|
||||
clear
|
||||
confirmation "Are you sure?" "Reboot" "Cancel" true 7 40
|
||||
confirmationReboot=$?
|
||||
if [ $confirmationReboot -eq 0 ]; then
|
||||
clear
|
||||
echo ""
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
OFF)
|
||||
clear
|
||||
confirmation "Are you sure?" "PowerOff" "Cancel" true 7 40
|
||||
confirmationShutdown=$?
|
||||
if [ $confirmationShutdown -eq 0 ]; then
|
||||
clear
|
||||
confirmation "Are you sure?" "PowerOff" "Cancel" true 7 40
|
||||
confirmationShutdown=$?
|
||||
if [ $confirmationShutdown -eq 0 ]; then
|
||||
clear
|
||||
echo ""
|
||||
sudo /home/admin/XXshutdown.sh
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
DELETE)
|
||||
sudo /home/admin/XXcleanHDD.sh
|
||||
sudo /home/admin/XXshutdown.sh reboot
|
||||
exit 0
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
echo "***********************************"
|
||||
echo "* RaspiBlitz Commandline"
|
||||
echo "* Here be dragons .. have fun :)"
|
||||
echo "***********************************"
|
||||
echo "Bitcoin command line options: bitcoin-cli help"
|
||||
echo "LND command line options: lncli -h"
|
||||
echo "Back to main menu use command: raspiblitz"
|
||||
echo
|
||||
exit 0
|
||||
exit 1
|
||||
esac
|
||||
|
||||
# go into loop - start script from beginning to load config/sate fresh
|
||||
/home/admin/00mainMenu.sh
|
||||
# forward exit code of submenu to outside loop
|
||||
# 0 = continue loop / everything else = break loop and exit to terminal
|
||||
exitCodeOfSubmenu=$?
|
||||
if [ "${exitCodeOfSubmenu}" != "0" ]; then
|
||||
echo "# submenu signaled exit code '${exitCodeOfSubmenu}' --> forward to outside loop"
|
||||
fi
|
||||
exit ${exitCodeOfSubmenu}
|
11
home.admin/00prepareSystem.sh
Executable file
11
home.admin/00prepareSystem.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/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
|
@ -1,7 +1,11 @@
|
||||
#!/bin/bash
|
||||
echo "For debug logs CTRL+C and: tail -n1000 -f raspiblitz.log"
|
||||
echo "or call the command 'debug' to see bigger report."
|
||||
echo "Starting the main menu ..."
|
||||
|
||||
#######################################
|
||||
# SSH USER INTERFACE
|
||||
# gets called when user logins per SSH
|
||||
# or calls 'raspiblitz' on the terminal
|
||||
#######################################
|
||||
echo "Starting SSH user interface ... (please wait)"
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
@ -9,21 +13,126 @@ configFile="/mnt/hdd/raspiblitz.conf"
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
|
||||
# use blitz.datadrive.sh to analyse HDD situation
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
if [ "${error}" != "" ]; then
|
||||
echo "# FAIL blitz.datadrive.sh status --> ${error}"
|
||||
echo "# Please report issue to the raspiblitz github."
|
||||
# check if raspiblitz.info exists
|
||||
systemInfoExists=$(ls ${infoFile} | grep -c "${infoFile}")
|
||||
if [ "${systemInfoExists}" != "1" ]; then
|
||||
echo "systemInfoExists(${systemInfoExists})"
|
||||
echo "FAIL: ${infoFile} does not exist .. which it should at this point."
|
||||
echo "Check logs & bootstrap.service for errors and report to devs."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if HDD is connected
|
||||
if [ "${isMounted}" == "0" ] && [ ${#hddCandidate} -eq 0 ]; then
|
||||
echo "***********************************************************"
|
||||
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart."
|
||||
echo "***********************************************************"
|
||||
vagrant=$(df | grep -c "/vagrant")
|
||||
if [ ${vagrant} -gt 0 ]; then
|
||||
# get system state information raspiblitz.info
|
||||
source ${infoFile}
|
||||
|
||||
# check that basic system phase/state information is available
|
||||
if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then
|
||||
echo "setupPhase(${setupPhase}) state(${state})"
|
||||
echo "FAIL: ${infoFile} does not contain important state information."
|
||||
echo "Check logs & bootstrap.service for errors and report to devs."
|
||||
exit 1
|
||||
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
|
||||
sudo touch /var/cache/raspiblitz/raspiblitz.status
|
||||
sudo chown admin:admin /var/cache/raspiblitz/raspiblitz.status
|
||||
sudo chmod 740 /var/cache/raspiblitz/raspiblitz.status
|
||||
|
||||
#####################################
|
||||
# SSH MENU LOOP
|
||||
# this loop runs until user exits or
|
||||
# an error drops user to terminal
|
||||
#####################################
|
||||
|
||||
exitMenuLoop=0
|
||||
doneIBD=0
|
||||
while [ ${exitMenuLoop} -eq 0 ]
|
||||
do
|
||||
|
||||
#####################################
|
||||
# Access fresh system info on every loop
|
||||
|
||||
# refresh system state information
|
||||
source ${infoFile}
|
||||
|
||||
# gather fresh status scan and store results in memory
|
||||
# TODO: move this into background loop and unify with redis data storage later
|
||||
sudo /home/admin/config.scripts/blitz.statusscan.sh > /var/cache/raspiblitz/raspiblitz.status
|
||||
source /var/cache/raspiblitz/raspiblitz.status
|
||||
|
||||
#####################################
|
||||
# ALWAYS: Handle System States
|
||||
#####################################
|
||||
|
||||
############################
|
||||
# LND Wallet Unlock
|
||||
|
||||
if [ "${walletLocked}" == "1" ]; then
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# SETUP MENU
|
||||
#####################################
|
||||
|
||||
# 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
|
||||
# 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=$?
|
||||
if [ "${exitMenuLoop}" != "0" ]; then break; fi
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# SETUP DONE DIALOGS
|
||||
#####################################
|
||||
|
||||
# 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
|
||||
continue
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# INITIAL BLOCKCHAIN SYNC (SUBLOOP)
|
||||
#####################################
|
||||
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ "${initialSync}" == "1" ]; then
|
||||
/home/admin/setup.scripts/eventBlockchainSync.sh ssh loop
|
||||
continue
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# MAIN MENU or BLOCKCHAIN SYNC
|
||||
#####################################
|
||||
|
||||
# when setup is done & state is ready .. jump to main menu
|
||||
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ]; then
|
||||
# MAIN MENU
|
||||
/home/admin/00mainMenu.sh
|
||||
# use the exit code from main menu as signal if menu loop should exited
|
||||
# 0 = continue loop / everything else = break loop and exit to terminal
|
||||
exitMenuLoop=$?
|
||||
if [ "${exitMenuLoop}" != "0" ]; then break; fi
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# DURING SETUP: Handle System States
|
||||
#####################################
|
||||
|
||||
if [ "${setupPhase}" != "done" ]; then
|
||||
|
||||
echo "# DURING SETUP: Handle System State (${state})"
|
||||
|
||||
# when no HDD on Vagrant - just print info & exit (admin info & exit)
|
||||
if [ "${state}" == "noHDD" ] && [ ${vagrant} -gt 0 ]; then
|
||||
echo "***********************************************************"
|
||||
echo "VAGRANT INFO"
|
||||
echo "***********************************************************"
|
||||
echo "To connect a HDD data disk to your VagrantVM:"
|
||||
echo "- shutdown VM with command: off"
|
||||
echo "- open your VirtualBox GUI and select RaspiBlitzVM"
|
||||
@ -35,9 +144,59 @@ if [ "${isMounted}" == "0" ] && [ ${#hddCandidate} -eq 0 ]; then
|
||||
echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB"
|
||||
echo "space on your laptop you can store the VDI file on an external drive."
|
||||
echo "***********************************************************"
|
||||
exit 1
|
||||
fi
|
||||
exit
|
||||
|
||||
# for all critical errors (admin info & exit)
|
||||
if [ "${state}" == "errorHDD" ]; then
|
||||
echo "***********************************************************"
|
||||
echo "SETUP ERROR - please report to development team"
|
||||
echo "***********************************************************"
|
||||
echo "state(${state}) message(${message})"
|
||||
if [ "${state}" == "errorHDD" ]; then
|
||||
# print some debug detail info on HDD/SSD error
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh status
|
||||
fi
|
||||
echo "command to shutdown --> off"
|
||||
exit 1
|
||||
else
|
||||
# every other state just push as event to SSH frontend
|
||||
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
#####################################
|
||||
# AFTER SETUP: Handle System States
|
||||
#####################################
|
||||
|
||||
if [ "${setupPhase}" == "done" ]; then
|
||||
echo "# AFTER SETUP: Handle System States "
|
||||
fi
|
||||
|
||||
# debug wait
|
||||
sleep 3
|
||||
|
||||
done
|
||||
|
||||
echo "# menu loop received exit code ${exitMenuLoop} --> exit to terminal"
|
||||
echo "***********************************"
|
||||
echo "* RaspiBlitz Commandline"
|
||||
echo "* Here be dragons .. have fun :)"
|
||||
echo "***********************************"
|
||||
if [ "${setupPhase}" == "done" ]; then
|
||||
echo "Bitcoin command line options: bitcoin-cli help"
|
||||
echo "LND command line options: lncli -h"
|
||||
else
|
||||
echo "Your setup is not finished."
|
||||
echo "For setup logs: cat raspiblitz.log"
|
||||
echo "or call the command 'debug' to see bigger report."
|
||||
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
|
||||
@ -359,50 +518,7 @@ else
|
||||
# wait all is synced and ready
|
||||
waitUntilChainNetworkIsReady
|
||||
|
||||
# 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
|
||||
|
||||
# check if DNS is working (if not it will trigger dialog)
|
||||
sudo /home/admin/config.scripts/internet.dns.sh test
|
||||
@ -459,7 +575,6 @@ case $CHOICE in
|
||||
if [ "$?" = "1" ]; then
|
||||
echo
|
||||
echo "# clean and unmount for next try"
|
||||
sudo rm -f ${defaultZipPath}/raspiblitz-*.tar.gz 2>/dev/null
|
||||
sudo umount /mnt/hdd 2>/dev/null
|
||||
sudo umount /mnt/storage 2>/dev/null
|
||||
sudo umount /mnt/temp 2>/dev/null
|
||||
|
@ -6,6 +6,7 @@ source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
echo "services default values"
|
||||
if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi
|
||||
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
|
||||
if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi
|
||||
if [ ${#specter} -eq 0 ]; then specter="off"; fi
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - its now done in bootstrap and setupcontroller
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/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
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/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
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/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
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/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
|
||||
@ -78,17 +80,7 @@ while [ ${chainIsReady} -eq 0 ]
|
||||
echo "*** Check LND Config ***"
|
||||
configExists=$( sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c lnd.conf )
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
echo "Creating LND config ..."
|
||||
sudo mkdir /mnt/hdd/lnd 2> /dev/null
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
|
||||
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
|
||||
if [ -d /home/bitcoin/.lnd ]; then
|
||||
echo "OK - LND config written"
|
||||
else
|
||||
echo "FAIL - Was not able to setup LND"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
echo "OK - exists"
|
||||
fi
|
||||
|
@ -19,33 +19,9 @@ if [ "$USER" == "admin" ]; then
|
||||
adminStr="Use CTRL+c to EXIT to Terminal"
|
||||
fi
|
||||
|
||||
# waiting for Internet connection
|
||||
if [ "${state}" = "nointernet" ]; then
|
||||
l1="Waiting for Internet ...\n"
|
||||
l2="Please check infrastructure:\n"
|
||||
l3="Router online? Network connected?\n"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2$l3" 5 45
|
||||
sleep 3
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# bitcoin errors always first
|
||||
if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ] || [ "${1}" == "blockchain-error" ]; then
|
||||
|
||||
####################
|
||||
# Copy Blockchain Source Mode
|
||||
# https://github.com/rootzoll/raspiblitz/issues/1081
|
||||
####################
|
||||
|
||||
if [ "${state}" = "copysource" ]; then
|
||||
l1="Copy Blockchain Source Modus\n"
|
||||
l2="May needs restart node when done.\n"
|
||||
l3="Restart from Terminal: restart"
|
||||
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${localIP}" --infobox "$l1$l2$l3" 5 45
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
####################
|
||||
# On Bitcoin Error
|
||||
####################
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/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
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
# TODO: COPY OVER COMPLETLY INTO _provison_.sh
|
||||
|
||||
mkdir /home/admin/tmpScriptDL
|
||||
cd /home/admin/tmpScriptDL
|
||||
echo "installing bash completion for bitcoin-cli and lncli"
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/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
|
||||
|
||||
@ -20,8 +22,8 @@ dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) "
|
||||
Press OK for a final reboot.
|
||||
" 10 42
|
||||
|
||||
# let migration/init script do the rest
|
||||
/home/admin/_bootstrap.migration.sh
|
||||
# let update script do the rest
|
||||
/home/admin/_bootstrap.update.sh
|
||||
|
||||
# copy logfile to analyse setup
|
||||
cp $logFile /home/admin/raspiblitz.setup.log
|
||||
|
@ -33,7 +33,7 @@ elif [ "${CHOICE}" = "REINDEX" ]; then
|
||||
sudo /home/admin/config.scripts/network.reindex.sh
|
||||
|
||||
elif [ "${CHOICE}" = "BACKUP" ]; then
|
||||
sudo /home/admin/config.scripts/lnd.rescue.sh backup
|
||||
sudo /home/admin/config.scripts/lnd.backup.sh lnd-export-gui
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
|
||||
|
@ -20,7 +20,7 @@ Download LND Data Backup now?
|
||||
echo "*************************************"
|
||||
echo "please wait .."
|
||||
sleep 2
|
||||
/home/admin/config.scripts/lnd.rescue.sh backup
|
||||
/home/admin/config.scripts/lnd.backup.sh lnd-export-gui
|
||||
echo
|
||||
echo "PRESS ENTER to continue once you are done downloading."
|
||||
read key
|
||||
@ -31,7 +31,7 @@ Download LND Data Backup now?
|
||||
echo "*************************************"
|
||||
echo "please wait .."
|
||||
sleep 2
|
||||
/home/admin/config.scripts/lnd.rescue.sh backup no-download
|
||||
/home/admin/config.scripts/lnd.backup.sh lnd-export
|
||||
fi
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ case $CHOICE in
|
||||
read key
|
||||
;;
|
||||
BACKUP-LND)
|
||||
sudo /home/admin/config.scripts/lnd.rescue.sh backup
|
||||
sudo /home/admin/config.scripts/lnd.backup.sh lnd-export-gui
|
||||
echo
|
||||
echo "Press ENTER when your backup download is done to shutdown."
|
||||
read key
|
||||
|
@ -38,7 +38,7 @@ Do you want to download LND Data Backup now?
|
||||
echo "*************************************"
|
||||
echo "please wait .."
|
||||
sleep 2
|
||||
/home/admin/config.scripts/lnd.rescue.sh backup
|
||||
/home/admin/config.scripts/lnd.backup.sh lnd-export-gui
|
||||
echo
|
||||
echo "PRESS ENTER to continue once you're done downloading."
|
||||
read key
|
||||
@ -49,7 +49,7 @@ Do you want to download LND Data Backup now?
|
||||
echo "*************************************"
|
||||
echo "please wait .."
|
||||
sleep 2
|
||||
/home/admin/config.scripts/lnd.rescue.sh backup no-download
|
||||
/home/admin/config.scripts/lnd.backup.sh lnd-export
|
||||
fi
|
||||
|
||||
whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down.
|
||||
|
@ -82,7 +82,7 @@ echo "--> CHECK CONFIG: sudo nginx -t"
|
||||
sudo nginx -t
|
||||
echo ""
|
||||
|
||||
if [ "${touchscreen}" = "0" ]; then
|
||||
if [ "${touchscreen}" = "" ] || [ "${touchscreen}" = "0" ]; then
|
||||
echo "- TOUCHSCREEN is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -92,7 +92,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${loop}" = "off" ]; then
|
||||
if [ "${loop}" = "" ] || [ "${loop}" = "off" ]; then
|
||||
echo "- Loop is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -102,7 +102,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${rtlWebinterface}" = "off" ]; then
|
||||
if [ "${rtlWebinterface}" = "" ] || [ "${rtlWebinterface}" = "off" ]; then
|
||||
echo "- RTL is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -112,7 +112,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${ElectRS}" = "off" ]; then
|
||||
if [ "${ElectRS}" = "" ] || [ "${ElectRS}" = "off" ]; then
|
||||
echo "- Electrum Rust Server is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -125,7 +125,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${lit}" = "off" ]; then
|
||||
if [ "${lit}" = "" ] || [ "${lit}" = "off" ]; then
|
||||
echo "- LIT is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -135,7 +135,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${BTCPayServer}" = "off" ]; then
|
||||
if [ "${BTCPayServer}" = "" ] || [ "${BTCPayServer}" = "off" ]; then
|
||||
echo "- BTCPayServer is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -145,7 +145,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${LNBits}" = "off" ]; then
|
||||
if [ "${LNBits}" = "" ] || [ "${LNBits}" = "off" ]; then
|
||||
echo "- LNbits is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -155,7 +155,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${thunderhub}" = "off" ]; then
|
||||
if [ "${thunderhub}" = "" ] || [ "${thunderhub}" = "off" ]; then
|
||||
echo "- Thunderhub is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -165,7 +165,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${specter}" = "off" ]; then
|
||||
if [ "${specter}" = "" ] || [ "${specter}" = "off" ]; then
|
||||
echo "- SPECTER is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
@ -175,7 +175,7 @@ else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${sphinxrelay}" = "off" ]; then
|
||||
if [ "${sphinxrelay}" = "" ] || [ "${sphinxrelay}" = "off" ]; then
|
||||
echo "- SPHINX is OFF by config"
|
||||
else
|
||||
echo ""
|
||||
|
@ -158,12 +158,9 @@ fi
|
||||
|
||||
echo "# COPYING from GIT-Directory to /home/admin/"
|
||||
sudo rm -r /home/admin/config.scripts
|
||||
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin
|
||||
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/assets /home/admin
|
||||
sudo -u admin chmod +x /home/admin/*.sh
|
||||
sudo -u admin chmod +x /home/admin/*.py
|
||||
sudo -u admin chmod +x /home/admin/config.scripts/*.sh
|
||||
sudo -u admin chmod +x /home/admin/config.scripts/*.py
|
||||
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/* /home/admin
|
||||
sudo -u admin chmod -R +x /home/admin/config.scripts
|
||||
sudo -u admin chmod -R +x /home/admin/setup.scripts
|
||||
echo "# ******************************************"
|
||||
|
||||
echo "# Checking if the content of BlitzPy changed .."
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: check & update localip in raspiblitz info for display (only write on change)
|
||||
|
||||
# This script runs on after start in background
|
||||
# as a service and gets restarted on failure
|
||||
# it runs ALMOST every seconds
|
||||
@ -37,15 +39,47 @@ do
|
||||
# count up
|
||||
counter=$(($counter+1))
|
||||
|
||||
# limit counter to max seconds per week:
|
||||
# 604800 = 60sec * 60min * 24hours * 7days
|
||||
if [ ${counter} -gt 604800 ]; then
|
||||
counter=0
|
||||
echo "counter zero reset"
|
||||
fi
|
||||
|
||||
# gather the uptime seconds
|
||||
upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+')
|
||||
|
||||
# prevent restart if COPY OVER LAN is running
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/1179#issuecomment-646079467
|
||||
source ${infoFile}
|
||||
if [ "${state}" == "copysource" ]; then
|
||||
echo "copysource mode: skipping background loop"
|
||||
sleep 10
|
||||
# source info file fresh on every loop
|
||||
source ${infoFile} 2>/dev/null
|
||||
|
||||
####################################################
|
||||
# SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES
|
||||
# https://github.com/rootzoll/raspiblitz/issues/160
|
||||
####################################################
|
||||
|
||||
if [ "${state}" == "" ] || [ "${state}" == "copysource" ]; then
|
||||
echo "skipping background loop (${counter}) - state(${state})"
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
|
||||
####################################################
|
||||
# CHECK IF LOCAL IP CHANGED
|
||||
####################################################
|
||||
oldLocalIP="${localip}";
|
||||
source <(/home/admin/config.scripts/internet.sh status)
|
||||
if [ "${oldLocalIP}" != "${localip}" ]; then
|
||||
echo "local IP changed old(${oldLocalIP}) new(${localip}) - updating in raspiblitz.info"
|
||||
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
|
||||
fi
|
||||
|
||||
####################################################
|
||||
# SKIP REST OF THE TASKS IF STILL IN SETUP PHASE
|
||||
####################################################
|
||||
|
||||
if [ "${setupPhase}" != "done" ]; then
|
||||
echo "skipping rest of tasks because still in setupPhase(${setupPhase})"
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -354,7 +388,6 @@ do
|
||||
|
||||
fi
|
||||
|
||||
|
||||
###############################
|
||||
# LND AUTO-UNLOCK
|
||||
###############################
|
||||
@ -406,7 +439,7 @@ do
|
||||
recheckIBD=$((($counter % 60)+1))
|
||||
if [ ${recheckIBD} -eq 1 ]; then
|
||||
# check if flag exists (got created on 50syncHDD.sh)
|
||||
flagExists=$(ls /home/admin/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
|
||||
flagExists=$(ls /mnt/hdd/${network}/blocks/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
|
||||
if [ ${flagExists} -eq 1 ]; then
|
||||
finishedIBD=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep "initialblockdownload" | grep -c "false")
|
||||
if [ ${finishedIBD} -eq 1 ]; then
|
||||
@ -463,12 +496,5 @@ do
|
||||
# sleep 1 sec
|
||||
sleep 1
|
||||
|
||||
# limit counter to max seconds per week:
|
||||
# 604800 = 60sec * 60min * 24hours * 7days
|
||||
if [ ${counter} -gt 604800 ]; then
|
||||
counter=0
|
||||
echo "counter zero reset"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
55
home.admin/_provision.migration.sh
Executable file
55
home.admin/_provision.migration.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LOGFILE - store debug logs of bootstrap
|
||||
logFile="/home/admin/raspiblitz.log"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
source ${infoFile}
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# log header
|
||||
echo "" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
echo "# _provision.migration.sh" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Provision Migration'/g" ${infoFile}
|
||||
|
||||
if [ "${hddGotMigrationData}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing hddGotMigrationData'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing hddGotMigrationData in (${infoFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
err=""
|
||||
nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]")
|
||||
echo "**************************************************" >> ${logFile}
|
||||
echo "MIGRATION FROM ${nodenameUpperCase} TO RASPIBLITZ" >> ${logFile}
|
||||
echo "**************************************************" >> ${logFile}
|
||||
echo "- started ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
|
||||
if [ "${err}" != "" ]; then
|
||||
echo "MIGRATION FAILED: ${err}" >> ${logFile}
|
||||
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup." >> ${logFile}
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='migration failed'/g" ${infoFile}
|
||||
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'" >> ${logFile}
|
||||
sudo rm -R /mnt/hdd/backup_migration
|
||||
else
|
||||
echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'" >> ${logFile}
|
||||
fi
|
||||
echo "OK MIGRATION" >> ${logFile}
|
||||
echo "END Migration" >> ${logFile}
|
||||
exit 0
|
||||
|
380
home.admin/_provision.setup.sh
Executable file
380
home.admin/_provision.setup.sh
Executable file
@ -0,0 +1,380 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LOGFILE - store debug logs of bootstrap
|
||||
logFile="/home/admin/raspiblitz.log"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
source ${infoFile}
|
||||
|
||||
# SETUPFILE - setup data of RaspiBlitz
|
||||
setupFile="/var/cache/raspiblitz/temp/raspiblitz.setup"
|
||||
source ${setupFile}
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
source ${configFile}
|
||||
|
||||
# log header
|
||||
echo "" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
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
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/1798
|
||||
sudo sed -i "s/^message=.*/message='SSH Keys'/g" ${infoFile}
|
||||
|
||||
# link ssh directory from SD card to HDD
|
||||
echo "# --> SSH key settings" >> ${logFile}
|
||||
echo "# copying SSH pub keys to HDD" >> ${logFile}
|
||||
sudo cp -r /etc/ssh /mnt/hdd/ssh >> ${logFile}
|
||||
echo "# OK" >> ${logFile}
|
||||
|
||||
###################################
|
||||
# Prepare Blockchain Service
|
||||
sudo sed -i "s/^message=.*/message='Blockchain Setup'/g" ${infoFile}
|
||||
|
||||
if [ "${network}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing network'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing network in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${chain}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing chain'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing chain in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure choosen blockchain service is installed
|
||||
if [ "${network}" != "bitcoin" ]; then
|
||||
# TODO also ... check if /home/admin/selfsync.flag is needed on other chains
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='TODO: install ${network}'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "TODO: make sure ${network} is installed!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy configs files and directories
|
||||
echo ""
|
||||
echo "*** Prepare ${network} ***" >> ${logFile}
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network} 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/blocks 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/chainstate 2>/dev/null
|
||||
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
|
||||
|
||||
# set password B as RPC password
|
||||
echo "SETTING PASSWORD B" >> ${logFile}
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh b "${passwordB}" >> ${logFile}
|
||||
|
||||
# optimize RAM for blockchain validation (bitcoin only)
|
||||
if [ "${network}" == "bitcoin" ] && [ "${hddBlocksBitcoin}" == "0" ]; then
|
||||
echo "*** Optimizing RAM for Sync ***" >> ${logFile}
|
||||
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
|
||||
echo "dont forget to reduce dbcache once IBD is done" > "/mnt/hdd/${network}/blocks/selfsync.flag"
|
||||
# RP4 4GB
|
||||
if [ ${kbSizeRAM} -gt 3500000 ]; then
|
||||
echo "Detected RAM >=4GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=3072/g" /mnt/hdd/${network}/${network}.conf
|
||||
# RP4 2GB
|
||||
elif [ ${kbSizeRAM} -gt 1500000 ]; then
|
||||
echo "Detected RAM >=2GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=1536/g" /mnt/hdd/${network}/${network}.conf
|
||||
#RP3/4 1GB
|
||||
else
|
||||
echo "Detected RAM <=1GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
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}
|
||||
|
||||
# check if bitcoin has started
|
||||
bitcoinRunning=0
|
||||
loopcount=0
|
||||
while [ ${bitcoinRunning} -eq 0 ]
|
||||
do
|
||||
>&2 echo "# (${loopcount}/200) checking if ${network}d is running ... " >> ${logFile}
|
||||
bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
|
||||
sleep 2
|
||||
sync
|
||||
loopcount=$(($loopcount +1))
|
||||
if [ ${loopcount} -gt 200 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: failed ${network}'/g" ${infoFile}
|
||||
echo "FAIL: setup: failed ${network}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "OK ${network} startup successfull " >> ${logFile}
|
||||
|
||||
|
||||
###################################
|
||||
# Prepare Lightning
|
||||
echo "Prepare Lightning (${lightning})" >> ${logFile}
|
||||
|
||||
if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
###################################
|
||||
# LND
|
||||
sudo sed -i "s/^message=.*/message='LND Setup'/g" ${infoFile}
|
||||
|
||||
if [ "${passwordC}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing passwordC'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing passwordC in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if user uploaded an LND rescue file
|
||||
if [ "${lndrescue}" != "" ]; then
|
||||
echo "Restore LND data from uploaded rescue file ${lndrescue} ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh lnd-import ${lndrescue})
|
||||
if [ "${error}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd import backup failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd import backup failed" >> ${logFile}
|
||||
echo "${error}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# preparing new LND config
|
||||
echo "Creating new LND config ..." >> ${logFile}
|
||||
sudo -u bitcoin mkdir /mnt/hdd/lnd 2> /dev/null
|
||||
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
|
||||
sudo /home/admin/config.scripts/lnd.setname.sh ${hostname}
|
||||
fi
|
||||
|
||||
# check if now a config exists
|
||||
configLinkedCorrectly=$(sudo ls sudo ls /home/bitcoin/.lnd/lnd.conf | grep -c "lnd.conf")
|
||||
if [ "${configLinkedCorrectly}" != "1" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd conf link broken'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd conf link broken" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Init LND service & start
|
||||
echo "*** Init LND Service & Start ***" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='LND Testrun'/g" ${infoFile}
|
||||
|
||||
# just in case
|
||||
sudo systemctl stop lnd 2>/dev/null
|
||||
sudo systemctl disable lnd 2>/dev/null
|
||||
|
||||
# make sure lnd gets started after blockchain service
|
||||
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile}
|
||||
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile}
|
||||
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile}
|
||||
|
||||
# make sure LND starts with Tor by default
|
||||
sudo /home/admin/config.scripts/internet.tor.sh lndconf-on >> ${logFile}
|
||||
|
||||
# start lnd up
|
||||
echo "Starting LND Service ..." >> ${logFile}
|
||||
sudo systemctl enable lnd >> ${logFile}
|
||||
sudo systemctl start lnd >> ${logFile}
|
||||
|
||||
# check that lnd started
|
||||
lndRunning=0
|
||||
loopcount=0
|
||||
while [ ${lndRunning} -eq 0 ]
|
||||
do
|
||||
lndRunning=$(sudo systemctl status lnd.service | grep -c running)
|
||||
if [ ${lndRunning} -eq 0 ]; then
|
||||
date +%s >> ${logFile}
|
||||
echo "LND not ready yet ... waiting another 60 seconds." >> ${logFile}
|
||||
sleep 10
|
||||
fi
|
||||
loopcount=$(($loopcount +1))
|
||||
if [ ${loopcount} -gt 100 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: failed lnd start'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: failed lnd start" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "OK - LND is running" ${logFile}
|
||||
sleep 10
|
||||
|
||||
# Check LND health/fails (to be extended)
|
||||
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert")
|
||||
if [ ${tlsExists} -eq 0 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: missing lnd tls'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: missing lnd tls" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# import static channel backup if was uploaded
|
||||
if [ "${staticchannelbackup}" != "" ]; then
|
||||
echo "Preparing static channel backup file ${staticchannelbackup} ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh scb-import ${staticchannelbackup})
|
||||
if [ "${error}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd import SCB failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd import SCB failed" >> ${logFile}
|
||||
echo "${error}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# WALLET --> SEED + SCB
|
||||
if [ "${seedWords}" != "" ] && [ "${staticchannelbackup}" != "" ]; then
|
||||
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (SEED & SCB)'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py scb ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SCB failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SCB failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# WALLET --> SEED
|
||||
elif [ "${seedWords}" != "" ]; then
|
||||
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (SEED)'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${seedWords}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# WALLET --> NEW
|
||||
else
|
||||
|
||||
sudo sed -i "s/^message=.*/message='LND Wallet (NEW)'/g" ${infoFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py new ${passwordC})
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# write created seedwords into SETUPFILE to be displayed to user on final setup later
|
||||
echo "seedwordsNEW='${seedwords}'" >> ${setupFile}
|
||||
echo "seedwords6x4NEW='${seedwords6x4}'" >> ${setupFile}
|
||||
|
||||
fi
|
||||
|
||||
# sync macaroons & TLS to other users
|
||||
echo "*** Copy LND Macaroons to user admin ***" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='LND Credentials'/g" ${infoFile}
|
||||
|
||||
# make sure wallet is unlocked
|
||||
sleep 3
|
||||
/home/admin/config.scripts/lnd.unlock.sh "${passwordC}" >> ${logFile}
|
||||
sleep 3
|
||||
|
||||
# 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
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd no macaroons'/g" ${infoFile}
|
||||
echo "FAIL: setup: lnd no macaroons" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# now sync macaroons & TLS zo other users
|
||||
sudo /home/admin/config.scripts/lnd.credentials.sh sync >> ${logFile}
|
||||
|
||||
# unlock Wallet (if needed)
|
||||
echo "*** Check Wallet Lock ***" >> ${logFile}
|
||||
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" >> ${logFile}
|
||||
/home/admin/config.scripts/lnd.unlock.sh "${passwordC}" >> ${logFile}
|
||||
else
|
||||
echo "OK - Wallet is already unlocked" >> ${logFile}
|
||||
fi
|
||||
|
||||
# make a final lnd check
|
||||
source <(/home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "${lightning}" == "cln" ]; then
|
||||
|
||||
###################################
|
||||
# c-lightning
|
||||
sudo sed -i "s/^message=.*/message='c-lightning Setup'/g" ${infoFile}
|
||||
|
||||
# TODO: implement
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='TODO: install c-lightning'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "TODO: install c-lightning!" >> ${logFile}
|
||||
exit 1
|
||||
|
||||
# these vars are available from the setup process for cln loaded from setupfile
|
||||
# seedWords --> if entered on old seed
|
||||
# clnrescue --> if user uploaded a rescue file
|
||||
# setPasswordC --> for any new wallet encryption
|
||||
|
||||
fi
|
||||
|
||||
sudo sed -i "s/^message=.*/message='Provision Setup Finish'/g" ${infoFile}
|
||||
echo "END Setup" >> ${logFile}
|
||||
exit 0
|
||||
|
@ -9,10 +9,15 @@ infoFile="/home/admin/raspiblitz.info"
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# debug info
|
||||
echo "STARTED Migration/Init --> see logs in ${logFile}"
|
||||
echo "STARTED Migration/Init" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Running Data Migration'/g" ${infoFile}
|
||||
# SETUPFILE - configuration of RaspiBlitz
|
||||
setupFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# log header
|
||||
echo "" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
echo "# _provision.update.sh" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Running Data Update'/g" ${infoFile}
|
||||
|
||||
# HDD BTRFS RAID REPAIR IF NEEDED
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
@ -29,19 +34,13 @@ fi
|
||||
|
||||
# LOAD DATA & PRECHECK
|
||||
|
||||
# check if there is a config file
|
||||
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: no config file (${configFile}) found to init or upgrade!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# load old or init raspiblitz config
|
||||
source ${configFile}
|
||||
|
||||
# check if config files contains basic: hostname
|
||||
if [ ${#hostname} -eq 0 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing hostname'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing hostname in (${configFile})!" >> ${logFile}
|
||||
exit 1
|
||||
@ -52,6 +51,8 @@ source /home/admin/_version.info
|
||||
|
||||
# check if code version was loaded
|
||||
if [ ${#codeVersion} -eq 0 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='missing /home/admin/_version.info'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: no code version (/home/admin/_version.info) found!" >> ${logFile}
|
||||
exit 1
|
||||
@ -59,34 +60,6 @@ fi
|
||||
|
||||
echo "prechecks OK" >> ${logFile}
|
||||
|
||||
# DEFAULT VALUES - MISSING data fields on init or upadte
|
||||
|
||||
# AUTOPILOT
|
||||
# autoPilot=off|on
|
||||
if [ ${#autoPilot} -eq 0 ]; then
|
||||
echo "autoPilot=off" >> $configFile
|
||||
fi
|
||||
|
||||
# AUTO NAT DISCOVERY
|
||||
# autoNatDiscovery=off|on
|
||||
if [ ${#autoNatDiscovery} -eq 0 ]; then
|
||||
echo "autoNatDiscovery=off" >> $configFile
|
||||
fi
|
||||
|
||||
# TOR
|
||||
# runBehindTor=off|on
|
||||
if [ ${#runBehindTor} -eq 0 ]; then
|
||||
echo "runBehindTor=off" >> $configFile
|
||||
fi
|
||||
|
||||
# RideTheLightning RTL
|
||||
# rtlWebinterface=off|on
|
||||
if [ ${#rtlWebinterface} -eq 0 ]; then
|
||||
echo "rtlWebinterface=off" >> $configFile
|
||||
fi
|
||||
|
||||
echo "default values OK" >> ${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
|
@ -14,9 +14,11 @@ infoFile="/home/admin/raspiblitz.info"
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# debug info
|
||||
echo "STARTED Provisioning --> see logs in ${logFile}"
|
||||
echo "STARTED Provisioning from preset config file" >> ${logFile}
|
||||
# log header
|
||||
echo "" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
echo "# _provision_.sh" >> ${logFile}
|
||||
echo "###################################" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile}
|
||||
|
||||
# check if there is a config file
|
||||
@ -32,80 +34,7 @@ if [ ${parameterExists} -eq 0 ]; then
|
||||
echo "lndExtraParameter=''" >> ${configFile}
|
||||
fi
|
||||
|
||||
# check if file system was expanded to full capacity and sd card is bigger than 8GB
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/936
|
||||
echo "CHECK IF SD CARD NEEDS EXPANSION" >> ${logFile}
|
||||
source ${infoFile}
|
||||
|
||||
# remember the DisplayClass from info file - before its gets overwritten by raspiblitz.conf to detect change
|
||||
infoFileDisplayClass="${displayClass}"
|
||||
|
||||
minimumSizeByte=8192000000
|
||||
rootPartition=$(sudo mount | grep " / " | cut -d " " -f 1 | cut -d "/" -f 3)
|
||||
rootPartitionBytes=$(lsblk -b -o NAME,SIZE | grep "${rootPartition}" | tr -s ' ' | cut -d " " -f 2)
|
||||
|
||||
echo "rootPartition(${rootPartition})" >> ${logFile}
|
||||
echo "rootPartitionBytes(${rootPartitionBytes})" >> ${logFile}
|
||||
|
||||
if [ ${#rootPartition} -gt 0 ]; then
|
||||
echo "### CHECKING ROOT PARTITION SIZE ###" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Checking Disk size'/g" ${infoFile}
|
||||
echo "Size in Bytes is: ${rootPartitionBytes} bytes on ($rootPartition)" >> ${logFile}
|
||||
if [ $rootPartitionBytes -lt $minimumSizeByte ]; then
|
||||
echo "Disk filesystem is smaller than ${minimumSizeByte} byte." >> ${logFile}
|
||||
if [ ${fsexpanded} -eq 1 ]; then
|
||||
echo "There was already an attempt to expand the fs, but still not bigger than 8GB." >> ${logFile}
|
||||
echo "SD card seems to small - at least a 16GB disk is needed. Display on LCD to user." >> ${logFile}
|
||||
sudo sed -i "s/^state=.*/state=sdtoosmall/g" ${infoFile}
|
||||
sudo sed -i "s/^message=.*/message='Min 16GB SD card needed'/g" ${infoFile}
|
||||
exit 1
|
||||
else
|
||||
echo "Try to expand SD card FS, display info and reboot." >> ${logFile}
|
||||
sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile}
|
||||
sudo sed -i "s/^message=.*/message='Expanding SD Card'/g" ${infoFile}
|
||||
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" ${infoFile}
|
||||
sleep 4
|
||||
if [ "${cpu}" == "x86_64" ]; then
|
||||
echo "Please expand disk size." >> ${logFile}
|
||||
# TODO: Expand disk size on x86_64
|
||||
elif [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
|
||||
resizeRaspbian="/usr/bin/raspi-config"
|
||||
if [ -x ${resizeRaspbian} ]; then
|
||||
echo "RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}" >> ${logFile}
|
||||
sudo $resizeRaspbian --expand-rootfs
|
||||
echo "going into reboot" >> ${logFile}
|
||||
sudo cp ${logFile} ${logFile}.fsexpand.recover
|
||||
sudo shutdown -r now
|
||||
exit 0
|
||||
else
|
||||
echo "FAIL to execute: ${resizeRaspbian}" >> ${logFile}
|
||||
fi
|
||||
elif [ "${baseimage}" = "armbian" ]; then
|
||||
resizeArmbian="/usr/lib/armbian/armbian-resize-filesystem"
|
||||
if [ -x ${resizeArmbian} ]; then
|
||||
echo "RUNNING EXPAND ARMBIAN: ${resizeArmbian}" >> ${logFile}
|
||||
sudo $resizeArmbian start
|
||||
echo "going into reboot" >> ${logFile}
|
||||
sudo cp ${logFile} ${logFile}.fsexpand.recover
|
||||
sudo shutdown -r now
|
||||
sleep 100
|
||||
exit 0
|
||||
else
|
||||
echo "FAIL to execute: ${resizeArmbian}" >> ${logFile}
|
||||
fi
|
||||
else
|
||||
echo "WARN on provision - Not known system expand-rootfs OS: ${baseimage}" >> ${logFile}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Size looks good. Bigger than ${minimumSizeByte} byte disk is used." >> ${logFile}
|
||||
fi
|
||||
else
|
||||
echo "Disk of root partition ('$rootPartition') not detected, skipping the size check." >> ${logFile}
|
||||
fi
|
||||
|
||||
# import config values
|
||||
sudo chmod 777 ${configFile}
|
||||
source ${configFile}
|
||||
|
||||
##########################
|
||||
@ -175,6 +104,9 @@ if [ "${network}" = "litecoin" ]; then
|
||||
/home/admin/config.scripts/blitz.litecoin.sh on >> ${logFile}
|
||||
fi
|
||||
|
||||
echo "# Make sure the user bitcoin is in the debian-tor group"
|
||||
sudo usermod -a -G debian-tor bitcoin
|
||||
|
||||
# set hostname data
|
||||
echo "Setting lightning alias: ${hostname}" >> ${logFile}
|
||||
sudo sed -i "s/^alias=.*/alias=${hostname}/g" /home/admin/assets/lnd.${network}.conf >> ${logFile} 2>&1
|
||||
@ -194,11 +126,10 @@ fi
|
||||
#sudo ln -s /mnt/hdd/ssh /etc/ssh >> ${logFile} 2>&1
|
||||
#sudo /home/admin/config.scripts/blitz.systemd.sh update-sshd >> ${logFile} 2>&1
|
||||
|
||||
# optimze if RAM >1GB
|
||||
# optimze mempool 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=1024/g" /mnt/hdd/${network}/${network}.conf
|
||||
sudo sed -i "s/^maxmempool=.*/maxmempool=300/g" /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
if [ ${kbSizeRAM} -gt 3500000 ]; then
|
||||
@ -229,7 +160,7 @@ sudo ln -s -f /mnt/hdd/.tmux.conf.local /home/admin/.tmux.conf.local >> ${logFil
|
||||
# backup LND dir (especially for macaroons and tlscerts)
|
||||
# https://github.com/rootzoll/raspiblitz/issues/324
|
||||
echo "*** Make backup of LND directory" >> ${logFile}
|
||||
sudo rm -r /mnt/hdd/backup_lnd
|
||||
sudo rm -r /mnt/hdd/backup_lnd 2>/dev/null
|
||||
sudo cp -r /mnt/hdd/lnd /mnt/hdd/backup_lnd >> ${logFile} 2>&1
|
||||
numOfDiffers=$(sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd | grep -c "differ")
|
||||
if [ ${numOfDiffers} -gt 0 ]; then
|
||||
@ -302,7 +233,8 @@ else
|
||||
fi
|
||||
|
||||
# TOR
|
||||
if [ "${runBehindTor}" = "on" ]; then
|
||||
source <(/home/admin/config.scripts/internet.tor.sh status)
|
||||
if [ "${runBehindTor}" == "on" ] && [ "${torRunning}" == "0" ]; then
|
||||
echo "Provisioning TOR - run config script" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup Tor (takes time)'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
|
||||
@ -392,13 +324,7 @@ if [ "${BTCPayServer}" = "on" ]; then
|
||||
echo "Provisioning BTCPAYSERVER on TOR - running setup" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup BTCPay (takes time)'/g" ${infoFile}
|
||||
sudo -u admin /home/admin/config.scripts/bonus.btcpayserver.sh on >> ${logFile} 2>&1
|
||||
|
||||
#echo "Provisioning BTCPAYSERVER on TOR - run on after bootup script" >> ${logFile}
|
||||
# because BTCPAY server freezes during recovery .. it will get installed after reboot
|
||||
#echo "sudo -u admin /home/admin/config.scripts/bonus.btcpayserver.sh on" >> /home/admin/setup.sh
|
||||
#sudo chmod +x /home/admin/setup.sh >> ${logFile}
|
||||
#sudo ls -la /home/admin/setup.sh >> ${logFile}
|
||||
|
||||
|
||||
else
|
||||
echo "Provisioning BTCPayServer - keep default" >> ${logFile}
|
||||
fi
|
||||
@ -672,7 +598,7 @@ fi
|
||||
echo "" >> ${logFile}
|
||||
|
||||
# repair Bitcoin conf if needed
|
||||
echo "*** Repair Bitcioin Conf (if needed)" >> ${logFile}
|
||||
echo "*** Repair Bitcoin Conf (if needed)" >> ${logFile}
|
||||
confExists="$(sudo ls /mnt/hdd/${network} | grep -c "${network}.conf")"
|
||||
if [ ${confExists} -eq 0 ]; then
|
||||
echo "Doing init of ${network}.conf" >> ${logFile}
|
||||
@ -680,6 +606,11 @@ if [ ${confExists} -eq 0 ]; then
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/bitcoin/bitcoin.conf
|
||||
fi
|
||||
|
||||
# make sure basic info id in raspiblitz.info
|
||||
sudo sed -i "s/^network=.*/network=${network}/g" ${infoFile}
|
||||
sudo sed -i "s/^chain=.*/chain=${chain}/g" ${infoFile}
|
||||
sudo sed -i "s/^lightning=.*/lightning=${lightning}/g" ${infoFile}
|
||||
|
||||
# singal setup done
|
||||
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile}
|
||||
|
@ -14,8 +14,10 @@ peerbloomfilters=1
|
||||
rpcuser=raspibolt
|
||||
rpcpassword=passwordB
|
||||
main.rpcport=8332
|
||||
test.rpcport=18332
|
||||
rpcallowip=127.0.0.1
|
||||
main.rpcbind=127.0.0.1:8332
|
||||
test.rpcbind=127.0.0.1:18332
|
||||
zmqpubrawblock=tcp://127.0.0.1:28332
|
||||
zmqpubrawtx=tcp://127.0.0.1:28333
|
||||
|
||||
@ -27,3 +29,11 @@ maxconnections=40
|
||||
maxuploadtarget=5000
|
||||
|
||||
datadir=/mnt/hdd/bitcoin
|
||||
|
||||
# tor by default
|
||||
onlynet=onion
|
||||
proxy=127.0.0.1:9050
|
||||
main.bind=127.0.0.1
|
||||
test.bind=127.0.0.1
|
||||
dnsseed=0
|
||||
dns=0
|
||||
|
@ -1,11 +1,12 @@
|
||||
# RaspiBlitz: systemd unit for bitcoind
|
||||
# edit final Wants/After when provision is done
|
||||
Wants=network.target
|
||||
After=network.target
|
||||
|
||||
[Unit]
|
||||
Description=Bitcoin daemon
|
||||
Wants=bootstrap.service
|
||||
After=bootstrap.service
|
||||
Description=Bitcoin-Daemon
|
||||
|
||||
# for use with sendmail alert (coming soon)
|
||||
# for use with sendmail alert
|
||||
#OnFailure=systemd-sendmail@%n
|
||||
|
||||
[Service]
|
||||
@ -14,7 +15,7 @@ Group=bitcoin
|
||||
Type=forking
|
||||
PIDFile=/mnt/hdd/bitcoin/bitcoind.pid
|
||||
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
|
||||
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid
|
||||
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/mnt/hdd/bitcoin/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid
|
||||
KillMode=process
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
|
@ -27,3 +27,11 @@ discardfee=0.00000001
|
||||
mintxfee=0.00000001
|
||||
minrelaytxfee=0.00000001
|
||||
datadir=/mnt/hdd/litecoin
|
||||
|
||||
# tor by default
|
||||
onlynet=onion
|
||||
proxy=127.0.0.1:9050
|
||||
main.bind=127.0.0.1
|
||||
test.bind=127.0.0.1
|
||||
dnsseed=0
|
||||
dns=0
|
||||
|
@ -1,7 +1,10 @@
|
||||
# RaspiBlitz: systemd unit for bitcoind
|
||||
# edit final Wants/After when provision is done
|
||||
Wants=network.target
|
||||
After=network.target
|
||||
|
||||
[Unit]
|
||||
Description=Litecoin daemon
|
||||
Wants=bootstrap.service
|
||||
After=bootstrap.service
|
||||
Description=Litecoin-Daemon
|
||||
|
||||
# for use with sendmail alert (coming soon)
|
||||
#OnFailure=systemd-sendmail@%n
|
||||
|
95
home.admin/config.scripts/blitz.bootdrive.sh
Normal file
95
home.admin/config.scripts/blitz.bootdrive.sh
Normal file
@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
|
||||
# basic background on this feature
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/936
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/raspiblitz.info </dev/null
|
||||
|
||||
# command info
|
||||
if [ "$1" == "" ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# tools for the boot drive / sd card"
|
||||
echo "# blitz.sdcard.sh status"
|
||||
echo "# blitz.sdcard.sh expand"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if sudo
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then echo "Please run as root (with sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1st PARAMETER: action
|
||||
action=$1
|
||||
|
||||
#########################
|
||||
# STATUS
|
||||
|
||||
# gather data on sd card
|
||||
minimumSizeByte=8192000000
|
||||
rootPartition=$(sudo mount | grep " / " | cut -d " " -f 1 | cut -d "/" -f 3)
|
||||
rootPartitionBytes=$(lsblk -b -o NAME,SIZE | grep "${rootPartition}" | tr -s ' ' | cut -d " " -f 2)
|
||||
|
||||
# make conculsions
|
||||
needsExpansion=0
|
||||
tooSmall=0
|
||||
if [ $rootPartitionBytes -lt $minimumSizeByte ]; then
|
||||
needsExpansion=1
|
||||
if [ "${fsexpanded}" == "1" ]; then
|
||||
tooSmall=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${action}" == "status" ]; then
|
||||
|
||||
echo "rootPartition='${rootPartition}'"
|
||||
echo "rootPartitionBytes=${rootPartitionBytes}"
|
||||
echo "needsExpansion=${needsExpansion}"
|
||||
echo "fsexpanded=${fsexpanded}" # from raspiblitz.info
|
||||
echo "tooSmall=${tooSmall}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
###########################
|
||||
# EXPAND FILE SYSTEM OF SD
|
||||
|
||||
if [ "${action}" == "fsexpand" ]; then
|
||||
|
||||
echo "# blitz.bootdrive.sh fsexpand"
|
||||
echo "# starting expand of file system of sd card"
|
||||
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info
|
||||
|
||||
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
|
||||
resizeRaspbian="/usr/bin/raspi-config"
|
||||
if [ -x ${resizeRaspbian} ]; then
|
||||
echo "# RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}"
|
||||
sudo $resizeRaspbian --expand-rootfs 1>&2
|
||||
echo "# DONE - please reboot"
|
||||
else
|
||||
echo "# FAIL to execute on ${baseimage}: ${resizeRaspbian}"
|
||||
echo "err='expand failed'"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "${baseimage}" = "armbian" ]; then
|
||||
resizeArmbian="/usr/lib/armbian/armbian-resize-filesystem"
|
||||
if [ -x ${resizeArmbian} ]; then
|
||||
echo "# RUNNING EXPAND ARMBIAN: ${resizeArmbian}"
|
||||
sudo $resizeArmbian start 1>&2
|
||||
echo "# DONE - please reboot"
|
||||
else
|
||||
echo "# FAIL to execute on ${baseimage}: ${resizeArmbian}"
|
||||
echo "err='expand failed'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "#FAIL no implementation for: ${baseimage}"
|
||||
echo "err='missing implementation'"
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "err='unknown parameter'"
|
||||
exit 1
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
>&2 echo "# managing the data drive(s) with old EXT4 or new BTRFS"
|
||||
>&2 echo "# blitz.datadrive.sh [status|tempmount|format|fstab|raid|link|swap|clean|snapshot]"
|
||||
>&2 echo "# blitz.datadrive.sh [status|tempmount|unmount|format|fstab|raid|link|swap|clean|snapshot|uasp-fix]"
|
||||
echo "error='missing parameters'"
|
||||
exit 1
|
||||
fi
|
||||
@ -49,7 +49,7 @@ fi
|
||||
isMounted=$(sudo df | grep -c /mnt/hdd)
|
||||
isBTRFS=$(sudo btrfs filesystem show 2>/dev/null| grep -c 'BLITZSTORAGE')
|
||||
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
|
||||
isSSD="Unknown"
|
||||
isSSD="0"
|
||||
|
||||
# determine if swap is external on or not
|
||||
externalSwapPath="/mnt/hdd/swapfile"
|
||||
@ -71,7 +71,7 @@ if [ "$1" = "status" ]; then
|
||||
echo "isMounted=${isMounted}"
|
||||
echo "isBTRFS=${isBTRFS}"
|
||||
|
||||
# if HDD is not mounted system is in the pre-setup phase
|
||||
# if HDD is not mounted system then it is in the pre-setup phase
|
||||
# deliver all the detailes needed about the data drive
|
||||
# and it content for the setup dialogs
|
||||
if [ ${isMounted} -eq 0 ]; then
|
||||
@ -79,10 +79,10 @@ if [ "$1" = "status" ]; then
|
||||
echo "# SETUP INFO"
|
||||
|
||||
# find the HDD (biggest single partition)
|
||||
# will then be used to offer formatting and permanent mounting
|
||||
hdd=""
|
||||
sizeDataPartition=0
|
||||
OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g")
|
||||
|
||||
lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp
|
||||
while read line; do
|
||||
|
||||
@ -141,14 +141,17 @@ if [ "$1" = "status" ]; then
|
||||
done < .lsblk.tmp
|
||||
rm -f .lsblk.tmp 1>/dev/null 2>/dev/null
|
||||
|
||||
# display possible warnings from hdd partition detection
|
||||
if [ "${hddPartitionCandidate}" != "" ] && [ ${#hddDataPartition} -lt 4 ]; then
|
||||
echo "# WARNING: found invalid partition (${hddDataPartition}) - redacting"
|
||||
hddDataPartition=""
|
||||
fi
|
||||
|
||||
# try to detect if its an SSD
|
||||
isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
|
||||
echo "isSSD=${isSSD}"
|
||||
|
||||
# display results from hdd & partition detection
|
||||
echo "hddCandidate='${hdd}'"
|
||||
hddBytes=0
|
||||
hddGigaBytes=0
|
||||
@ -158,9 +161,9 @@ if [ "$1" = "status" ]; then
|
||||
fi
|
||||
echo "hddBytes=${hddBytes}"
|
||||
echo "hddGigaBytes=${hddGigaBytes}"
|
||||
|
||||
echo "hddPartitionCandidate='${hddDataPartition}'"
|
||||
|
||||
# if positive deliver more data
|
||||
if [ ${#hddDataPartition} -gt 0 ]; then
|
||||
|
||||
# check partition size in bytes and GBs
|
||||
@ -168,13 +171,6 @@ if [ "$1" = "status" ]; then
|
||||
hddDataPartitionGigaBytes=$(echo "scale=0; ${sizeDataPartition}/1024/1024/1024" | bc -l)
|
||||
echo "hddPartitionGigaBytes=${hddDataPartitionGigaBytes}"
|
||||
|
||||
# check if single drive with that size
|
||||
hddCount=0
|
||||
if [ ${#hddDataPartition} -gt 0 ]; then
|
||||
hddCount=1
|
||||
fi
|
||||
echo "hddCount=${hddCount}"
|
||||
|
||||
# check format of devices partition
|
||||
hddFormat=$(lsblk -o FSTYPE,NAME,TYPE | grep part | grep "${hddDataPartition}" | cut -d " " -f 1)
|
||||
echo "hddFormat='${hddFormat}'"
|
||||
@ -182,7 +178,7 @@ if [ "$1" = "status" ]; then
|
||||
# if 'ext4' or 'btrfs' then temp mount and investigate content
|
||||
if [ "${hddFormat}" = "ext4" ] || [ "${hddFormat}" = "btrfs" ]; then
|
||||
|
||||
# BTRFS is working with subvolumnes for snapshots / ext4 has no SubVolumes
|
||||
# BTRFS is working with subvolumes for snapshots / ext4 has no SubVolumes
|
||||
subVolumeDir=""
|
||||
if [ "${hddFormat}" = "btrfs" ]; then
|
||||
subVolumeDir="/WORKINGDIR"
|
||||
@ -206,11 +202,30 @@ if [ "$1" = "status" ]; then
|
||||
echo "hddError='data mount failed'"
|
||||
else
|
||||
|
||||
# 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)
|
||||
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
|
||||
echo "hddRaspiData=${hddRaspiData}"
|
||||
sudo umount /mnt/hdd
|
||||
#####################################
|
||||
# Pre-Setup Invetigation 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)
|
||||
#isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
|
||||
echo "hddRaspiData=${hddRaspiData}"
|
||||
hddRaspiVersion=""
|
||||
if [ ${hddRaspiData} -eq 1 ]; then
|
||||
source /mnt/hdd${subVolumeDir}/raspiblitz.conf
|
||||
hddRaspiVersion="${raspiBlitzVersion}"
|
||||
fi
|
||||
echo "hddRaspiVersion='${hddRaspiVersion}'"
|
||||
|
||||
# check if there is a wifi configuration as backup
|
||||
hddGotWifiConf=$(ls /mnt/hdd${subVolumeDir}/app-data/wpa_supplicant.conf 2>/dev/null | grep -c "wpa_supplicant.conf")
|
||||
if [ ${hddGotWifiConf} -eq 1 ]; then
|
||||
# make a copy to the mem cache drive (so that Wifi can be connected before setup & final HDD mount)
|
||||
sudo cp /mnt/hdd${subVolumeDir}/app-data/wpa_supplicant.conf /var/cache/raspiblitz/wpa_supplicant.conf
|
||||
echo "wifiBackupConfigCopy='/var/cache/raspiblitz/wpa_supplicant.conf'"
|
||||
fi
|
||||
|
||||
# comment this line out if case to study the contect of the data section
|
||||
sudo umount /mnt/hdd
|
||||
fi
|
||||
|
||||
# temp storage data drive
|
||||
@ -228,6 +243,9 @@ if [ "$1" = "status" ]; then
|
||||
echo "hddError='storage mount failed'"
|
||||
else
|
||||
|
||||
########################################
|
||||
# Pre-Setup Invetigation of STORAGE-PART
|
||||
|
||||
# check for blockchain data on storage
|
||||
hddBlocksBitcoin=$(sudo ls /mnt/storage${subVolumeDir}/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
|
||||
echo "hddBlocksBitcoin=${hddBlocksBitcoin}"
|
||||
@ -252,7 +270,7 @@ if [ "$1" = "status" ]; then
|
||||
echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
|
||||
|
||||
# check if its another fullnode implementation data disk
|
||||
hddGotMigrationData="none"
|
||||
hddGotMigrationData=""
|
||||
if [ "${hddFormat}" = "ext4" ]; then
|
||||
# check for umbrel
|
||||
isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json')
|
||||
@ -268,7 +286,7 @@ if [ "$1" = "status" ]; then
|
||||
fi
|
||||
echo "hddGotMigrationData='${hddGotMigrationData}'"
|
||||
|
||||
# unmount
|
||||
# comment this line out if case to study the contect of the storage section
|
||||
sudo umount /mnt/storage
|
||||
fi
|
||||
else
|
||||
@ -298,6 +316,12 @@ if [ "$1" = "status" ]; then
|
||||
fi
|
||||
hddRaspiData=$(sudo ls -l /mnt/hdd | grep -c raspiblitz.conf)
|
||||
echo "hddRaspiData=${hddRaspiData}"
|
||||
hddRaspiVersion=""
|
||||
if [ ${hddRaspiData} -eq 1 ]; then
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
hddRaspiVersion="${raspiBlitzVersion}"
|
||||
fi
|
||||
echo "hddRaspiVersion='${hddRaspiVersion}'"
|
||||
|
||||
isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
|
||||
echo "isSSD=${isSSD}"
|
||||
@ -346,6 +370,7 @@ if [ "$1" = "status" ]; then
|
||||
fi
|
||||
|
||||
# HDD Adpater UASP support --> https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
|
||||
# in both cases (if mounted or not - using the hdd selection from both cases)
|
||||
if [ ${#hdd} -gt 0 ]; then
|
||||
|
||||
# determine USB HDD adapter model ID
|
||||
@ -1174,17 +1199,28 @@ fi
|
||||
|
||||
if [ "$1" = "tempmount" ]; then
|
||||
|
||||
# get HDD status and candidates
|
||||
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
if [ ${isMounted} -eq 1 ]; then
|
||||
echo "error='already mounted'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get device to temp mount
|
||||
# get device to temp mount from parameter (optional)
|
||||
hdd=$2
|
||||
if [ ${#hdd} -eq 0 ]; then
|
||||
>&2 echo "# FAIL which device should be temp mounted (e.g. sda)"
|
||||
>&2 echo "# run 'status' to see device candidates"
|
||||
echo "error='missing second parameter'"
|
||||
# automount if no parameter the hddcandinate
|
||||
if [ "${hdd}" == "" ]; then
|
||||
if [ "${hddFormat}" != "btrfs" ]; then
|
||||
hdd="${hddPartitionCandidate}"
|
||||
else
|
||||
hdd="${hddCandidate}"
|
||||
fi
|
||||
fi
|
||||
# if still no hdd .. throw error
|
||||
if [ "${hdd}" == "" ]; then
|
||||
>&2 echo "# FAIL there is no detected hdd candidate to tempmount"
|
||||
echo "error='hdd not found'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -1264,6 +1300,14 @@ if [ "$1" = "tempmount" ]; then
|
||||
|
||||
fi
|
||||
|
||||
if [ "$1" = "unmount" ]; then
|
||||
sudo umount /mnt/hdd 2>/dev/null
|
||||
sudo umount /mnt/storage 2>/dev/null
|
||||
sudo umount /mnt/temp 2>/dev/null
|
||||
echo "# OK done unmount"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
########################################
|
||||
# LINKING all directories with ln
|
||||
########################################
|
||||
@ -1482,6 +1526,9 @@ if [ "$1" = "clean" ]; then
|
||||
|
||||
>&2 echo "# RASPIBLITZ DATA DRIVES - CLEANING"
|
||||
|
||||
# get HDD status
|
||||
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
if [ ${isMounted} -eq 0 ]; then
|
||||
>&2 echo "# FAIL: cannot clean - the drive is not mounted'"
|
||||
echo "error='not mounted'"
|
||||
@ -1492,9 +1539,9 @@ if [ "$1" = "clean" ]; then
|
||||
sudo apt-get install -y secure-delete 1>/dev/null
|
||||
|
||||
>&2 echo
|
||||
>&2 echo "# IMPORTANT: There is no 100% guarantee that sensitive data is completely deleted!"
|
||||
>&2 echo "# see: https://www.davescomputers.com/securely-deleting-files-solid-state-drive/"
|
||||
>&2 echo "# see: https://unix.stackexchange.com/questions/62345/securely-delete-files-on-btrfs-filesystem"
|
||||
>&2 echo "# IMPORTANT: No 100% guarantee that sensitive data is completely deleted!"
|
||||
# see: https://www.davescomputers.com/securely-deleting-files-solid-state-drive/"
|
||||
# see: https://unix.stackexchange.com/questions/62345/securely-delete-files-on-btrfs-filesystem"
|
||||
>&2 echo "# --> Dont resell or gift data drive. Destroy physically if needed."
|
||||
>&2 echo
|
||||
|
||||
@ -1537,7 +1584,7 @@ if [ "$1" = "clean" ]; then
|
||||
fi
|
||||
# on SSDs never shredd
|
||||
# https://www.davescomputers.com/securely-deleting-files-solid-state-drive/
|
||||
if [ ${isSSD} -eq 1 ]; then
|
||||
if [ "${isSSD}" == "1" ]; then
|
||||
whenDeleteSchredd=0
|
||||
fi
|
||||
|
||||
@ -1672,5 +1719,43 @@ if [ "$1" = "clean" ]; then
|
||||
|
||||
fi
|
||||
|
||||
########################################
|
||||
# UASP-fix
|
||||
########################################
|
||||
|
||||
if [ "$1" = "uasp-fix" ]; then
|
||||
|
||||
# get HDD status and if the connected adapter is supports UASP
|
||||
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
# check if UASP is already deactivated (on RaspiOS)
|
||||
# https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
|
||||
cmdlineExists=$(sudo ls /boot/cmdline.txt 2>/dev/null | grep -c "cmdline.txt")
|
||||
if [ ${cmdlineExists} -eq 1 ] && [ ${#hddAdapterUSB} -gt 0 ] && [ ${hddAdapterUSAP} -eq 0 ]; then
|
||||
echo "# Checking for UASP deactivation ..."
|
||||
usbQuirkActive=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=")
|
||||
usbQuirkDone=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=${hddAdapterUSB}:u")
|
||||
if [ ${usbQuirkActive} -gt 0 ] && [ ${usbQuirkDone} -eq 0 ]; then
|
||||
# remove old usb-storage.quirks
|
||||
sudo sed -i "s/usb-storage.quirks=[^ ]* //g" /boot/cmdline.txt
|
||||
fi
|
||||
if [ ${usbQuirkDone} -eq 0 ]; then
|
||||
# add new usb-storage.quirks
|
||||
sudo sed -i "1s/^/usb-storage.quirks=${hddAdapterUSB}:u /" /boot/cmdline.txt
|
||||
# go into reboot to activate new setting
|
||||
echo "# DONE deactivating UASP for ${hddAdapterUSB} ... reboot needed"
|
||||
echo "neededReboot=1"
|
||||
else
|
||||
echo "# Already UASP deactivated for ${hddAdapterUSB}"
|
||||
echo "neededReboot=0"
|
||||
fi
|
||||
else
|
||||
echo "# Skipping UASP deactivation ... cmdlineExists(${cmdlineExists}) hddAdapterUSB(${hddAdapterUSB}) hddAdapterUSAP(${hddAdapterUSAP})"
|
||||
echo "neededReboot=0"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "error='unkown command'"
|
||||
exit 1
|
||||
|
35
home.admin/config.scripts/blitz.hardware.sh
Normal file
35
home.admin/config.scripts/blitz.hardware.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "Hardware Tool Script"
|
||||
echo "blitz.hardware.sh [status]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
########################
|
||||
# GATHER HARDWARE INFO
|
||||
#######################
|
||||
|
||||
# detect known SBCs
|
||||
board=""
|
||||
isRaspberryPi4=$(cat /proc/device-tree/model | grep -c "Raspberry Pi 4")
|
||||
if [ "${isRaspberryPi4}" == "1" ]; then
|
||||
board="rp4"
|
||||
fi
|
||||
|
||||
# get how many RAM (in MB)
|
||||
ramMB=$(awk '/MemTotal/ {printf( "%d\n", $2 / 1024 )}' /proc/meminfo)
|
||||
|
||||
# get how many RAM (in GB - approx)
|
||||
ramGB=$(awk '/MemTotal/ {printf( "%d\n", $2 / 950000 )}' /proc/meminfo)
|
||||
|
||||
########################
|
||||
# OUTPUT HARDWARE INFO
|
||||
#######################
|
||||
|
||||
if [ "$1" = "status" ]; then
|
||||
echo "board='${board}'"
|
||||
echo "ramMB=${ramMB}"
|
||||
echo "ramGB=${ramGB}"
|
||||
fi
|
@ -1,10 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: check if services/apps are running and stop all ... or let thet to outside?
|
||||
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# managing the RaspiBlitz data - import, export, backup."
|
||||
echo "# blitz.migration.sh [status|export|import|export-gui|import-gui|migration-umbrel|migration-mynode]"
|
||||
echo "# blitz.migration.sh [export|import|export-gui|migration-umbrel|migration-mynode]"
|
||||
echo "error='missing parameters'"
|
||||
exit 1
|
||||
fi
|
||||
@ -22,25 +20,23 @@ fi
|
||||
# check if data drive is mounted - other wise cannot operate
|
||||
isMounted=$(sudo df | grep -c /mnt/hdd)
|
||||
|
||||
# gathering system info
|
||||
isBTRFS=$(lsblk -o FSTYPE,MOUNTPOINT | grep /mnt/hdd | awk '$1=$1' | cut -d " " -f 1 | grep -c btrfs)
|
||||
|
||||
# set place where zipped TAR file gets stored
|
||||
defaultZipPath="/mnt/hdd/temp"
|
||||
defaultUploadPath="/mnt/hdd/temp/migration"
|
||||
|
||||
# get local ip
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# SCP download and upload links
|
||||
scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz' ./"
|
||||
scpDownloadWin="scp -r bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz ."
|
||||
scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}"
|
||||
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}"
|
||||
scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./"
|
||||
scpDownloadWin="scp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ."
|
||||
scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
|
||||
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
|
||||
|
||||
# output status data & exit
|
||||
if [ "$1" = "status" ]; then
|
||||
echo "# RASPIBLITZ Data Import & Export"
|
||||
echo "isBTRFS=${isBTRFS}"
|
||||
echo "localip=\"${localip}\""
|
||||
echo "defaultUploadPath=\"${defaultUploadPath}\""
|
||||
echo "scpDownloadUnix=\"${scpDownloadUnix}\""
|
||||
echo "scpUploadUnix=\"${scpUploadUnix}\""
|
||||
echo "scpDownloadWin=\"${scpDownloadWin}\""
|
||||
@ -310,23 +306,23 @@ if [ "$1" = "export" ]; then
|
||||
|
||||
# zip it
|
||||
echo "# Building the Export File (this can take some time) .."
|
||||
sudo tar -zcvf ${defaultZipPath}/raspiblitz-export-temp.tar.gz -X ~/.exclude.temp /mnt/hdd 1>~/.include.temp 2>/dev/null
|
||||
sudo tar -zcvf ${defaultUploadPath}/raspiblitz-export-temp.tar.gz -X ~/.exclude.temp /mnt/hdd 1>~/.include.temp 2>/dev/null
|
||||
|
||||
# get md5 checksum
|
||||
echo "# Building checksum (can take also a while) ..."
|
||||
md5checksum=$(md5sum ${defaultZipPath}/raspiblitz-export-temp.tar.gz | head -n1 | cut -d " " -f1)
|
||||
md5checksum=$(md5sum ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | head -n1 | cut -d " " -f1)
|
||||
echo "md5checksum=${md5checksum}"
|
||||
|
||||
# get byte size
|
||||
bytesize=$(wc -c ${defaultZipPath}/raspiblitz-export-temp.tar.gz | cut -d " " -f 1)
|
||||
bytesize=$(wc -c ${defaultUploadPath}/raspiblitz-export-temp.tar.gz | cut -d " " -f 1)
|
||||
echo "bytesize=${bytesize}"
|
||||
|
||||
# final renaming
|
||||
name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz"
|
||||
echo "exportpath='${defaultZipPath}'"
|
||||
echo "exportpath='${defaultUploadPath}'"
|
||||
echo "filename='${name}'"
|
||||
sudo mv ${defaultZipPath}/raspiblitz-export-temp.tar.gz ${defaultZipPath}/${name}
|
||||
sudo chown bitcoin:bitcoin ${defaultZipPath}/${name}
|
||||
sudo mv ${defaultUploadPath}/raspiblitz-export-temp.tar.gz ${defaultUploadPath}/${name}
|
||||
sudo chown bitcoin:bitcoin ${defaultUploadPath}/${name}
|
||||
|
||||
# delete temp files
|
||||
rm ~/.exclude.temp
|
||||
@ -341,7 +337,7 @@ fi
|
||||
if [ "$1" = "export-gui" ]; then
|
||||
|
||||
# cleaning old migration files from blitz
|
||||
sudo rm ${defaultZipPath}/*.tar.gz 2>/dev/null
|
||||
sudo rm ${defaultUploadPath}/*.tar.gz 2>/dev/null
|
||||
|
||||
# stopping lnd / bitcoin
|
||||
echo "--> stopping services ..."
|
||||
@ -351,7 +347,7 @@ if [ "$1" = "export-gui" ]; then
|
||||
# create new migration file
|
||||
clear
|
||||
echo "--> creating blitz migration file ... (please wait)"
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh "export")
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh export)
|
||||
if [ ${#filename} -eq 0 ]; then
|
||||
echo "# FAIL: was not able to create migration file"
|
||||
exit 0
|
||||
@ -391,71 +387,29 @@ fi
|
||||
|
||||
if [ "$1" = "import" ]; then
|
||||
|
||||
# check second parameter for path and/or filename of import
|
||||
importFile="${defaultZipPath}/raspiblitz-*.tar.gz"
|
||||
if [ ${#2} -gt 0 ]; then
|
||||
# check if and/or filename of import
|
||||
containsPath=$(echo $2 | grep -c '/')
|
||||
if [ ${containsPath} -gt 0 ]; then
|
||||
startsOnPath=$(echo $2 | grep -c '^/')
|
||||
if [ ${startsOnPath} -eq 0 ]; then
|
||||
echo "# needs to be an absolut path: ${2}"
|
||||
echo "error='invalid path'"
|
||||
exit 1
|
||||
else
|
||||
if [ -d "$2" ]; then
|
||||
echo "# using path from parameter to search for import"
|
||||
endsOnPath=$(echo $2 | grep -c '/$')
|
||||
if [ ${endsOnPath} -eq 1 ]; then
|
||||
importFile="${2}raspiblitz-*.tar.gz"
|
||||
else
|
||||
importFile="${2}/raspiblitz-*.tar.gz"
|
||||
fi
|
||||
else
|
||||
echo "# using path+file from parameter for import"
|
||||
importFile=$2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# is just filename - to use with default path
|
||||
echo "# using file from parameter for import"
|
||||
importFile="${defaultZipPath}/${2}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# checking if file exists and unique
|
||||
echo "# checking for file with: ${importFile}"
|
||||
countZips=$(sudo ls ${importFile} 2>/dev/null | grep -c '.tar.gz')
|
||||
if [ ${countZips} -eq 0 ]; then
|
||||
echo "# can just find file when ends on .tar.gz and exists"
|
||||
echo "scpUploadUnix=\"${scpUploadUnix}\""
|
||||
echo "scpUploadWin=\"${scpUploadWin}\""
|
||||
echo "error='file not found'"
|
||||
# BACKGROUND:
|
||||
# the migration import is only called during setup phase - assume a prepared but clean HDD
|
||||
|
||||
# 2nd PARAMETER: file to import (expect that the file was valid checked from calling script)
|
||||
importFile=$2
|
||||
if [ "${importFile}" == "" ]; then
|
||||
echo "error='filename missing'"
|
||||
exit 1
|
||||
elif [ ${countZips} -eq 1 ]; then
|
||||
importFile=$(sudo ls ${importFile})
|
||||
else
|
||||
echo "# Multiple files found. Not sure which to use."
|
||||
echo "# Please use absolut-path+file as second parameter."
|
||||
echo "error='file not unique'"
|
||||
fi
|
||||
fileExists=$(sudo ls ${importFile} 2>/dev/null | grep -c "${importFile}")
|
||||
if [ "${fileExists}" != "1" ]; then
|
||||
echo "error='filename not found'"
|
||||
exit 1
|
||||
fi
|
||||
echo "importFile='${importFile}'"
|
||||
|
||||
echo "# Validating Checksum (can take some time) .."
|
||||
md5checksum=$(md5sum ${importFile} | head -n1 | cut -d " " -f1)
|
||||
isCorrect=$(echo ${importFile} | grep -c ${md5checksum})
|
||||
if [ ${isCorrect} -eq 1 ]; then
|
||||
echo "# OK -> checksum looks good: ${md5checksum}"
|
||||
else
|
||||
echo "# FAIL -> Checksum not correct: ${md5checksum}"
|
||||
echo "# Maybe transfer/upload failed?"
|
||||
echo "error='bad checksum'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "# Importing (overwrite) (can take some time) .."
|
||||
sudo tar -xf ${importFile} -C /
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "error='non zero exit state of unzipping migration file'"
|
||||
echo "# reboot system ... HDD will offer fresh formating"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy bitcoin/litecoin data backups back to orgplaces (if part of backup)
|
||||
if [ -d "/mnt/hdd/backup_bitcoin" ]; then
|
||||
@ -475,197 +429,18 @@ if [ "$1" = "import" ]; then
|
||||
sudo chown bitcoin:bitcoin -R /mnt/storage/litecoin 2>/dev/null
|
||||
fi
|
||||
|
||||
echo "# OK done - you may now want to:"
|
||||
echo "# make sure that HDD is not registered in /etc/fstab & reboot"
|
||||
echo "# to kickstart recovering system based in imported data"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "import-gui" ]; then
|
||||
|
||||
# get info about HDD
|
||||
echo "# Gathering HDD/SSD info ..."
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
# make sure HDD/SSD is not mounted
|
||||
# because importing migration just works during early setup
|
||||
if [ ${isMounted} -eq 1 ]; then
|
||||
echo "FAIL --> cannot import migration data when HDD/SSD is mounted"
|
||||
# check migration
|
||||
raspiblitzConfExists=$(sudo ls /mnt/hdd/raspiblitz.conf | grep -c "raspiblitz.conf")
|
||||
if [ "${raspiblitzConfExists}" != "1" ]; then
|
||||
echo "error='no raspiblitz.conf after unzip migration file'"
|
||||
echo "# reboot system ... HDD will offer fresh formating"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure a HDD/SSD is connected
|
||||
if [ ${#hddCandidate} -eq 0 ]; then
|
||||
echo "FAIL --> there is no HDD/SSD connected to migrate data to"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if HDD/SSD is big enough
|
||||
if [ ${hddGigaBytes} -lt 120 ]; then
|
||||
echo "FAIL --> connected HDD/SSD is too small"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ask format for new HDD/SSD
|
||||
OPTIONS=()
|
||||
# check if HDD/SSD contains Bitcoin Blockchain
|
||||
if [ "${hddBlocksBitcoin}" == "1" ]; then
|
||||
OPTIONS+=(KEEP "Dont format & use Blockchain")
|
||||
fi
|
||||
OPTIONS+=(EXT4 "Ext4 & 1 Partition (default)")
|
||||
OPTIONS+=(BTRFS "BTRFS & 3 Partitions (experimental)")
|
||||
|
||||
useBlockchain=0
|
||||
hddFormat=None
|
||||
CHOICE=$(whiptail --clear --title "Formatting ${hddCandidate}" --menu "" 10 52 3 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
clear
|
||||
case $CHOICE in
|
||||
EXT4)
|
||||
hddFormat=ext4
|
||||
echo "EXT4 FORMAT -->"
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ext4 ${hddPartitionCandidate})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL --> ${error}"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
BTRFS)
|
||||
hddFormat=btrfs
|
||||
echo "BTRFS FORMAT"
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format btrfs ${hddCandidate})
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo "FAIL --> ${error}"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
KEEP)
|
||||
echo "Keep HDD & Blockchain"
|
||||
useBlockchain=1
|
||||
;;
|
||||
*)
|
||||
echo "CANCEL"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ${useBlockchain} -eq 1 ]; then
|
||||
if [ ${isBTRFS} -eq 1 ]; then
|
||||
hddFormat=btrfs
|
||||
else
|
||||
hddFormat=ext4
|
||||
fi
|
||||
fi
|
||||
|
||||
# now temp mount the HDD/SSD
|
||||
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: Was not able to temp mount the HDD/SSD --> ${error}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure all directories betare propper linked
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh link
|
||||
|
||||
# make sure that temp directory exists and can be written by admin
|
||||
sudo mkdir -p ${defaultZipPath}
|
||||
sudo chmod 777 -R ${defaultZipPath}
|
||||
|
||||
clear
|
||||
echo
|
||||
echo "*****************************"
|
||||
echo "* UPLOAD THE MIGRATION FILE *"
|
||||
echo "*****************************"
|
||||
echo "If you have a migration file on your laptop you can now"
|
||||
echo "upload it and restore on the new HDD/SSD."
|
||||
echo
|
||||
echo "ON YOUR LAPTOP open a new terminal and change into"
|
||||
echo "the directory where your migration file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp -r ./raspiblitz-*.tar.gz admin@${localip}:${defaultZipPath}"
|
||||
echo ""
|
||||
echo "Use password 'raspiblitz' to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done."
|
||||
read key
|
||||
|
||||
countZips=$(sudo ls ${defaultZipPath}/raspiblitz-*.tar.gz 2>/dev/null | grep -c 'raspiblitz-')
|
||||
|
||||
# in case no upload found
|
||||
if [ ${countZips} -eq 0 ]; then
|
||||
echo
|
||||
echo "FAIL: Was not able to detect uploaded file in ${defaultZipPath}"
|
||||
echo "error='no file found'"
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# in case of multiple files
|
||||
if [ ${countZips} -gt 1 ]; then
|
||||
echo
|
||||
echo "# FAIL: Multiple possible files detected in ${defaultZipPath}"
|
||||
echo "error='multiple files'"
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# restore upload
|
||||
echo
|
||||
echo "OK: Upload found in ${defaultZipPath} - restoring data ... (please wait)"
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh "import")
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
echo
|
||||
echo "# FAIL: Was not able to restore data"
|
||||
echo "error='${error}'"
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check & load config
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo
|
||||
echo "FAIL: No raspiblitz.conf found afer migration restore"
|
||||
echo "error='migration contains no raspiblitz.conf'"
|
||||
sleep 3
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "OK: Migration data was imported"
|
||||
echo "PRESS ENTER"
|
||||
read key
|
||||
|
||||
# Copy from other computer is only option for Bitcoin
|
||||
if [ "${network}" == "bitcoin" ] && [ ${useBlockchain} -eq 0 ]; then
|
||||
OPTIONS=(SYNC "Re-Sync & Validate Blockchain" \
|
||||
COPY "Copy over LAN from other Computer"
|
||||
)
|
||||
CHOICE=$(whiptail --clear --title "How to get Blockchain?" --menu "" 9 52 2 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
clear
|
||||
case $CHOICE in
|
||||
COPY)
|
||||
echo "Copy Blockchain Data -->"
|
||||
/home/admin/50copyHDD.sh stop-after-script
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# if there is no blockchain yet - fallback to syncing
|
||||
if [ $(sudo ls /mnt/hdd/bitcoin/ 2>/dev/null | grep -c blocks) -eq 0 ]; then
|
||||
echo "Setting Blockchain Data to resync ..."
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/blocks 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/chainstate 2>/dev/null
|
||||
sudo -u bitcoin touch /mnt/hdd/${network}/blocks/.selfsync
|
||||
fi
|
||||
|
||||
echo "--> Now rebooting and kicking your node in to recovery/update mode ..."
|
||||
sudo shutdown -r now
|
||||
# correcting all user rights on data will be done by provisioning process
|
||||
echo "# OK import done - provisioning process needed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "error='unkown command'"
|
||||
exit 1
|
||||
exit 1
|
@ -4,7 +4,7 @@
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "small config script to set a passwords A,B,C & D"
|
||||
echo "blitz.setpassword.sh a [?newpassword] "
|
||||
echo "blitz.setpassword.sh b [?newpassword] "
|
||||
echo "blitz.setpassword.sh b [?newpassword] "
|
||||
echo "blitz.setpassword.sh c [?oldpassword] [?newpassword] "
|
||||
echo "or just as a password enter dialog (result as file)"
|
||||
echo "blitz.setpassword.sh [x] [text] [result-file] [?empty-allowed]"
|
||||
@ -69,9 +69,6 @@ if [ ${#abcd} -eq 0 ]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Changing Password ${abcd} ..."
|
||||
echo ""
|
||||
|
||||
############################
|
||||
# PASSWORD A
|
||||
if [ "${abcd}" = "a" ]; then
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
|
||||
# LNTYPE is lnd | cln
|
||||
if [ $# -gt 0 ];then
|
||||
@ -70,6 +70,13 @@ if [ ${bitcoinRunning} -eq 1 ]; then
|
||||
echo "bitcoinErrorFull='${bitcoinErrorFull}'"
|
||||
else
|
||||
|
||||
###################################
|
||||
# Get data from blockchain network
|
||||
###################################
|
||||
|
||||
source <(sudo -u bitcoin /home/admin/config.scripts/network.monitor.sh peer-status)
|
||||
echo "blockchainPeers=${peers}"
|
||||
|
||||
##############################
|
||||
# Get data from blockchaininfo
|
||||
##############################
|
||||
@ -278,6 +285,9 @@ else
|
||||
echo "blitzTUIRestarts=0"
|
||||
fi
|
||||
|
||||
# check if runnig in vagrant
|
||||
vagrant=$(df | grep -c "/vagrant")
|
||||
echo "vagrant=${vagrant}"
|
||||
|
||||
# check if online if problem with other stuff
|
||||
|
||||
|
@ -46,8 +46,8 @@ cfg.reload()
|
||||
|
||||
# todo: make sure that also ACME script uses TOR if activated
|
||||
session = requests.session()
|
||||
if cfg.run_behind_tor.value:
|
||||
session.proxies = {'http': 'socks5h://127.0.0.1:9050', 'https': 'socks5h://127.0.0.1:9050'}
|
||||
# if cfg.run_behind_tor.value:
|
||||
# session.proxies = {'http': 'socks5h://127.0.0.1:9050', 'https': 'socks5h://127.0.0.1:9050'}
|
||||
|
||||
|
||||
#####################
|
||||
@ -613,7 +613,7 @@ This looks not like a valid IP.
|
||||
|
||||
# restart certain services to update urls
|
||||
if "SPHINX" in serviceName:
|
||||
print("# restarting Sphinx Relay to pickup new public url (please wait) ...")
|
||||
print("# restarting services to pickup new public url (please wait) ...")
|
||||
os.system("sudo systemctl restart sphinxrelay")
|
||||
time.sleep(8)
|
||||
|
||||
|
@ -210,7 +210,7 @@ The following additional information is available:
|
||||
time.sleep(3)
|
||||
|
||||
# trigger restart of relevant services so they can pickup new environment
|
||||
print("# restarting Sphinx Relay to pickup new public url (please wait) ...")
|
||||
print("# restarting services to pickup new public url (please wait) ...")
|
||||
os.system("sudo systemctl restart sphinxrelay 2>/dev/null")
|
||||
time.sleep(8)
|
||||
|
||||
@ -416,7 +416,7 @@ def main():
|
||||
|
||||
# action after possibly new created bride
|
||||
if service_name == SERVICE_SPHINX:
|
||||
print("# restarting Sphinx Relay to pickup new public url (please wait) ...")
|
||||
print("# restarting services to pickup new public url (please wait) ...")
|
||||
os.system("sudo systemctl restart sphinxrelay")
|
||||
time.sleep(8)
|
||||
|
||||
|
143
home.admin/config.scripts/blitz.upload.sh
Normal file
143
home.admin/config.scripts/blitz.upload.sh
Normal file
@ -0,0 +1,143 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# use to prepare & check scp or web file upload to RaspiBlitz"
|
||||
echo "# blitz.upload.sh prepare-upload"
|
||||
echo "# blitz.upload.sh check-upload ?[scb|lnd-rescue|migration]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# get local ip
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# set upload path
|
||||
if [ -d "/mnt/hdd/temp" ]; then
|
||||
# HDD with temp directory is connected - the use it
|
||||
defaultUploadPath="/mnt/hdd/temp/upload"
|
||||
defaultUploadUser="bitcoin"
|
||||
else
|
||||
# fallback if no HDD is connected
|
||||
defaultUploadPath="/home/bitcoin/temp/upload"
|
||||
defaultUploadUser="bitcoin"
|
||||
fi
|
||||
|
||||
|
||||
# 1st PRAMETER action
|
||||
action="$1"
|
||||
|
||||
if [ "${action}" == "prepare-upload" ]; then
|
||||
|
||||
# make sure that temp directory exists, is clear and can be written by ${defaultUploadUser}
|
||||
sudo mkdir -p ${defaultUploadPath} 2>/dev/null
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
sudo chown -R ${defaultUploadUser}:${defaultUploadUser} ${defaultUploadPath} 2>/dev/null
|
||||
|
||||
echo "localip='${localip}'"
|
||||
echo "defaultUploadPath='${defaultUploadPath}'"
|
||||
echo "defaultUploadUser='${defaultUploadUser}'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${action}" == "check-upload" ]; then
|
||||
|
||||
# 2nd PARAMETER is type of upload (optional)
|
||||
type=$2
|
||||
echo "type='${type}'"
|
||||
|
||||
# check if there to less or to many files in upload directory
|
||||
countFiles=$(ls ${defaultUploadPath} | wc -l 2>/dev/null)
|
||||
if [ ${countFiles} -lt 1 ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='not-found'"
|
||||
exit 1
|
||||
fi
|
||||
if [ ${countFiles} -gt 1 ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='multiple'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get the file uploaded (full path)
|
||||
filename=$(sudo ls ${defaultUploadPath}/*.*)
|
||||
echo "# filename(${filename})"
|
||||
|
||||
# check of size >0
|
||||
byteSize=$(ls -l ${filename} | awk '{print $5}')
|
||||
echo "# byteSize(${byteSize})"
|
||||
if [ "${byteSize}" == "" ] || [ "${byteSize}" == "0" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='invalid byte size: ${byteSize}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# SCB check if file looks valid
|
||||
if [ "${type}" == "scb" ]; then
|
||||
|
||||
# general filename check
|
||||
typeCount=$(sudo ls ${defaultUploadPath}/*.backup 2>/dev/null | grep -c '.backup')
|
||||
if [ "${typeCount}" != "1" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='not *.backup'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# LND-RESCUE check if file looks valid
|
||||
if [ "${type}" == "lnd-rescue" ]; then
|
||||
|
||||
# general filename check
|
||||
typeCount=$(sudo ls ${defaultUploadPath}/lnd-rescue-*.tar.gz 2>/dev/null | grep -c 'lnd-rescue')
|
||||
if [ "${typeCount}" != "1" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='not lnd-rescue-*.tar.gz'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# checksum test
|
||||
md5checksum=$(md5sum ${filename} | head -n1 | cut -d " " -f1)
|
||||
echo "# filename(${md5checksum})"
|
||||
isCorrect=$(echo ${filename} | grep -c ${md5checksum})
|
||||
if [ "${isCorrect}" != "1" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='incorrect checksum'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# MIGRATION check if file looks valid
|
||||
if [ "${type}" == "migration" ]; then
|
||||
|
||||
# general filename check
|
||||
typeCount=$(sudo ls ${defaultUploadPath}/raspiblitz-*.tar.gz 2>/dev/null | grep -c 'raspiblitz')
|
||||
if [ "${typeCount}" != "1" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='not raspiblitz-*.tar.gz'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# checksum test
|
||||
md5checksum=$(md5sum ${filename} | head -n1 | cut -d " " -f1)
|
||||
echo "# filename(${md5checksum})"
|
||||
isCorrect=$(echo ${filename} | grep -c ${md5checksum})
|
||||
if [ "${isCorrect}" != "1" ]; then
|
||||
sudo rm ${defaultUploadPath}/* 2>/dev/null
|
||||
echo "error='invalid'"
|
||||
echo "errorDetail='incorrect checksum'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ok looks good - return filename & more info
|
||||
echo "filename=${filename}"
|
||||
echo "bytesize=${byteSize}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "error='unkown parameter'"
|
||||
exit 1
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
|
@ -22,16 +22,17 @@ ACME_CERT_HOME="${ACME_CONFIG_HOME}/certs"
|
||||
ACME_IS_INSTALLED=0
|
||||
|
||||
# if Tor is on test that CURL is by default running over Tor
|
||||
if [ "${runBehindTor}" == "on" ]; then
|
||||
echo "# checking if Tor proxy for CURL is working ..."
|
||||
checkTor=$(curl -s https://check.torproject.org | grep -c "Congratulations")
|
||||
if [ ${checkTor} -eq 0 ]; then
|
||||
echo "err='curl tor proxy not working'"
|
||||
exit 1
|
||||
else
|
||||
echo "# OK Tor proxy for CURL"
|
||||
fi
|
||||
fi
|
||||
# TODO: issue https://github.com/rootzoll/raspiblitz/issues/1341
|
||||
#if [ "${runBehindTor}" == "on" ]; then
|
||||
# echo "# checking if Tor proxy for CURL is working ..."
|
||||
# checkTor=$(curl -s https://check.torproject.org | grep -c "Congratulations")
|
||||
# if [ ${checkTor} -eq 0 ]; then
|
||||
# echo "err='curl tor proxy not working'"
|
||||
# exit 1
|
||||
# else
|
||||
# echo "# OK Tor proxy for CURL"
|
||||
# fi
|
||||
#fi
|
||||
|
||||
###################
|
||||
# FUNCTIONS
|
||||
@ -139,13 +140,18 @@ function refresh_certs_with_nginx() {
|
||||
fi
|
||||
|
||||
certsDirectories=$(sudo ls ${ACME_CERT_HOME})
|
||||
echo "# certsDirectories(${certsDirectories})"
|
||||
directoryArray=(`echo "${certsDirectories}" | tr ' ' ' '`)
|
||||
for i in "${directoryArray[@]}"; do
|
||||
FQDN=$(echo "${i}" | cut -d "_" -f1)
|
||||
echo "# i(${i})"
|
||||
echo "# FQDN(${FQDN})"
|
||||
# check if there is a LetsEncrypt Subscription for this domain
|
||||
details=$(/home/admin/config.scripts/blitz.subscriptions.letsencrypt.py subscription-detail $FQDN)
|
||||
if [ ${#details} -gt 10 ]; then
|
||||
|
||||
echo "# details(${details})"
|
||||
|
||||
# get target for that domain
|
||||
options=$(echo "${details}" | jq -r ".target")
|
||||
|
||||
|
@ -79,6 +79,10 @@ if [ "${localip:0:4}" = "169." ]; then
|
||||
dhcp=0
|
||||
fi
|
||||
|
||||
#############################################
|
||||
# check WifiConfig
|
||||
configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null| grep -c "network=")
|
||||
|
||||
#############################################
|
||||
# check for internet connection
|
||||
online=0
|
||||
@ -175,6 +179,7 @@ if [ "$1" == "status" ]; then
|
||||
echo "### LOCAL INTERNET ###"
|
||||
echo "localip=${localip}"
|
||||
echo "dhcp=${dhcp}"
|
||||
echo "configWifiExists=${configWifiExists}"
|
||||
echo "network_device=${networkDevice}"
|
||||
echo "network_rx='${network_rx}'"
|
||||
echo "network_tx='${network_tx}'"
|
||||
|
@ -29,11 +29,8 @@ activateBitcoinOverTOR()
|
||||
# make sure all is turned off and removed and then activate fresh (so that also old settings get removed)
|
||||
deactivateBitcoinOverTOR
|
||||
|
||||
echo "# Make sure the user bitcoin is in the debian-tor group"
|
||||
sudo usermod -a -G debian-tor bitcoin
|
||||
sudo chmod 777 /home/bitcoin/.${network}/${network}.conf
|
||||
echo "Adding Tor config to the the ${network}.conf ..."
|
||||
# deprecate 'torpassword='
|
||||
sudo sed -i "s/^torpassword=.*//g" /home/bitcoin/.${network}/${network}.conf
|
||||
echo "onlynet=onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "proxy=127.0.0.1:9050" >> /home/bitcoin/.${network}/${network}.conf
|
||||
@ -41,15 +38,7 @@ activateBitcoinOverTOR()
|
||||
echo "test.bind=127.0.0.1" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "dnsseed=0" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "dns=0" >> /home/bitcoin/.${network}/${network}.conf
|
||||
if [ "${network}" = "bitcoin" ]; then
|
||||
# adding some bitcoin onion nodes to connect to to make connection easier
|
||||
echo "main.addnode=ira7kqcbff52wofoong2dieh2xlvmw4e7ya3znsqn7wivn6armetvrqd.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "main.addnode=xlpi353v7ia5b73msynr7tmddgxoco7n2r2bljt5txpv6bpzzphkreyd.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "main.addnode=ccjrb6va3j6re4lg2lerlt6wyvlb4tod7qbe7rwiouuapb7etvterxyd.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "main.addnode=s7m4mnd6bokujhywsocxibispktruormushdroeaeqeb3imvztfs3vid.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "main.addnode=ldvhlpsrvspquqnl3gutz7grfu5lb3m2dgnezpl3tlkxgpoiw2g5mzid.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
echo "main.addnode=gliovxxzyy2rkwaoz25khf6oa64c3csqzjn3t6dodsjuf34w6a6ktsyd.onion" >> /home/bitcoin/.${network}/${network}.conf
|
||||
fi
|
||||
|
||||
# remove empty lines
|
||||
sudo sed -i '/^ *$/d' /home/bitcoin/.${network}/${network}.conf
|
||||
sudo chmod 444 /home/bitcoin/.${network}/${network}.conf
|
||||
@ -194,6 +183,11 @@ if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
torRunning=$(sudo systemctl --no-pager status tor@default | grep -c "Active: active")
|
||||
torFunctional=$(curl --connect-timeout 30 --socks5-hostname "127.0.0.1:9050" https://check.torproject.org 2>/dev/null | grep -c "Congratulations. This browser is configured to use Tor.")
|
||||
if [ "${torFunctional}" == "" ]; then torFunctional=0; fi
|
||||
if [ ${torFunctional} -gt 1 ]; then torFunctional=1; fi
|
||||
|
||||
# if started with status
|
||||
if [ "$1" = "status" ]; then
|
||||
# is Tor activated
|
||||
@ -202,7 +196,8 @@ if [ "$1" = "status" ]; then
|
||||
else
|
||||
echo "activated=0"
|
||||
fi
|
||||
|
||||
echo "torRunning=${torRunning}"
|
||||
echo "torFunctional=${torFunctional}"
|
||||
echo "config='${torrc}'"
|
||||
exit 0
|
||||
fi
|
||||
@ -269,20 +264,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# check if Tor was already installed and is funtional
|
||||
echo ""
|
||||
echo "*** Check if Tor service is functional ***"
|
||||
torRunning=$(curl --connect-timeout 10 --socks5-hostname 127.0.0.1:9050 https://check.torproject.org 2>/dev/null | grep "Congratulations. This browser is configured to use Tor." -c)
|
||||
if [ ${torRunning} -gt 0 ]; then
|
||||
clear
|
||||
echo "You are all good - Tor is already running."
|
||||
echo ""
|
||||
exit 0
|
||||
else
|
||||
echo "Tor not running ... proceed with switching to Tor."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# install package just in case it was deinstalled
|
||||
packageInstalled=$(dpkg -s tor-arm | grep -c 'Status: install ok')
|
||||
if [ ${packageInstalled} -eq 0 ]; then
|
||||
|
@ -81,25 +81,48 @@ update_config=1"
|
||||
# or when WIFI is inactive but a wpa_supplicant.conf exists restore this
|
||||
elif [ "$1" == "backup-restore" ]; then
|
||||
|
||||
# check if HDD already exists
|
||||
if [ -d /mnt/hdd/app-data ]; then
|
||||
echo "# running backup/restore wifi settings"
|
||||
else
|
||||
echo "error='no hdd'"
|
||||
exit 1
|
||||
fi
|
||||
# print wifi state
|
||||
echo "wifiIsSet=${wifiIsSet}"
|
||||
|
||||
# check if HDD backup location is available (for backup or restore)
|
||||
hddBackupLocationAvailable=0
|
||||
if [ -d /mnt/hdd/app-data ]; then
|
||||
hddBackupLocationAvailable=1
|
||||
fi
|
||||
echo "hddBackupLocationAvailable=${hddBackupLocationAvailable}"
|
||||
|
||||
hddRestoreConfigAvailable=$(sudo ls /mnt/hdd/app-data/wpa_supplicant.conf 2>/dev/null | grep -c "wpa_supplicant.conf")
|
||||
echo "hddRestoreConfigAvailable=${hddRestoreConfigAvailable}"
|
||||
|
||||
# check if mem copy of wifi config is available (for restore only)
|
||||
# this should be available if a backup on HDD exists and HDD is not mounted yet but was inspected by datadrive script
|
||||
memRestoreConfigAvailable=$(sudo ls /var/cache/raspiblitz/wpa_supplicant.conf 2>/dev/null | grep -c "wpa_supplicant.conf")
|
||||
echo "memRestoreConfigAvailable=${memRestoreConfigAvailable}"
|
||||
|
||||
wifiBackUpExists=$()
|
||||
if [ ${wifiIsSet} -eq 1 ]; then
|
||||
# BACKUP latest wifi settings to HDD
|
||||
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /mnt/hdd/app-data/wpa_supplicant.conf
|
||||
echo "wifiRestore=0"
|
||||
echo "wifiBackup=1"
|
||||
# BACKUP latest wifi settings to HDD if available
|
||||
if [ ${hddBackupLocationAvailable} -eq 1 ]; then
|
||||
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /mnt/hdd/app-data/wpa_supplicant.conf
|
||||
echo "wifiRestore=0"
|
||||
echo "wifiBackup=1"
|
||||
else
|
||||
echo "wifiRestore=0"
|
||||
echo "wifiBackup=0"
|
||||
fi
|
||||
exit 0
|
||||
elif [ -f /mnt/hdd/app-data/wpa_supplicant.conf ]; then
|
||||
elif [ ${hddRestoreConfigAvailable} -eq 1 ]; then
|
||||
# RESTORE backuped wifi settings from HDD to RaspiBlitz
|
||||
sudo cp /mnt/hdd/app-data/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
echo "# restoring old wifi settings ... wait 4 secounds to connect"
|
||||
echo "# restoring old wifi settings from HDD ... wait 4 secounds to connect"
|
||||
sudo wpa_cli -i wlan0 reconfigure 1>/dev/null
|
||||
sleep 4
|
||||
echo "wifiRestore=1"
|
||||
echo "wifiBackup=0"
|
||||
exit 0
|
||||
elif [ ${hddRestoreConfigAvailable} -eq 1 ]; then
|
||||
# RESTORE backuped wifi settings from MEMCOPY to RaspiBlitz
|
||||
sudo cp /var/cache/raspiblitz/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
echo "# restoring old wifi settings from MEMCOPY ... wait 4 secounds to connect"
|
||||
sudo wpa_cli -i wlan0 reconfigure 1>/dev/null
|
||||
sleep 4
|
||||
echo "wifiRestore=1"
|
||||
|
571
home.admin/config.scripts/lnd.backup.sh
Executable file
571
home.admin/config.scripts/lnd.backup.sh
Executable file
@ -0,0 +1,571 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# LND RESCUE FILE (tar.gz of complete lnd directory)"
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# lnd.backup.sh lnd-export"
|
||||
echo "# lnd.backup.sh lnd-export-gui"
|
||||
echo "# lnd.backup.sh lnd-import [file]"
|
||||
echo "# lnd.backup.sh lnd-import-gui [setup|production] [?resultfile]"
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# STATIC CHANNEL BACKUP"
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# lnd.backup.sh scb-export"
|
||||
echo "# lnd.backup.sh scb-export-gui"
|
||||
echo "# lnd.backup.sh scb-import [file]"
|
||||
echo "# lnd.backup.sh scb-import-gui [setup|production] [?resultfile]"
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# SEED WORDS"
|
||||
echo "# ---------------------------------------------------"
|
||||
echo "# lnd.backup.sh seed-export-gui [lndseeddata]"
|
||||
echo "# lnd.backup.sh seed-import-gui [resultfile]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1st PRAMETER action
|
||||
mode="$1"
|
||||
|
||||
################################
|
||||
# LND RESCUE FILE - EXPORT
|
||||
################################
|
||||
|
||||
if [ ${mode} = "lnd-export" ]; then
|
||||
|
||||
echo "# *** LND.RESCUE --> BACKUP"
|
||||
downloadPath="/home/admin"
|
||||
fileowner="admin"
|
||||
|
||||
# stop LND
|
||||
echo "# Stopping lnd..."
|
||||
sudo systemctl stop lnd
|
||||
sleep 5
|
||||
echo "# OK"
|
||||
echo
|
||||
|
||||
# add lnd version info into lnd dir (to detect needed updates later)
|
||||
lndVersion=$(sudo -u bitcoin lncli getinfo | jq -r ".version" | cut -d ' ' -f1)
|
||||
sudo rm /mnt/hdd/lnd/version.info 2>/dev/null
|
||||
echo "${lndVersion}" > /home/admin/lnd.version.info
|
||||
sudo mv /home/admin/lnd.version.info /mnt/hdd/lnd/version.info
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/version.info
|
||||
|
||||
# zip it
|
||||
sudo tar -zcvf ${downloadPath}/lnd-rescue.tar.gz /mnt/hdd/lnd 1>&2
|
||||
sudo chown ${fileowner}:${fileowner} ${downloadPath}/lnd-rescue.tar.gz 1>&2
|
||||
|
||||
# delete old backups
|
||||
rm ${downloadPath}/lnd-rescue-*.tar.gz 2>/dev/null 1>/dev/null
|
||||
|
||||
# name with md5 checksum
|
||||
md5checksum=$(md5sum ${downloadPath}/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1)
|
||||
mv ${downloadPath}/lnd-rescue.tar.gz ${downloadPath}/lnd-rescue-${md5checksum}.tar.gz 1>&2
|
||||
byteSize=$(ls -l ${downloadPath}/lnd-rescue-${md5checksum}.tar.gz | awk '{print $5}')
|
||||
|
||||
# check file size
|
||||
if [ ${byteSize} -lt 100 ]; then
|
||||
echo "error='backup is empty'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# output result data
|
||||
echo "# lnd service is stopped for security"
|
||||
echo "filename='${downloadPath}/lnd-rescue-${md5checksum}.tar.gz'"
|
||||
echo "fileowner='${fileowner}'"
|
||||
echo "size=${byteSize}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ${mode} = "lnd-export-gui" ]; then
|
||||
|
||||
# create lnd rescue file
|
||||
source <(/home/admin/config.scripts/lnd.backup.sh lnd-export)
|
||||
if [ "${error}" != "" ]; then
|
||||
echo "error='${error}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get local ip info
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
|
||||
# offer SCP for download
|
||||
clear
|
||||
echo
|
||||
echo "****************************"
|
||||
echo "* DOWNLOAD THE RESCUE FILE *"
|
||||
echo "****************************"
|
||||
echo
|
||||
echo "ON YOUR MAC & LINUX LAPTOP - RUN IN NEW TERMINAL:"
|
||||
echo "scp '${fileowner}@${localip}:${filename}' ./"
|
||||
echo "ON WINDOWS USE:"
|
||||
echo "scp ${fileowner}@${localip}:${filename} ."
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo "Check for correct file size after transfer: ${byteSize} byte"
|
||||
echo
|
||||
echo "BEWARE: Your Lightning node is now stopped. It's safe to backup the data and"
|
||||
echo "restore it on a fresh RaspiBlitz. But once this Lightning node gets started"
|
||||
echo "again or rebooted, it's not advised to restore the backup file because"
|
||||
echo "it would contain outdated channel data and can lead to loss of channel funds."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
################################
|
||||
# LND RESCUE FILE - IMPORT
|
||||
################################
|
||||
|
||||
if [ ${mode} = "lnd-import" ]; then
|
||||
|
||||
# 2nd PARAMETER: file to import (expect that the file was valid checked from calling script)
|
||||
filename=$2
|
||||
if [ "${filename}" == "" ]; then
|
||||
echo "error='filename missing'"
|
||||
exit 1
|
||||
fi
|
||||
fileExists=$(sudo ls ${filename} 2>/dev/null | grep -c "${filename}")
|
||||
if [ "${fileExists}" != "1" ]; then
|
||||
echo "error='filename not found'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# stop LND
|
||||
echo "# stopping lnd..."
|
||||
sudo systemctl stop lnd 1>/dev/null
|
||||
sleep 5
|
||||
|
||||
# clean DIR
|
||||
echo "# cleaning old LND data ..."
|
||||
sudo rm -r /mnt/hdd/lnd/* 1>/dev/null 2>/dev/null
|
||||
|
||||
# unpack zip
|
||||
echo "# restoring LND data from ${filename} ..."
|
||||
sudo tar -xf ${filename} -C / 1>/dev/null
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd 1>/dev/null
|
||||
|
||||
# lnd version of LND rescue file (thats packed as extra info in the file)
|
||||
# its included since RaspiBlitz v1.7.1 /mnt/hdd/lnd/version.info
|
||||
# this can happen if someone uses the manual LND update and then uploads to an old default LND
|
||||
# if so just signal this in the output
|
||||
|
||||
echo "# DONE - lnd service is still stopped - start manually with command:"
|
||||
echo "# sudo systemctl start lnd"
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
if [ ${mode} = "lnd-import-gui" ]; then
|
||||
|
||||
# get by second parameter if this call if happening during setup or production
|
||||
scenario=$2
|
||||
if [ "${scenario}" != "setup" ] && [ "${scenario}" != "production" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
RESULTFILE=$3
|
||||
if [ "${RESULTFILE}" == "" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine password info based on scenario
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
passwordInfo="password 'raspiblitz'"
|
||||
else
|
||||
passwordInfo="your Password A"
|
||||
fi
|
||||
|
||||
# get defaultUploadPath, localIP, etc
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh prepare-upload)
|
||||
|
||||
filename=""
|
||||
while [ "${filename}" == "" ]
|
||||
do
|
||||
clear
|
||||
echo "**************************"
|
||||
echo "* UPLOAD THE RESCUE FILE *"
|
||||
echo "**************************"
|
||||
echo "If you have a lnd-rescue backup file on your laptop you can now"
|
||||
echo "upload it and restore your latest LND state."
|
||||
echo
|
||||
echo "CAUTION: Dont restore old LND states - risk of loosing funds!"
|
||||
echo
|
||||
echo "To make upload open a new terminal on your laptop,"
|
||||
echo "change into the directory where your lnd-rescue file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp -r ./lnd-rescue-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/"
|
||||
echo ""
|
||||
echo "Use ${passwordInfo} to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done"
|
||||
read key
|
||||
|
||||
# check upload (will return filename or error)
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh check-upload lnd-rescue)
|
||||
if [ "${filename}" != "" ]; then
|
||||
echo "OK - File found: ${filename}"
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
elif [ "${error}" == "not-found" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There was no upload found in ${defaultUploadPath}"
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "multiple" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There are multiple lnd-rescue files in directory ${defaultUploadPath}"
|
||||
echo "Make sure you upload only one tar.gz-file and start again."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "invalid" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "The file uploaded is not a valid (complete upload failed or not correct file)."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
else
|
||||
# create no result file and exit
|
||||
echo "!! WARNING !! Unknown State (report to devs)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${keyRetry}" == "x" ] || [ "${keyRetry}" == "X" ] || [ "${keyRetry}" == "'x'" ]; then
|
||||
# create no result file and exit
|
||||
echo "# USER CANCEL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# in setup scenario the final import is happening during provison
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
# just add lndrescue filename to give file
|
||||
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
|
||||
echo "lndrescue='${filename}'" >> $RESULTFILE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# in production now start restoring LND data based on file
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# ask security question before deleting old wallet
|
||||
echo "WARNING: This will delete/overwrite the LND state/funds of this RaspiBlitz."
|
||||
echo
|
||||
echo "Write the word 'override' and press ENTER to CONTINUE:"
|
||||
read securityInput
|
||||
if [ "${securityInput}" != "override" ] && [ "${securityInput}" != "'override'" ]; then
|
||||
echo
|
||||
echo "CANCELED import of uploaded rescue file"
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
|
||||
# run import process
|
||||
echo "OK deleting old LND data & restoring imported rescue file ..."
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh lnd-import ${filename})
|
||||
|
||||
# TODO: check if update of LND is needed (see detailes in lnd-import) for edge case
|
||||
|
||||
# turn off auto-unlock if activated because password c might now change
|
||||
if [ "${autoUnlock}" == "on" ]; then
|
||||
/home/admin/config.scripts/lnd.autounlock.sh off
|
||||
fi
|
||||
|
||||
# restarting lnd & give final info
|
||||
sudo systemctl start lnd
|
||||
echo "DONE - lnd is now restarting .. Password C is now like within your rescue file"
|
||||
echo "Check that LND is starting up correctly and your old channel & funds are restored."
|
||||
echo "Take into account that some channels might have been force closed in the meanwhile."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################################
|
||||
# STATIC CHANEL BACKUP FILE - EXPORT
|
||||
####################################
|
||||
|
||||
if [ ${mode} = "scb-export" ]; then
|
||||
|
||||
# get file info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
echo "filename='/mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup'"
|
||||
echo "fileuser='bitcoin'"
|
||||
|
||||
# localip
|
||||
source <(/home/admin/config.scripts/internet.sh status local)
|
||||
echo "localip='${localip}'"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ${mode} = "scb-export-gui" ]; then
|
||||
|
||||
# get the scb info
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh scb-export)
|
||||
|
||||
# show download info
|
||||
clear
|
||||
echo "**************************************"
|
||||
echo "* DOWNLOAD STATIC CHANEL BACKUP FILE *"
|
||||
echo "**************************************"
|
||||
echo
|
||||
echo "RUN THE FOLLOWING COMMAND ON YOUR LAPTOP IN NEW TERMINAL:"
|
||||
echo "scp -r ${fileuser}@${localip}:${filename} ./"
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo
|
||||
echo "NOTE: Use this file when setting up a fresh RaspiBlitz by choosing"
|
||||
echo "option OLD WALLET and then SCB+SEED -> Seed & channel.backup file"
|
||||
echo "Will just recover on-chain & channel-funds, but closing all channels"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################################
|
||||
# STATIC CHANEL BACKUP FILE - IMPORT
|
||||
####################################
|
||||
|
||||
if [ ${mode} = "scb-import" ]; then
|
||||
|
||||
# 2nd PARAMETER: file to import (expect that the file was valid checked from calling script)
|
||||
filename=$2
|
||||
if [ "${filename}" == "" ]; then
|
||||
echo "error='filename missing'"
|
||||
exit 1
|
||||
fi
|
||||
fileExists=$(sudo ls ${filename} 2>/dev/null | grep -c "${filename}")
|
||||
if [ "${fileExists}" != "1" ]; then
|
||||
echo "error='filename not found'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# place the the file at '/home/admin/channel.backup'
|
||||
sudo mv ${filename} /home/admin/channel.backup
|
||||
sudo chmod 777 /home/admin/channel.backup
|
||||
sudo chown admin:admin /home/admin/channel.backup
|
||||
echo "# OK - placed SCB file at /home/admin/channel.backup"
|
||||
|
||||
fi
|
||||
|
||||
if [ ${mode} = "scb-import-gui" ]; then
|
||||
|
||||
# get by second parameter if this call if happening during setup or production
|
||||
scenario=$2
|
||||
if [ "${scenario}" != "setup" ] && [ "${scenario}" != "production" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
RESULTFILE=$3
|
||||
if [ "${RESULTFILE}" == "" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# determine password info based on scenario
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
passwordInfo="password 'raspiblitz'"
|
||||
else
|
||||
passwordInfo="your Password A"
|
||||
fi
|
||||
|
||||
# get defaultUploadPath, localIP, etc
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh prepare-upload)
|
||||
|
||||
filename=""
|
||||
while [ "${filename}" == "" ]
|
||||
do
|
||||
|
||||
clear
|
||||
echo "**********************************"
|
||||
echo "* UPLOAD THE channel.backup FILE *"
|
||||
echo "**********************************"
|
||||
echo
|
||||
echo "If you have the channel.backup file on your laptop or on"
|
||||
echo "another server you can now upload it to the RaspiBlitz."
|
||||
echo
|
||||
echo "To make upload open a new terminal and change,"
|
||||
echo "into the directory where your lnd-rescue file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp ./*.backup ${defaultUploadUser}@${localip}:${defaultUploadPath}/"
|
||||
echo ""
|
||||
echo "Use ${passwordInfo} to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done."
|
||||
read key
|
||||
|
||||
# check upload (will return filename or error)
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh check-upload scb)
|
||||
if [ "${filename}" != "" ]; then
|
||||
echo "OK - File found: ${filename}"
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
elif [ "${error}" == "not-found" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There was no upload found in ${defaultUploadPath}"
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "multiple" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There are multiple lnd-rescue files in directory ${defaultUploadPath}"
|
||||
echo "Make sure you upload only one tar.gz-file and start again."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "invalid" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "The file uploaded is not a valid (complete upload failed or not correct file)."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
else
|
||||
echo "!! WARNING !! Unknown State (report to devs)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${keyRetry}" == "x" ] || [ "${keyRetry}" == "X" ] || [ "${keyRetry}" == "'x'" ]; then
|
||||
# create no result file and exit
|
||||
echo "# USER CANCEL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# in setup scenario the final import is happening during provison
|
||||
if [ "${scenario}" == "setup" ]; then
|
||||
# just add staticchannelbackup filename to give file
|
||||
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
|
||||
echo "staticchannelbackup='${filename}'" >> $RESULTFILE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# run import process
|
||||
echo "OK importing channel.backup file ..."
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh scb-import ${filename})
|
||||
|
||||
# give final info
|
||||
echo "DONE - placed SCB file at /home/admin/channel.backup"
|
||||
echo "Reboot and login to trigger import."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################################
|
||||
# SEED WORDS - GUI PARTS
|
||||
####################################
|
||||
|
||||
if [ ${mode} = "seed-export-gui" ]; then
|
||||
|
||||
# use text snippet for testing:
|
||||
#
|
||||
|
||||
# 2nd PARAMETER: lnd seed data
|
||||
seedwords6x4=$2
|
||||
if [ "${seedwords6x4}" == "" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
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
|
||||
|
||||
fi
|
||||
|
||||
# Results will be stored on memory cache:
|
||||
# /var/cache/raspiblitz/seed-import.results
|
||||
if [ ${mode} = "seed-import-gui" ]; then
|
||||
|
||||
# fake seed 24 words for testing input:
|
||||
# eins zwei polizei drei vier great idea fünf sechs alte keks sieben auch gute nacht ja ja ja was ist los was ist das
|
||||
|
||||
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
|
||||
RESULTFILE=$2
|
||||
if [ "${RESULTFILE}" == "" ]; then
|
||||
echo "error='mising parameter'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# prepare seed result file
|
||||
sudo rm /var/cache/raspiblitz/seed-import.results 2>/dev/null
|
||||
sudo touch /var/cache/raspiblitz/seed-import.results
|
||||
sudo chown admin:admin /var/cache/raspiblitz/seed-import.results
|
||||
|
||||
# input loop for seed words
|
||||
wordsCorrect=0
|
||||
while [ ${wordsCorrect} -eq 0 ]
|
||||
do
|
||||
|
||||
# prepare temp file
|
||||
sudo rm /var/cache/raspiblitz/.seed.tmp 2>/dev/null
|
||||
sudo touch /var/cache/raspiblitz/.seed.tmp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/.seed.tmp
|
||||
|
||||
# dialog to enter
|
||||
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')
|
||||
sudo shred -u /var/cache/raspiblitz/.seed.tmp 2>/dev/null
|
||||
echo "processing ..."
|
||||
|
||||
# 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
|
||||
clear
|
||||
echo "# CANCEL empty results in: ${RESULTFILE}"
|
||||
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 rm /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
|
||||
|
||||
# writing result file data
|
||||
clear
|
||||
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
|
||||
echo "seedWords='${wordstring}'" >> $RESULTFILE
|
||||
echo "seedPassword='${passwordD}'" >> $RESULTFILE
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
echo "error='unknown parameter'"
|
||||
exit 1
|
@ -1,280 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "# small rescue script to to backup or restore LND data"
|
||||
echo "# -> backup all LND data in a tar.gz file for download:"
|
||||
echo "# lnd.rescue.sh backup [?no-download]"
|
||||
echo "# -> upload a LND data tar.gz file to replace LND data:"
|
||||
echo "# lnd.rescue.sh restore"
|
||||
echo "# -> download the LND channel.backup file from SD card:"
|
||||
echo "# lnd.rescue.sh scb-down"
|
||||
echo "# -> upload the LND channel.backup to recover wallet:"
|
||||
echo "# lnd.rescue.sh scb-up"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
|
||||
mode="$1"
|
||||
if [ ${mode} = "backup" ]; then
|
||||
|
||||
################################
|
||||
# BACKUP
|
||||
################################
|
||||
|
||||
echo "# *** LND.RESCUE --> BACKUP"
|
||||
|
||||
# stop LND
|
||||
echo "# Stopping lnd..."
|
||||
sudo systemctl stop lnd
|
||||
sleep 5
|
||||
echo "# OK"
|
||||
echo
|
||||
|
||||
# zip it
|
||||
sudo tar -zcvf /home/admin/lnd-rescue.tar.gz /mnt/hdd/lnd 1>&2
|
||||
sudo chown admin:admin /home/admin/lnd-rescue.tar.gz 1>&2
|
||||
|
||||
# delete old backups
|
||||
rm /home/admin/lnd-rescue-*.tar.gz 2>/dev/null 1>/dev/null
|
||||
|
||||
# name with md5 checksum
|
||||
md5checksum=$(md5sum /home/admin/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1)
|
||||
mv /home/admin/lnd-rescue.tar.gz /home/admin/lnd-rescue-${md5checksum}.tar.gz 1>&2
|
||||
echo "file='lnd-rescue-${md5checksum}.tar.gz'"
|
||||
echo "path='/home/admin/'"
|
||||
|
||||
byteSize=$(ls -l /home/admin/lnd-rescue-${md5checksum}.tar.gz | awk '{print $5}')
|
||||
echo "size=${byteSize}"
|
||||
|
||||
if [ ${byteSize} -lt 100 ]; then
|
||||
echo "error='backup is empty'"
|
||||
echo
|
||||
echo "# *****************************"
|
||||
echo "# * BACKUP ERROR *"
|
||||
echo "# *****************************"
|
||||
echo "# The byte size of the created rescue-file is too small (${byteSize}) - might be empty!"
|
||||
echo "# If you plan any update or recovery please stop and report this error to dev team. Thx."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# stop here in case of 'no-download' option
|
||||
if [ "${2}" == "no-download" ]; then
|
||||
echo "# No download of LND data requested."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# offer SCP for download
|
||||
clear
|
||||
echo
|
||||
echo "****************************"
|
||||
echo "* DOWNLOAD THE RESCUE FILE *"
|
||||
echo "****************************"
|
||||
echo
|
||||
echo "ON YOUR MAC & LINUX LAPTOP - RUN IN NEW TERMINAL:"
|
||||
echo "scp -r 'admin@${localip}:/home/admin/lnd-rescue-*.tar.gz' ./"
|
||||
echo "ON WINDOWS USE:"
|
||||
echo "scp -r admin@${localip}:/home/admin/lnd-rescue-*.tar.gz ."
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo "Check for correct file size after transfer: ${byteSize} byte"
|
||||
echo
|
||||
echo "BEWARE: Your Lightning node is now stopped. It's safe to backup the data and"
|
||||
echo "restore it on a fresh RaspiBlitz. But once this Lightning node gets started"
|
||||
echo "again or rebooted, it's not advised to restore the backup file because"
|
||||
echo "it would contain outdated channel data and can lead to loss of channel funds."
|
||||
|
||||
elif [ ${mode} = "restore" ]; then
|
||||
|
||||
################################
|
||||
# RESTORE
|
||||
################################
|
||||
|
||||
echo "# LND.RESCUE --> RESTORE"
|
||||
echo ""
|
||||
|
||||
# delete old backups
|
||||
rm /home/admin/lnd-rescue-*.tar.gz
|
||||
|
||||
filename=""
|
||||
while [ ${#filename} -eq 0 ]
|
||||
do
|
||||
countZips=$(sudo ls /home/admin/lnd-rescue-*.tar.gz 2>/dev/null | grep -c 'lnd-rescue')
|
||||
if [ ${countZips} -lt 1 ]; then
|
||||
echo "**************************"
|
||||
echo "* UPLOAD THE RESCUE FILE *"
|
||||
echo "**************************"
|
||||
echo "If you have a lnd-rescue backup file on your laptop you can now"
|
||||
echo "upload it and restore the your latest LND state."
|
||||
echo
|
||||
echo "CAUTION: Dont restore old LND states - risk of loosing funds!"
|
||||
echo
|
||||
echo "To make upload open a new terminal on your laptop,"
|
||||
echo "change into the directory where your lnd-rescue file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/"
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done."
|
||||
fi
|
||||
if [ ${countZips} -gt 1 ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There are multiple lnd-rescue files in directory /home/admin."
|
||||
echo "Make sure you upload only one tar.gz-file and start again."
|
||||
echo
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
exit 1
|
||||
fi
|
||||
if [ ${countZips} -eq 1 ]; then
|
||||
|
||||
clear
|
||||
echo
|
||||
echo "**************************"
|
||||
echo "* RESTORING BACKUP FILE *"
|
||||
echo "**************************"
|
||||
echo
|
||||
|
||||
filename=$(sudo ls /home/admin/lnd-rescue-*.tar.gz)
|
||||
echo "OK -> found file to restore: ${filename}"
|
||||
|
||||
# checksum test
|
||||
md5checksum=$(md5sum ${filename} | head -n1 | cut -d " " -f1)
|
||||
isCorrect=$(echo ${filename} | grep -c ${md5checksum})
|
||||
if [ ${isCorrect} -eq 1 ]; then
|
||||
echo "OK -> checksum looks good: ${md5checksum}"
|
||||
else
|
||||
echo "!!! FAIL -> Checksum not correct."
|
||||
echo "Maybe transfer failed? Continue at your own risk!"
|
||||
echo "It is recommended to abort and upload again!"
|
||||
fi
|
||||
|
||||
# overrride test
|
||||
oldWalletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep -c "wallet.db")
|
||||
if [ ${oldWalletExists} -gt 0 ]; then
|
||||
echo
|
||||
echo "WARNING: This will delete/overwrite the LND state/funds of this RaspiBlitz."
|
||||
fi
|
||||
echo
|
||||
echo "PRESS ENTER to start restore. Enter x & ENTER to cancel."
|
||||
fi
|
||||
read key
|
||||
if [ "${key}" == "x" ]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# stop LND
|
||||
echo "Stopping lnd..."
|
||||
sudo systemctl stop lnd
|
||||
sleep 5
|
||||
echo "OK"
|
||||
echo
|
||||
|
||||
# clean DIR
|
||||
echo "Cleaning LND data ..."
|
||||
sudo rm -r /mnt/hdd/lnd/*
|
||||
echo "OK"
|
||||
echo
|
||||
|
||||
# unpack zip
|
||||
echo "Restoring LND data from ${filename} ..."
|
||||
sudo tar -xf ${filename} -C /
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
|
||||
echo "OK"
|
||||
echo
|
||||
|
||||
# check if LND needs update
|
||||
# (if RaspiBlitz has an optional LND version update, then install it
|
||||
# the newer LND version can always handle older data)
|
||||
echo "Checking LND version ..."
|
||||
source <(sudo -u admin /home/admin/config.scripts/lnd.update.sh info)
|
||||
if [ ${lndUpdateInstalled} -eq 0 ]; then
|
||||
echo "Installing available LND update ... (newer version can handle more wallet formats)"
|
||||
sudo -u admin /home/admin/config.scripts/lnd.update.sh verified
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
echo
|
||||
|
||||
# start LND
|
||||
echo "Starting lnd..."
|
||||
sudo systemctl start lnd
|
||||
echo "OK"
|
||||
echo
|
||||
|
||||
echo "DONE - please check if LND starts up correctly with restored state and funds."
|
||||
echo "Keep in mind that some channels maybe forced closed in the meanwhile."
|
||||
echo
|
||||
|
||||
elif [ ${mode} = "scb-down" ]; then
|
||||
|
||||
echo
|
||||
echo "****************************"
|
||||
echo "* DOWNLOAD THE BACKUP FILE *"
|
||||
echo "****************************"
|
||||
echo
|
||||
echo "RUN THE FOLLOWING COMMAND ON YOUR LAPTOP IN NEW TERMINAL:"
|
||||
echo "scp -r admin@${localip}:/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ./"
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo
|
||||
echo "NOTE: Use this file when setting up a fresh RaspiBlitz by choosing"
|
||||
echo "option OLD WALLET and then SCB+SEED -> Seed & channel.backup file"
|
||||
echo "Will just recover on-chain & channel-funds, but closing all channels"
|
||||
|
||||
elif [ ${mode} = "scb-up" ]; then
|
||||
|
||||
gotFile=-1
|
||||
while [ ${gotFile} -lt 1 ]
|
||||
do
|
||||
|
||||
# show info
|
||||
clear
|
||||
sleep 1
|
||||
echo "**********************************"
|
||||
echo "* UPLOAD THE channel.backup FILE *"
|
||||
echo "**********************************"
|
||||
echo
|
||||
if [ ${gotFile} -eq -1 ]; then
|
||||
echo "If you have the channel.backup file on your laptop or on"
|
||||
echo "another server you can now upload it to the RaspiBlitz."
|
||||
elif [ ${gotFile} -eq 0 ]; then
|
||||
echo "NO channel.backup FOUND IN /home/admin"
|
||||
echo "Please try upload again."
|
||||
fi
|
||||
echo
|
||||
echo "To make upload open a new terminal and change,"
|
||||
echo "into the directory where your lnd-rescue file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp ./channel.backup admin@${localip}:/home/admin/"
|
||||
echo ""
|
||||
echo "Use password A to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel."
|
||||
|
||||
# wait user interaction
|
||||
echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel."
|
||||
read key
|
||||
if [ "${key}" == "x" ]; then
|
||||
# EXIT with CODE 1 --> USER CANCEL
|
||||
echo "# CANCEL upload"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# test upload
|
||||
gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup')
|
||||
|
||||
done
|
||||
|
||||
# EXIT with CODE 1 --> FILE UPLOADED
|
||||
echo
|
||||
echo "# OK channel.backup uploaded"
|
||||
sleep 2
|
||||
exit 0
|
||||
|
||||
else
|
||||
echo "unknown parameter '${mode}' - exit"
|
||||
fi
|
@ -9,8 +9,8 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${chain}net)
|
||||
shopt -s expand_aliases
|
||||
|
51
home.admin/setup.scripts/afterProvision.sh
Normal file
51
home.admin/setup.scripts/afterProvision.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/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
|
10
home.admin/setup.scripts/beforeProvision.sh
Executable file
10
home.admin/setup.scripts/beforeProvision.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/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
|
41
home.admin/setup.scripts/dialogBasicSetup.sh
Normal file
41
home.admin/setup.scripts/dialogBasicSetup.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/_version.info
|
||||
|
||||
# chose how to setup node (fresh or from a upload backup)
|
||||
OPTIONS=()
|
||||
OPTIONS+=(FRESHSETUP "Setup a new RaspiBlitz")
|
||||
OPTIONS+=(FROMBACKUP "Upload Migration Backup")
|
||||
OPTIONS+=(SHUTDOWN "Shutdown without Changes")
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
|
||||
--title "⚡ Welcome to your RaspiBlitz ⚡" \
|
||||
--menu "\nChoose how you want to setup your RaspiBlitz: \n " \
|
||||
12 64 6 \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
clear
|
||||
case $CHOICE in
|
||||
FRESHSETUP)
|
||||
# 0 --> FRESH SETUP
|
||||
exit 0;
|
||||
;;
|
||||
FROMBACKUP)
|
||||
# 1 --> UPLOAD MIGRATION BACKUP
|
||||
exit 1
|
||||
;;
|
||||
SHUTDOWN)
|
||||
# 2 --> SHUTDOWN
|
||||
clear
|
||||
echo "Shutting down without changes ..."
|
||||
echo "Cut power when you see no status LED blinking anymore."
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
# 3 --> ESC/CANCEL = EXIT TO TERMINAL
|
||||
clear
|
||||
echo "Exit to Terminal from RaspiBlitz Setup ..."
|
||||
exit 3
|
||||
esac
|
89
home.admin/setup.scripts/dialogBlockchainLightning.sh
Normal file
89
home.admin/setup.scripts/dialogBlockchainLightning.sh
Normal file
@ -0,0 +1,89 @@
|
||||
#!/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
|
||||
|
||||
|
||||
#################################
|
||||
# SELECT BLOCKCHAIN
|
||||
# when not already set by setupfile
|
||||
|
||||
if [ "${network}" == "" ]; then
|
||||
|
||||
OPTIONS=()
|
||||
OPTIONS+=(BITCOIN "Setup BITCOIN Blockchain (BitcoinCore)")
|
||||
OPTIONS+=(LITECOIN "Setup LITECOIN Blockchain (experimental)")
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
|
||||
--title "⚡ Blockchain ⚡" \
|
||||
--menu "\nChoose which Blockchain to run: \n " \
|
||||
11 64 5 \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
clear
|
||||
case $CHOICE in
|
||||
BITCOIN)
|
||||
# bitcoin core
|
||||
network="bitcoin"
|
||||
;;
|
||||
LITECOIN)
|
||||
# litecoin
|
||||
network="litecoin"
|
||||
# can only work with LND
|
||||
lightning="lnd"
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
echo "User Cancel"
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
#################################
|
||||
# SELECT LIGHTNING
|
||||
# only possible when network is bitcoin
|
||||
|
||||
if [ "${network}" == "bitcoin" ]; then
|
||||
|
||||
# choose lightning client
|
||||
OPTIONS=()
|
||||
OPTIONS+=(LND "LND - Lightning Network Daemon (DEFAULT)")
|
||||
OPTIONS+=(CLN "c-lightning by blockstream (fewer Apps)")
|
||||
OPTIONS+=(NONE "Run without Lightning")
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
|
||||
--title "⚡ Lightning ⚡" \
|
||||
--menu "\nChoose your Lightning Client: \n " \
|
||||
12 64 6 \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
clear
|
||||
case $CHOICE in
|
||||
LND)
|
||||
lightning="lnd"
|
||||
;;
|
||||
CLN)
|
||||
lightning="cln"
|
||||
;;
|
||||
NONE)
|
||||
lightning=""
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
echo "User Cancel"
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
# write results to setup sate
|
||||
echo "lightning=${lightning}" >> $SETUPFILE
|
||||
echo "network=${network}" >> $SETUPFILE
|
||||
|
||||
exit 0
|
57
home.admin/setup.scripts/dialogDeleteData.sh
Normal file
57
home.admin/setup.scripts/dialogDeleteData.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FIRST PARAMETER can be the name of the blockchain data that is available in the HDD/SS
|
||||
# if set the user will be given to option to DELETE ALL DATA but KEEP BLOCKCHAIN
|
||||
blockchainName=$1
|
||||
|
||||
keepBlockchain=0
|
||||
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.
|
||||
|
||||
Using existing blockchain data can reduce the setup/sync time. But if you didnt validated the blockchain yourself there is a level of trust involved.
|
||||
|
||||
Do you want to use that blockchain data and run ${blockchainName}?
|
||||
" 14 68
|
||||
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> use blockchain & delete all other data
|
||||
keepBlockchain=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# normally when the the HDD will get formatted and the user will get asked about that
|
||||
# if before the user decided to keep the blockchain instead if formatting just "ALL OTHER DATA" wil get deleted
|
||||
|
||||
if [ "${keepBlockchain}" == "1" ]; then
|
||||
|
||||
# deleting all data around blockchain security question
|
||||
whiptail --title " DELETING ALL OTHER DATA " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "OK we will keep the blockchain data - but all other data on your HDD/SSD will get deleted on setup. Make sure that there is no important data or old funds on that data drive.
|
||||
|
||||
Are you sure to DELETE ALL OTHER DATA on the HDD/SSD?
|
||||
" 11 65
|
||||
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> keep blockchain + delete all other data
|
||||
exit 2
|
||||
else
|
||||
# 1 --> cancel / stop
|
||||
exit 0
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# normal formatting data drive security question
|
||||
whiptail --title " FORMATTING DATA DRVE " --yes-button "DELETE DATA" --no-button "STOP SETUP" --yesno "Your data drive will now get formatted. This will delete all data on your connected HDD/SSD. Make sure that there is no important data or old funds on that data drive.
|
||||
|
||||
Are you sure to format the HDD/SSD and DELETE ALL DATA on it?
|
||||
" 11 65
|
||||
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> format drive
|
||||
exit 1
|
||||
else
|
||||
# 1 --> cancel / stop
|
||||
exit 0
|
||||
fi
|
||||
fi
|
146
home.admin/setup.scripts/dialogLightningWallet-cln.sh
Normal file
146
home.admin/setup.scripts/dialogLightningWallet-cln.sh
Normal file
@ -0,0 +1,146 @@
|
||||
# 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
|
||||
|
||||
# flags for sub dialogs after choice
|
||||
uploadRESCUE=0
|
||||
enterSEED=0
|
||||
|
||||
OPTIONS=()
|
||||
OPTIONS+=(NEW "Setup a brand new Lightning Node (DEFAULT)")
|
||||
OPTIONS+=(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)
|
||||
|
||||
if [ "${CHOICE}" == "NEW" ]; then
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# mark all passwords to be set at the end
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
|
||||
elif [ "${CHOICE}" == "OLD" ]; then
|
||||
|
||||
CHOICE=""
|
||||
while [ "${CHOICESUB}" == "" ]
|
||||
do
|
||||
|
||||
# get more details what kind of old lightning wallet user has
|
||||
OPTIONS=()
|
||||
OPTIONS+=(CLNRESCUE "CLN tar.gz-Backupfile (BEST)")
|
||||
OPTIONS+=(ONLYSEED "Only Seed Word List (FALLBACK)")
|
||||
CHOICESUB=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER CLN DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
if [ "${CHOICESUB}" == "CLNRESCUE" ]; then
|
||||
|
||||
# just activate LND rescue upload
|
||||
uploadRESCUE=1
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# dont set password c anymore - mark the rest
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
|
||||
elif [ "${CHOICESUB}" == "ONLYSEED" ]; then
|
||||
|
||||
# let people know about just seed backup
|
||||
whiptail --title "IMPORTANT INFO" --yes-button "JUST SEED" --no-button "Go Back" --yesno "
|
||||
Using JUST SEED WORDS will only recover your on-chain funds.
|
||||
To recover also your channel funds a complete rescue-backup
|
||||
from your old node would be recommended.
|
||||
" 11 65
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
# when user wants to go back
|
||||
CHOICESUB=""
|
||||
else
|
||||
# activate SEED input & SCB upload
|
||||
enterSEED=1
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# mark all passwords to be set at the end
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
# user cancel - signal to outside app by exit code (2 = submenu)
|
||||
exit 2
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
else
|
||||
# user cancel - signal to outside app by exit code (1 = mainmenu)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# UPLOAD LND RESCUE FILE dialog (if activated by dialogs above)
|
||||
if [ ${uploadRESCUE} -eq 1 ]; then
|
||||
|
||||
# run upload dialog and get result
|
||||
_temp="/var/cache/raspiblitz/temp/.temp.tmp"
|
||||
clear
|
||||
echo "TODO: cln.backup.sh cln-import-gui"
|
||||
sleep 8
|
||||
#/home/admin/config.scripts/cln.backup.sh cln-import-gui setup $_temp
|
||||
source $_temp 2>/dev/null
|
||||
sudo rm $_temp 2>/dev/null
|
||||
|
||||
# if user canceled upload
|
||||
if [ "${clnrescue}" == "" ]; then
|
||||
# signal cancel to the calling script by exit code (3 = exit on lndrescue)
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^clnrescue=/d' $SETUPFILE
|
||||
|
||||
# store result in setup state
|
||||
echo "clnrescue='${lndrescue}'" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
# INPUT LIGHTNING SEED dialog (if activated by dialogs above)
|
||||
if [ ${enterSEED} -eq 1 ]; then
|
||||
|
||||
# start seed input and get results
|
||||
_temp="/var/cache/raspiblitz/.temp.tmp"
|
||||
clear
|
||||
echo "TODO: cln.backup.sh seed-import-gui"
|
||||
sleep 8
|
||||
#/home/admin/config.scripts/cln.backup.sh seed-import-gui $_temp
|
||||
source $_temp 2>/dev/null
|
||||
sudo rm $_temp 2>/dev/null
|
||||
|
||||
# if user canceled the seed input
|
||||
if [ "${seedWords}" == "" ]; then
|
||||
# signal cancel to the calling script by exit code (4 = exit on seedwords)
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^seedWords=/d' $SETUPFILE
|
||||
sudo sed -i '/^seedPassword=/d' $SETUPFILE
|
||||
|
||||
# write the seed data into the setup state
|
||||
echo "seedWords='${seedWords}'" >> $SETUPFILE
|
||||
fi
|
183
home.admin/setup.scripts/dialogLightningWallet-lnd.sh
Normal file
183
home.admin/setup.scripts/dialogLightningWallet-lnd.sh
Normal file
@ -0,0 +1,183 @@
|
||||
# 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
|
||||
|
||||
# flags for sub dialogs after choice
|
||||
uploadLNDRESCUE=0
|
||||
enterSEED=0
|
||||
uploadSCB=0
|
||||
|
||||
OPTIONS=()
|
||||
OPTIONS+=(NEW "Setup a brand new Lightning Node (DEFAULT)")
|
||||
OPTIONS+=(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)
|
||||
|
||||
if [ "${CHOICE}" == "NEW" ]; then
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# mark all passwords to be set at the end
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
|
||||
elif [ "${CHOICE}" == "OLD" ]; then
|
||||
|
||||
CHOICE=""
|
||||
while [ "${CHOICESUB}" == "" ]
|
||||
do
|
||||
|
||||
# get more details what kind of old lightning wallet user has
|
||||
OPTIONS=()
|
||||
OPTIONS+=(LNDRESCUE "LND tar.gz-Backupfile (BEST)")
|
||||
OPTIONS+=(SEED+SCB "Seed & channel.backup file (OK)")
|
||||
OPTIONS+=(ONLYSEED "Only Seed Word List (FALLBACK)")
|
||||
CHOICESUB=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
if [ "${CHOICESUB}" == "LNDRESCUE" ]; then
|
||||
|
||||
# just activate LND rescue upload
|
||||
uploadLNDRESCUE=1
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# dont set password c anymore - mark the rest
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
|
||||
elif [ "${CHOICESUB}" == "SEED+SCB" ]; then
|
||||
|
||||
# activate SEED input & SCB upload
|
||||
enterSEED=1
|
||||
uploadSCB=1
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# mark all passwords to be set at the end
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
|
||||
elif [ "${CHOICESUB}" == "ONLYSEED" ]; then
|
||||
|
||||
# let people know about the difference between SEED & SEED+SCB
|
||||
whiptail --title "IMPORTANT INFO" --yes-button "JUST SEED" --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
|
||||
# when user wants to go back
|
||||
CHOICESUB=""
|
||||
else
|
||||
# activate SEED input & SCB upload
|
||||
enterSEED=1
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
|
||||
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
|
||||
|
||||
# mark all passwords to be set at the end
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
# user cancel - signal to outside app by exit code (2 = submenu)
|
||||
exit 2
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
else
|
||||
# user cancel - signal to outside app by exit code (1 = mainmenu)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# UPLOAD LND RESCUE FILE dialog (if activated by dialogs above)
|
||||
if [ ${uploadLNDRESCUE} -eq 1 ]; then
|
||||
|
||||
# run upload dialog and get result
|
||||
_temp="/var/cache/raspiblitz/temp/.temp.tmp"
|
||||
/home/admin/config.scripts/lnd.backup.sh lnd-import-gui setup $_temp
|
||||
source $_temp 2>/dev/null
|
||||
sudo rm $_temp 2>/dev/null
|
||||
|
||||
# if user canceled upload
|
||||
if [ "${lndrescue}" == "" ]; then
|
||||
# signal cancel to the calling script by exit code (3 = exit on lndrescue)
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^lndrescue=/d' $SETUPFILE
|
||||
|
||||
# store result in setup state
|
||||
echo "lndrescue='${lndrescue}'" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
# INPUT LIGHTNING SEED dialog (if activated by dialogs above)
|
||||
if [ ${enterSEED} -eq 1 ]; then
|
||||
|
||||
# start seed input and get results
|
||||
_temp="/var/cache/raspiblitz/.temp.tmp"
|
||||
/home/admin/config.scripts/lnd.backup.sh seed-import-gui $_temp
|
||||
source $_temp 2>/dev/null
|
||||
sudo rm $_temp 2>/dev/null
|
||||
|
||||
# if user canceled the seed input
|
||||
if [ "${seedWords}" == "" ]; then
|
||||
# signal cancel to the calling script by exit code (4 = exit on seedwords)
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^seedWords=/d' $SETUPFILE
|
||||
sudo sed -i '/^seedPassword=/d' $SETUPFILE
|
||||
|
||||
# write the seed data into the setup state
|
||||
echo "seedWords='${seedWords}'" >> $SETUPFILE
|
||||
echo "seedPassword='${seedPassword}'" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
# UPLOAD STATIC CHANNEL BACKUP FILE dialog (if activated by dialogs above)
|
||||
if [ ${uploadSCB} -eq 1 ]; then
|
||||
|
||||
# start seed input and get results
|
||||
_temp="/var/cache/raspiblitz/.temp.tmp"
|
||||
/home/admin/config.scripts/lnd.backup.sh scb-import-gui setup $_temp
|
||||
source $_temp 2>/dev/null
|
||||
sudo rm $_temp 2>/dev/null
|
||||
|
||||
# if user canceled the upload
|
||||
if [ "${staticchannelbackup}" == "" ]; then
|
||||
# signal cancel to the calling script by exit code (5 = exit on scb)
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# clear setup state from all fomer possible choices (previous loop)
|
||||
sudo sed -i '/^staticchannelbackup=/d' $SETUPFILE
|
||||
|
||||
# write the filename into the setup state
|
||||
echo "staticchannelbackup='${staticchannelbackup}'" >> $SETUPFILE
|
||||
|
||||
fi
|
161
home.admin/setup.scripts/dialogMigration.sh
Executable file
161
home.admin/setup.scripts/dialogMigration.sh
Executable file
@ -0,0 +1,161 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: also the raspiblitz-migration & other-node-migration might need to be adapted to work with an already mounted HDD later
|
||||
|
||||
# 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
|
||||
|
||||
#########################
|
||||
# Parameters
|
||||
# this is useful for testing the dialog outside of the setup process
|
||||
# normally migrationOS & migrationVersion are provided by raspiblitz.info or raspiblitz.setup
|
||||
|
||||
# 1st PARAMATER (optional): [raspiblitz|mynode|umbrel]
|
||||
if [ "${migrationOS}" == "" ]; then
|
||||
migrationOS="$1"
|
||||
fi
|
||||
|
||||
# 2nd PARAMATER (optional): the version of the former fullnode OS if available
|
||||
if [ "${migrationVersion}" == "" ]; then
|
||||
migrationVersion="$2"
|
||||
fi
|
||||
|
||||
# check parameter values
|
||||
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ]; then
|
||||
echo "# FAIL: the given migrationOS '${migrationOS}' is not supported yet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
####################################################
|
||||
# RASPIBLITZ
|
||||
# migrating from other hardware with migration file
|
||||
####################################################
|
||||
|
||||
if [ "${migrationOS}" == "raspiblitz" ]; then
|
||||
|
||||
# get defaultUploadPath, localIP, etc
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh prepare-upload)
|
||||
|
||||
filename=""
|
||||
while [ "${filename}" == "" ]
|
||||
do
|
||||
|
||||
clear
|
||||
echo "*****************************"
|
||||
echo "* UPLOAD THE MIGRATION FILE *"
|
||||
echo "*****************************"
|
||||
echo "If you have a migration file on your laptop you can now"
|
||||
echo "upload it and restore on the new HDD/SSD."
|
||||
echo
|
||||
echo "ON YOUR LAPTOP open a new terminal and change into"
|
||||
echo "the directory where your migration file is and"
|
||||
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
|
||||
echo "scp -r ./raspiblitz-*.tar.gz ${defaultUploadUser}@${localip}:${defaultUploadPath}/"
|
||||
echo ""
|
||||
echo "Use password 'raspiblitz' to authenticate file transfer."
|
||||
echo "PRESS ENTER when upload is done."
|
||||
read key
|
||||
|
||||
# check upload (will return filename or error)
|
||||
source <(sudo /home/admin/config.scripts/blitz.upload.sh check-upload migration)
|
||||
if [ "${filename}" != "" ]; then
|
||||
echo "OK - File found: ${filename}"
|
||||
echo "PRESS ENTER to continue."
|
||||
read key
|
||||
elif [ "${error}" == "not-found" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There was no upload found in ${defaultUploadPath}"
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "multiple" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "There are multiple lnd-rescue files in directory ${defaultUploadPath}"
|
||||
echo "Make sure you upload only one tar.gz-file and start again."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
elif [ "${error}" == "invalid" ]; then
|
||||
echo "!! WARNING !!"
|
||||
echo "The file uploaded is not a valid (complete upload failed or not correct file)."
|
||||
echo "PRESS ENTER to continue & retry ... or 'x'+ ENTER to cancel"
|
||||
read keyRetry
|
||||
else
|
||||
# create no result file and exit
|
||||
echo "!! WARNING !! Unknown State (report to devs) error(${error})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${keyRetry}" == "x" ] || [ "${keyRetry}" == "X" ] || [ "${keyRetry}" == "'x'" ]; then
|
||||
# create no result file and exit
|
||||
echo "# USER CANCEL"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# migration OS & Version were already set earlier in setup process - now add migration filename
|
||||
echo "migrationFile='${filename}'" >> $SETUPFILE
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
####################################################
|
||||
# UMBREL
|
||||
# migrating from Umbrel to RaspiBlitz
|
||||
####################################################
|
||||
|
||||
if [ "${migrationOS}" == "umbrel" ]; then
|
||||
|
||||
# infodialog
|
||||
whiptail --title " UMBREL --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from UMBREL
|
||||
|
||||
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
|
||||
|
||||
Please make sure to have your UMBREL seed words & static channel backup file (just in case). Also any data of additional apps you had installed on UMBREL might get lost.
|
||||
|
||||
Do you want to start migration to RaspiBlitz now?
|
||||
" 16 58
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
# user cancel - signal by exit code
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# signal that user wants to proceed with migration
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
####################################################
|
||||
# MYNODE
|
||||
# migrating from myNode to RaspiBlitz
|
||||
####################################################
|
||||
|
||||
if [ "${migrationOS}" == "mynode" ]; then
|
||||
|
||||
# infodialog
|
||||
whiptail --title " MYNODE --> RASPIBLITZ " --yes-button "Start Migration" --no-button "No+Shutdown" --yesno "RaspiBlitz found data from MYNODE
|
||||
|
||||
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
|
||||
|
||||
Please make sure to have your MYNODE seed words & static channel backup file (just in case). Also any data of additional apps you had installed on MYNODE might get lost.
|
||||
|
||||
Do you want to start migration to RaspiBlitz now?
|
||||
" 16 58
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
# user cancel - signal by exit code
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# signal that user wants to proceed with migration
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
echo "FAIL: Exited in unknown state from migration dialog."
|
||||
exit 1
|
32
home.admin/setup.scripts/dialogName.sh
Normal file
32
home.admin/setup.scripts/dialogName.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/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
|
||||
|
||||
###################
|
||||
# ENTER NAME
|
||||
###################
|
||||
|
||||
# temp file for password results
|
||||
_temp="/var/cache/raspiblitz/temp/.temp.tmp"
|
||||
|
||||
# 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" --inputbox "$l1$l2" 11 52 2>$_temp
|
||||
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
|
||||
sudo rm $_temp
|
||||
done
|
||||
|
||||
# store name in setup state
|
||||
sudo sed -i '/^hostname=/d' $SETUPFILE
|
||||
echo "hostname=${result}" >> $SETUPFILE
|
105
home.admin/setup.scripts/dialogPasswords.sh
Normal file
105
home.admin/setup.scripts/dialogPasswords.sh
Normal file
@ -0,0 +1,105 @@
|
||||
#!/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
|
||||
|
||||
####################################################
|
||||
# INPUT PASSWORDS (based on flags from raspiblitz.setup)
|
||||
|
||||
# dynamic info string on what passwords need to be changed
|
||||
# at the moment its always
|
||||
passwordinfo="A"
|
||||
echo "A"
|
||||
if [ "${setPasswordB}" == "1" ]; then
|
||||
passwordinfo="${passwordinfo}, B"
|
||||
echo "A1"
|
||||
fi
|
||||
if [ "${setPasswordC}" == "1" ]; then
|
||||
passwordinfo="${passwordinfo}, C"
|
||||
fi
|
||||
|
||||
# if passwords are set in a migration situation, use different info text
|
||||
if [ "${migrationOS}" == "" ]; then
|
||||
|
||||
# info text on normal setup
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 3 different passwords.
|
||||
Referenced as password A, B & C.
|
||||
|
||||
PASSWORD A) Main User Password (SSH & WebUI, sudo)
|
||||
PASSWORD B) APP Password (Additional Apps & API)
|
||||
PASSWORD C) Lightning Wallet Password for Unlock
|
||||
|
||||
You will need to set now Password: ${passwordinfo}
|
||||
|
||||
Follow Password Rule: Minimal of 8 chars,,
|
||||
no spaces and only special characters - or .
|
||||
Write them down & store them in a safe place.
|
||||
" 16 54
|
||||
|
||||
else
|
||||
|
||||
# info text on migration setup
|
||||
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "You will need to set new passwords.
|
||||
|
||||
RaspiBlitz works with 3 different passwords:
|
||||
PASSWORD A) Main User Password (SSH & WebUI, sudo)
|
||||
PASSWORD B) APP Password (Additional Apps & API)
|
||||
PASSWORD C) Lightning Wallet Password for Unlock
|
||||
|
||||
You will need to set now Password: ${passwordinfo}
|
||||
(other passwords might stay like on your old node)
|
||||
|
||||
Follow Password Rules: Minimal of 8 chars,
|
||||
no spaces and only special characters - or .
|
||||
Write them down & store them in a safe place.
|
||||
" 17 64
|
||||
|
||||
fi
|
||||
|
||||
# temp file for password results
|
||||
_temp="/var/cache/raspiblitz/temp/.temp.tmp"
|
||||
|
||||
# PASSWORD A
|
||||
if [ "${setPasswordA}" == "1" ]; then
|
||||
clear
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
|
||||
password=$(sudo cat $_temp)
|
||||
sudo rm $_temp
|
||||
sudo sed -i '/^passwordA=/d' $SETUPFILE
|
||||
echo "passwordA='${password}'" >> $SETUPFILE
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\nThanks - Password A accepted.\n\nUse this password for future SSH or Web-Admin logins to your RaspiBlitz & for sudo commands." 11 35
|
||||
fi
|
||||
|
||||
# PASSWORD B
|
||||
if [ "${setPasswordB}" == "1" ]; then
|
||||
clear
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
|
||||
password=$(sudo cat $_temp)
|
||||
sudo rm $_temp
|
||||
sudo sed -i '/^passwordB=/d' $SETUPFILE
|
||||
echo "passwordB='${password}'" >> $SETUPFILE
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\nThanks - Password B accepted.\n\nUse this password as login for\nadditial Apps & API access." 10 34
|
||||
fi
|
||||
|
||||
# PASSWORD C
|
||||
if [ "${setPasswordC}" == "1" ]; then
|
||||
clear
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
|
||||
password=$(sudo cat $_temp)
|
||||
sudo rm $_temp
|
||||
sudo sed -i '/^passwordC=/d' $SETUPFILE
|
||||
echo "passwordC='${password}'" >> $SETUPFILE
|
||||
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\nThanks - Password C accepted.\n\nAlways use this password to \nunlock your Lightning Wallet." 10 34
|
||||
fi
|
||||
|
||||
# debug info
|
||||
clear
|
||||
echo "# data from dialogs stored in to be further processed:"
|
||||
echo "${SETUPFILE}"
|
||||
exit 0
|
24
home.admin/setup.scripts/dialogRecovery.sh
Normal file
24
home.admin/setup.scripts/dialogRecovery.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
whiptail --title " RASPIBLITZ RECOVERY " --yes-button "Start Recovery" --no-button "Other Options" --yesno "We found data from an existing RaspiBlitz on your HDD/SSD.
|
||||
|
||||
You can now start RECOVERY to freshly build your system based on existing configuration & data. This process is often used to repair broken features or clean the system up.
|
||||
|
||||
You will need to set a new Password A for the SSH login. All other passwords will stay the same and channels will stay open.
|
||||
|
||||
Please make sure to have your seed words & static channel backup file (just in case).
|
||||
|
||||
Do you want to start RECOVERY of your RaspiBlitz now?
|
||||
" 20 68
|
||||
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> run recover
|
||||
exit 0
|
||||
else
|
||||
# 1 --> other options
|
||||
exit 1
|
||||
fi
|
25
home.admin/setup.scripts/dialogUpdate.sh
Normal file
25
home.admin/setup.scripts/dialogUpdate.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/_version.info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
whiptail --title " RASPIBLITZ UPDATE " --yes-button "Start Update" --no-button "Other Options" --yesno "We found data from an old RaspiBlitz on your HDD/SSD.
|
||||
|
||||
You can start now the UPDATE to version ${codeVersion}.
|
||||
|
||||
You will need to set a new Password A for the SSH login. All your channels will stay open and other passwords will stay the same.
|
||||
|
||||
Please make sure to have your seed words & static channel backup file (just in case).
|
||||
|
||||
Do you want to start UPDATE of your RaspiBlitz now?
|
||||
" 18 65
|
||||
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> run recover
|
||||
exit 0
|
||||
else
|
||||
# 1 --> other options
|
||||
exit 1
|
||||
fi
|
84
home.admin/setup.scripts/eventBlockchainSync.sh
Normal file
84
home.admin/setup.scripts/eventBlockchainSync.sh
Normal file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
# this is an dialog that handles all UI events during setup that require a "info & wait" with no interaction
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/_version.info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
# 1st PARAMETER: ssh|lcd
|
||||
lcd=0
|
||||
if [ "$1" == "lcd" ]; then
|
||||
lcd=1
|
||||
fi
|
||||
|
||||
# 2nd PARAMETER (optional): -loop-until-synced
|
||||
loopUntilSynced=0
|
||||
if [ "$2" == "loop" ]; then
|
||||
loopUntilSynced=1
|
||||
fi
|
||||
|
||||
loop=1
|
||||
while [ ${loop} -eq 1 ]
|
||||
do
|
||||
|
||||
# get fresh data
|
||||
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
|
||||
|
||||
# display blockchain sync
|
||||
height=6
|
||||
width=45
|
||||
actionString="Please wait - this can take some time"
|
||||
|
||||
# formatting BLOCKCHAIN SYNC PROGRESS
|
||||
if [ "${syncProgress}" == "" ]; then
|
||||
if [ ${startcountBlockchain} -lt 2 ]; then
|
||||
syncProgress="waiting"
|
||||
else
|
||||
syncProgress="${startcountBlockchain} restarts"
|
||||
fi
|
||||
elif [ ${#syncProgress} -lt 6 ]; then
|
||||
syncProgress=" ${syncProgress} % ${blockchainPeers} peers"
|
||||
else
|
||||
syncProgress="${syncProgress} % ${blockchainPeers} peers"
|
||||
fi
|
||||
|
||||
# formatting LIGHTNING SCAN PROGRESS
|
||||
if [ "${scanProgress}" == "" ]; then
|
||||
# in case of LND RPC is not ready yet
|
||||
if [ ${scanTimestamp} -eq -2 ]; then
|
||||
scanProgress="prepare sync"
|
||||
# in case LND restarting >2
|
||||
elif [ ${startcountLightning} -gt 2 ]; then
|
||||
scanProgress="${startcountLightning} restarts"
|
||||
# unkown cases
|
||||
else
|
||||
scanProgress="waiting"
|
||||
fi
|
||||
elif [ ${#scanProgress} -lt 6 ]; then
|
||||
scanProgress=" ${scanProgress} %"
|
||||
else
|
||||
scanProgress="${scanProgress} %"
|
||||
fi
|
||||
|
||||
# setting info string
|
||||
infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n ${actionString}"
|
||||
|
||||
# set admin string
|
||||
if [ ${lcd} -eq 1 ]; then
|
||||
adminStr="ssh admin@${localip} ->Password A"
|
||||
else
|
||||
adminStr="Use CTRL+c to EXIT to Terminal"
|
||||
fi
|
||||
|
||||
# display info to user
|
||||
dialog --title " Node is Syncing " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width}
|
||||
|
||||
# determine to loop or not
|
||||
loop=0
|
||||
if [ ${loopUntilSynced} -eq 1 ] && [ "${syncedToChain}" == "0" ]; then
|
||||
# loop until synced to chain
|
||||
loop=1
|
||||
sleep 3
|
||||
fi
|
||||
done
|
256
home.admin/setup.scripts/eventInfoWait.sh
Normal file
256
home.admin/setup.scripts/eventInfoWait.sh
Normal file
@ -0,0 +1,256 @@
|
||||
#!/bin/bash
|
||||
# this is an dialog that handles all UI events during setup that require a "info & wait" with no interaction
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/_version.info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
# 1st PARAMETER: eventID
|
||||
# fixed ID string for a certain event
|
||||
eventID=$1
|
||||
if [ "${eventID}" == "" ]; then
|
||||
echo "err='missing eventID'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2nd PARAMETER (optional): dynamic content that can be used in two ways
|
||||
# 1) contentWords[] --> if eventID is known & well defined between backend & frontend, then use the single words of this string as dynamic content for static text info
|
||||
# 2) contentString --> if eventID is new and not well defined yet, then just show a generic info and use the complete string as info message
|
||||
# just see examples of this two use cases below
|
||||
contentWords=($2)
|
||||
contentString=$2
|
||||
|
||||
# 3rd PARAMETER (optional): Place of display - could be "lcd" or "ssh" (defalt)
|
||||
mode=$3
|
||||
if [ "${mode}" == "" ]; then
|
||||
mode="ssh"
|
||||
fi
|
||||
if [ "${mode}" != "lcd" ] && [ "${mode}" != "ssh" ]; then
|
||||
echo "error='unknown 3rd parameter value'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# default backtitle for dialog
|
||||
backtitle="RaspiBlitz ${codeVersion} / ${localip} / ${eventID}"
|
||||
|
||||
################################################
|
||||
# 1) WELL DEFINED EVENTS
|
||||
################################################
|
||||
|
||||
if [ "${eventID}" == "starting" ] || [ "${eventID}" == "system-init" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Starting RaspiBlitz
|
||||
Please wait ...
|
||||
" 6 24
|
||||
|
||||
elif [ "${eventID}" == "reboot" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Shutting down for reboot.
|
||||
" 5 30
|
||||
|
||||
elif [ "${eventID}" == "error" ] && [ "${mode}" == "lcd" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
SYSTEM RAN INTO AN ERROR:
|
||||
${contentString}
|
||||
------------------------------------
|
||||
Use terminal command to login:
|
||||
ssh admin@${localip}
|
||||
" 10 41
|
||||
|
||||
elif [ "${eventID}" == "error" ] && [ "${mode}" == "ssh" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
SYSTEM RAN INTO AN ERROR:
|
||||
${contentString}
|
||||
|
||||
Please report to the Raspiblitz GitHub
|
||||
Use CTRL+C to exit to terminal.
|
||||
For shutdown use command: off
|
||||
" 10 50
|
||||
|
||||
elif [ "${eventID}" == "provision" ] || [ "${eventID}" == "recovering" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Upgrade/Recover/Provision
|
||||
---> ${contentString}
|
||||
Please keep running until reboot.
|
||||
" 7 40
|
||||
|
||||
elif [ "${eventID}" == "repair" ] && [ "${mode}" == "lcd" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Repair-Mode - Login for Details:
|
||||
ssh admin@${localip}
|
||||
Use your Password A
|
||||
" 7 41
|
||||
|
||||
elif [ "${eventID}" == "inconsistentsystem" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
PLEASE START WITH A FRESH SD CARD IMAGE
|
||||
---------------------------------------
|
||||
Cut power & remove sd card and then
|
||||
flash a fresh RaspiBlitz image on it.
|
||||
" 8 45
|
||||
|
||||
elif [ "${eventID}" == "waitsetup" ] && [ "${mode}" == "lcd" ]; then
|
||||
|
||||
if [ "${setupPhase}" == "setup" ] || [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then
|
||||
|
||||
# custom backtitle for this dialog
|
||||
backtitle="RaspiBlitz ${codeVersion} / ${setupPhase}"
|
||||
|
||||
# display if HDD conatains blockhain or not
|
||||
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddBlocksLitecoin}" == "1" ]; then
|
||||
backtitle="${backtitle} / (pre-synced)"
|
||||
fi
|
||||
|
||||
# custom welcomeline for this dialog
|
||||
welcomeline="Your RaspiBlitz is ready for Setup"
|
||||
if [ "${setupPhase}" == "update" ]; then
|
||||
welcomeline="RaspiBlitz is ready for Update"
|
||||
fi
|
||||
if [ "${setupPhase}" == "recovery" ]; then
|
||||
welcomeline="RaspiBlitz is ready for Recovery"
|
||||
fi
|
||||
if [ "${setupPhase}" == "migration" ]; then
|
||||
welcomeline="Ready for migration to RaspiBlitz"
|
||||
fi
|
||||
|
||||
# show default login help info
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
${welcomeline}
|
||||
------------------------------------
|
||||
Use terminal command to login:
|
||||
ssh admin@${localip}
|
||||
password: raspiblitz
|
||||
" 9 41
|
||||
|
||||
else
|
||||
|
||||
# custom backtitle for this dialog
|
||||
backtitle="RaspiBlitz ${codeVersion} / ${setupPhase}"
|
||||
|
||||
# on all other cases (add info message)
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Login for Maintenance:
|
||||
---> ${contentString}
|
||||
ssh admin@${localip}
|
||||
Use password: raspiblitz
|
||||
" 8 41
|
||||
fi
|
||||
|
||||
elif [ "${eventID}" == "waitfinal" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Setup-Done - Login for Details:
|
||||
ssh admin@${localip}
|
||||
Use your Password A
|
||||
" 7 41
|
||||
|
||||
elif [ "${eventID}" == "shutdown" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Shutting down - please wait.
|
||||
" 5 35
|
||||
|
||||
elif [ "${eventID}" == "noDHCP" ]; then
|
||||
|
||||
# this event is mostly for LCD/HDMI display
|
||||
# because if device gets no local IP
|
||||
# SSH & WEBUI would not have connected yet
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Waiting for local IP address ...
|
||||
If this takes too long please check
|
||||
your connection to internet router.
|
||||
" 7 41
|
||||
|
||||
elif [ "${eventID}" == "waitsetup" ] && [ "${mode}" == "ssh" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Please wait ...
|
||||
" 5 22
|
||||
|
||||
elif [ "${eventID}" == "waitprovision" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Preparing Provision
|
||||
Please wait ...
|
||||
" 6 24
|
||||
|
||||
elif [ "${eventID}" = "noIP-LAN" ] || [ "${eventID}" = "noIP-WIFI" ]; then
|
||||
|
||||
# this event is mostly for LCD/HDMI display
|
||||
# because if device gets no local IP
|
||||
# SSH & WEBUI would not have connected yet
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Waiting for Network ...
|
||||
Not able to get local IP.
|
||||
LAN cable connected? WIFI lost?
|
||||
" 7 41
|
||||
|
||||
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}" = "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 "
|
||||
Checking HDD/SSD ...
|
||||
Please wait.
|
||||
" 6 26
|
||||
|
||||
elif [ "${eventID}" == "noHDD" ]; then
|
||||
|
||||
# contentWords[0] --> size string (for example '1TB')
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Waiting for HDD/SSD ...
|
||||
Please connect a ${contentWords[0]}
|
||||
HDD or SSD to the device.
|
||||
" 7 35
|
||||
|
||||
elif [ "${eventID}" == "errorHDD" ]; then
|
||||
|
||||
# contentString --> detail error message
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
PROBLEM: FAILED HDD/SSD
|
||||
Detailed Error Message:
|
||||
${contentString}
|
||||
" 7 35
|
||||
|
||||
elif [ "${eventID}" == "sdtoosmall" ]; then
|
||||
|
||||
# contentWords[0] --> size string (for example '16GB')
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
PROBLEM: SD CARD IS TOO SMALL
|
||||
Minimum of ${contentWords[0]} needed
|
||||
Cut power & create fresh sd card
|
||||
" 7 40
|
||||
|
||||
################################################
|
||||
# 2) GENERIC EVENT
|
||||
# may get better defined in the future
|
||||
################################################
|
||||
|
||||
else
|
||||
|
||||
# a generic info box for not further defined events
|
||||
dialog --title "${eventid}" --backtitle "${backtitle}" --cr-wrap --infobox "\n${contentString}" 7 50
|
||||
|
||||
fi
|
66
home.admin/setup.scripts/finalDialogControl.sh
Executable file
66
home.admin/setup.scripts/finalDialogControl.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/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
|
310
home.admin/setup.scripts/setupDialogControl.sh
Executable file
310
home.admin/setup.scripts/setupDialogControl.sh
Executable file
@ -0,0 +1,310 @@
|
||||
#!/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"
|
||||
|
||||
# remember original setupphase
|
||||
orgSetupPhase="${setupPhase}"
|
||||
|
||||
# init SETUPFILE & temp dir on mem drive
|
||||
sudo mkdir /var/cache/raspiblitz/temp
|
||||
sudo chown admin:admin /var/cache/raspiblitz/temp
|
||||
sudo rm $SETUPFILE 2>/dev/null
|
||||
echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE
|
||||
sudo chown admin:admin $SETUPFILE
|
||||
sudo chmod 777 $SETUPFILE
|
||||
|
||||
############################################
|
||||
# QuickOption: Update
|
||||
if [ "${setupPhase}" == "update" ]; then
|
||||
# show update dialog
|
||||
/home/admin/setup.scripts/dialogUpdate.sh
|
||||
if [ "$?" == "0" ]; then
|
||||
# proceed with provision (mark Password A to be set)
|
||||
echo "# OK update process starting .."
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
else
|
||||
# default to normal setup options
|
||||
setupPhase="setup"
|
||||
sudo sed -i "s/^setupPhase=.*/setupPhase='setup'/g" /home/admin/raspiblitz.info
|
||||
echo "# you refused recovery option - defaulting to normal setup"
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################
|
||||
# QuickOption: Recovery
|
||||
if [ "${setupPhase}" == "recovery" ]; then
|
||||
# show recovery dialog
|
||||
/home/admin/setup.scripts/dialogRecovery.sh
|
||||
if [ "$?" == "0" ]; then
|
||||
# proceed with provision (mark Password A to be set)
|
||||
echo "# OK recover process starting .."
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
else
|
||||
# default to normal setup options
|
||||
setupPhase="setup"
|
||||
sudo sed -i "s/^setupPhase=.*/setupPhase='setup'/g" /home/admin/raspiblitz.info
|
||||
echo "# you refused recovery option - defaulting to normal setup"
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################
|
||||
# QuickOption: Migration from other node
|
||||
if [ "${setupPhase}" == "migration" ]; then
|
||||
# show recovery dialog
|
||||
echo "# Starting migration dialog ..."
|
||||
/home/admin/setup.scripts/dialogMigration.sh ${migrationOS}
|
||||
if [ "$?" == "0" ]; then
|
||||
# mark migration to happen on provision
|
||||
echo "migrationOS='umbrel'" >> $SETUPFILE
|
||||
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
|
||||
# user needs to reset password A, B & C
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
else
|
||||
# on cancel - default to normal setup
|
||||
setupPhase="setup"
|
||||
sudo sed -i "s/^setupPhase=.*/setupPhase='setup'/g" /home/admin/raspiblitz.info
|
||||
echo "# you refused node migration option - defaulting to normal setup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
############################################
|
||||
# DEFAULT: Basic Setup menu
|
||||
# user might default to from quick options
|
||||
if [ "${setupPhase}" == "setup" ]; then
|
||||
|
||||
echo "# Starting basic setup dialog ..."
|
||||
/home/admin/setup.scripts/dialogBasicSetup.sh
|
||||
menuresult=$?
|
||||
|
||||
# exit to terminal
|
||||
if [ "${menuresult}" == "3" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shutdown without changes
|
||||
if [ "${menuresult}" == "2" ]; then
|
||||
sudo shutdown now
|
||||
exit 0
|
||||
fi
|
||||
|
||||
###############################################
|
||||
# FORMAT DRIVE on NEW SETUP or MIGRATION UPLOAD
|
||||
if [ "${menuresult}" == "0" ] || [ "${menuresult}" == "1" ]; then
|
||||
|
||||
# check if there is a blockchain to use (so HDD is already formatted)
|
||||
# thats also true if the node is coming from another nodeOS
|
||||
existingBlockchain=""
|
||||
if [ "${hddBlocksLitecoin}" == "1" ]; then
|
||||
existingBlockchain="LITECOIN"
|
||||
fi
|
||||
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddGotMigrationData}" != "" ]; then
|
||||
existingBlockchain="BITCOIN"
|
||||
fi
|
||||
|
||||
# ask user about possible existing blockchain and formatting HDD
|
||||
/home/admin/setup.scripts/dialogDeleteData.sh "${existingBlockchain}"
|
||||
userChoice=$?
|
||||
if [ "${userChoice}" == "1" ]; then
|
||||
|
||||
# FORMAT DATA DRIVE
|
||||
filesystem="ext4"
|
||||
|
||||
# check if there is a flag set on sd card boot section to format as btrfs (experimental)
|
||||
flagBTRFS=$(sudo ls /boot/btrfs* 2>/dev/null | grep -c btrfs)
|
||||
if [ "${flagBTRFS}" != "0" ]; then
|
||||
echo "Found BTRFS flag ---> formatting with experimental BTRFS filesystem"
|
||||
filesystem="btrfs"
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# run formatting
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${filesystem} ${hddCandidate})
|
||||
if [ "${error}" != "" ]; then
|
||||
echo "FAIL ON FORMATTING THE DRIVE:"
|
||||
echo "${error}"
|
||||
echo "Please report as issue on the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# DEBUG EXIT
|
||||
echo "OK Format done"
|
||||
exit 1
|
||||
|
||||
elif [ "${userChoice}" == "2" ]; then
|
||||
|
||||
# KEEP BLOCKCHAIN + DLETE ALL THE REST
|
||||
|
||||
# when blockchain comes from another node migrate data first
|
||||
if [ "${hddGotMigrationData}" != "" ]; then
|
||||
clear
|
||||
echo "Migrating Blockchain of ${hddGotMigrationData}'"
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
|
||||
if [ "${err}" != "" ]; then
|
||||
echo "MIGRATION OF BLOCKHAIN FAILED: ${err}"
|
||||
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# delete everything but blockchain
|
||||
echo "Deleting everything on HDD/SSD while keeping blockchain ..."
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh clean all -keepblockchain
|
||||
if [ "${error}" != "" ]; then
|
||||
echo "CLEANING HDD FAILED:"
|
||||
echo "${error}"
|
||||
echo "Please report as issue on the raspiblitz github."
|
||||
exit 1
|
||||
fi
|
||||
sudo /home/admin/config.scripts/blitz.datadrive.sh unmount
|
||||
sleep 2
|
||||
|
||||
# by keeping that blockchain - user choosed already the blockchain type
|
||||
echo "Selecting as blockchain network automatically .."
|
||||
if [ "${hddBlocksLitecoin}" == "1" ]; then
|
||||
echo "network=litecoin" >> $SETUPFILE
|
||||
else
|
||||
echo "network=bitcoin" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# STOP SETUP - loop back to setup menu start
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
############################################
|
||||
# UPLOAD MIGRATION
|
||||
if [ "${menuresult}" == "1" ]; then
|
||||
/home/admin/setup.scripts/dialogMigration.sh raspiblitz
|
||||
if [ "$?" == "1" ]; then
|
||||
# upload did not worked .. exit with 0 to restart process from outside loop
|
||||
echo "Upload failed ... return to menu"
|
||||
sleep 2
|
||||
exit 0
|
||||
fi
|
||||
# user needs to reset password A
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
############################################
|
||||
# FRESH SETUP
|
||||
if [ "${menuresult}" == "0" ]; then
|
||||
|
||||
############################################
|
||||
# Choosing Blockchain & Lightning
|
||||
|
||||
echo "# Starting Blockchain & Lightning selection ..."
|
||||
/home/admin/setup.scripts/dialogBlockchainLightning.sh
|
||||
if [ "$?" == "1" ]; then
|
||||
# exit with 0 to restart process from outside loop
|
||||
exit 0
|
||||
fi
|
||||
|
||||
############################################
|
||||
# Setting Name for Node
|
||||
|
||||
echo "# Starting name dialog ..."
|
||||
/home/admin/setup.scripts/dialogName.sh
|
||||
|
||||
############################################
|
||||
# Lightning Wallet (new or restore) do this before passwords
|
||||
# because password C not needed if LND rescue file is uploaded
|
||||
|
||||
lightningWalletDone=0
|
||||
source ${SETUPFILE}
|
||||
if [ "${lightning}" == "" ]; then lightningWalletDone=1; fi
|
||||
while [ "${lightningWalletDone}" == "0" ]
|
||||
do
|
||||
|
||||
if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
echo "# Starting lightning wallet dialog for LND ..."
|
||||
/home/admin/setup.scripts/dialogLightningWallet-lnd.sh
|
||||
dialogResult=$?
|
||||
|
||||
elif [ "${lightning}" == "cln" ]; then
|
||||
|
||||
echo "# Starting lightning wallet dialog for C-LIGHTNING ..."
|
||||
/home/admin/setup.scripts/dialogLightningWallet-cln.sh
|
||||
dialogResult=$?
|
||||
|
||||
else
|
||||
echo "FAIL: unkown lightning implementation (${lightning})"
|
||||
lightningWalletDone=1
|
||||
sleep 8
|
||||
fi
|
||||
|
||||
# break loop only if a clean exit
|
||||
if [ "${dialogResult}" == "0" ]; then
|
||||
lightningWalletDone=1
|
||||
fi
|
||||
|
||||
# allow user to cancel to terminal on dialog main menu
|
||||
# all other cancels have other exit codes
|
||||
if [ "${dialogResult}" == "1" ]; then
|
||||
echo "# you selected cancel - sending exit code 1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "# CREATING raspiblitz.conf from your setup choices"
|
||||
|
||||
# source the raspiblitz version
|
||||
source /home/admin/_version.info
|
||||
|
||||
# source the setup state fresh
|
||||
source $SETUPFILE
|
||||
|
||||
# prepare config file
|
||||
CONFIGFILE="/var/cache/raspiblitz/temp/raspiblitz.conf"
|
||||
sudo rm $CONFIGFILE 2>/dev/null
|
||||
sudo chown admin:admin $CONFIGFILE
|
||||
sudo chmod 777 $CONFIGFILE
|
||||
|
||||
# write basic config file data
|
||||
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE
|
||||
echo "raspiBlitzVersion='${codeVersion}'" >> $CONFIGFILE
|
||||
echo "lcdrotate=1" >> $CONFIGFILE
|
||||
echo "lightning=${lightning}" >> $CONFIGFILE
|
||||
echo "network=${network}" >> $CONFIGFILE
|
||||
echo "chain=main" >> $CONFIGFILE
|
||||
echo "hostname='${hostname}'" >> $CONFIGFILE
|
||||
echo "runBehindTor=on" >> $CONFIGFILE
|
||||
|
||||
# user needs to set all passwords
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
############################################
|
||||
# Enter Passwords
|
||||
# for fresh setup & migration
|
||||
|
||||
echo "# Starting passwords dialog ..."
|
||||
/home/admin/setup.scripts/dialogPasswords.sh
|
||||
|
||||
# set flag for bootstrap process to kick-off provision process
|
||||
sudo sed -i "s/^state=.*/state=waitprovision/g" /home/admin/raspiblitz.info
|
||||
|
||||
clear
|
||||
echo "# setup dialog done - results in:"
|
||||
echo "# $SETUPFILE"
|
||||
echo "# $CONFIGFILE"
|
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 109 KiB |
Loading…
x
Reference in New Issue
Block a user