merging pre-1.7.1 (#2462)

* fix copychain returns

* typo in sync loop

* stop services on inconsistent state

* calling correct provisioning

* apply bitcoin and lncli aliases in all scripts

* network.aliases: add CLNETWORK

* make cln default plugin dir: cln-plugins-enabled

similar to the nginx model make 2 directories for plugins:
cln-plugins-enabled - symlinked to ~/.lightning/plugins
plugins from here are loaded automatically on cln start

cln-plugins-available: plugins are downloaded here to
be run until the next cln restart (or stopped with runonce)

note the disk is mounted with noexec so plugins can't
run from there

discuss in: https://github.com/rootzoll/raspiblitz/issues/2295

* move shutdown script

* change all place where shutdown script is used

* change notify & release

* moved shutdown script

* moved shutdown scripts

* add more debug info

* moving github script

* remove chain in sync

* no longer needed chain in sync

* move debug script

* patch patch command

* make sure setup file is sourced

* remove debug output

* make sure lnd is put behind tor

* change indent

* get fresh sync progress

* avoid scrolling in menus

* use new selfsignedcert if no lnd tls.cert present

* sparko: add info and connect menu with own cert

https://github.com/rootzoll/raspiblitz/issues/2295

* cln.rest: add connect option for Zeus

https://github.com/rootzoll/raspiblitz/issues/2295

* cln: add the backup plugin + options

Usage options:
cln-plugin.backup.sh [on] [testnet|mainnet|signet]
cln-plugin.backup.sh [restore] [testnet|mainnet|signet] [force]
cln-plugin.backup.sh [backup-compact] [testnet|mainnet|signet]
https://github.com/lightningd/plugins/tree/master/backup

Discussed in: https://github.com/rootzoll/raspiblitz/issues/2295

* cln: add cln-plugin.standard.python.sh

Install and show the output of the chosen plugin for C-lightning
Usage:
cln-plugin.standard-python.sh on [plugin-name] [testnet|mainnet|signet] [runonce]
tested plugins:
summary | helpme | feeadjuster

find more at:
https://github.com/lightningd/plugins
discussed in:
https://github.com/rootzoll/raspiblitz/issues/2295

* shellcheck: change all `egrep` to `grep -E`

https://github.com/koalaman/shellcheck/wiki/SC2196

* do not resolve aliases, use as variables

* lnd: fix lnd.conf for parallel networks

discussed in: https://github.com/rootzoll/raspiblitz/issues/2290

* lnd: add LND option for parallel networks

* deprecate Testnet in SETTINGS
keysend and autopilot only for mainnet

due to: https://github.com/rootzoll/raspiblitz/issues/2290

* lnd: autopilot and autounlock for testnet

* fix comments

* add the SYSTEM menu for parallel chains

* RTL update to v0.11.0

make chain specific directory for the config: /home/rtl/${netprefix}RTL/
use ${netprefix}lnd.conf in config
override Environmen tvaribales for cln in the systemd service:
/etc/systemd/system/${netprefix}${typeprefix}RTL.service

discussed in: https://github.com/rootzoll/raspiblitz/issues/2384

* lnd.setname.sh for testnet

* display ${CHAIN} in the SYSTEM menu options

* keep _aliases file when live patches are applied

* all lncli_aliases to be used as variables

* default to KIllMode=control-group in services

https://www.man7.org/linux/man-pages/man5/systemd.kill.5.html
discussed in: https://github.com/rootzoll/raspiblitz/issues/1901

* add cln.hsmtool.sh for  hsm_secret handling

encrypt | decrypt | autounlock the hsm_secret for C-lightning
usage:
cln.hsmtool.sh [unlock] [testnet|mainnet|signet]
cln.hsmtool.sh [encrypt|decrypt] [testnet|mainnet|signet]
cln.hsmtool.sh [autounlock-on|autounlock-off] [testnet|mainnet|signet]

discussed in: https://github.com/rootzoll/raspiblitz/issues/2295

* add cln.install-service.sh to set up cln with systemd

script to set up or update the CLN systemd service
checks for hsm_secret encryption, autounlock and the sparko plugin
usage:
/home/admin/config.scripts/cln.install-service.sh $CHAIN

discussed in: https://github.com/rootzoll/raspiblitz/issues/2295

* use symlink to cln-plugins-enabled for all plugins

* keep lnd autopilot and autounlock mainnet only

mainnet only settings:
lnd autopilot
lnd keysend
circuibreaker
lnd autounlock
StaticChannelBackup to DropBox and USB

* cln FUNDING fix parsing address

* cln.hsmtool: add change-password and lock options

* always set password A

* cached peer info

* fix printing cache

* fix check for existing files

* handle bitcoind not running

* result with newline

* test line break

* test new line

* test new line

* two vars on output

* #2388 improve online check (less pinging)

* used cached peer status

* move chache

* cach file permissions

* allow sudo call

* fix cache

* remove double scan info

* add conf info to sync screen

* reorder info

* add space

* add space

* order info

* internet suppress error messages

* order info

* fix offering Blockchain copy

* fix hostname

* final ready state info

* lnd unlock after provision

* remove debug exit

* harmonize ready state

* add status to lnd unlock

* update lnd unlock script

* edit the unlock

* remove debug echo

* add debug

* add debug

* fix if statement

* debug output

* switch position of source setupdata

* #1126 preparing new setup with new c-lightning  (#2396)

* move debug script

* patch patch command

* make sure setup file is sourced

* remove debug output

* make sure lnd is put behind tor

* change indent

* get fresh sync progress

* always set password A

* cached peer info

* fix printing cache

* fix check for existing files

* handle bitcoind not running

* result with newline

* test line break

* test new line

* test new line

* two vars on output

* #2388 improve online check (less pinging)

* used cached peer status

* move chache

* cach file permissions

* allow sudo call

* fix cache

* remove double scan info

* add conf info to sync screen

* reorder info

* add space

* add space

* order info

* internet suppress error messages

* order info

* fix offering Blockchain copy

* fix hostname

* final ready state info

* lnd unlock after provision

* remove debug exit

* harmonize ready state

* add status to lnd unlock

* update lnd unlock script

* edit the unlock

* remove debug echo

* add debug

* add debug

* fix if statement

* debug output

* switch position of source setupdata

* lnd.unlock: fix typo

* netwok.monitor.sh debug

* cln-plugin.summary: fix paths

* rtl: fix permission of config on copy

* CASHOUT: use aliases for lnd

* rtl: install correctly for paralell chains

* use CHAIN in CLN and LND menu

* cln: add  CASHOUT option

* CLOSEALL and  CASHOUT: Improve labels and comments

Explaining CASHOUT in the label as discussed in:
https://github.com/rootzoll/raspiblitz/issues/2358

* cln.install: fix tor config

* cln: installthe  latest master until the next release

* _commands: source _aliases only if exists

* network aliases: fall back to 'main' for 'chain'

* new setup: keep testnet3 blocks and chainstate

* new setup: improve capitalization in menu

* improve help and comments

* cln: install Sparko if configured, but not present

* cln: add new wallet and import seed options

* fix peernum

* make sure that aliases get created on lnd setup

* no error if aliases not yet exist

* debug state

* fix network alias when not set

* fix syntax error

* add debug error info

* mute unlocking echos

* add debug wait

* add debug wait

* make sure info is uptodate

* make alias info as defaults

* rename option

* update sync info for no lightning

* add action string

* update sync info

* move name dialog

* wait for sync progress info

* wait for syncprogress info

* fix syntax

* get fresh data

* make sure to disable lnd

* add c-lightning to debug

* add setup logs to debug output

* fix syntax error

* add new-force wallet

* try fix call hsmtool

* hsm output tool

* fix output

* add seed-force

* refactor blitz.mnemonic.py

* test seed

* debug info

* dump object

* try check

* correct putput

* fix syntax

* check lnd for valid seed

* fix gui

* add Suez install script

discussed in:
https://github.com/rootzoll/raspiblitz/issues/2366

* cln rescue file export

* get correct version

* add cln export gui

* cln.backup.sh cln-import

* correct bytesize

* generate cln wallet with passwordc

* fix syntax

* fix syntax

* mute not needed error msg

* PEERING: correct message on success

* cln.install-service: fix sparko check

* add Suez to menu for CLN and LND

needs to be installed with the bitcoin user to be able to interact with CLN
related: https://github.com/rootzoll/raspiblitz/issues/2366

* debug _provison.setup.sh

stop bitcoind and restart with new config to avoid rpc password error
disable and enable service instead of daemon-reload
CLN: don't use passwordC  as seedPassword

* add cln.setname.sh

make lnd.setname.sh work with parallel wallets

* improve comments

* SYSTEM: add CLNLOG and CLNCONF options

* SYSTEM menu fixes

* cln: add more aliases cln, clnlog, clnconf

* cln: activate the backup plugin on every install

* SERVICES menu: fix chantools/CLN switch

* cln: load plugins from ${netprefix}cln-plugins-enabled

changed the config paths to $lightning-dir/config or /networkname/config

plugins are downloaded to the SDcard:
/home/bitcoin/cln-plugins-available/
symlinked and loaded automatically from:
/home/bitcoin/${netprefix}cln-plugins-enabled

Related: #2295

* sparko: don't show logs after install

* #2425 Adding experimental Blitz WebUI & API (#2426)

* no password C & D when cln

* add debug echos

* set defaults before

* #2228 wider grep to detect nvms (#2427)

* cln.hsmtool: init backup with the new wallet

* cln.install: fix access to raspiblitz.conf

* cln-plugin.backup: fix path to backup-cli

* cln: hide unhelpful warnings during setup

* remove old jinja template rendering

* fix lnd unlock detection

* cln: look for files in .lightning dir with sudo

* cln: correct lightning name in FInalDialog + typo

* cln: make sure .lightning/bitcoin dir exists

* FinalDialog: make the 24 words fit

* cln.install.sh: create cln config if not present

* Simplify localIP detection and improve compatibility (#2432)

* show tail info on provision

* only show lnd options when activated

* fix syntax

* only show main lightning impl options for RC1

* cln: always start the lightnind.service

* cln: clear before showing summary

* start cln on the end of provisioning

* exit 0 on cln menu

* press key after single actions

* remove key press on cln actions

* change to none

* detect cln running

* fix syntax

* fix lightniing info

* add TODO for CLN

* add clnblockheight

* zty with user bitcoin

* check synced to chain for cln

* fix increment

* try scanprogress

* use cln sync detection and progress

* replace LNTYPE

* next line

* fix spaces

* fix spaces

* Update README.md (#2456)

Fix 404

* Fix FAQ links (#2441)

* Fix invalid URL ( (#2440)

* support channels (#2382)

* use #2370 height optimization

* adjust exit codes in menu scripts

* adjust password menu exit codes

* adapt shutdown for cln

* settings adapt to running lightning impl

* fix syntax

* debug info

* add debug

* better height

* add default values

* add config entry if not there yet

* change default value

* Added exit info for cln

* make sure to load config file if available

* add sparko to menu

* add default for sparko

* replace default sparko entry

* show sparko installed or not

* add more description to sparko option

* RTL for clightnign in service menu

* main menu item rtl

* add RTL description

* debug in RTL install

* install sparko on recovery

* update menu with cln

* rework menu options

Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: rek79 <rek79@users.noreply.github.com>
Co-authored-by: Bitpaint <67663265+bitpaint@users.noreply.github.com>
Co-authored-by: João Thallis <joaothallis@icloud.com>
Co-authored-by: Peter Flock <78184669+peterflock@users.noreply.github.com>
Co-authored-by: nyxnor <nyxnor@protonmail.com>
This commit is contained in:
/rootzoll 2021-08-04 00:18:30 +02:00 committed by GitHub
parent 23aec4d791
commit 074c9d8549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
155 changed files with 10348 additions and 5807 deletions

24
FAQ.md
View File

@ -190,7 +190,7 @@ If your RaspiBlitz is not working correctly and you like to get help from the co
- SSH into your raspiblitz as admin user with your password A - SSH into your raspiblitz as admin user with your password A
- If you see the menu - use CTRL+C to get to the terminal - If you see the menu - use CTRL+C to get to the terminal
- To generate debug report run: `./XXdebugLogs.sh` - To generate debug report run: `debug`
- Then copy all output beginning with `*** RASPIBLITZ LOGS ***` and share this - Then copy all output beginning with `*** RASPIBLITZ LOGS ***` and share this
*PLEASE NOTICE: It's possible that these logs can contain private information (like IPs, node IDs, ...) - just share publicly what you feel OK with.* *PLEASE NOTICE: It's possible that these logs can contain private information (like IPs, node IDs, ...) - just share publicly what you feel OK with.*
@ -237,7 +237,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): To rescue/export your Lightning data from a RaspiBlitz (since v1.1):
* SSH into your RaspiBlitz and EXIT to terminal from the menu. * 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. * 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. 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.
@ -245,7 +245,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: 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. * 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. * 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. 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.
@ -416,13 +416,13 @@ For example if you want to make a build from the 'dev' branch you execute the fo
If you fork the RaspiBlitz repo (much welcome) and you want to run that code on your RaspiBlitz, there are two ways to do that: If you fork the RaspiBlitz repo (much welcome) and you want to run that code on your RaspiBlitz, there are two ways to do that:
* The quick way: For small changes in scripts, go to `/home/admin` on your running RaspiBlitz, delete the old git with `sudo rm -r raspiblitz` then replace it with your code `git clone [YOURREPO]` and `/home/admin/XXsyncScripts.sh` * The quick way: For small changes in scripts, go to `/home/admin` on your running RaspiBlitz, delete the old git with `sudo rm -r raspiblitz` then replace it with your code `git clone [YOURREPO]` and `patch`
* The long way: If you like to install/remove/change services and system configurations you need to build a SD card from your own code. Prepare like in [Build the SD Card Image](README.md#build-the-sd-card-image) from the README but in the end run the command: * The long way: If you like to install/remove/change services and system configurations you need to build a SD card from your own code. Prepare like in [Build the SD Card Image](README.md#build-the-sd-card-image) from the README but in the end run the command:
`wget --no-cache https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false false [GITHUB-USERNAME] [BRANCH] lcd true true` `wget --no-cache https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false false [GITHUB-USERNAME] [BRANCH] lcd true true`
If you are then working in your forked repo and want to update the scripts on your RaspiBlitz with your latest repo changes, run `/home/admin/XXsyncScripts.sh` - That's OK as long as you don't make changes to the SD card build script - for that you would need to build a fresh SD card again from your repo. If you are then working in your forked repo and want to update the scripts on your RaspiBlitz with your latest repo changes, run `patch` - That's OK as long as you don't make changes to the SD card build script - for that you would need to build a fresh SD card again from your repo.
## How can I checkout a new branch from the RaspiBlitz repo to my forked repo? ## How can I checkout a new branch from the RaspiBlitz repo to my forked repo?
@ -453,7 +453,7 @@ git remote set-url origin [THE-URL-OF-YOUR-FORKED-REPO]
Now to sync your branch namend BRANCH on your forked repo with your RaspiBlitz, you always just run: Now to sync your branch namend BRANCH on your forked repo with your RaspiBlitz, you always just run:
``` ```
/home/admin/XXsyncScripts.sh BRANCH /home/admin/config.scripts/blitz.github.sh BRANCH
``` ```
So your workflow can go like this: You write code on your local computer. Commit to your local repo, push it to your forked repo and use the sync-script above to get the code to your RaspiBlitz. So your workflow can go like this: You write code on your local computer. Commit to your local repo, push it to your forked repo and use the sync-script above to get the code to your RaspiBlitz.
@ -474,14 +474,14 @@ cd /home/admin/raspiblitz
git fetch origin pull/[PRNUMBER]/head:pr[PRNUMBER] git fetch origin pull/[PRNUMBER]/head:pr[PRNUMBER]
git checkout pr[PRNUMBER] git checkout pr[PRNUMBER]
cd /home/admin cd /home/admin
./XXsyncScripts.sh -justinstall /home/admin/config.scripts/blitz.github.sh -justinstall
``` ```
Now you have the code of the PR active - depending on what scripts are changed you might need to reboot. Now you have the code of the PR active - depending on what scripts are changed you might need to reboot.
To change back to the code: To change back to the code:
``` ```
./XXsyncScripts.sh master /home/admin/config.scripts/blitz.github.sh master
``` ```
## How to attach the RaspberryPi to the HDD? ## How to attach the RaspberryPi to the HDD?
@ -541,7 +541,7 @@ Work notes for the process of producing a new SD card image release:
* Run the following command BUT REPLACE `[BRANCH]` with the branch-string of your latest version * Run the following command BUT REPLACE `[BRANCH]` with the branch-string of your latest version
* `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false true rootzoll [BRANCH] lcd true true` * `wget --no-cache https://raw.githubusercontent.com/rootzoll/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false true rootzoll [BRANCH] lcd true true`
* Monitor/Check outputs for warnings/errors - install LCD * Monitor/Check outputs for warnings/errors - install LCD
* Login new with `ssh admin@[IP-OF-RASPIBLITZ]` (pw: raspiblitz) and run `./XXprepareRelease.sh` * Login new with `ssh admin@[IP-OF-RASPIBLITZ]` (pw: raspiblitz) and run `release`
* Disconnect WiFi/LAN on build laptop (hardware switch off) and shutdown * Disconnect WiFi/LAN on build laptop (hardware switch off) and shutdown
* Remove `Ubuntu LIVE` USB stick and cut power from the RaspberryPi * Remove `Ubuntu LIVE` USB stick and cut power from the RaspberryPi
* Connect USB stick with latest `TAILS` (make it stay offline) * Connect USB stick with latest `TAILS` (make it stay offline)
@ -839,13 +839,13 @@ https://seravo.fi/2015/using-raid-btrfs-recovering-broken-disks
## How do I fix a displayed Error in my Config? ## How do I fix a displayed Error in my Config?
When the LCD display is telling you to do a config check: When the LCD display is telling you to do a config check:
- go to the RaspiBlitz terminal (X on main menu) and run './XXsyncScripts.sh' - go to the RaspiBlitz terminal (X on main menu) and run 'patch'
- start reboot with command: './XXshutdown.sh reboot' - start reboot with command: 'restart'
- go to the RaspiBlitz terminal run the command: 'check' - go to the RaspiBlitz terminal run the command: 'check'
- now edit the RaspiBlitz config and get rid of the errors: 'nano /mnt/hdd/raspiblitz.conf' - now edit the RaspiBlitz config and get rid of the errors: 'nano /mnt/hdd/raspiblitz.conf'
- save config with: CTRL+o - save config with: CTRL+o
- exit nano editor with: CTRL+x - exit nano editor with: CTRL+x
- start reboot with command: './XXshutdown.sh reboot' - start reboot with command: 'restart'
## How to fix my upside down LCD after update? ## How to fix my upside down LCD after update?

View File

@ -2,7 +2,7 @@
*Build your own Lightning Node on a RaspberryPi with a nice Display.* *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)`
![RaspiBlitz](pictures/raspiblitz.jpg) ![RaspiBlitz](pictures/raspiblitz.jpg)
@ -103,6 +103,7 @@ In the end your RaspiBlitz should look like this:
## Downloading the Software ## Downloading the Software
|Method|Install the image|Build the sd card| |Method|Install the image|Build the sd card|
|------|-----------------|-----------------| |------|-----------------|-----------------|
|Philosophy|Trust|Sovereignty| |Philosophy|Trust|Sovereignty|
@ -142,9 +143,9 @@ Insert the SD card and connect the power plug.
**Troubleshoot:** **Troubleshoot:**
* [I don't have a LAN port on my Laptop - how to connect to my RaspiBlitz?](FAQ.md#i-dont-have-a-lan-port-on-my-laptop---how-to-connect-to-my-raspiblitz) * [I don't have a LAN port on my Laptop - how to connect to my RaspiBlitz?](FAQ.md#i-dont-have-a-lan-port-on-my-laptop---how-do-i-connect-to-my-raspiblitz)
* [Is it possible to connect the Blitz over Wifi instead of using a LAN cable?](FAQ.md#is-it-possible-to-connect-the-blitz-over-wifi-instead-of-using-a-lan-cable) * [Is it possible to connect the Blitz over Wifi instead of using a LAN cable?](FAQ.md#is-it-possible-to-connect-the-blitz-over-wifi-instead-of-using-a-lan-cable)
* [Can I directly connect the RaspiBlitz with my laptop?](FAQ.md#can-i-directly-connect-the-raspiblitz-with-my-laptop) * [Can I directly connect the RaspiBlitz with my laptop?](FAQ.md#can-i-directly-connect-the-raspiblitz-to-my-laptop)
* [I connected my HDD, but it still says 'Connect HDD' on the display?](FAQ.md#i-connected-my-hdd-but-it-still-says-connect-hdd-on-the-display) * [I connected my HDD, but it still says 'Connect HDD' on the display?](FAQ.md#i-connected-my-hdd-but-it-still-says-connect-hdd-on-the-display)
When everything boots up correctly, you should see the local IP address of your RaspiBlitz on the LCD panel. When everything boots up correctly, you should see the local IP address of your RaspiBlitz on the LCD panel.
@ -165,17 +166,39 @@ Now open up a terminal ([OSX](https://www.youtube.com/watch?v=5XgBd6rjuDQ)/[Win1
If you run into a problem or you have still a question, follow the steps below to get support. Also check the [setup documentation](#setup-process-detailed-documentation) for details. If you run into a problem or you have still a question, follow the steps below to get support. Also check the [setup documentation](#setup-process-detailed-documentation) for details.
### Documentation
1. Look up the [FAQ](FAQ.md) if you can't find an answer to this question/problem. 1. Look up the [FAQ](FAQ.md) if you can't find an answer to this question/problem.
2. If you have a hardware problem, please check that your hardware parts are exactly the parts recommended in the shopping list above. Different screens or even SSD-casings can cause problems. 2. If you have a hardware problem, please check that your hardware parts are exactly the parts recommended in the shopping list above. Different screens or even SSD-casings can cause problems.
3. There is a Telegram Group of RaspiBlitz users helping each other: https://t.me/raspiblitz 3. Please determine if your problem/question is about RaspiBlitz or for example with LND. For example if you can't route a payment or get an error when opening a channel that is an LND question/problem and is best answered by the LND dev community: https://dev.lightning.community
4. Please determine if your problem/question is about RaspiBlitz or for example with LND. For example if you can't route a payment or get an error when opening a channel that is an LND question/problem and is best answered by the LND dev community: https://dev.lightning.community 4. Go to the GitHub issues of the RaspiBlitz: https://github.com/rootzoll/raspiblitz/issues Do a search there. Also check closed issues by removing 'is:open' from the filter/search-box.
5. Go to the GitHub issues of the RaspiBlitz: https://github.com/rootzoll/raspiblitz/issues Do a search there. Also check closed issues by removing 'is:open' from the filter/search-box. 5. If you haven't found an answer yet, open a new issue on the RaspiBlitz GitHub. You may have to register an account with GitHub for this. If it's a bug with the RaspiBlitz, please add (copy+paste) a Debug Report to your issue (see [FAQ](FAQ.md) for how to generate them) and/or add some screenshots/photos so the community gets more insight into your problem.
6. If you haven't found an answer yet, open a new issue on the RaspiBlitz GitHub. You may have to register an account with GitHub for this. If it's a bug with the RaspiBlitz, please add (copy+paste) a Debug Report to your issue (see [FAQ](FAQ.md) for how to generate them) and/or add some screenshots/photos so the community gets more insight into your problem. ### Groups
There are plenty off rooms you can find Raspiblitz users that can help you:
1. [Telegram English](https://t.me/raspiblitz)
2. [Telegram Deutsch](https://t.me/raspiblitz_DE)
3. [Telegram Spanish](https://t.me/raspiblitz_ES)
4. [Telegram Italian](https://t.me/raspiblitz_IT)
5. [Telegram Russian](https://t.me/raspiblitz_RU)
6. [Keybase](https://keybase.io/team/raspiblitz)
7. [Matrix - Element client](https://element.io/) Channel: #raspiblitz:libera.chat
8. IRC - Libera chat -> irc.libera.chat:6697 -> Channel: #raspiblitz
9. Sphinx Chat -> sphinx.chat://?action=tribe&uuid=YFsuxCApuU-TBIRWeWY_Gl52IOx2clJKZYLxDn78Z9RgcWNx9zUube7mkK4IyXQjLril-tgKZs3wOxDlWqpiyxp8jTbt&host=tribes.sphinx.chat -> [Connection code](YFsuxCApuU-TBIRWeWY_Gl52IOx2clJKZYLxDn78Z9RgcWNx9zUube7mkK4IyXQjLril-tgKZs3wOxDlWqpiyxp8jTbt) --> [QR code](https://github.com/rootzoll/raspiblitz/issues/2089#issuecomment-805789854)
## Setup Process (Detailed Documentation) ## Setup Process (Detailed Documentation)
@ -391,7 +414,7 @@ Under `LIGHTNING` you find some basic steps to manage your Lightning node. Those
Before you can open channels with other nodes you need to put some coins in your LND on-chain wallet. Use this option to generate an address to send funds to. Before you can open channels with other nodes you need to put some coins in your LND on-chain wallet. Use this option to generate an address to send funds to.
*Reminder: RaspiBlitz & LND is still experimental software. With funding your LND node you accept the risk of losing funds. So just play with small amounts - something in the area of 20 EUR/USD should be enough to make your first experiences. Also, it's a good privacy practice to [coinjoin your coins](https://bitcoin-only.com/#privacy) before sending them to any Lightning Network wallet.* *Reminder: RaspiBlitz & LND is still experimental software. With funding your LND node you accept the risk of losing funds. So just play with small amounts - something in the area of 20 EUR/USD should be enough to make your first experiences. Also, it's a good privacy practice to [coinjoin your coins](https://bitcoin-only.com/privacy) before sending them to any Lightning Network wallet.*
You can fund it multiple times - starting with small amounts first to test. LND will always generate a different address, but all funds you send will get into the same LND on-chain wallet. You can fund it multiple times - starting with small amounts first to test. LND will always generate a different address, but all funds you send will get into the same LND on-chain wallet.
@ -622,7 +645,7 @@ After install, you will see a new `LIT` option in the SSH main menu - it will gi
![BTCPAY](pictures/btcpay.png) ![BTCPAY](pictures/btcpay.png)
Find all details on how to use the BTCPay Server on your RaspiBlitz in this great tutorial: https://coincharge.io/en/raspiblitz-btcpay-server/ Find all details on how to use the BTCPay Server on your RaspiBlitz in this great tutorial: https://coincharge.io/en/btcpay-server-on-the-raspiblitz/
After install, you will see a new `BTCPAY` option in the SSH main menu - it will give you all the information you need to start using it. After install, you will see a new `BTCPAY` option in the SSH main menu - it will give you all the information you need to start using it.
@ -1111,7 +1134,7 @@ Now you are ready to start the SD card build script (check the code to see if th
As you can see from the URL, you can find the build script in this Git repo under `build_sdcard.sh`. You can check what gets installed and configured in detail. Feel free to post improvements as pull requests. As you can see from the URL, you can find the build script in this Git repo under `build_sdcard.sh`. You can check what gets installed and configured in detail. Feel free to post improvements as pull requests.
The whole build process takes a while. At the end the LCD drivers get installed and a reboot is needed. A user `admin` is created during the process. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use admin: `ssh admin@[IP-OF-YOUR-RASPI]`. The install dialog of the RaspiBlitz should automatically start. If you do not want to continue with the installation at this moment and use this sd card as a template for setting up multiple RaspiBlitzes, click `Cancel` and run `/home/admin/XXprepareRelease.sh`. Once you see the LCD going white and the activity LED of the pi starts going dark, you can unplug power and remove the SD card. You have now built your own RaspiBlitz SD card image. The whole build process takes a while. At the end the LCD drivers get installed and a reboot is needed. A user `admin` is created during the process. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use admin: `ssh admin@[IP-OF-YOUR-RASPI]`. The install dialog of the RaspiBlitz schould automatically start. If you do not want to continue with the installation at this moment and use this sd card as a template for setting up multiple RaspiBlitzes, click `Cancel` and run `release`. Once you see the LCD going white and the activity LED of the pi starts going dark, you can unplug power and remove the SD card. You have now built your own RaspiBlitz SD card image.
*Note: If you plan to use your self-build sd card as a MASTER copy and distribute it: Use a smaller 8GB card for that. This way it's ensured that it will fit on every 16 GB card recommended for RaspiBlitz later on.* *Note: If you plan to use your self-build sd card as a MASTER copy and distribute it: Use a smaller 8GB card for that. This way it's ensured that it will fit on every 16 GB card recommended for RaspiBlitz later on.*

View File

@ -49,6 +49,7 @@ Ensure that you put quotes around fingerprints containing spaces if importing wi
# Physical Security # Physical Security
* The lightning wallet and user interfaces are password protected by default so this has more privacy implications (in the case of physical theft) than security. * The lightning wallet and user interfaces are password protected by default so this has more privacy implications (in the case of physical theft) than security.
* Basic hardening measures are applied to all systemd services
* Optional log in through SSH using a hardware wallet. * Optional log in through SSH using a hardware wallet.
* LUKS encryption would be welcome in the future. * LUKS encryption would be welcome in the future.

View File

@ -5,10 +5,10 @@ echo "************* Vagrant Provisioning ********************"
echo 'Syncing local code with RaspiBlitzVM' echo 'Syncing local code with RaspiBlitzVM'
# make sure the lastest sync script is in place # make sure the lastest sync script is in place
cp /vagrant/home.admin/XXsyncScripts.sh /home/admin/XXsyncScripts.sh cp /vagrant/home.admin/config.scripts/blitz.github.sh /home/admin/config.scripts/blitz.github.sh
# execute 'patch' command to sync laptop with VM # execute 'patch' command to sync laptop with VM
/home/admin/XXsyncScripts.sh -run /home/admin/config.scripts/blitz.github.sh -run
source <(/home/admin/config.scripts/internet.sh status) source <(/home/admin/config.scripts/internet.sh status)

View File

@ -87,7 +87,7 @@ During the RaspiBlitz setup process:
`sudo tail -n100 /mnt/hdd/bitcoin/debug.log` - shows the last 100 lines `sudo tail -n100 /mnt/hdd/bitcoin/debug.log` - shows the last 100 lines
`sudo systemctl status lnd` - status of the lnd service `sudo systemctl status lnd` - status of the lnd service
`sudo journalctl -f -u lnd` `sudo journalctl -f -u lnd`
`./home/admin/XXdebugLogs.sh` - debug log collection on the RaspiBlitz `debug` - debug log collection on the RaspiBlitz
--- ---

View File

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

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# 00infoBlitz.sh <cln|lnd> <testnet|mainnet|signet>
# load code software version # load code software version
source /home/admin/_version.info source /home/admin/_version.info
@ -14,6 +16,8 @@ color_gray='\033[0;37m'
source /home/admin/raspiblitz.info 2>/dev/null source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
## get HDD/SSD info ## get HDD/SSD info
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
hdd="${hddUsedInfo}" hdd="${hddUsedInfo}"
@ -45,7 +49,7 @@ if [ ${#network} -eq 0 ]; then
if [ ${litecoinActive} -eq 1 ]; then if [ ${litecoinActive} -eq 1 ]; then
network="litecoin" network="litecoin"
else else
network=`sudo cat /home/admin/.network 2>/dev/null` network=$(sudo cat /home/admin/.network 2>/dev/null)
fi fi
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
network="bitcoin" network="bitcoin"
@ -62,7 +66,6 @@ if [ ${#chain} -eq 0 ]; then
fi fi
# set datadir # set datadir
bitcoin_dir="/home/bitcoin/.${network}"
lnd_dir="/home/bitcoin/.lnd" lnd_dir="/home/bitcoin/.lnd"
lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net" lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net"
@ -74,9 +77,13 @@ cpu=0
if [ -d "/sys/class/thermal/thermal_zone0/" ]; then if [ -d "/sys/class/thermal/thermal_zone0/" ]; then
cpu=$(cat /sys/class/thermal/thermal_zone0/temp) cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
fi fi
tempC=$((cpu/1000)) if [ $cpu = 0 ];then
tempF=$(((tempC * 18 + 325) / 10)) tempC=""
tempF=""
else
tempC=$((cpu/1000))
tempF=$(((tempC * 18 + 325) / 10))
fi
# get memory # get memory
ram_avail=$(free -m | grep Mem | awk '{ print $7 }') ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')") ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")
@ -90,17 +97,17 @@ fi
# Bitcoin blockchain # Bitcoin blockchain
btc_path=$(command -v ${network}-cli) btc_path=$(command -v ${network}-cli)
blockInfo="-" blockInfo="-"
if [ -n ${btc_path} ]; then if [ -n "${btc_path}" ]; then
btc_title=$network btc_title=$network
blockchaininfo="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo 2>/dev/null)" blockchaininfo="$($bitcoincli_alias getblockchaininfo 2>/dev/null)"
if [ ${#blockchaininfo} -gt 0 ]; then if [ ${#blockchaininfo} -gt 0 ]; then
btc_title="${btc_title} (${chain}net)" btc_title="${btc_title} (${chain}net)"
# get sync status # get sync status
block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)" last_block="$($bitcoincli_alias getblockcount 2>/dev/null)"
block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')" block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')"
block_diff=$(expr ${block_chain} - ${block_verified}) block_diff=$(expr ${last_block} - ${block_verified})
blockInfo="${block_verified}/${block_chain}" blockInfo="${block_verified}/${last_block}"
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}') sync_percentage=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}')
@ -124,13 +131,12 @@ if [ -n ${btc_path} ]; then
fi fi
# get last known block # get last known block
last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)"
if [ ! -z "${last_block}" ]; then if [ ! -z "${last_block}" ]; then
btc_line2="${btc_line2} ${color_gray}(block ${last_block})" btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
fi fi
# get mem pool transactions # get mem pool transactions
mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo 2>/dev/null | jq -r '.size')" mempool="$($bitcoincli_alias getmempoolinfo 2>/dev/null | jq -r '.size')"
else else
btc_line2="${color_red}NOT RUNNING\t\t" btc_line2="${color_red}NOT RUNNING\t\t"
@ -138,7 +144,7 @@ if [ -n ${btc_path} ]; then
fi fi
# get IP address & port # get IP address & port
networkInfo=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo 2>/dev/null) networkInfo=$($bitcoincli_alias getnetworkinfo 2>/dev/null)
local_ip="${localip}" # from internet.sh local_ip="${localip}" # from internet.sh
public_ip="${cleanip}" public_ip="${cleanip}"
public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')" public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')"
@ -152,9 +158,14 @@ fi
# check if RTL web interface is installed # check if RTL web interface is installed
webinterfaceInfo="" webinterfaceInfo=""
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') runningRTL=$(systemctl status ${netprefix}${typeprefix}RTL.service 2>/dev/null | grep -c active)
if [ ${runningRTL} -eq 1 ]; then if [ ${runningRTL} -eq 1 ]; then
webinterfaceInfo="Web admin --> ${color_green}http://${local_ip}:3000" if [ "${lightning}" == "cln" ]; then
RTLHTTP=${portprefix}7000
elif [ "${lightning}" == "lnd" ];then
RTLHTTP=${portprefix}3000
fi
webinterfaceInfo="Web admin --> ${color_green}http://${local_ip}:${RTLHTTP}"
fi fi
# CHAIN NETWORK # CHAIN NETWORK
@ -162,9 +173,8 @@ public_addr_pre="Public "
public_addr="??" public_addr="??"
torInfo="" torInfo=""
# Version # Version
networkVersion=$(${network}-cli -datadir=${bitcoin_dir} -version 2>/dev/null | cut -d ' ' -f6) networkVersion=$($bitcoincli_alias -version 2>/dev/null | cut -d ' ' -f6)
# TOR or IP # TOR or IP
networkInfo=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo)
networkConnections=$(echo ${networkInfo} | jq -r '.connections') networkConnections=$(echo ${networkInfo} | jq -r '.connections')
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections" networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections"
@ -222,69 +232,183 @@ else
fi fi
# LIGHTNING NETWORK # LIGHTNING NETWORK
if [ "${lightning}" == "cln" ]; then
ln_baseInfo="-" ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
ln_channelInfo="\n" ln_baseInfo="-"
ln_external="\n" ln_channelInfo="\n"
ln_alias="${hostname}" ln_external="\n"
ln_publicColor="" ln_alias="$(sudo cat /home/bitcoin/.lightning/${netprefix}config | grep "^alias=*" | cut -f2 -d=)"
ln_port=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':') if [ ${#ln_alias} -eq 0 ];then
if [ ${#ln_port} -eq 0 ]; then ln_alias=$(echo "${ln_getInfo}" | grep '"alias":' | cut -d '"' -f4)
ln_port="9735"
fi
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock)
if [ "$wallet_unlocked" -gt 0 ] ; then
alias_color="${color_red}"
ln_alias="Wallet Locked"
else
ln_getInfo=$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
if [ ${ln_tor} -eq 1 ]; then
ln_publicColor="${color_green}"
else
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
ln_publicColor="${color_amber}"
else
ln_publicColor="${color_red}"
fi
fi fi
alias_color="${color_grey}" if [ ${#ln_alias} -eq 0 ];then
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c) ln_alias=${hostname}
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1) fi
if [ ${ln_sync} -eq 0 ]; then ln_publicColor=""
if [ ${#ln_getInfo} -eq 0 ]; then ln_port=$(sudo cat /home/bitcoin/.lightning/${netprefix}config | grep "^bind-addr=*" | cut -f2 -d':')
ln_baseInfo="${color_red} Not Started | Not Ready Yet" if [ ${#ln_port} -eq 0 ]; then
else ln_port=$(echo "${ln_getInfo}" | grep '"port":' | cut -d: -f2 | tail -1 | bc)
ln_baseInfo="${color_amber} Waiting for Chain Sync" fi
fi wallet_unlocked=0 #TODO
if [ "$wallet_unlocked" -gt 0 ] ; then
ln_alias="Wallet Locked"
else
pubkey=$(echo "${ln_getInfo}" | grep '"id":' | cut -d '"' -f4)
address=$(echo "${ln_getInfo}" | grep '.onion' | cut -d '"' -f4)
if [ ${#address} -eq 0 ];then
address=$(echo "${ln_getInfo}" | grep '"ipv4"' -A 1 | tail -1 | cut -d '"' -f4)
fi
ln_external="${pubkey}@${address}"
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
if [ ${ln_tor} -eq 1 ]; then
ln_publicColor="${color_green}"
else else
ln_walletbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
ln_walletbalance_wait="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.unconfirmed_balance')" 2>/dev/null if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi # only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi ln_publicColor="${color_amber}"
ln_channelbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null else
ln_channelbalance_pending="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.pending_open_balance')" 2>/dev/null ln_publicColor="${color_red}"
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi fi
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} sat ${ln_walletbalance_wait}"
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat${ln_channelbalance_pending}"
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
ln_dailyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.day_fee_sum')" 2>/dev/null
ln_weeklyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.week_fee_sum')" 2>/dev/null
ln_monthlyfees="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport | jq -r '.month_fee_sum')" 2>/dev/null
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
fi fi
BLOCKHEIGHT=$(echo "$blockchaininfo"|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$(echo "${ln_getInfo}" | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
ln_sync=1
else
ln_sync=0
fi
ln_version=$($lightningcli_alias -V)
if [ ${ln_sync} -eq 0 ]; then
if [ ${#ln_getInfo} -eq 0 ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
else
ln_baseInfo="
${color_amber}Scanning blocks: ${CLHEIGHT}/${BLOCKHEIGHT}"
fi
else
ln_walletbalance=0
cln_listfunds=$($lightningcli_alias listfunds 2>/dev/null)
for i in $(echo "$cln_listfunds" \
|jq .outputs[]|jq 'select(.status=="confirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
ln_walletbalance=$((ln_walletbalance+i))
done
for i in $(echo "$cln_listfunds" \
|jq .outputs[]|jq 'select(.status=="unconfirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
done
# ln_closedchannelbalance: "state": "ONCHAIN" funds in channels
for i in $(echo "$cln_listfunds" \
|jq .channels[]|jq 'select(.state=="ONCHAIN")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_closedchannelbalance=$((ln_closedchannelbalance+i))
done
# ln_pendingonchain: waiting onchain + waiting closed channel funds
ln_pendingonchain=$((ln_walletbalance_wait+ln_closedchannelbalance))
if [ "${ln_pendingonchain}" = "0" ]; then ln_pendingonchain=""; fi
if [ ${#ln_pendingonchain} -gt 0 ]; then ln_pendingonchain="(+${ln_pendingonchain})"; fi
# ln_channelbalance: "state": "CHANNELD_NORMAL" funds in channels
for i in $(echo "$cln_listfunds" \
|jq .channels[]|jq 'select(.state=="CHANNELD_NORMAL")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance=$((ln_channelbalance+i))
done
if [ ${#ln_channelbalance} -eq 0 ];then
ln_channelbalance=0
fi
# ln_channelbalance_all: all funds in channels
for i in $(echo "$cln_listfunds" \
|jq .channels[]|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance_all=$((ln_channelbalance_all+i))
done
ln_channelbalance_pending=$((ln_channelbalance_all-ln_channelbalance-ln_closedchannelbalance))
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
# - **num_peers** (u32): The total count of peers, connected or with channels
# - **num_pending_channels** (u32): The total count of channels being opened
# - **num_active_channels** (u32): The total count of channels in normal state
# - **num_inactive_channels** (u32): The total count of channels waiting for opening or closing
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
cln_num_pending_channels="$(echo "${ln_getInfo}" | jq -r '.num_pending_channels')" 2>/dev/null
cln_num_inactive_channels="$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')" 2>/dev/null
ln_channels_total=$((ln_channels_online+cln_num_pending_channels+cln_num_inactive_channels))
ln_baseInfo="${color_gray}Wallet ${ln_walletbalance} ${netprefix}sat ${ln_pendingonchain}"
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}"
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
# - **fees_collected_msat** (msat): Total routing fees collected by this node
#ln_dailyfees="$($lncli_alias feereport | jq -r '.day_fee_sum')" 2>/dev/null
#ln_weeklyfees="$($lncli_alias feereport | jq -r '.week_fee_sum')" 2>/dev/null
#ln_monthlyfees="$($lncli_alias feereport | jq -r '.month_fee_sum')" 2>/dev/null
#ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
ln_feeReport="Fees collected: $(echo "${ln_getInfo}" | jq -r '.fees_collected_msat')"
fi
fi
elif [ "${lightning}" == "lnd" ];then
ln_baseInfo="-"
ln_channelInfo="\n"
ln_external="\n"
ln_alias="$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^alias=*" | cut -f2 -d=)"
if [ ${#ln_alias} -eq 0 ];then
ln_alias=${hostname}
fi
ln_publicColor=""
ln_port=$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^listen=*" | cut -f2 -d':')
if [ ${#ln_port} -eq 0 ]; then
ln_port="9735"
fi
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock)
if [ "$wallet_unlocked" -gt 0 ] ; then
ln_alias="Wallet Locked"
else
ln_getInfo=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
if [ ${ln_tor} -eq 1 ]; then
ln_publicColor="${color_green}"
else
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
ln_publicColor="${color_amber}"
else
ln_publicColor="${color_red}"
fi
fi
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1)
if [ ${ln_sync} -eq 0 ]; then
if [ ${#ln_getInfo} -eq 0 ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
else
ln_baseInfo="${color_amber} Waiting for Chain Sync"
fi
else
lnd_walletbalance=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance 2>/dev/null)
ln_walletbalance="$(echo "$lnd_walletbalance" | jq -r '.confirmed_balance')" 2>/dev/null
ln_walletbalance_wait="$(echo "$lnd_walletbalance" | jq -r '.unconfirmed_balance')" 2>/dev/null
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi
lnd_channelbalance=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance 2>/dev/null)
ln_channelbalance="$(echo "$lnd_channelbalance" | jq -r '.balance')" 2>/dev/null
ln_channelbalance_pending="$(echo "$lnd_channelbalance" | jq -r '.pending_open_balance')" 2>/dev/null
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} ${netprefix}sat ${ln_walletbalance_wait}"
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}"
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
lnd_feereport=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport 2>/dev/null)
ln_dailyfees="$(echo "$lnd_feereport" | jq -r '.day_fee_sum')" 2>/dev/null
ln_weeklyfees="$(echo "$lnd_feereport" | jq -r '.week_fee_sum')" 2>/dev/null
ln_monthlyfees="$(echo "$lnd_feereport" | jq -r '.month_fee_sum')" 2>/dev/null
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
fi
fi
fi fi
# show JoinMarket stats in place of the LND URI only if the Yield Generator is running # show JoinMarket stats in place of the LND URI only if the Yield Generator is running
source /home/joinmarket/joinin.conf 2>/dev/null source /home/joinmarket/joinin.conf 2>/dev/null
if [ "${joinmarket}" = "on" ] && [ $(sudo -u joinmarket pgrep -f "python yg-privacyenhanced.py $YGwallet --wallet-password-stdin" 2>/dev/null | wc -l) -gt 2 ]; then if [ "${joinmarket}" = "on" ] && [ $(sudo -u joinmarket pgrep -f "python yg-privacyenhanced.py $YGwallet --wallet-password-stdin" 2>/dev/null | wc -l) -gt 2 ]; then
JMstats=$(mktemp 2>/dev/null) JMstats=$(mktemp 2>/dev/null)
@ -305,6 +429,17 @@ ${color_yellow}
${color_yellow}${ln_publicColor}${ln_external}${color_gray}" ${color_yellow}${ln_publicColor}${ln_external}${color_gray}"
fi fi
if [ "${lightning}" == "cln" ];then
LNline="C-LIGHTNING ${color_green}${ln_version}\n ${ln_baseInfo}"
elif [ "${lightning}" == "lnd" ];then
LNline="LND ${color_green}${ln_version} ${ln_baseInfo}"
fi
if [ $cpu = 0 ];then
templine="on $(uname -m) VM%s%s"
else
templine="temp %s°C %s°F"
fi
sleep 5 sleep 5
## get uptime and current date & time ## get uptime and current date & time
@ -320,14 +455,14 @@ ${color_yellow} ${color_amber}%s ${color_green} ${ln_alias} ${upsI
${color_yellow} ${color_gray}${network^} Fullnode + Lightning Network ${torInfo} ${color_yellow} ${color_gray}${network^} Fullnode + Lightning Network ${torInfo}
${color_yellow} ,/ ${color_yellow}%s ${color_yellow} ,/ ${color_yellow}%s
${color_yellow} ,'/ ${color_gray}%s ${color_yellow} ,'/ ${color_gray}%s
${color_yellow} ,' / ${color_gray}%s, temp %s°C %s°F ${color_yellow} ,' / ${color_gray}%s, ${templine}
${color_yellow} ,' /_____, ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray} ${color_yellow} ,' /_____, ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray}
${color_yellow} .'____ ,' ${color_gray}SSH admin@${color_green}${local_ip}${color_gray} d${network_rx} u${network_tx} ${color_yellow} .'____ ,' ${color_gray}SSH admin@${color_green}${local_ip}${color_gray} d${network_rx} u${network_tx}
${color_yellow} / ,' ${color_gray}${webinterfaceInfo} ${color_yellow} / ,' ${color_gray}${webinterfaceInfo}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${color_gray}${chain}net ${networkConnectionsInfo} ${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${color_gray}${chain}net ${networkConnectionsInfo}
${color_yellow} /,' ${color_gray}Blocks ${blockInfo} ${color_gray}Sync ${sync_color}${sync} %s ${color_yellow} /,' ${color_gray}Blocks ${blockInfo} ${color_gray}Sync ${sync_color}${sync} %s
${color_yellow} /' ${color_gray} ${color_yellow} /' ${color_gray}
${color_yellow} ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo} ${color_yellow} ${color_gray}${LNline}
${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo} ${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo}
${color_yellow} ${color_gray}${ln_feeReport} ${color_yellow} ${color_gray}${ln_feeReport}
$lastLine $lastLine
@ -373,57 +508,4 @@ else
fi fi
# if running as user "pi": # EOF
# - write results to a JSON file on RAM disk
# - update info.html file
if [ "${EUID}" = "$(id -u pi)" ]; then
json_ln_baseInfo=$(echo "${ln_baseInfo}" | cut -c 11-)
cat <<EOF > /var/cache/raspiblitz/info.json
{
"uptime": "${uptime}",
"datetime": "${datetime}",
"codeVersion": "${codeVersion}",
"hostname": "${hostname}",
"network": "${network}",
"torInfo": "${torInfo}",
"load": "${load}",
"tempC": "${tempC}",
"tempF": "${tempF}",
"ram": "${ram}",
"hddUsedInfo": "${hddUsedInfo}",
"local_ip": "${local_ip}",
"network_rx": "${network_rx}",
"network_tx": "${network_tx}",
"runningRTL": "${runningRTL}",
"networkVersion": "${networkVersion}",
"chain": "${chain}",
"progress": "${progress}",
"sync_percentage": "${sync_percentage}",
"public_addr_pre": "${public_addr_pre}",
"public_addr": "${public_addr}",
"public": "${public}",
"networkConnections": "${networkConnections}",
"mempool": "${mempool}",
"ln_sync": "${ln_sync}",
"ln_version": "${ln_version}",
"ln_baseInfo": "${json_ln_baseInfo}",
"ln_peers": "${ln_peers}",
"ln_channelInfo": "${ln_channelInfo}",
"ln_external": "${ln_external}"
}
EOF
# use Jinja2 and apply json data to template to produce static html file
templateExists=$(sudo ls /var/cache/raspiblitz/info.json 2>/dev/null | grep -c 'info.json')
if [ ${templateExists} -gt 0 ]; then
res=$(/usr/local/bin/j2 /var/www/blitzweb/info/info.j2 /var/cache/raspiblitz/info.json -o /var/cache/raspiblitz/info.html)
if ! [ $? -eq 0 ]; then
echo "an error occured.. maybe JSON syntax is wrong..!"
echo "${res}"
fi
fi
fi
# EOF

View File

@ -20,6 +20,8 @@ function usage() {
verbose=0 verbose=0
pause=12 pause=12
# this is used by touchscreen and command 'satus'
# TODO: remove on v1.8
while [[ "$1" == -* ]]; do while [[ "$1" == -* ]]; do
case "$1" in case "$1" in
-h|--help) -h|--help)
@ -82,239 +84,29 @@ while :
# CHECK BASIC DATA # 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) # get config info if already available (with state value)
source ${infoFile} source ${infoFile}
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
source ${configFile} source ${configFile}
source <(/home/admin/config.scripts/network.aliases.sh getvars)
fi fi
# reboot info if [ "${setupPhase}" != "done" ] || [ "${state}" == "copytarget" ] || [ "${state}" == "copysource" ] || [ "${state}" == "copystation" ]; then
if [ "${state}" = "reboot" ]; then
dialog --backtitle "RaspiBlitz ${codeVersion}" --infobox "Waiting for Reboot ..." 3 30
sleep 20
continue
fi
# shutdown info # show status info during boot & setup & repair on LCD
if [ "${state}" = "shutdown" ]; then /home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}" lcd
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
sleep 1 sleep 1
continue continue
fi fi
# if no information available from files - set default # TODO: ALSO SEPERATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
if [ ${#setupStep} -eq 0 ]; then # if lightning is syncing or scanning
setupStep=0 source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
fi if [ "${syncedToChain}" != "1" ]; then
/home/admin/setup.scripts/eventBlockchainSync.sh lcd
# before setup even started sleep 10
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
# if LND is syncing or scanning
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSynced} -eq 0 ]; then
/home/admin/80scanLND.sh
sleep 20
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 continue
fi fi

View File

@ -40,10 +40,16 @@ confirmation()
# get the local network IP to be displayed on the LCD # get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local) source <(/home/admin/config.scripts/internet.sh status local)
if [ ${chain} = test ];then
netprefix="t"
elif [ ${chain} = sig ];then
netprefix="s"
elif [ ${chain} = main ];then
netprefix=""
fi
# BASIC MENU INFO # BASIC MENU INFO
HEIGHT=19
WIDTH=64 WIDTH=64
CHOICE_HEIGHT=12
BACKTITLE="RaspiBlitz" BACKTITLE="RaspiBlitz"
TITLE="" TITLE=""
MENU="Choose one of the following options:" MENU="Choose one of the following options:"
@ -62,110 +68,98 @@ if [ "${rtlWebinterface}" == "on" ]; then
fi fi
# Put Activated Apps on top # Put Activated Apps on top
if [ "${rtlWebinterface}" == "on" ]; then if [ "${rtlWebinterface}" == "on" ] || [ "${crtlWebinterface}" == "on" ]; then
OPTIONS+=(RTL "RTL Web Node Manager") OPTIONS+=(RTL "RTL Web Node Manager")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${BTCPayServer}" == "on" ]; then if [ "${BTCPayServer}" == "on" ]; then
OPTIONS+=(BTCPAY "BTCPay Server Info") OPTIONS+=(BTCPAY "BTCPay Server Info")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${lit}" == "on" ]; then if [ "${lit}" == "on" ]; then
OPTIONS+=(LIT "LIT (loop, pool, faraday)") OPTIONS+=(LIT "LIT (loop, pool, faraday)")
HEIGHT=$((HEIGHT+1)) fi
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) if [ "${sparko}" == "on" ]; then
OPTIONS+=(SPARKO "Sparko Webwallet")
fi fi
if [ "${ElectRS}" == "on" ]; then if [ "${ElectRS}" == "on" ]; then
OPTIONS+=(ELECTRS "Electrum Rust Server") OPTIONS+=(ELECTRS "Electrum Rust Server")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${BTCRPCexplorer}" == "on" ]; then if [ "${BTCRPCexplorer}" == "on" ]; then
OPTIONS+=(EXPLORE "BTC RPC Explorer") OPTIONS+=(EXPLORE "BTC RPC Explorer")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${LNBits}" == "on" ]; then if [ "${LNBits}" == "on" ]; then
OPTIONS+=(LNBITS "LNbits Server") OPTIONS+=(LNBITS "LNbits Server")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${lndmanage}" == "on" ]; then if [ "${lndmanage}" == "on" ]; then
OPTIONS+=(LNDMANAGE "LND Manage Script") OPTIONS+=(LNDMANAGE "LND Manage Script")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${loop}" == "on" ]; then if [ "${loop}" == "on" ]; then
OPTIONS+=(LOOP "Loop In/Out Service") OPTIONS+=(LOOP "Loop In/Out Service")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${mempoolExplorer}" == "on" ]; then if [ "${mempoolExplorer}" == "on" ]; then
OPTIONS+=(MEMPOOL "Mempool Space") OPTIONS+=(MEMPOOL "Mempool Space")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${specter}" == "on" ]; then if [ "${specter}" == "on" ]; then
OPTIONS+=(SPECTER "Cryptoadvance Specter") OPTIONS+=(SPECTER "Cryptoadvance Specter")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${joinmarket}" == "on" ]; then if [ "${joinmarket}" == "on" ]; then
OPTIONS+=(JMARKET "JoinMarket") OPTIONS+=(JMARKET "JoinMarket")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${faraday}" == "on" ]; then if [ "${faraday}" == "on" ]; then
OPTIONS+=(FARADAY "Faraday Channel Management") OPTIONS+=(FARADAY "Faraday Channel Management")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${bos}" == "on" ]; then if [ "${bos}" == "on" ]; then
OPTIONS+=(BOS "Balance of Satoshis") OPTIONS+=(BOS "Balance of Satoshis")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${pyblock}" == "on" ]; then if [ "${pyblock}" == "on" ]; then
OPTIONS+=(PYBLOCK "PyBlock") OPTIONS+=(PYBLOCK "PyBlock")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${thunderhub}" == "on" ]; then if [ "${thunderhub}" == "on" ]; then
OPTIONS+=(THUB "ThunderHub") OPTIONS+=(THUB "ThunderHub")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${zerotier}" == "on" ]; then if [ "${zerotier}" == "on" ]; then
OPTIONS+=(ZEROTIER "ZeroTier") OPTIONS+=(ZEROTIER "ZeroTier")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${pool}" == "on" ]; then if [ "${pool}" == "on" ]; then
OPTIONS+=(POOL "Lightning Pool") OPTIONS+=(POOL "Lightning Pool")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${sphinxrelay}" == "on" ]; then if [ "${sphinxrelay}" == "on" ]; then
OPTIONS+=(SPHINX "Sphinx Chat Relay") OPTIONS+=(SPHINX "Sphinx Chat Relay")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${chantools}" == "on" ]; then if [ "${chantools}" == "on" ]; then
OPTIONS+=(CHANTOOLS "ChannelTools (Fund Rescue)") OPTIONS+=(CHANTOOLS "ChannelTools (Fund Rescue)")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${circuitbreaker}" == "on" ]; then if [ "${circuitbreaker}" == "on" ]; then
OPTIONS+=(CIRCUIT "Circuitbreaker (LND firewall)") OPTIONS+=(CIRCUIT "Circuitbreaker (LND firewall)")
HEIGHT=$((HEIGHT+1)) fi
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
if [ "${testnet}" == "on" ]&&[ ${chain} != test ]; then
OPTIONS+=(TESTNET "Testnet Service Options")
fi
if [ ${chain} != main ]; then
OPTIONS+=(MAINNET "Mainnet Service Options")
fi fi
# Basic Options # Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen") OPTIONS+=(INFO "RaspiBlitz Status Screen")
OPTIONS+=(LIGHTNING "LND Wallet Options")
# if LND is main lightning
if [ "${lightning}" == "lnd" ]; then
OPTIONS+=(LND "LND Wallet Options")
fi
# if C-Lighthing is main lightning
if [ "${lightning}" == "cln" ]; then
# if CLN is main lightning
OPTIONS+=(CLN "C-lightning Wallet Options")
fi
# TODO: when more then one Lightning is active
#if [ "$cln" == "on" ] || [ $chain = test ] && [ "$tcln" == "on" ]; then
# OPTIONS+=(CLN "C-lightning Wallet Options")
# HEIGHT=$((HEIGHT+1))
# CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
#fi
OPTIONS+=(SETTINGS "Node Settings & Options") OPTIONS+=(SETTINGS "Node Settings & Options")
OPTIONS+=(SERVICES "Additional Apps & Services") OPTIONS+=(SERVICES "Additional Apps & Services")
OPTIONS+=(SYSTEM "Monitoring & Configuration") OPTIONS+=(SYSTEM "Monitoring & Configuration")
@ -175,8 +169,6 @@ OPTIONS+=(PASSWORD "Change Passwords")
if [ "${touchscreen}" == "1" ]; then if [ "${touchscreen}" == "1" ]; then
OPTIONS+=(SCREEN "Touchscreen Calibration") OPTIONS+=(SCREEN "Touchscreen Calibration")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
# final Options # final Options
@ -185,6 +177,9 @@ OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update")
OPTIONS+=(REBOOT "Reboot RaspiBlitz") OPTIONS+=(REBOOT "Reboot RaspiBlitz")
OPTIONS+=(OFF "PowerOff RaspiBlitz") OPTIONS+=(OFF "PowerOff RaspiBlitz")
CHOICE_HEIGHT=$(("${#OPTIONS[@]}"))
HEIGHT=$((CHOICE_HEIGHT+6))
CHOICE=$(dialog --clear \ CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--title "$TITLE" \ --title "$TITLE" \
@ -226,21 +221,24 @@ case $CHOICE in
exit 0 exit 0
fi fi
;; ;;
LIGHTNING) LND)
/home/admin/99lightningMenu.sh /home/admin/99lndMenu.sh
;;
CLN)
/home/admin/99clnMenu.sh ${chain}net
;; ;;
CONNECT) CONNECT)
/home/admin/99connectMenu.sh /home/admin/99connectMenu.sh
;; ;;
SYSTEM) SYSTEM)
/home/admin/99systemMenu.sh /home/admin/99systemMenu.sh ${chain}net
;; ;;
SCREEN) SCREEN)
dialog --title 'Touchscreen Calibration' --msgbox 'Choose OK and then follow the instructions on touchscreen for calibration.\n\nBest is to use a stylus for accurate touchscreen interaction.' 9 48 dialog --title 'Touchscreen Calibration' --msgbox 'Choose OK and then follow the instructions on touchscreen for calibration.\n\nBest is to use a stylus for accurate touchscreen interaction.' 9 48
/home/admin/config.scripts/blitz.touchscreen.sh calibrate /home/admin/config.scripts/blitz.touchscreen.sh calibrate
;; ;;
RTL) RTL)
/home/admin/config.scripts/bonus.rtl.sh menu /home/admin/config.scripts/bonus.rtl.sh menu ${lightning}
;; ;;
BTCPAY) BTCPAY)
/home/admin/config.scripts/bonus.btcpayserver.sh menu /home/admin/config.scripts/bonus.btcpayserver.sh menu
@ -254,6 +252,9 @@ case $CHOICE in
LIT) LIT)
/home/admin/config.scripts/bonus.lit.sh menu /home/admin/config.scripts/bonus.lit.sh menu
;; ;;
SPARKO)
/home/admin/config.scripts/cln-plugin.sparko.sh menu mainnet
;;
LNBITS) LNBITS)
/home/admin/config.scripts/bonus.lnbits.sh menu /home/admin/config.scripts/bonus.lnbits.sh menu
;; ;;
@ -298,6 +299,12 @@ case $CHOICE in
;; ;;
CIRCUIT) CIRCUIT)
sudo /home/admin/config.scripts/bonus.circuitbreaker.sh menu sudo /home/admin/config.scripts/bonus.circuitbreaker.sh menu
;;
TESTNET)
/home/admin/00parallelChainsMenu.sh testnet
;;
MAINNET)
/home/admin/00parallelChainsMenu.sh mainnet
;; ;;
SUBSCRIBE) SUBSCRIBE)
/home/admin/config.scripts/blitz.subscriptions.py /home/admin/config.scripts/blitz.subscriptions.py
@ -310,9 +317,6 @@ case $CHOICE in
;; ;;
REPAIR) REPAIR)
/home/admin/98repairMenu.sh /home/admin/98repairMenu.sh
if [ $? -eq 99 ]; then
exit 1
fi
;; ;;
PASSWORD) PASSWORD)
sudo /home/admin/config.scripts/blitz.setpassword.sh sudo /home/admin/config.scripts/blitz.setpassword.sh
@ -321,44 +325,41 @@ case $CHOICE in
/home/admin/99updateMenu.sh /home/admin/99updateMenu.sh
;; ;;
REBOOT) REBOOT)
clear clear
confirmation "Are you sure?" "Reboot" "Cancel" true 7 40 confirmation "Are you sure?" "Reboot" "Cancel" true 7 40
confirmationReboot=$? confirmationReboot=$?
if [ $confirmationReboot -eq 0 ]; then if [ $confirmationReboot -eq 0 ]; then
clear clear
echo "" echo ""
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0 exit 1
fi fi
;; ;;
OFF) OFF)
clear clear
confirmation "Are you sure?" "PowerOff" "Cancel" true 7 40 confirmation "Are you sure?" "PowerOff" "Cancel" true 7 40
confirmationShutdown=$? confirmationShutdown=$?
if [ $confirmationShutdown -eq 0 ]; then if [ $confirmationShutdown -eq 0 ]; then
clear clear
echo "" echo ""
sudo /home/admin/XXshutdown.sh sudo /home/admin/config.scripts/blitz.shutdown.sh
exit 0 exit 1
fi fi
;; ;;
DELETE) DELETE)
sudo /home/admin/XXcleanHDD.sh sudo /home/admin/XXcleanHDD.sh
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0 exit 1
;; ;;
*) *)
clear clear
echo "***********************************" exit 1
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
esac esac
# go into loop - start script from beginning to load config/sate fresh # forward exit code of submenu to outside loop
/home/admin/00mainMenu.sh # 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}

View File

@ -0,0 +1,197 @@
#!/bin/bash
# Usage:
# 00parallelChainsMenu.sh <testnet|signet|mainnet> <lnd|cln>
source /home/admin/raspiblitz.info
# add default value to raspi config if needed
if ! grep -Eq "^testnet=" /mnt/hdd/raspiblitz.conf; then
echo "testnet=off" >> /mnt/hdd/raspiblitz.conf
fi
if ! grep -Eq "^LNdefault=" /mnt/hdd/raspiblitz.conf; then
echo "LNdefault=lnd" >> /mnt/hdd/raspiblitz.conf
fi
source /mnt/hdd/raspiblitz.conf
# CHAIN is signet | testnet | mainnet
if [ $# -gt 0 ]; then
CHAIN=$1
if [ $1 != ${chain}net ];then
nonDefaultChain=1
fi
else
nonDefaultChain=0
CHAIN=${chain}net
fi
# LNTYPE is lnd | cln
if [ $# -gt 1 ]&&[ $2 != $LNdefault ];then
nonDefaultLNtype=1
LNTYPE=$2
else
nonDefaultLNtype=0
LNTYPE=$LNdefault
fi
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO
HEIGHT=10
WIDTH=64
CHOICE_HEIGHT=3
BACKTITLE="${CHAIN} options"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
plus=""
if [ "${runBehindTor}" = "on" ]; then
plus=" / TOR"
fi
if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
fi
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
# Put Activated Apps on top
if [ $chain = test ]&&[ "$trtlWebinterface" = "on" ]||\
[ $chain = sig ]&& [ "$srtlWebinterface" = "on" ]||\
[ $chain = main ]&&[ "$rtlWebinterface" = "on" ]; then
OPTIONS+=(RTL "RTL Web Node Manager for LND ${CHAIN}")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ $chain = test ]&&[ "$tlnd" = "on" ]||\
[ $chain = sig ]&& [ "$slnd" = "on" ]||\
[ $chain = main ]&&[ "$lnd" = "on" ]; then
OPTIONS+=(LND "LND options for ${CHAIN}")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ "$chain" = "test" ]&&[ "$tcrtlWebinterface" = "on" ]||\
[ "$chain" = "sig" ]&& [ "$scrtlWebinterface" = "on" ]||\
[ "$chain" = "main" ]&&[ "$crtlWebinterface" = "on" ]; then
OPTIONS+=(cRTL "RTL Web Node Manager for C-lightning ${CHAIN}")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ "$chain" = "test" ]&&[ "$tcln" = "on" ]||\
[ "$chain" = "sig" ]&& [ "$scln" = "on" ]||\
[ "$chain" = "main" ]&&[ "$cln" = "on" ]; then
OPTIONS+=(CLN "C-lightning options for ${CHAIN}")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
OPTIONS+=(INFO "RaspiBlitz Status Screen for ${CHAIN}")
if [ "$testnet" == "on" ]; then
OPTIONS+=(SERVICES "Additional Apps & Services on ${CHAIN}")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
OPTIONS+=(SYSTEM "Monitoring & Configuration")
#TODO OPTIONS+=(CONNECT "Connect Apps & Show Credentials")
if [ $nonDefaultLNtype = 1 ];then
OPTIONS+=(SWITCHLN "Make ${LNTYPE} the default lightning wallet")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
if [ $nonDefaultChain = 1 ];then
OPTIONS+=(MKDEFAULT "Make ${CHAIN} the default chain")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "Back" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
INFO)
# #TODO
# echo "Gathering Information (please wait) ..."
# walletLocked=$(lncli getinfo 2>&1 | grep -c "Wallet is encrypted")
# if [ ${walletLocked} -eq 0 ]; then
# while :
# do
# # show the same info as on LCD screen
# /home/admin/00infoBlitz.sh
# # wait 6 seconds for user exiting loop
# echo ""
# echo -en "Screen is updating in a loop .... press 'x' now to get back to menu."
# read -n 1 -t 6 keyPressed
# echo -en "\rGathering information to update info ... please wait. \n"
# # check if user wants to abort session
# if [ "${keyPressed}" = "x" ]; then
# echo ""
# echo "Returning to menu ....."
# sleep 4
# break
# fi
# done
# else
# /home/admin/00raspiblitz.sh
# exit 0
# fi
/home/admin/00infoBlitz.sh $CHAIN
;;
RTL)
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
;;
cRTL)
/home/admin/config.scripts/bonus.rtl.sh menu cln $CHAIN
;;
LND)
/home/admin/99lndMenu.sh $CHAIN
;;
CLN)
/home/admin/99clnMenu.sh $CHAIN
;;
SERVICES)
if [ $CHAIN = testnet ];then
/home/admin/00parallelTestnetServices.sh
elif [ $CHAIN = mainnet ];then
/home/admin/00parallelMainnetServices.sh $CHAIN
fi
;;
SYSTEM)
/home/admin/99systemMenu.sh $CHAIN
;;
CONNECT)
/home/admin/99connectMenu.sh $CHAIN
;;
SWITCHLN)
# setting value in raspi blitz config
sudo sed -i "s/^LNdefault=.*/LNdefault=$LNTYPE/g" /mnt/hdd/raspiblitz.conf
echo "# OK - Set LNdefault=$LNTYPE in /mnt/hdd/raspiblitz.conf"
echo
echo "Press ENTER to return to main menu."
;;
MKDEFAULT)
# setting value in raspi blitz config
newchain=${CHAIN::-3}
sudo sed -i "s/^chain=.*/chain=${newchain}/g" /mnt/hdd/raspiblitz.conf
echo "# OK - Set chain=${newchain} in /mnt/hdd/raspiblitz.conf"
sudo /home/admin/config.scripts/lnd.credentials.sh sync
if grep -Eq "^specter=on" /mnt/hdd/raspiblitz.conf; then
echo "# Restart Specter on $CHAIN"
sudo systemctl restart cryptoadvance-specter.service
fi
echo
echo "Press ENTER to return to main menu."
read key
;;
esac

View File

@ -0,0 +1,179 @@
#!/bin/bash
# get raspiblitz config
echo "get raspiblitz config"
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
CHAIN=mainnet
# for testnet
echo "services default values"
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
if [ ${#lnd} -eq 0 ]; then lnd="off"; fi
if [ ${#cln} -eq 0 ]; then cln="off"; fi
if [ ${#crtlWebinterface} -eq 0 ]; then crtlWebinterface="off"; fi
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
# show select dialog
echo "run dialog ..."
OPTIONS=()
OPTIONS+=(l "LND on $CHAIN" ${lnd})
OPTIONS+=(r "RTL for LND $CHAIN" ${rtlWebinterface})
OPTIONS+=(c "C-lightning on $CHAIN" ${cln})
OPTIONS+=(t "RTL for CLN on $CHAIN" ${crtlWebinterface})
OPTIONS+=(s "Sparko for CLN on $CHAIN" ${sparko})
CHOICES=$(dialog --title ' Additional Services ' \
--checklist ' use spacebar to activate/de-activate ' \
12 45 5 "${OPTIONS[@]}" 2>&1 >/dev/tty)
dialogcancel=$?
echo "done dialog"
clear
# check if user canceled dialog
echo "dialogcancel(${dialogcancel})"
if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled"
exit 0
elif [ ${dialogcancel} -eq 255 ]; then
echo "ESC pressed"
exit 0
fi
needsReboot=0
anychange=0
# lnd process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "l")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${lnd}" != "${choice}" ]; then
echo "# LND on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/lnd.chain.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed LND on $CHAIN"
else
l1="# !!! FAIL on LND on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/lnd.chain.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# LND on $CHAIN Setting unchanged."
fi
# cln process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "c")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${cln}" != "${choice}" ]; then
echo "# CLN on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/cln.install.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed CLN on $CHAIN"
else
l1="# !!! FAIL on CLN on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/cln.install.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# CLN on $CHAIN Setting unchanged."
fi
# RTL process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "r")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${rtlWebinterface}" != "${choice}" ]; then
echo "# RTL for LND $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice} lnd $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start RTL
echo "# waiting 10 secs .."
sleep 10
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
else
l1="# !!! FAIL on RTL for LND $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on lnd $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# RTL for LND $CHAIN Setting unchanged."
fi
# cRTL process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${crtlWebinterface}" != "${choice}" ]; then
echo "RTL for CLN $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice} cln $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start cRTL
echo "waiting 10 secs .."
sleep 10
/home/admin/config.scripts/bonus.rtl.sh menu cln $CHAIN
else
l1="!!! FAIL on RTL for CLN $CHAIN install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on cln $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "RTL for CLN $CHAIN Setting unchanged."
fi
# sparko process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "s")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${sparko}" != "${choice}" ]; then
echo "# Sparko on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/cln-plugin.sparko.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
/home/admin/config.scripts/cln-plugin.sparko.sh menu $CHAIN
else
l1="# !!! FAIL on Sparko on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/cln-plugin.sparko.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# Sparko on $CHAIN Setting unchanged."
fi
if [ ${anychange} -eq 0 ]; then
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
exit 0
fi
if [ ${needsReboot} -eq 1 ]; then
sleep 2
dialog --pause "OK. System will reboot to activate changes." 8 58 8
clear
echo "rebooting .. (please wait)"
# stop bitcoind
sudo -u bitcoin ${network}-cli stop
sleep 4
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi

View File

@ -0,0 +1,181 @@
#!/bin/bash
# get raspiblitz config
echo "get raspiblitz config"
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
CHAIN=testnet
# for testnet
echo "services default values"
if [ ${#trtlWebinterface} -eq 0 ]; then trtlWebinterface="off"; fi
if [ ${#tlnd} -eq 0 ]; then tlnd="off"; fi
if [ ${#tcrtlWebinterface} -eq 0 ]; then tcrtlWebinterface="off"; fi
if [ ${#tcln} -eq 0 ]; then tcln="off"; fi
if [ ${#tsparko} -eq 0 ]; then tsparko="off"; fi
# show select dialog
echo "run dialog ..."
OPTIONS=()
OPTIONS+=(l "LND on $CHAIN" ${tlnd})
OPTIONS+=(r "RTL for LND $CHAIN" ${trtlWebinterface})
OPTIONS+=(c "C-lightning on $CHAIN" ${tcln})
OPTIONS+=(t "RTL for CLN on $CHAIN" ${tcrtlWebinterface})
OPTIONS+=(s "Sparko for CLN on $CHAIN" ${tsparko})
CHOICES=$(dialog --title ' Additional Services ' \
--checklist ' use spacebar to activate/de-activate ' \
12 45 5 "${OPTIONS[@]}" 2>&1 >/dev/tty)
dialogcancel=$?
echo "done dialog"
clear
# check if user canceled dialog
echo "dialogcancel(${dialogcancel})"
if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled"
exit 0
elif [ ${dialogcancel} -eq 255 ]; then
echo "ESC pressed"
exit 0
fi
needsReboot=0
anychange=0
# tlnd process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "l")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${tlnd}" != "${choice}" ]; then
echo "# LND on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/lnd.chain.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed LND on $CHAIN"
else
l1="# !!! FAIL on LND on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/lnd.chain.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# LND on $CHAIN Setting unchanged."
fi
# tcln process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "c")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${tcln}" != "${choice}" ]; then
echo "# CLN on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/cln.install.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed CLN on $CHAIN"
else
l1="# !!! FAIL on CLN on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/cln.install.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# CLN on $CHAIN Setting unchanged."
fi
# tRTL process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "r")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${trtlWebinterface}" != "${choice}" ]; then
echo "# RTL for LND $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice} lnd $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start tRTL
echo "# waiting 10 secs .."
sleep 10
/home/admin/config.scripts/bonus.rtl.sh menu lnd $CHAIN
else
l1="# !!! FAIL on RTL for LND $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on lnd $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# RTL for LND $CHAIN Setting unchanged."
fi
# ctRTL process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${tcrtlWebinterface}" != "${choice}" ]; then
echo "RTL for CLN $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice} cln $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start tcRTL
echo "waiting 10 secs .."
sleep 10
/home/admin/config.scripts/bonus.rtl.sh menu cln $CHAIN
else
l1="!!! FAIL on RTL for CLN $CHAIN install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on cln $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "RTL for CLN $CHAIN Setting unchanged."
fi
# tsparko process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "s")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${tsparko}" != "${choice}" ]; then
echo "# Sparko on $CHAIN Setting changed .."
anychange=1
/home/admin/config.scripts/cln-plugin.sparko.sh ${choice} $CHAIN
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
/home/admin/config.scripts/cln-plugin.sparko.sh menu $CHAIN
else
l1="# !!! FAIL on Sparko on $CHAIN install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/cln-plugin.sparko.sh on $CHAIN"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# Sparko on $CHAIN Setting unchanged."
fi
if [ ${anychange} -eq 0 ]; then
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
exit 0
fi
if [ ${needsReboot} -eq 1 ]; then
sleep 2
dialog --pause "OK. System will reboot to activate changes." 8 58 8
clear
echo "rebooting .. (please wait)"
# stop bitcoind
sudo -u bitcoin ${network}-cli stop
sleep 4
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi

View File

@ -1,29 +1,175 @@
#!/bin/bash #!/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 - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf" configFile="/mnt/hdd/raspiblitz.conf"
source ${configFile} 2>/dev/null
# INFOFILE - state data from bootstrap # INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info" infoFile="/home/admin/raspiblitz.info"
# use blitz.datadrive.sh to analyse HDD situation # check if raspiblitz.info exists
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) systemInfoExists=$(ls ${infoFile} | grep -c "${infoFile}")
if [ "${error}" != "" ]; then if [ "${systemInfoExists}" != "1" ]; then
echo "# FAIL blitz.datadrive.sh status --> ${error}" echo "systemInfoExists(${systemInfoExists})"
echo "# Please report issue to the raspiblitz github." 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 exit 1
fi fi
# check if HDD is connected # get system state information raspiblitz.info
if [ "${isMounted}" == "0" ] && [ ${#hddCandidate} -eq 0 ]; then source ${infoFile}
echo "***********************************************************"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart." # check that basic system phase/state information is available
echo "***********************************************************" if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then
vagrant=$(df | grep -c "/vagrant") echo "setupPhase(${setupPhase}) state(${state})"
if [ ${vagrant} -gt 0 ]; then echo "FAIL: ${infoFile} does not exist or missing state."
echo "Check logs & bootstrap.service for errors and report to devs."
exit 1
fi
# special state: copysource
if [ "${state}" = "copysource" ]; then
echo "***********************************************************"
echo "INFO: You lost connection during copying the blockchain"
echo "You have the following options:"
echo "a) continue/check progress with command: sourcemode"
echo "b) return to normal mode with command: restart"
echo "***********************************************************"
exit
fi
# special state: copytarget
source <(/home/admin/config.scripts/blitz.copychain.sh status)
if [ "${copyInProgress}" = "1" ]; then
echo "Detected interrupted COPY blochain process ..."
/home/admin/config.scripts/blitz.copychain.sh target
exit
fi
# special state: reindex was triggered
if [ "${state}" = "reindex" ]; then
echo "Re-Index in progress ... start monitoring:"
/home/admin/config.scripts/network.reindex.sh
exit
fi
# special state: copystation
if [ "${state}" = "copystation" ]; then
echo "Copy Station is Runnning ..."
echo "reboot to return to normal"
sudo /home/admin/XXcopyStation.sh
exit
fi
# prepare status file
# TODO: this is to be replaced and unified together with raspiblitz.info
# when we move to a background monitoring thread & redis for WebUI with v1.8
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 [ "${lndActive}" == "1" ] && [ "${walletLocked}" == "1" ] && [ "${state}" == "ready" ]; 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/controlSetupDialog.sh
# use the exit code from setup menu as signal if menu loop should exited
# 0 = continue loop / everything else = break loop and exit to terminal
exitMenuLoop=$?
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/controlFinalDialog.sh
continue
fi
#####################################
# INITIAL BLOCKCHAIN SYNC (SUBLOOP)
#####################################
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ "${initialSync}" == "1" ]; then
echo "debug wait eventBlockchainSync.sh ..."
sleep 3
/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 "To connect a HDD data disk to your VagrantVM:"
echo "- shutdown VM with command: off" echo "- shutdown VM with command: off"
echo "- open your VirtualBox GUI and select RaspiBlitzVM" echo "- open your VirtualBox GUI and select RaspiBlitzVM"
@ -35,436 +181,50 @@ if [ "${isMounted}" == "0" ] && [ ${#hddCandidate} -eq 0 ]; then
echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB" 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 "space on your laptop you can store the VDI file on an external drive."
echo "***********************************************************" echo "***********************************************************"
fi
exit
fi
# check if HDD is from another fullnode OS and offer migration
if [ "${hddGotMigrationData}" != "" ] && [ "${hddGotMigrationData}" != "none" ]; then
nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]")
whiptail --title " ${nodenameUpperCase} --> RASPIBLITZ " --yes-button "Start Migration" --no-button "Ignore" --yesno "RaspiBlitz found data from ${nodenameUpperCase}
You can migrate your blockchain & LND data (funds & channels) over to RaspiBlitz.
Please make sure to have your ${nodenameUpperCase} seed words & static channel backup file (just in case). Also any data of additional apps you had installed on ${nodenameUpperCase} might get lost.
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ $? -eq 0 ]; then
err=""
echo "**************************************************"
echo "MIGRATION FROM ${nodenameUpperCase} TO RASPIBLITZ"
echo "**************************************************"
echo "- started ..."
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
if [ "${err}" != "" ]; then
echo "MIGRATION FAILED: ${err}"
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup."
exit 1 exit 1
fi fi
# if free space is lower than 100GB (100000000) delete backup files # for all critical errors (admin info & exit)
if [ "${hddDataFreeKB}" != "" ] && [ ${hddDataFreeKB} -lt 407051412 ]; then if [ "${state}" == "errorHDD" ]; then
echo "- free space of data disk is low ... deleting 'backup_migration'" echo "***********************************************************"
sudo rm -R /mnt/hdd/backup_migration 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 else
echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'" # every other state just push as event to SSH frontend
echo "debug wait eventInfoWait.sh ..."
sleep 3
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}"
fi fi
sleep 3
# kick into reboot
echo "******************************************************"
echo "OK MIGRATION --> will now reboot and update/recover"
echo "******************************************************"
sudo shutdown -h -r now
sleep 100
exit 0
else
echo "******************************************************"
echo "MIGRATION SKIPPED ... starting fresh RaspiBlitz Setup"
echo "******************************************************"
sleep 6
fi fi
fi
# check data from _bootstrap.sh that was running on device setup done
bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
echo "***********************************************************"
exit
fi
# load the data from the info file (will get produced on every startup) echo "# menu loop received exit code ${exitMenuLoop} --> exit to terminal"
source ${infoFile} echo "***********************************"
echo "* RaspiBlitz Commandline"
if [ "${state}" = "recovering" ]; then echo "* Here be dragons .. have fun :)"
echo "***********************************************************" echo "***********************************"
echo "WARNING: bootstrap still updating - close SSH, login later" if [ "${setupPhase}" == "done" ]; then
echo "To monitor progress --> tail -n1000 -f raspiblitz.log" echo "Bitcoin command line options: ${network}-cli help"
echo "***********************************************************" if [ "${lightning}" == "lnd" ]; then
exit echo "LND command line options: lncli -h"
fi fi
if [ "${lightning}" == "cln" ]; then
if [ "${state}" = "copysource" ]; then echo "C-Lightning command line options: lightning-cli help"
echo "***********************************************************"
echo "INFO: You lost connection during copying the blockchain"
echo "You have the following options:"
echo "a) continue/check progress with command: sourcemode"
echo "b) return to normal mode with command: restart"
echo "***********************************************************"
exit
fi
# check if copy blockchain over LAN to this RaspiBlitz was running
source <(/home/admin/config.scripts/blitz.copyblockchain.sh status)
if [ "${copyInProgress}" = "1" ]; then
echo "Detected interrupted COPY blochain process ..."
/home/admin/50copyHDD.sh
exit
fi
# signal that after bootstrap recover user dialog is needed
recoveredInfoExists=$(sudo ls /home/admin/recover.flag 2>/dev/null | grep -c '.flag')
if [ ${recoveredInfoExists} -gt 0 ]; then
echo "System recovered - needs final user settings"
/home/admin/20recoverDialog.sh
exit 1
fi
# signal that a reindex was triggered
if [ "${state}" = "reindex" ]; then
echo "Re-Index in progress ... start monitoring:"
/home/admin/config.scripts/network.reindex.sh
exit 1
fi
# singal that copstation is running
if [ "${state}" = "copystation" ]; then
echo "Copy Station is Runnning ..."
echo "reboot to return to normal"
sudo /home/admin/XXcopyStation.sh
exit
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "loading config data"
source ${configFile}
else
echo "setup still in progress - setupStep(${setupStep})"
fi fi
fi
## default menu settings
# to fit the main menu without scrolling:
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=6
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
# check if RTL web interface is installed
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
# function to use later
waitUntilChainNetworkIsReady()
{
source ${configFile}
echo "checking ${network}d - please wait .."
echo "can take longer if device was off or first time"
# check for error on network
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
clienterror=`cat error.tmp`
rm error.tmp
# check for missing blockchain data
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
minSize=210000000000
else
minSize=27000000000
fi
elif [ "${network}" = "litecoin" ]; then
if [ "${chain}" = "main" ]; then
minSize=20000000000
else
minSize=27000000000
fi
else
minSize=210000000000000
fi
isSyncing=$(sudo ls -la /mnt/hdd/${network}/blocks/.selfsync 2>/dev/null | grep -c '.selfsync')
blockchainsize=$(sudo du -shbc /mnt/hdd/${network}/ 2>/dev/null | head -n1 | awk '{print $1;}')
if [ ${#blockchainsize} -gt 0 ]; then
if [ ${blockchainsize} -lt ${minSize} ]; then
if [ ${isSyncing} -eq 0 ]; then
echo "blockchainsize(${blockchainsize})"
echo "Missing Blockchain Data (<${minSize}) ..."
clienterror="missing blockchain"
sleep 3
fi
fi
fi
if [ ${#clienterror} -gt 0 ]; then
#echo "clienterror(${clienterror})"
# analyse LOGS for possible reindex
reindex=$(sudo cat /mnt/hdd/${network}/debug.log 2>/dev/null | grep -c 'Please restart with -reindex or -reindex-chainstate to recover')
if [ ${reindex} -gt 0 ]; then
# dismiss if its just a date thing
futureBlock=$(sudo tail /mnt/hdd/${network}/debug.log 2>/dev/null | grep "Please restart with -reindex or -reindex-chainstate to recover" | grep -c "block database contains a block which appears to be from the future")
if [ ${futureBlock} -gt 0 ]; then
blockchainBroken=0
echo "-> Ignore reindex - its just a future block"
fi
if [ ${isSyncing} -gt 0 ]; then
reindex=0
fi
fi
if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then
if [ ${reindex} -gt 0 ]; then
echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options."
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
sleep 3
fi
whiptail --title "Blockchain not Complete" --yes-button "DELETE+REPAIR" --no-button "Continue Sync" --yesno "Your blockchain data is not complete (yet).
You can try to sync the chain further but if your stuck
this can be due to power problems or a failing HDD.
For more info see: https://raspiblitz.org -> FAQ
If you choose to DELETE+REPAIR the old blockchain gets
deleted but your Lightning funds & channel not be touched.
How do you want to continue?
" 15 65
if [ $? -eq 0 ]; then
#delete+repair
clear
echo "***********************************************************"
echo "DELETE+REPAIR blockchain ..."
echo "***********************************************************"
/home/admin/XXcleanHDD.sh -blockchain -force
/home/admin/98repairBlockchain.sh
/home/admin/00raspiblitz.sh
exit
else
# ignore - just delete blockchain logfile
clear
echo "***********************************************************"
echo "CONTINUE SYNC blockchain ..."
echo "***********************************************************"
fi
fi
# let 80scanLND script to the info to use
/home/admin/80scanLND.sh
if [ $? -gt 0 ]; then
echo "${network} error: ${clienterror}"
exit 0
fi
fi
while :
do
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ ${locked} -gt 0 ]; then
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
if [ "${autoUnlock}" == "on" ] && [ ${uptime} -lt 300 ]; then
# give autounlock 5 min after startup to react
sleep 1
else
# check how many times LND was restarted
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
if [ ${startcountLightning} -lt 4 ]; then
/home/admin/config.scripts/lnd.unlock.sh
echo "Starting up Wallet ... (10sec)"
sleep 5
sleep 5
echo "please wait ... update to next screen can be slow"
else
/home/admin/80scanLND.sh lightning-error
sudo rm /home/admin/systemd.lightning.log
echo "(exit after too much restarts/unlocks - restart to try again)"
exit 0
fi
fi
fi
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSynced} -eq 0 ]; then
/home/admin/80scanLND.sh
if [ $? -gt 0 ]; then
exit 0
fi
else
# everything is ready - return from loop
return
fi
sleep 5
done
}
if [ ${#setupStep} -eq 0 ]; then
echo "WARN: no setup step found in raspiblitz.info"
setupStep=0
fi
if [ ${setupStep} -eq 0 ]; then
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" \
MIGRATION "Upload a Migration File from old RaspiBlitz" )
HEIGHT=12
elif [ ${setupStep} -lt 100 ]; then
# continue setup
BACKTITLE="${hostname} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
else else
echo "Your setup is not finished."
# check if LND needs re-setup echo "For setup logs: cat raspiblitz.log"
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup) echo "or call the command 'debug' to see bigger report."
if [ "${wallet}" == "0" ] || [ "${macaroon}" == "0" ] || [ "${config}" == "0" ] || [ "${tls}" == "0" ]; then
echo "WARN: LND needs re-setup"
/home/admin/70initLND.sh
exit 0
fi
# wait all is synced and ready
waitUntilChainNetworkIsReady
# check if 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
#forward to main menu
/home/admin/00mainMenu.sh
exit 0
fi fi
echo "Back to menus use command: raspiblitz"
CHOICE=$(dialog --clear \ echo
--backtitle "$BACKTITLE" \ exit 0
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
CLOSE)
exit 1;
;;
BITCOIN)
# set network info
sed -i "s/^network=.*/network=bitcoin/g" ${infoFile}
sed -i "s/^chain=.*/chain=main/g" ${infoFile}
###### OPTIMIZE IF RAM >1GB
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /home/admin/assets/bitcoin.conf
sudo sed -i "s/^maxmempool=.*/maxmempool=300/g" /home/admin/assets/bitcoin.conf
fi
/home/admin/10setupBlitz.sh
exit 1;
;;
LITECOIN)
/home/admin/config.scripts/blitz.litecoin.sh on
/home/admin/10setupBlitz.sh
exit 1;
;;
MANUAL)
echo "************************************************************************************"
echo "PLEASE go to RaspiBlitz FAQ:"
echo "https://github.com/rootzoll/raspiblitz"
echo "And check: How can I recover my coins from a failing RaspiBlitz?"
echo "************************************************************************************"
exit 0
;;
MIGRATION)
sudo /home/admin/config.scripts/blitz.migration.sh "import-gui"
# on error clean & repeat
if [ "$?" = "1" ]; then
echo
echo "# clean and unmount for next try"
sudo 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
sleep 2
/home/admin/00raspiblitz.sh
fi
exit 0
;;
CONTINUE)
/home/admin/10setupBlitz.sh
exit 1;
;;
esac

View File

@ -9,13 +9,14 @@ echo "services default values"
if [ ${#autoPilot} -eq 0 ]; then autoPilot="off"; fi if [ ${#autoPilot} -eq 0 ]; then autoPilot="off"; fi
if [ ${#autoUnlock} -eq 0 ]; then autoUnlock="off"; fi if [ ${#autoUnlock} -eq 0 ]; then autoUnlock="off"; fi
if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi
if [ ${#chain} -eq 0 ]; then chain="main"; fi
if [ ${#autoNatDiscovery} -eq 0 ]; then autoNatDiscovery="off"; fi if [ ${#autoNatDiscovery} -eq 0 ]; then autoNatDiscovery="off"; fi
if [ ${#networkUPnP} -eq 0 ]; then networkUPnP="off"; fi if [ ${#networkUPnP} -eq 0 ]; then networkUPnP="off"; fi
if [ ${#touchscreen} -eq 0 ]; then touchscreen=0; fi if [ ${#touchscreen} -eq 0 ]; then touchscreen=0; fi
if [ ${#lcdrotate} -eq 0 ]; then lcdrotate=0; fi if [ ${#lcdrotate} -eq 0 ]; then lcdrotate=0; fi
if [ ${#zerotier} -eq 0 ]; then zerotier="off"; fi if [ ${#zerotier} -eq 0 ]; then zerotier="off"; fi
if [ ${#circuitbreaker} -eq 0 ]; then circuitbreaker="off"; fi if [ ${#circuitbreaker} -eq 0 ]; then circuitbreaker="off"; fi
if [ ${#testnet} -eq 0 ]; then testnet="off"; fi
if [ ${#cln} -eq 0 ]; then cln="off"; fi
echo "map dropboxbackup to on/off" echo "map dropboxbackup to on/off"
DropboxBackup="off" DropboxBackup="off"
@ -29,9 +30,9 @@ echo "map zerotier to on/off"
zerotierSwitch="off" zerotierSwitch="off"
if [ "${zerotier}" != "off" ]; then zerotierSwitch="on"; fi if [ "${zerotier}" != "off" ]; then zerotierSwitch="on"; fi
echo "map chain to on/off" # echo "map chain to on/off"
chainValue="off" # chainValue="off"
if [ "${chain}" = "test" ]; then chainValue="on"; fi # if [ "${chain}" = "test" ]; then chainValue="on"; fi
echo "map domain to on/off" echo "map domain to on/off"
domainValue="off" domainValue="off"
@ -53,7 +54,7 @@ if [ ${touchscreen} -gt 0 ]; then
touchscreenMenu='on' touchscreenMenu='on'
fi fi
echo "check autopilot by lnd.conf" echo "check autopilot in lnd.conf"
lndAutoPilotOn=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'autopilot.active=1') lndAutoPilotOn=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'autopilot.active=1')
if [ ${lndAutoPilotOn} -eq 1 ]; then if [ ${lndAutoPilotOn} -eq 1 ]; then
autoPilot="on" autoPilot="on"
@ -71,140 +72,143 @@ fi
# show select dialog # show select dialog
echo "run dialog ..." echo "run dialog ..."
# BASIC MENU INFO # BASIC MENU INFO
HEIGHT=19 # add 6 to CHOICE_HEIGHT + MENU lines
WIDTH=45
CHOICE_HEIGHT=11 # 1 line / OPTIONS
OPTIONS=() OPTIONS=()
OPTIONS+=(t 'Run behind TOR' ${runBehindTor}) OPTIONS+=(t 'Run behind TOR' ${runBehindTor})
if [ "${displayClass}" == "lcd" ]; then if [ "${displayClass}" == "lcd" ]; then
OPTIONS+=(s 'Touchscreen' ${touchscreenMenu}) OPTIONS+=(s 'Touchscreen' ${touchscreenMenu})
OPTIONS+=(r 'LCD Rotate' ${lcdrotateMenu}) OPTIONS+=(r 'LCD Rotate' ${lcdrotateMenu})
fi fi
OPTIONS+=(a 'Channel Autopilot' ${autoPilot})
OPTIONS+=(k 'Accept Keysend' ${keysend}) if [ "${lightning}" == "lnd" ]; then
OPTIONS+=(n 'Testnet' ${chainValue}) OPTIONS+=(a 'Channel Autopilot' ${autoPilot})
OPTIONS+=(c 'Circuitbreaker (LND firewall)' ${circuitbreaker}) OPTIONS+=(k 'Accept Keysend' ${keysend})
OPTIONS+=(u 'LND Auto-Unlock' ${autoUnlock}) OPTIONS+=(c 'Circuitbreaker (LND firewall)' ${circuitbreaker})
OPTIONS+=(d 'StaticChannelBackup on DropBox' ${DropboxBackup}) OPTIONS+=(u 'LND Auto-Unlock' ${autoUnlock})
OPTIONS+=(e 'StaticChannelBackup on USB Drive' ${LocalBackup}) OPTIONS+=(d 'StaticChannelBackup on DropBox' ${DropboxBackup})
OPTIONS+=(e 'StaticChannelBackup on USB Drive' ${LocalBackup})
fi
OPTIONS+=(z 'ZeroTier' ${zerotierSwitch}) OPTIONS+=(z 'ZeroTier' ${zerotierSwitch})
OPTIONS+=(t 'Parallel Testnet services' ${testnet})
if [ ${#runBehindTor} -eq 0 ] || [ "${runBehindTor}" = "off" ]; then # choose c-lightning just at setup for now
OPTIONS+=(y ${dynDomainMenu} ${domainValue}) #OPTIONS+=(n 'C-lightning' ${cln})
OPTIONS+=(b 'BTC UPnP (AutoNAT)' ${networkUPnP})
OPTIONS+=(l 'LND UPnP (AutoNAT)' ${autoNatDiscovery})
fi
CHOICES=$(dialog \ if [ ${chain} = "main" ];then
--title ' Node Settings & Options ' \ if [ ${#runBehindTor} -eq 0 ] || [ "${runBehindTor}" = "off" ]; then
--checklist ' use spacebar to activate/de-activate ' \ OPTIONS+=(y ${dynDomainMenu} ${domainValue})
$HEIGHT $WIDTH $CHOICE_HEIGHT \ OPTIONS+=(b 'BTC UPnP (AutoNAT)' ${networkUPnP})
"${OPTIONS[@]}" 2>&1 >/dev/tty) OPTIONS+=(l 'LND UPnP (AutoNAT)' ${autoNatDiscovery})
fi
fi
CHOICE_HEIGHT=$(("${#OPTIONS[@]}"))
CHOICES=$(dialog --title ' Node Settings & Options ' --checklist ' use spacebar to activate/de-activate ' $CHOICE_HEIGHT 45 $CHOICE_HEIGHT "${OPTIONS[@]}" 2>&1 >/dev/tty)
dialogcancel=$? dialogcancel=$?
echo "done dialog"
clear clear
# check if user canceled dialog # check if user canceled dialog
echo "dialogcancel(${dialogcancel})" echo "dialogcancel(${dialogcancel}) (${CHOICE_HEIGHT})"
if [ ${dialogcancel} -eq 1 ]; then if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled" echo "user canceled"
exit 1 exit 0
elif [ ${dialogcancel} -eq 255 ]; then elif [ ${dialogcancel} -eq 255 ]; then
echo "ESC pressed" echo "ESC pressed"
exit 1 exit 0
fi fi
needsReboot=0 needsReboot=0
anychange=0 anychange=0
# TESTNET process choice - KEEP FIRST IN ORDER # deprecated - see https://github.com/rootzoll/raspiblitz/issues/2290
choice="main"; check=$(echo "${CHOICES}" | grep -c "n") ## TESTNET process choice - KEEP FIRST IN ORDER
if [ ${check} -eq 1 ]; then choice="test"; fi #choice="main"; check=$(echo "${CHOICES}" | grep -c "n")
if [ "${chain}" != "${choice}" ]; then #if [ ${check} -eq 1 ]; then choice="test"; fi
if [ "${network}" = "litecoin" ] && [ "${choice}"="test" ]; then #if [ "${chain}" != "${choice}" ]; then
dialog --title 'FAIL' --msgbox 'Litecoin-Testnet not available.' 5 25 # if [ "${network}" = "litecoin" ] && [ "${choice}"="test" ]; then
elif [ "${BTCRPCexplorer}" = "on" ]; then # dialog --title 'FAIL' --msgbox 'Litecoin-Testnet not available.' 5 25
dialog --title 'NOTICE' --msgbox 'Please turn off BTC-RPC-Explorer FIRST\nbefore changing testnet.' 6 45 # elif [ "${BTCRPCexplorer}" = "on" ]; then
exit 1 # dialog --title 'NOTICE' --msgbox 'Please turn off BTC-RPC-Explorer FIRST\nbefore changing testnet.' 6 45
elif [ "${BTCPayServer}" = "on" ]; then # exit 1
dialog --title 'NOTICE' --msgbox 'Please turn off BTC-Pay-Server FIRST\nbefore changing testnet.' 6 45 # elif [ "${BTCPayServer}" = "on" ]; then
exit 1 # dialog --title 'NOTICE' --msgbox 'Please turn off BTC-Pay-Server FIRST\nbefore changing testnet.' 6 45
elif [ "${ElectRS}" = "on" ]; then # exit 1
dialog --title 'NOTICE' --msgbox 'Please turn off Electrum-Rust-Server FIRST\nbefore changing testnet.' 6 48 # elif [ "${ElectRS}" = "on" ]; then
exit 1 # dialog --title 'NOTICE' --msgbox 'Please turn off Electrum-Rust-Server FIRST\nbefore changing testnet.' 6 48
elif [ "${loop}" = "on" ]; then # exit 1
dialog --title 'NOTICE' --msgbox 'Please turn off Loop-Service FIRST\nbefore changing testnet.' 6 48 # elif [ "${loop}" = "on" ]; then
exit 1 # dialog --title 'NOTICE' --msgbox 'Please turn off Loop-Service FIRST\nbefore changing testnet.' 6 48
else # exit 1
echo "Testnet Setting changed .." # else
anychange=1 # echo "Testnet Setting changed .."
sudo /home/admin/config.scripts/network.chain.sh ${choice}net # anychange=1
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${choice}net/wallet.db 2>/dev/null | grep -c 'wallet.db') # sudo /home/admin/config.scripts/network.chain.sh ${choice}net
if [ ${walletExists} -eq 0 ]; then # walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${choice}net/wallet.db 2>/dev/null | grep -c 'wallet.db')
echo "Need to creating a new wallet ... wait 20secs" # if [ ${walletExists} -eq 0 ]; then
sudo systemctl start lnd # echo "Need to creating a new wallet ... wait 20secs"
sleep 20 # sudo systemctl start lnd
tryAgain=1 # sleep 20
while [ ${tryAgain} -eq 1 ] # tryAgain=1
do # while [ ${tryAgain} -eq 1 ]
echo "****************************************************************************" # do
echo "Creating a new LND Wallet for ${network}/${choice}net" # echo "****************************************************************************"
echo "****************************************************************************" # echo "Creating a new LND Wallet for ${network}/${choice}net"
echo "A) For 'Wallet Password' use your PASSWORD C --> !! minimum 8 characters !!" # echo "****************************************************************************"
echo "B) Answer 'n' because you don't have a 'cipher seed mnemonic' (24 words) yet" # echo "A) For 'Wallet Password' use your PASSWORD C --> !! minimum 8 characters !!"
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)" # echo "B) Answer 'n' because you don't have a 'cipher seed mnemonic' (24 words) yet"
echo "****************************************************************************" # echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>error.out # echo "****************************************************************************"
error=`sudo cat error.out` # source <(/home/admin/config.scripts/network.aliases.sh getvars lnd ${choice}net)
if [ ${#error} -eq 0 ]; then # $lncli_alias create 2>error.out
sleep 2 # error=$(sudo cat error.out)
# WIN # if [ ${#error} -eq 0 ]; then
tryAgain=0 # sleep 2
echo "!!! Make sure to write down the 24 words (cipher seed mnemonic) !!!" # # WIN
echo "If you are ready. Press ENTER." # tryAgain=0
else # echo "!!! Make sure to write down the 24 words (cipher seed mnemonic) !!!"
# FAIL # echo "If you are ready. Press ENTER."
tryAgain=1 # else
echo "!!! FAIL ---> SOMETHING WENT WRONG !!!" # # FAIL
echo "${error}" # tryAgain=1
echo "Press ENTER to retry ... or CTRL-c to EXIT" # echo "!!! FAIL ---> SOMETHING WENT WRONG !!!"
fi # echo "${error}"
read key # echo "Press ENTER to retry ... or CTRL-c to EXIT"
done # fi
echo "Check for Macaroon .. (10sec)" # read key
sleep 10 # done
macaroonExists=$(sudo ls /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon | grep -c 'admin.macaroon') # echo "Check for Macaroon .. (10sec)"
if [ ${macaroonExists} -eq 0 ]; then # sleep 10
echo "*** PLEASE UNLOCK your wallet with PASSWORD C to create macaroon" # macaroonExists=$(sudo ls /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon | grep -c 'admin.macaroon')
lncli unlock 2>/dev/null # if [ ${macaroonExists} -eq 0 ]; then
sleep 6 # echo "*** PLEASE UNLOCK your wallet with PASSWORD C to create macaroon"
fi # lncli unlock 2>/dev/null
macaroonExists=$(sudo ls /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon | grep -c 'admin.macaroon') # sleep 6
if [ ${macaroonExists} -eq 0 ]; then # fi
echo "FAIL --> Was not able to create macaroon" # macaroonExists=$(sudo ls /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon | grep -c 'admin.macaroon')
echo "Please report problem." # if [ ${macaroonExists} -eq 0 ]; then
exit 1 # echo "FAIL --> Was not able to create macaroon"
fi # echo "Please report problem."
echo "stopping lnd again" # exit 1
sleep 5 # fi
sudo systemctl stop lnd # echo "stopping lnd again"
fi # sleep 5
# sudo systemctl stop lnd
echo "Update Admin Macaroon" # fi
sudo rm -r /home/admin/.lnd/data/chain/${network}/${choice}net 2>/dev/null #
sudo mkdir /home/admin/.lnd/data/chain/${network}/${choice}net # echo "Update Admin Macaroon"
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon /home/admin/.lnd/data/chain/${network}/${choice}net # sudo rm -r /home/admin/.lnd/data/chain/${network}/${choice}net 2>/dev/null
sudo chown -R admin:admin /home/admin/.lnd/ # sudo mkdir /home/admin/.lnd/data/chain/${network}/${choice}net
# sudo cp /home/bitcoin/.lnd/data/chain/${network}/${choice}net/admin.macaroon /home/admin/.lnd/data/chain/${network}/${choice}net
needsReboot=1 # sudo chown -R admin:admin /home/admin/.lnd/
fi #
else # needsReboot=1
echo "Testnet Setting unchanged." # fi
fi # else
# echo "Testnet Setting unchanged."
# fi
# AUTOPILOT process choice # AUTOPILOT process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "a") choice="off"; check=$(echo "${CHOICES}" | grep -c "a")
@ -423,6 +427,57 @@ else
echo "ZeroTier setting unchanged." echo "ZeroTier setting unchanged."
fi fi
# testnet process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${testnet}" != "${choice}" ]; then
echo "# Testnet Setting changed .."
anychange=1
/home/admin/config.scripts/bitcoin.chains.sh ${choice} testnet
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
echo "# Successfully installed Testnet"
echo
echo "# Press ENTER to continue ..."
read key
else
l1="# !!! FAIL on Testnet install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bitcoin.chains.sh on testnet"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# Testnet Setting unchanged."
fi
# cln process choice
#choice="off"; check=$(echo "${CHOICES}" | grep -c "n")
#if [ ${check} -eq 1 ]; then choice="on"; fi
#if [ "${cln}" != "${choice}" ]; then
# echo "# C-lightning Setting changed .."
# anychange=1
# /home/admin/config.scripts/cln.install.sh ${choice}
# errorOnInstall=$?
# if [ "${choice}" = "on" ]; then
# if [ ${errorOnInstall} -eq 0 ]; then
# echo "# Successfully installed C-lightning"
# echo
# echo "# Press ENTER to continue ..."
# read key
# else
# l1="# !!! FAIL on C-lightning install !!!"
# l2="# Try manual install on terminal after reboot with:"
# l3="/home/admin/config.scripts/cln.install.sh on"
# dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
# fi
# fi
#else
# echo "# C-lightning Setting unchanged."
#fi
if [ ${anychange} -eq 0 ]; then if [ ${anychange} -eq 0 ]; then
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58 dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
exit 0 exit 0
@ -436,5 +491,5 @@ if [ ${needsReboot} -eq 1 ]; then
# stop bitcoind # stop bitcoind
sudo -u bitcoin ${network}-cli stop sudo -u bitcoin ${network}-cli stop
sleep 4 sleep 4
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi fi

View File

@ -6,7 +6,9 @@ source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
echo "services default values" echo "services default values"
if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
if [ ${#crtlWebinterface} -eq 0 ]; then crtlWebinterface="off"; fi
if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi
if [ ${#specter} -eq 0 ]; then specter="off"; fi if [ ${#specter} -eq 0 ]; then specter="off"; fi
if [ ${#BTCPayServer} -eq 0 ]; then BTCPayServer="off"; fi if [ ${#BTCPayServer} -eq 0 ]; then BTCPayServer="off"; fi
@ -22,30 +24,42 @@ if [ ${#sphinxrelay} -eq 0 ]; then sphinxrelay="off"; fi
if [ ${#lit} -eq 0 ]; then lit="off"; fi if [ ${#lit} -eq 0 ]; then lit="off"; fi
if [ ${#whitepaper} -eq 0 ]; then whitepaper="off"; fi if [ ${#whitepaper} -eq 0 ]; then whitepaper="off"; fi
if [ ${#chantools} -eq 0 ]; then chantools="off"; fi if [ ${#chantools} -eq 0 ]; then chantools="off"; fi
if [ ${#sparko} -eq 0 ]; then sparko="off"; fi
# show select dialog # show select dialog
echo "run dialog ..." echo "run dialog ..."
OPTIONS=() OPTIONS=()
OPTIONS+=(e 'Electrum Rust Server' ${ElectRS}) OPTIONS+=(e 'Electrum Rust Server' ${ElectRS})
OPTIONS+=(r 'RTL Webinterface' ${rtlWebinterface})
OPTIONS+=(t 'ThunderHub' ${thunderhub})
OPTIONS+=(l 'LIT (loop, pool, faraday)' ${lit})
OPTIONS+=(p 'BTCPayServer' ${BTCPayServer}) OPTIONS+=(p 'BTCPayServer' ${BTCPayServer})
OPTIONS+=(i 'LNbits' ${LNBits})
OPTIONS+=(b 'BTC-RPC-Explorer' ${BTCRPCexplorer}) OPTIONS+=(b 'BTC-RPC-Explorer' ${BTCRPCexplorer})
OPTIONS+=(s 'Cryptoadvance Specter' ${specter}) OPTIONS+=(s 'Cryptoadvance Specter' ${specter})
OPTIONS+=(a 'Mempool Space' ${mempoolExplorer}) OPTIONS+=(a 'Mempool Space' ${mempoolExplorer})
# just available for LND
if [ "${lightning}" == "lnd" ]; then
OPTIONS+=(r 'RTL LND Webinterface' ${rtlWebinterface})
OPTIONS+=(t 'ThunderHub' ${thunderhub})
OPTIONS+=(l 'LIT (loop, pool, faraday)' ${lit})
OPTIONS+=(i 'LNbits' ${LNBits})
OPTIONS+=(o 'Balance of Satoshis' ${bos})
OPTIONS+=(y 'PyBLOCK' ${pyblock})
OPTIONS+=(h 'ChannelTools (Fund Rescue)' ${chantools})
OPTIONS+=(x 'Sphinx-Relay' ${sphinxrelay})
fi
# just available for CLN
if [ "${lightning}" == "cln" ]; then
OPTIONS+=(r 'RTL C-Lightning Webinterface' ${crtlWebinterface})
OPTIONS+=(k 'Sparko C-Lightning WebWallet' ${sparko})
fi
OPTIONS+=(j 'JoinMarket' ${joinmarket}) OPTIONS+=(j 'JoinMarket' ${joinmarket})
OPTIONS+=(o 'Balance of Satoshis' ${bos})
OPTIONS+=(x 'Sphinx-Relay' ${sphinxrelay})
OPTIONS+=(y 'PyBLOCK' ${pyblock})
OPTIONS+=(c 'ChannelTools (Fund Rescue)' ${chantools})
OPTIONS+=(w 'Download Bitcoin Whitepaper' ${whitepaper}) OPTIONS+=(w 'Download Bitcoin Whitepaper' ${whitepaper})
CHOICES=$(dialog --title ' Additional Services ' \ CHOICES=$(dialog --title ' Additional Services ' \
--checklist ' use spacebar to activate/de-activate ' \ --checklist ' use spacebar to activate/de-activate ' \
22 45 15 "${OPTIONS[@]}" 2>&1 >/dev/tty) 24 45 17 "${OPTIONS[@]}" 2>&1 >/dev/tty)
dialogcancel=$? dialogcancel=$?
echo "done dialog" echo "done dialog"
@ -55,10 +69,10 @@ clear
echo "dialogcancel(${dialogcancel})" echo "dialogcancel(${dialogcancel})"
if [ ${dialogcancel} -eq 1 ]; then if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled" echo "user canceled"
exit 1 exit 0
elif [ ${dialogcancel} -eq 255 ]; then elif [ ${dialogcancel} -eq 255 ]; then
echo "ESC pressed" echo "ESC pressed"
exit 1 exit 0
fi fi
needsReboot=0 needsReboot=0
@ -70,18 +84,18 @@ if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${rtlWebinterface}" != "${choice}" ]; then if [ "${rtlWebinterface}" != "${choice}" ]; then
echo "RTL Webinterface Setting changed .." echo "RTL Webinterface Setting changed .."
anychange=1 anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice} /home/admin/config.scripts/bonus.rtl.sh ${choice} ${lightning} mainnet
errorOnInstall=$? errorOnInstall=$?
if [ "${choice}" = "on" ]; then if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start RTL sudo systemctl start RTL
echo "waiting 10 secs .." echo "waiting 10 secs .."
sleep 10 sleep 10
/home/admin/config.scripts/bonus.rtl.sh menu /home/admin/config.scripts/bonus.rtl.sh menu ${lightning} mainnet
else else
l1="!!! FAIL on RTL install !!!" l1="!!! FAIL on RTL ${lightning} install !!!"
l2="Try manual install on terminal after reboot with:" l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on" l3="/home/admin/config.scripts/bonus.rtl.sh on ${lightning} mainnet"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65 dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi fi
fi fi
@ -242,7 +256,7 @@ else
fi fi
# CHANTOOLS process choice # CHANTOOLS process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "c") choice="off"; check=$(echo "${CHOICES}" | grep -c "h")
if [ ${check} -eq 1 ]; then choice="on"; fi if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${chantools}" != "${choice}" ]; then if [ "${chantools}" != "${choice}" ]; then
echo "chantools Setting changed .." echo "chantools Setting changed .."
@ -431,6 +445,28 @@ else
echo "Whitepaper setting unchanged." echo "Whitepaper setting unchanged."
fi fi
# sparko process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "k")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${sparko}" != "${choice}" ]; then
echo "# Sparko on mainnet Setting changed .."
anychange=1
/home/admin/config.scripts/cln-plugin.sparko.sh ${choice} mainnet
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
/home/admin/config.scripts/cln-plugin.sparko.sh menu mainnet
else
l1="# !!! FAIL on Sparko on mainnet install !!!"
l2="# Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/cln-plugin.sparko.sh on mainnet"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "# Sparko on mainnet Setting unchanged."
fi
if [ ${anychange} -eq 0 ]; then if [ ${anychange} -eq 0 ]; then
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58 dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
exit 0 exit 0
@ -444,5 +480,5 @@ if [ ${needsReboot} -eq 1 ]; then
# stop bitcoind # stop bitcoind
sudo -u bitcoin ${network}-cli stop sudo -u bitcoin ${network}-cli stop
sleep 4 sleep 4
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
fi fi

View File

@ -1,267 +0,0 @@
#!/bin/bash
# CHECK WHAT IS ALREADY WORKING
# check list from top down - so ./10setupBlitz.sh
# and re-enters the setup process at the correct spot
# in case it got interrupted
echo "checking setup script"
# INFOFILE on SD - state data from bootstrap & setup
infoFile="/home/admin/raspiblitz.info"
source ${infoFile}
echo "network(${network})"
echo "chain(${chain})"
echo "setupStep(${setupStep})"
if [ ${#network} -eq 0 ]; then
echo "FAIL: Something is wrong. There is no value for network in ${infoFile}."
echo "Should be at least default value. EXIT"
exit 1
fi
# if no setup step in info file init with 0
if [ ${#setupStep} -eq 0 ];then
echo "Init setupStep=0"
echo "setupStep=0" >> ${infoFile}
setupStep=0
fi
# check if LND needs re-setup
if [ ${setupStep} -gt 79 ];then
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
if [ ${wallet} -eq 0 ] || [ ${macaroon} -eq 0 ] || [ ${config} -eq 0 ] || [ ${tls} -eq 0 ]; then
echo "WARN: LND needs re-setup"
sudo /home/admin/70initLND.sh
exit 0
fi
fi
# if setup if ready --> REBOOT
if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})"
sleep 3
sudo /home/admin/90finishSetup.sh
sudo /home/admin/95finalSetup.sh
exit 0
fi
# check if lightning is running
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 1 ]; then
echo "LND is running ..."
sleep 1
# check if LND wallet exists and if locked
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
walletLocked=0
# only when a wallet exists - it can be locked
if [ ${walletExists} -eq 1 ];then
echo "lnd wallet exists ... checking if locked"
sleep 2
walletLocked=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>&1 | grep -c unlock)
fi
if [ ${walletLocked} -gt 0 ]; then
# LND wallet is locked
/home/admin/config.scripts/lnd.unlock.sh
/home/admin/10setupBlitz.sh
exit 0
fi
# check if blockchain still syncing (during sync sometimes CLI returns with error at this point)
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainSyncing=1
if [ ${#chainInfo} -gt 0 ];then
echo "check chaininfo"
chainSyncing=$(echo "${chainInfo}" | grep "true" -c)
else
echo "chaininfo is zero"
fi
if [ ${chainSyncing} -eq 1 ]; then
echo "Sync Chain ..."
sleep 3
/home/admin/70initLND.sh
exit 0
fi
# check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | grep "synced_to_chain")
lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c)
fi
if [ ${lndSyncing} -eq 1 ]; then
echo "Sync LND ..."
sleep 3
/home/admin/70initLND.sh
exit 0
fi
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup
echo "FINSIH ... "
sleep 3
sudo /home/admin/90finishSetup.sh
sudo /home/admin/95finalSetup.sh
exit 0
fi #end - when lighting is running
# check if bitcoin is running
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
# double check
seconds=120
if [ ${setupStep} -lt 60 ]; then
seconds=10
fi
dialog --pause " Double checking for ${network}d - please wait .." 8 58 ${seconds}
clear
bitcoinRunning=$(${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
else
echo "${network} is running"
fi
if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - ${network}d is running"
echo "Next step run Lightning"
/home/admin/70initLND.sh
exit 1
else
echo "${network} still not running"
fi #end - when bitcoin is running
# --- so neither bitcoin or lnd or running yet --> find the earlier step in the setup process:
# use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
if [ ${#error} -gt 0 ]; then
echo "# FAIL blitz.datadrive.sh status --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
fi
# check if HDD is auto-mounted
if [ ${isMounted} -eq 1 ]; then
# FAILSAFE: check if raspiblitz.conf is available
configExists=$(ls /mnt/hdd/raspiblitz.conf | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL: /mnt/hdd/raspiblitz.conf should exists at this point, but not found!"
echo "Please report to: https://github.com/rootzoll/raspiblitz/issues/293"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Press ENTER to EXIT."
read key
exit 1
fi
# are there any signs of blockchain data and activity
# setup running with admin user, but has no permission to read /mnt/hdd/bitcoin/blocks/, sudo needed
blockchainDataExists=$(sudo ls /mnt/hdd/${network}/blocks 2>/dev/null | grep -c '.dat')
configExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c '.conf')
if [ ${blockchainDataExists} -gt 0 ]; then
if [ ${configExists} -eq 1 ]; then
/home/admin/XXdebugLogs.sh
echo "UNKOWN STATE - there is blockain data config, but blockchain service is not running"
echo "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Or something with the config is not correct."
echo "Sometimes a reboot helps - use command: restart"
echo "Or try to repair blockchain - use command: repair"
exit 1
else
echo "Got mounted blockchain, but no config and running service yet --> finish HDD"
/home/admin/60finishHDD.sh
exit 1
fi
fi
# HDD is empty - get Blockchain
# detect hardware version of RaspberryPi
# https://www.unixtutorial.org/command-to-confirm-raspberry-pi-model
raspberryPi=$(cat /proc/device-tree/model | cut -d " " -f 3 | sed 's/[^0-9]*//g')
if [ ${#raspberryPi} -eq 0 ]; then
raspberryPi=0
fi
# Bitcoin on older/weak RaspberryPi3 (LEGACY)
if [ ${network} = "bitcoin" ] && [ ${raspberryPi} -eq 3 ]; then
echo "Bitcoin-RP3 Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
--menu "You need a copy of the Bitcoin Blockchain - choose method:" 13 75 5 \
C "COPY --> Copy from laptop/node over LAN (±6hours)" \
S "SYNC --> Selfvalidate all Blocks (VERY SLOW ±2month)" 2>&1 >/dev/tty)
# Bitcoin on stronger RaspberryPi4 (new DEFAULT)
elif [ ${network} = "bitcoin" ]; then
echo "Bitcoin-RP4 Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
--menu "You need a copy of the Bitcoin Blockchain - choose method:" 13 75 5 \
S "SYNC --> Selfvalidate all Blocks (DEFAULT ±2days)" \
C "COPY --> Copy from laptop/node over LAN (±6hours)" 2>&1 >/dev/tty)
# Litecoin
elif [ ${network} = "litecoin" ]; then
echo "Litecoin Options"
menuitem=$(dialog --clear --beep --backtitle "RaspiBlitz" --title " Getting the Blockchain " \
--menu "You need a copy of the Litecoin Blockchain:" 13 75 4 \
S "SYNC --> Selfvalidate all Blocks (±1day)" 2>&1 >/dev/tty)
# error
else
echo "FAIL Unkown network(${network})"
exit 1
fi
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=50/g" ${infoFile}
clear
case $menuitem in
C)
/home/admin/50copyHDD.sh
;;
S)
/home/admin/50syncHDD.sh
/home/admin/10setupBlitz.sh
;;
*)
echo "Use 'raspiblitz' command to return to setup ..."
;;
esac
exit 1
fi # end HDD is already auto-mountes
# --- the HDD is not auto-mounted --> very early stage of setup
# if the script is called for the first time
if [ ${setupStep} -eq 0 ]; then
# run initial user dialog
/home/admin/20setupDialog.sh
fi
# if the script is called for the first time
if [ ${setupStep} -eq 20 ]; then
# run initial user dialog
/home/admin/30initHDD.sh
exit 1
fi
# the HDD is already ext4 formated and cointains blockchain data
if [ "${hddFormat}" = "ext4" ] || [ "${hddFormat}" = "btrfs" ]; then
if [ ${hddGotBlockchain} -eq 1 ]; then
echo "HDD was already initialized/prepared"
echo "Now needs to be mounted"
/home/admin/40addHDD.sh
exit 1
fi
fi
# the HDD had no init yet
echo "init HDD ..."
/home/admin/30initHDD.sh
exit 1

View File

@ -1,127 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# show password info dialog
resetAlsoPasswordB=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null | grep -c "rpcpassword=passwordB")
resetAlsoPasswordC=$(sudo ls /mnt/hdd/passwordc.flag 2>/dev/null | grep -c ".flag")
if [ ${resetAlsoPasswordC} -gt 0 ]; then
# password A + B + C
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
You need to set a new Password A, B & C:
A) Main User Password (SSH, WebUI, ..)
B) RPC & APP Password (Additional Apps, ..)
C) Lightning Wallet Unlock Password
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
oldPasswordC=$(sudo cat /mnt/hdd/passwordc.flag)
sudo /home/admin/config.scripts/blitz.setpassword.sh c $oldPasswordC
if [ "$?" != "0" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "Please write down your Password C:\n${oldPasswordC}" 10 52
else
dialog --backtitle "RaspiBlitz" --msgbox "OK - password C was set\nuse it to unlock your Lightning Wallet after restarts." 8 52
fi
elif [ ${resetAlsoPasswordB} -gt 0 ]; then
# password A + B
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
You need to set a new Password A & B:
A) Main User Password (SSH, WebUI, ..)
B) RPC & APP Password (Additional Apps, ..)
Passwords C (for your Lightning wallet) stays to the password you set before.
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
else
# just password A
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
You need to set a new Password A:
A) Master User Password
Passwords B & C stay as before.
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 14 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
fi
# activate lnd & bitcoin service
echo "Enabling Services"
sudo systemctl daemon-reload
sudo systemctl enable lnd.service
sudo systemctl enable ${network}d.service
if [ "${rtlWebinterface}" = "on" ]; then
sudo systemctl enable RTL
fi
if [ "${loop}" = "on" ]; then
sudo systemctl enable loopd
fi
if [ "${BTCRPCexplorer}" = "on" ]; then
sudo systemctl enable btc-rpc-explorer
fi
if [ "${ElectRS}" = "on" ]; then
sudo systemctl enable electrs
fi
# remove flag that freshly recovered
sudo rm /home/admin/recover.flag
# when auto-unlock is activated then Password C is needed to be restored on SD card
if [ "${autoUnlock}" = "on" ]; then
# reset auto-unlock feature
dialog --backtitle "RaspiBlitz - Setup" --msgbox "You had the Auto-Unlock feature enabled.
In the next dialog you need to re-enter your
ACTUAL/OLD Password C to re-activate the
Auto-Unlock feature. Enter a empty password
to deactivate the Auto-Unlock feature.
" 10 52
echo "Activating Auto-Unlock (please wait) .."
sudo /home/admin/config.scripts/lnd.autounlock.sh on
dialog --backtitle "RaspiBlitz" --pause " FINAL REBOOT IS NEEDED." 8 52 5
else
dialog --backtitle "RaspiBlitz" --pause " OK - Passwords set.\n FINAL REBOOT IS NEEDED." 9 52 5
fi
sudo /home/admin/XXshutdown.sh reboot

View File

@ -1,90 +0,0 @@
#!/bin/bash
_temp=$(mktemp -p /dev/shm/)
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
###################
# CHECK IF DNS NEEDS SETTING DURING SETUP
# https://github.com/rootzoll/raspiblitz/issues/787
###################
sudo /home/admin/config.scripts/internet.dns.sh test
###################
# ENTER NAME
###################
# welcome and ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
do
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2" 11 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred -u $_temp
echo "processing ..."
sleep 3
done
# set lightning alias
sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
# store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system
valueExistsInInfoFile=$(sudo cat /home/admin/raspiblitz.info | grep -c "hostname=")
if [ ${valueExistsInInfoFile} -eq 0 ]; then
# add
echo "hostname=${result}" >> /home/admin/raspiblitz.info
else
# update
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
fi
###################
# ENTER PASSWORDS
###################
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "RaspiBlitz uses 4 different passwords.
Referenced as password A, B, C and D.
A) Master User Password
B) Blockchain RPC Password
C) LND Wallet Password
D) LND Seed Password
Choose now 4 new passwords - all min 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 15 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
# call set password b script
sudo /home/admin/config.scripts/blitz.setpassword.sh b
# success info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - RPC password changed \n\nNow starting the Setup of your RaspiBlitz." 7 52
###################
# TOR BY DEFAULT
# https://github.com/rootzoll/raspiblitz/issues/592
#
###################
echo "runBehindTor=on" >> /home/admin/raspiblitz.info
#whiptail --title ' Privacy Level - How do you want to run your node? ' --yes-button='Public IP' --no-button='TOR NETWORK' --yesno "Running your Lightning node with your Public IP is common and faster, but might reveal your personal identity and location.\n
#You can better protect your privacy with running your lightning node as a TOR Hidden Service from the start, but it can make it harder to connect with other non-TOR nodes and remote mobile apps later on.
# " 12 75
#if [ $? -eq 1 ]; then
# echo "runBehindTor=on" >> /home/admin/raspiblitz.info
#fi
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=20/g" /home/admin/raspiblitz.info
clear

View File

@ -1,136 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
clear
echo ""
echo "# *** 30initHDD.sh ***"
echo
echo "# --> Checking HDD/SSD status..."
# use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
if [ ${#error} -gt 0 ]; then
echo "# FAIL blitz.datadrive.sh status --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
fi
# check if HDD is mounted (secure against formatting a mounted disk with data)
echo "isMounted=${isMounted}"
if [ ${isMounted} -eq 1 ]; then
echo "# FAIL HDD/SSD is mounted - please unmount and call ./30initHDD.sh again"
exit 1
fi
# check if HDD contains old RaspiBlitz data (secure against wrongly formatting)
echo "hddRaspiData=${hddRaspiData}"
if [ ${hddRaspiData} -eq 1 ]; then
echo "# FAIL HDD/SSD contains old data - please delete manual and call ./30initHDD.sh again"
exit 1
fi
# check if there is a HDD connectecd to use as data drive
echo "hddCandidate=${hddCandidate}"
if [ ${#hddCandidate} -eq 0 ]; then
echo "# FAIL please connect a HDD and call ./30initHDD.sh again"
exit 1
fi
echo "OK"
# check minimal size of data drive needed
echo
echo "# --> Check HDD/SSD for Size ..."
# bitcoin: 400 GB
# litecoin: 120 GB
minSize=400
if [ "${network}" = "litecoin" ]; then
minSize=120
fi
if [ ${hddGigaBytes} -lt ${minSize} ]; then
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING: HDD is too small"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "# HDD was detected with the size of ${hddGigaBytes} GB"
echo "# For ${network} at least ${minSize} GB is needed"
echo ""
echo "# If you want to change to a bigger HDD:"
echo "# * Unplug power of RaspiBlitz"
echo "# * Make a fresh SD card again"
echo "# * Start again with bigger HDD"
exit 1
fi
echo " OK"
# format drive if it does not have any blockchain or blitz data on it
# to be sure that HDD has no faulty partions, etc.
echo
echo "# --> Check HDD/SSD for Blockchain ..."
echo "# hddGotBlockchain=${hddGotBlockchain}"
raidSizeGB=$(echo "${raidCandidate[0]}" | cut -d " " -f 2)
echo "# raidCandidates=${raidCandidates}"
echo "# raidSizeGB=${raidSizeGB}"
if [ "${hddGotBlockchain}" == "" ] || [ ${hddGotBlockchain} -eq 0 ]; then
format="ext4"
# test feature: if there is a USB stick as a raid connected, then format in BTRFS an not in EXT4
if [ ${raidCandidates} -eq 1 ] && [ ${raidSizeGB} -gt 14 ]; then
echo
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# EXPERIMENTAL FEATURE: BTRFS + RAID"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# You connected an extra USB thumb drive to your RaspiBlitz."
echo "# This activates the exterimental feature of running BTRFS"
echo "# instead of EXT4 and is still unstable but needs testing."
echo "# PRESS ENTER to continue with BTRFS+RAID setup or press"
echo "# CTRL+C, remove device & call ./30initHDD.sh again."
read key
format="btrfs"
# check that raid cadidate is big enough
# a 32GB drive gets shown with 28GB in mby tests
if [ ${raidSizeGB} -lt 27 ]; then
echo "# FAIL the raid device needs to be at least a 32GB thumb drive."
echo "# Please remove or replace and call ./30initHDD.sh again"
exit 1
fi
elif [ ${raidCandidates} -gt 1 ]; then
echo "# FAIL more then one USB raid drive candidate connected."
echo "# Please max one extra usb drive and the call ./30initHDD.sh again"
exit 1
fi
# now partition/format HDD
echo
if (whiptail --title "FORMAT HDD/SSD" --yesno "The connected hard drive needs to get formatted.\nIMPORTANT: This will delete all data on that drive." 8 56); then
clear
echo "# --> Formatting HDD/SSD ..."
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${format} ${hddCandidate})
if [ ${#error} -gt 0 ]; then
echo "# FAIL blitz.datadrive.sh format --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
fi
else
clear
echo "# Not formatting the HDD/SSD - Setup Process stopped."
echo "# Rearrange your hardware and restart with a fresh sd card again."
exit 1
fi
fi
echo "# OK"
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info
# automatically now add the HDD to the system
./40addHDD.sh

View File

@ -1,165 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
echo ""
echo "# *** 40addHDD.sh ***"
# use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh status --> ${error}"
echo "Please report issue to the raspiblitz github."
exit 1
fi
# temp mount
if [ "$hddFormat" == "btrfs" ]; then
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddCandidate})
else
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${hddPartitionCandidate})
fi
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh tempmount --> ${error}"
echo "Please report issue to the raspiblitz github."
exit 1
fi
# linking drives/directories
echo
echo "# --> Linking drives/directories"
echo "# hddCandidate='${hddCandidate}'"
echo "# hddPartitionCandidate='${hddPartitionCandidate}'"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh link)
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh link --> ${error}"
echo "Please report issue to the raspiblitz github."
exit 1
fi
# adding drives to fstab for permanent mount
echo
echo "# --> Adding the data drive to OS ..."
echo "# hddCandidate='${hddCandidate}'"
echo "# hddPartitionCandidate='${hddPartitionCandidate}'"
echo "# hddFormat='${hddFormat}'"
if [ "$hddFormat" == "btrfs" ]; then
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddCandidate})
else
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddPartitionCandidate})
fi
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh fstab --> ${error}"
echo "Please report issue to the raspiblitz github."
exit 1
fi
# adding RAID drive
echo "# isBTRFS=${isBTRFS}"
echo "# raidCandidates=${raidCandidates}"
if [ ${isBTRFS} -eq 1 ] && [ ${raidCandidates} -eq 1 ]; then
# example string: 'sdb 28 GB SanDisk'
raidDevice=$(echo "${raidCandidate[0]}" | cut -d " " -f 1)
raidSizeGB=$(echo "${raidCandidate[0]}" | cut -d " " -f 2)
echo
echo "# --> Adding Raid Drive ..."
echo "# raidDevice='${raidDevice}'"
echo "# raidSizeGB=${raidSizeGB}"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh raid on ${raidDevice})
if [ ${#error} -gt 0 ]; then
echo "# FAIL blitz.datadrive.sh raid on --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
fi
fi
# init the RASPIBLITZ Config
echo
echo "# --> Init raspiblitz.conf ..."
configFile="/mnt/hdd/raspiblitz.conf"
configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf')
if [ ${configExists} -eq 1 ]; then
# config exists - nothing much to do
echo "# config file already exists on HDD/SSD"
sudo chmod 777 ${configFile}
else
# create file and use init values from raspiblitz.info
echo "# CREATING new ${configFile}"
source /home/admin/_version.info
echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf
echo "raspiBlitzVersion='${codeVersion}'" >> /home/admin/raspiblitz.conf
echo "network=${network}" >> /home/admin/raspiblitz.conf
echo "chain=${chain}" >> /home/admin/raspiblitz.conf
echo "hostname=${hostname}" >> /home/admin/raspiblitz.conf
echo "displayClass=${displayClass}" >> /home/admin/raspiblitz.conf
echo "displayType=${displayType}" >> /home/admin/raspiblitz.conf
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
sudo mv /home/admin/raspiblitz.conf $configFile
sudo chown root:root ${configFile}
sudo chmod 777 ${configFile}
sleep 3
# try to determine publicIP and make sure its in raspiblitz.conf
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
/home/admin/config.scripts/internet.sh update-publicip
fi
# link ssh directory from SD card to HDD
echo "# --> SSH key settings"
echo "# copying SSH pub keys to HDD"
sudo cp -r /etc/ssh /mnt/hdd/ssh
# just copy dont link anymore
# see: https://github.com/rootzoll/raspiblitz/issues/1798
#sudo rm -rf /etc/ssh
#sudo ln -s /mnt/hdd/ssh /etc/ssh
#sudo /home/admin/config.scripts/blitz.systemd.sh update-sshd
echo "# OK"
echo ""
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
# check if HDD contains a blockchain to work with
echo "hddGotBlockchain=${hddGotBlockchain}"
if [ ${hddGotBlockchain} -eq 1 ]; then
echo "# Looks like the HDD is prepared with the Blockchain."
# ask user if prepared blockchain is to use or self-validate
whiptail --title ' Use Blockchain from HDD/SSD? ' --yes-button='Continue' --no-button='DELETE' --yesno "
On the HDD/SSD Blockchain data was found.\n
Continue if you trust that data to be valid.\n
If you dont trust that data you can now choose to delete it - but keep in mind that this can add multiple days of waiting time to your setup process to regain or self-validate the initial blockchain data.
" 14 75
if [ $? -eq 1 ]; then
# DELETE
echo "# Deleting old blockchain data .."
sudo rm -R /mnt/hdd/bitcoin 2>/dev/null
sudo rm -R /mnt/hdd/litecoin 2>/dev/null
# HDD is now empty - let setupBlitz - display next options
echo "# HDD now empty --> follow further setup"
./10setupBlitz.sh
else
# CONTINUE
echo "# Continuing with finishing the system setup ..."
./60finishHDD.sh
fi
else
# HDD is empty - let setupBlitz - display next options
echo "# HDD empty --> follow further setup"
./10setupBlitz.sh
fi

View File

@ -1,256 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
# get local ip
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# Basic Options
OPTIONS=(WINDOWS "Windows" \
MACOS "Apple MacOSX" \
LINUX "Linux" \
BLITZ "RaspiBlitz"
)
CHOICE=$(dialog --clear --title " Copy Blockchain from another laptop/node over LAN " --menu "\nWhich system is running on the other laptop/node you want to copy the blockchain from?\n " 14 60 9 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
case $CHOICE in
MACOS) echo "Steve";;
LINUX) echo "Linus";;
WINDOWS) echo "Bill";;
BLITZ) echo "Satoshi";;
*) exit 1;;
esac
# additional prep if this is used to replace corrupted blockchain
if [ "${setupStep}" = "100" ]; then
# make sure services are not running
echo "stopping services ..."
sudo systemctl stop background
sudo systemctl stop lnd
sudo systemctl stop bitcoind
sudo cp -f /mnt/hdd/bitcoin/bitcoin.conf /home/admin/assets/bitcoin.conf
else
# make sure bitcoind is not running
sudo systemctl stop background <2 /dev/null
sudo systemctl stop bitcoind <2 /dev/null
fi
# check if old blockchain data exists
hasOldBlockchainData=0
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then
hasOldBlockchainData=1
fi
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]')
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
hasOldBlockchainData=1
fi
if [ ${hasOldBlockchainData} -eq 1 ] && [ "$1" != "stop-after-script" ]; then
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
response=$?
echo "response(${response})"
if [ "${response}" = "1" ]; then
echo "OK - keep old blockchain - just try to repair by copying over it"
sleep 3
else
echo "OK - delete old blockchain"
sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null
sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null
sleep 3
fi
fi
# make sure /mnt/hdd/bitcoin exists
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
# allow all users write to it
sudo chmod 777 /mnt/hdd/bitcoin
echo
clear
if [ "${CHOICE}" = "WINDOWS" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a WINDOWS computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR WINDOWS COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your Windows computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your Windows computer & change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on Windows thats: C:\Users\YourUserName\Appdata\Roaming\Bitcoin"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:"
echo "scp -r ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "If asked for a password use PASSWORD A (or 'raspiblitz')."
fi
if [ "${CHOICE}" = "MACOS" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a MacOSX computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR MacOSX COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your MacOSX computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your MacOSX computer and change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on MacOSX thats: cd ~/Library/Application Support/Bitcoin/"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your MacOSX terminal:"
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "You will be asked for passwords. First can be the user password of your MacOSX"
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
fi
if [ "${CHOICE}" = "LINUX" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a LINUX computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR LINUX COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your Linux computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your Linux computer and change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on Linux thats: cd ~/.bitcoin/"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your Linux terminal:"
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "You will be asked for passwords. First can be the user password of your Linux"
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
fi
if [ "${CHOICE}" = "BLITZ" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another RaspiBlitz"
echo "****************************************************************************"
echo ""
echo "The other RaspiBlitz needs a minimum version of 1.6 (if lower, update first)."
echo "Make sure that the other RaspiBlitz is on the same local network."
echo ""
echo "Open a fresh terminal and login per SSH into that other RaspiBlitz."
echo "Once in the main menu go: MAINMENU > REPAIR > COPY-SOURCE"
echo "Follow the given instructions ..."
echo ""
echo "The LOCAL IP of this target RaspiBlitz is: ${localip}"
fi
echo ""
echo "It can take multiple hours until transfer is complete - be patient."
echo "****************************************************************************"
echo "PRESS ENTER if transfers is done OR if you want to choose another option."
sleep 2
read key
# make quick check if data is there
anyDataAtAll=0
quickCheckOK=1
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.dat -type f | wc -l)
if [ ${count} -gt 0 ]; then
echo "Found data in /mnt/hdd/bitcoin/blocks"
anyDataAtAll=1
fi
if [ ${count} -lt 300 ]; then
echo "FAIL: transfer seems invalid - less then 300 .dat files (${count})"
quickCheckOK=0
fi
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.ldb -type f | wc -l)
if [ ${count} -gt 0 ]; then
echo "Found data in /mnt/hdd/bitcoin/chainstate"
anyDataAtAll=1
fi
if [ ${count} -lt 700 ]; then
echo "FAIL: transfer seems invalid - less then 700 .ldb files (${count})"
quickCheckOK=0
fi
echo "*********************************************"
echo "QUICK CHECK RESULT"
echo "*********************************************"
# just if any data transferred ..
if [ ${anyDataAtAll} -eq 1 ]; then
# data was invalid - ask user to keep?
if [ ${quickCheckOK} -eq 0 ]; then
echo "FAIL -> DATA seems incomplete."
else
echo "OK -> DATA LOOKS GOOD :D"
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
fi
else
echo "CANCEL -> NO DATA was copied."
quickCheckOK=0
fi
echo "*********************************************"
# if started with parameter "stop-after-script" - quit here
if [ "$1" == "stop-after-script" ]; then
echo "DONE Copy"
exit 0
fi
# if started after intial setup - quit here
if [ "${setupStep}" = "100" ]; then
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
sudo systemctl enable bitcoind
echo "DONE - rebooting: sudo shutdown -r now"
sudo shutdown -r now
exit 0
fi
# REACT ON QUICK CHECK DURING INITAL SETUP
if [ ${quickCheckOK} -eq 0 ]; then
echo "*********************************************"
echo "There seems to be an invalid transfer."
echo "Wait 5 secs ..."
sleep 5
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
response=$?
echo "response(${response})"
if [ "${response}" == "0" ]; then
/home/admin/50copyHDD.sh
exit 0
fi
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data?" 8 60
response=$?
echo "response(${response})"
case $response in
1) quickCheckOK=1 ;;
esac
fi
if [ ${quickCheckOK} -eq 0 ]; then
echo "Deleting invalid Data ... "
sudo rm -rf /mnt/hdd/bitcoin
sleep 2
fi
# setup script will decide the next logical step
/home/admin/10setupBlitz.sh

View File

@ -1,98 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
# only show warning when bitcoin
if [ "$network" = "bitcoin" ]; then
# detect hardware version of RaspberryPi
# https://www.unixtutorial.org/command-to-confirm-raspberry-pi-model
raspberryPi=$(cat /proc/device-tree/model | cut -d " " -f 3 | sed 's/[^0-9]*//g')
if [ ${#raspberryPi} -eq 0 ]; then
raspberryPi=0
fi
echo "RaspberryPi Model Version: ${raspberryPi}"
if [ ${raspberryPi} -lt 4 ]; then
# raspberryPi 3 and lower
msg=" This old RaspberryPi has very limited CPU power.\n"
msg="$msg To sync & validate the complete blockchain\n"
msg="$msg can take multiple days - even weeks\n"
msg="$msg Its recommended to use another option.\n"
msg="$msg \n"
msg="$msg So do you really want start syncing now?"
dialog --title " WARNING " --yesno "${msg}" 11 57
response=$?
case $response in
0) echo "--> OK";;
1) exit 1;;
255) exit 1;;
esac
fi
fi
# ask if really sync behind TOR
# if [ "${runBehindTor}" = "on" ]; then
# whiptail --title ' Sync Blockchain from behind TOR? ' --yes-button='Public-Sync' --no-button='TOR-Sync' --yesno "You decided to run your node behind TOR and validate the blockchain with your RaspiBlitz - thats good. But downloading the complete blockchain thru TOR can add some extra time (maybe a day) to the process and adds a heavy load on the TOR network.\n
#Your RaspiBlitz can just run the initial blockchain download with your public IP (Public-Sync) but keep your Lighting node safe behind TOR.
#It would speed up the self-validation while not revealing your Lightning node identity. But for most privacy choose (TOR-Sync).
# " 15 76
# if [ $? -eq 0 ]; then
# # set flag to not run bitcoin behind TOR during IDB
# echo "ibdBehindTor=off" >> /home/admin/raspiblitz.info
# fi
#fi
echo "**********************************"
echo "Dont Trust, verify - starting sync"
echo "**********************************"
echo ""
sleep 3
echo "*** Optimizing RAM for Sync ***"
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
echo "dont forget to reduce dbcache once IBD is done" > "/home/admin/selfsync.flag"
# RP4 4GB
if [ ${kbSizeRAM} -gt 3500000 ]; then
echo "Detected RAM >=4GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=3072/g" /home/admin/assets/${network}.conf
# RP4 2GB
elif [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >=2GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=1536/g" /home/admin/assets/${network}.conf
# RP3/4 1GB
else
echo "Detected RAM <=1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /home/admin/assets/${network}.conf
fi
echo ""
echo "*** Activating Blockain Sync ***"
sudo mkdir /mnt/hdd/${network} 2>/dev/null
sudo /home/admin/XXcleanHDD.sh -blockchain -force
sudo -u bitcoin mkdir /mnt/hdd/${network}/blocks 2>/dev/null
sudo -u bitcoin mkdir /mnt/hdd/${network}/chainstate 2>/dev/null
# set so that 10raspiblitz.sh has a flag to see that resync is running
sudo touch /mnt/hdd/${network}/blocks/.selfsync
sudo sed -i "s/^state=.*/state=sync/g" /home/admin/raspiblitz.info
echo "OK - sync is activated"
if [ "${setupStep}" = "100" ]; then
# start servives
echo "reboot needed: shutdown -r now"
else
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=50/g" /home/admin/raspiblitz.info
# continue setup
./60finishHDD.sh
fi

View File

@ -1,89 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
echo ""
echo "*** 60finishHDD.sh ***"
# use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
if [ ${#error} -gt 0 ]; then
echo "# FAIL blitz.datadrive.sh status --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
fi
# check that data drive is mounted
if [ ${isMounted} -eq 0 ]; then
echo "# FAIL - HDD is not mounted."
exit 1
fi
###### COPY BASIC NETWORK CONFIG
echo ""
echo "*** Prepare ${network} ***"
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
sudo mkdir /home/admin/.${network} 2>/dev/null
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
# make sure all files are linked correct
sudo /home/admin/config.scripts/blitz.datadrive.sh link
# BLITZ WEB SERVICE
/home/admin/config.scripts/blitz.web.sh on
###### ACTIVATE TOR IF SET DURING SETUP
if [ "${runBehindTor}" = "on" ]; then
echo "runBehindTor --> ON"
sudo /home/admin/config.scripts/internet.tor.sh on
# but if IBD is allowed to be public switch off TOR just fro bitcoin
# until IBD is done. background service will after that switch TOR on
if [ "${ibdBehindTor}" = "off" ]; then
echo "ibdBehindTor --> OFF"
sudo /home/admin/config.scripts/internet.tor.sh btcconf-off
else
echo "ibdBehindTor --> ON"
fi
else
echo "runBehindTor --> OFF"
fi
###### START NETWORK SERVICE
echo ""
echo "*** Start ${network} ***"
echo "- This can take a while .."
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
#sudo chmod +x /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload
sudo systemctl enable ${network}d.service
sudo systemctl start ${network}d.service
# check if bitcoin has started
bitcoinRunning=0
loopcount=0
while [ ${bitcoinRunning} -eq 0 ]
do
>&2 echo "# (${loopcount}/200) checking if ${network}d is running ... "
bitcoinRunning=$(${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
sleep 2
sync
loopcount=$(($loopcount +1))
if [ ${loopcount} -gt 200 ]; then
/home/admin/XXdebugLogs.sh
echo "***********************************"
echo "FAIL: ${network} failed to start :("
echo "Get support or try again the command: raspiblitz"
exit 1
fi
done
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info
./10setupBlitz.sh

View File

@ -1,489 +0,0 @@
#!/bin/bash
## get basic info
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
echo ""
echo "*** 70initLND.sh ***"
# CHECK #########
echo "*** Check Basic Config ***"
if [ ${#network} -eq 0 ]; then
echo "FAIL - missing: network"
exit 1
fi
if [ ${#chain} -eq 0 ]; then
echo "FAIL - missing: chain"
exit 1
fi
# CHECK #########
echo "*** Check ${network} Running ***"
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
bitcoinRunning=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | grep -c verificationprogress)
fi
if [ ${bitcoinRunning} -eq 0 ]; then
whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "Service ${network}d is not running." 8 50
if [ $? -eq 0 ]; then
/home/admin/70initLND.sh
else
/home/admin/XXdebugLogs.sh
fi
exit 1
fi
# CHECK #########
echo "*** Check ${network} Responding *** (can take a while)"
chainIsReady=0
loopCount=0
while [ ${chainIsReady} -eq 0 ]
do
loopCount=$(($loopCount +1))
result=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>error.out)
error=$(cat error.out)
rm error.out
if [ ${#error} -gt 0 ]; then
if [ ${loopCount} -gt 33 ]; then
echo "*** TAKES LONGER THEN EXCEPTED ***"
date +%s
echo "result(${result})"
echo "error(${error})"
testnetAdd=""
if [ "${chain}" = "test" ]; then
testnetAdd="testnet3/"
fi
sudo tail -n 5 /mnt/hdd/${network}/${testnetAdd}debug.log
echo "If you see an error -28 relax, just give it some time."
echo "Waiting 1 minute and then trying again ..."
sleep 60
else
echo "(${loopCount}/33) still waiting .."
sleep 10
fi
else
echo "OK - chainnetwork is working"
echo ""
chainIsReady=1
break
fi
done
# CHECK #########
echo "*** Check LND Config ***"
configExists=$( sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c lnd.conf )
if [ ${configExists} -eq 0 ]; then
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
echo ""
###### Init LND service & start
echo "*** Init LND Service & Start ***"
lndRunning=$(sudo systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
echo "stopping lnd .."
sudo systemctl stop lnd 2>/dev/null
sudo systemctl disable lnd 2>/dev/null
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
#sudo chmod +x /etc/systemd/system/lnd.service
###### ACTIVATE TOR IF SET DURING SETUP
if [ "${runBehindTor}" = "on" ]; then
echo "TOR was selected"
sudo /home/admin/config.scripts/internet.tor.sh lndconf-on
else
echo "TOR was not selected"
fi
echo "Starting LND Service ..."
sudo systemctl enable lnd
sudo systemctl start lnd
echo ""
echo "waiting ."
sleep 10
echo "waiting .."
sleep 10
echo "waiting ..."
sleep 10
dialog --pause " Starting LND - please wait .." 8 58 90
fi
###### Check LND starting
while [ ${lndRunning} -eq 0 ]
do
lndRunning=$(sudo systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
date +%s
echo "LND not ready yet ... waiting another 60 seconds."
echo "If this takes too long (more then 10min total) --> CTRL+c and report Problem"
sleep 60
fi
done
echo "OK - LND is running"
echo ""
###### Check LND health/fails (to be extended)
fail=""
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert")
if [ ${tlsExists} -eq 0 ]; then
fail="LND was starting, but missing /mnt/hdd/lnd/tls.cert"
fi
if [ ${#fail} -gt 0 ]; then
whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "${fail}" 8 50
if [ $? -eq 0 ]; then
/home/admin/70initLND.sh
else
/home/admin/XXdebugLogs.sh
fi
exit 1
fi
###### Instructions on Creating/Restoring LND Wallet
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
echo "walletExists(${walletExists})"
sleep 2
if [ ${walletExists} -eq 0 ]; then
# UI: Ask if user wants NEW wallet or RECOVER a wallet
OPTIONS=(NEW "Setup a brand new Lightning Node (DEFAULT)" \
OLD "I had an old Node I want to recover/restore")
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
echo "choice($CHOICE)"
if [ "${CHOICE}" == "NEW" ]; then
############################
# NEW WALLET
############################
# let user enter password c
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
sudo touch /var/cache/raspiblitz/.pass.tmp
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /var/cache/raspiblitz/.pass.tmp
passwordC=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
# make sure passwordC is set
if [ ${#passwordC} -eq 0 ]; then
/home/admin/70initLND.sh
exit 1
fi
# generate wallet with seed and set passwordC
clear
echo "Generating new Wallet ...."
sudo touch /var/cache/raspiblitz/.seed.tmp
sudo chown admin:admin /var/cache/raspiblitz/.seed.tmp
python3 /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /var/cache/raspiblitz/.seed.tmp
source /var/cache/raspiblitz/.seed.tmp
sudo shred -u /var/cache/raspiblitz/.seed.tmp 2>/dev/null
# in case of error - retry
if [ ${#err} -gt 0 ]; then
whiptail --title "lnd.initwallet.py - ERROR" --msgbox "${err}" 8 50
/home/admin/70initLND.sh
exit 1
else
if [ ${#seedwords} -eq 0 ]; then
echo "FAIL!! -> MISSING seedwords data - but also no err data ?!?"
echo "CHECK output data above - PRESS ENTER to restart 70initLND.sh"
read key
/home/admin/70initLND.sh
exit 1
fi
fi
if [ ${#seedwords6x4} -eq 0 ]; then
seedwords6x4="${seedwords}"
fi
ack=0
while [ ${ack} -eq 0 ]
do
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox "LND Wallet got created. Store these numbered words in a safe location:\n\n${seedwords6x4}" 12 76
whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55
if [ $? -eq 1 ]; then
ack=1
fi
done
if [ ${setupStep} -lt 100 ]; then
sudo sed -i "s/^setupStep=.*/setupStep=65/g" /home/admin/raspiblitz.info
fi
echo "waiting ."
sleep 10
else
############################
# RECOVER OLD WALLET
############################
OPTIONS=(LNDRESCUE "LND tar.gz-Backupfile (BEST)" \
SEED+SCB "Seed & channel.backup file (OK)" \
ONLYSEED "Only Seed Word List (FALLBACK)")
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
# LND RESCUE
if [ "${CHOICE}" == "LNDRESCUE" ]; then
sudo /home/admin/config.scripts/lnd.rescue.sh restore
echo ""
echo "PRESS ENTER to continue."
read key
/home/admin/70initLND.sh
exit 1
fi
# WARNING ON ONLY SEED
if [ "${CHOICE}" == "ONLYSEED" ]; then
# let people know about the difference between SEED & SEED+SCB
whiptail --title "IMPORTANT INFO" --yes-button "Continue" --no-button "Go Back" --yesno "
Using JUST SEED WORDS will only recover your on-chain funds.
To also try to recover the open channel funds you need the
channel.backup file (since RaspiBlitz v1.2 / LND 0.6-beta)
or having a complete LND rescue-backup from your old node.
" 11 65
if [ $? -eq 1 ]; then
/home/admin/70initLND.sh
exit 1
fi
fi
# IF SEED and SCB - make user upload channel.backup file now
# and it will get automated activated after syns are ready
# TODO: later activate directly with call to lnd.iniwallet.py
if [ "${CHOICE}" == "SEED+SCB" ]; then
# let lnd.rescue script do the upload process
/home/admin/config.scripts/lnd.rescue.sh scb-up
# check exit code of script
if [ $? -eq 1 ]; then
echo "USER CANCEL --> back to menu"
/home/admin/70initLND.sh
exit 1
else
clear
echo "channel.backup will get checked/activated after blockchain/lightning is synced"
sleep 2
echo "NEXT --> Set password for new LND wallet"
sleep 3
fi
fi
clear
# let user enter password c
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
sudo touch /var/cache/raspiblitz/.pass.tmp
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /var/cache/raspiblitz/.pass.tmp
passwordC=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
# get seed word list
if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then
wordsCorrect=0
while [ ${wordsCorrect} -eq 0 ]
do
# dialog to enter
sudo touch /var/cache/raspiblitz/.seed.tmp
sudo chown admin:admin /var/cache/raspiblitz/.seed.tmp
dialog --backtitle "RaspiBlitz - LND Recover" --inputbox "Please enter/paste the SEED WORD LIST:\n(just the words, seperated by spaces, in correct order as numbered)" 9 78 2>/var/cache/raspiblitz/.seed.tmp
wordstring=$( cat /var/cache/raspiblitz/.seed.tmp | sed 's/[^a-zA-Z0-9 ]//g' )
shred -u /var/cache/raspiblitz/.seed.tmp
echo "processing ... ${wordstring}"
# check correct number of words
wordcount=$(echo "${wordstring}" | wc -w)
if [ ${wordcount} -eq 24 ]; then
echo "OK - 24 words"
wordsCorrect=1
else
whiptail --title " WARNING " \
--yes-button "Try Again" \
--no-button "Cancel" \
--yesno "
The word list has ${wordcount} words. But it must be 24.
Please check your list and try again.
Best is to write words in external editor
and then copy and paste them into dialog.
The Word list should look like this:
wordone wordtweo wordthree ...
" 16 52
if [ $? -eq 1 ]; then
/home/admin/70initLND.sh
exit 1
fi
fi
done
# ask if seed was protected by password D
passwordD=""
dialog --title "SEED PASSWORD" --yes-button "No extra Password" --no-button "Yes" --yesno "
Are your seed words protected by an extra password?
During wallet creation LND offers to set an extra password
to protect the seed words. Most users did not set this.
" 11 65
if [ $? -eq 1 ]; then
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
sudo touch /var/cache/raspiblitz/.pass.tmp
sudo chown admin:admin /var/cache/raspiblitz/.pass.tmp
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Enter extra Password D" /var/cache/raspiblitz/.pass.tmp empty-allowed
passwordD=$(sudo cat /var/cache/raspiblitz/.pass.tmp)
sudo shred -u /var/cache/raspiblitz/.pass.tmp 2>/dev/null
fi
fi
# FOR NOW: let channel.backup file get activated by lncli after syncs
# LATER: make different call to lnd.initwallet.py
if [ "${CHOICE}" == "SEED+SCB" ] || [ "${CHOICE}" == "ONLYSEED" ]; then
# trigger wallet recovery
source <(python3 /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${wordstring}" ${passwordD} 2>/dev/null)
# check if wallet was created for real
if [ ${#err} -eq 0 ]; then
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
if [ ${walletExists} -eq 0 ]; then
err="Was not able to create wallet (unknown error)."
fi
fi
# set fundRecovery=1 in raspiblitz.info
sed -i "s/^fundRecovery=.*/fundRecovery=1/g" /home/admin/raspiblitz.info
# user feedback
if [ ${#err} -eq 0 ]; then
dialog --title " SUCCESS " --msgbox "
Looks good :) LND was able to recover the wallet.
IMPORTANT: LND needs now to scan the blockchain
for your funds - this can take some extra time.
" 10 60
clear
else
whiptail --title " FAIL " --msgbox "
Something went wrong - see info below:
${err}
${errMore}
" 13 72
clear
echo "Restarting LND Wallet Setup .."
sleep 2
echo
/home/admin/70initLND.sh
exit 1
fi
fi
fi # END OLD WALLET
else
echo "OK - LND wallet already exists."
fi
echo "waiting .."
sleep 10
dialog --pause " Waiting for LND - please wait .." 8 58 45
############################
# Copy LND macaroons to admin
############################
clear
echo ""
echo "*** Copy LND Macaroons to user admin ***"
# check if macaroon exists and if not try to unlock LND wallet first
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
/home/admin/config.scripts/lnd.unlock.sh
sleep 3
fi
# check if macaroon exists now - if not fail
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon
echo ""
echo "FAIL - LND Macaroons not created"
echo "Please check the following LND issue:"
echo "https://github.com/lightningnetwork/lnd/issues/890"
echo "You may want try again with starting ./70initLND.sh"
exit 1
fi
# copy macaroons to all needed users
sudo /home/admin/config.scripts/lnd.credentials.sh sync
echo "OK - LND Macaroons created and copied"
echo ""
###### Unlock Wallet (if needed)
echo "*** Check Wallet Lock ***"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "OK - Wallet is locked ... starting unlocking dialog"
/home/admin/config.scripts/lnd.unlock.sh
else
echo "OK - Wallet is already unlocked"
fi
echo ""
if [ ${setupStep} -lt 100 ]; then
# set SetupState (scan is done - so its 80%)
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
###### finishSetup
sudo /home/admin/90finishSetup.sh
sudo /home/admin/95finalSetup.sh
else
# its important that RaspiBlitz dont get rebooted
# before LND rescan is finished
whiptail --title "RESET DONE" --msgbox "
OK LND Reset is done.
You may now give it
extra time to rescan.
" 10 25
fi

View File

@ -1,274 +0,0 @@
#!/bin/bash
source /home/admin/_version.info
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# all system/service info gets detected by blitz.statusscan.sh
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
source <(sudo /home/admin/config.scripts/internet.sh status)
# when admin and no other error found run LND setup check
if [ "$USER" == "admin" ] && [ ${#lndErrorFull} -eq 0 ]; then
lndErrorFull=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err=" | tail -1)
fi
# set follow up info different for LCD and ADMIN
adminStr="ssh admin@${localip} ->Password A"
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
####################
height=6
width=43
title="Blockchain Info"
if [ ${#bitcoinErrorShort} -eq 0 ]; then
bitcoinErrorShort="Initial Startup - Please Wait"
fi
if [ "$USER" != "admin" ]; then
if [ ${uptime} -gt 600 ]; then
if [ ${uptime} -gt 1000 ] || [ ${#bitcoinErrorFull} -gt 0 ] || [ "${1}" == "blockchain-error" ]; then
infoStr=" The ${network}d service is NOT RUNNING!\n ${bitcoinErrorShort}\n Login for more details & options:"
else
infoStr=" The ${network}d service is running:\n ${bitcoinErrorShort}\n Login with SSH for more details:"
fi
else
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Login with SSH for more details:"
fi
else
# output when user login in as admin and bitcoind is not running
if [ ${uptime} -lt 600 ]; then
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Please wait at least 10min ..."
elif [[ "${bitcoinErrorFull}" == *"error code: -28"* ]]; then
infoStr=" The ${network}d service is warming up:\n ${bitcoinErrorShort}\n Please wait ..."
elif [ ${#bitcoinErrorFull} -gt 0 ] || [ "${bitcoinErrorShort}" == "Error found in Logs" ] || [ "${1}" == "blockchain-error" ]; then
clear
echo ""
echo "*****************************************"
echo "* The ${network}d service is not running."
echo "*****************************************"
echo "If you just started some config/setup, this might be OK."
echo
if [ ${startcountBlockchain} -gt 1 ]; then
echo "${startcountBlockchain} RESTARTS DETECTED - ${network}d might be in a error loop"
cat /home/admin/systemd.blockchain.log | grep "ERROR" | tail -n -1
echo
fi
if [ ${#bitcoinErrorFull} -gt 0 ]; then
echo "More Error Detail:"
echo ${bitcoinErrorFull}
echo
fi
echo "POSSIBLE OPTIONS:"
source <(/home/admin/config.scripts/network.txindex.sh status)
if [ "${txindex}" == "1" ]; then
echo "-> Use command 'repair' and then choose 'DELETE-INDEX' to try rebuilding transaction index."
fi
echo "-> Use command 'repair' and then choose 'RESET-CHAIN' to try downloading new blockchain."
echo "-> Use command 'debug' for more log output you can use for getting support."
echo "-> Use command 'menu' to open main menu."
echo "-> Have you tried to turn it off and on again? Use command 'restart'"
echo ""
exit 1
fi
fi
# LND errors second
elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ] || [ "${1}" == "lightning-error" ]; then
####################
# On LND Error
####################
height=6
width=43
title="Lightning Info"
if [ ${uptime} -gt 600 ] || [ "${1}" == "lightning-error" ]; then
if [ ${#lndErrorShort} -gt 0 ]; then
height=6
lndErrorShort=" ${lndErrorShort}\n"
fi
if [ ${lndActive} -eq 0 ]; then
infoStr=" The LND service is not running.\n${lndErrorShort} Login for more details:"
else
infoStr=" The LND service is running with error.\n${lndErrorShort} Login for more details:"
fi
if [ "$USER" == "admin" ]; then
clear
echo ""
echo "****************************************"
if [ ${lndActive} -eq 0 ]; then
echo "* The LND service is not running."
else
echo "* The LND service is running with error."
fi
echo "****************************************"
echo "If you just started some config/setup, this might be OK."
echo
if [ ${startcountLightning} -gt 1 ]; then
echo "${startcountLightning} RESTARTS DETECTED - LND might be in a error loop"
cat /home/admin/systemd.lightning.log | grep "ERROR" | tail -n -1
fi
sudo journalctl -u lnd -b --no-pager -n14 | grep "lnd\["
sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err="
if [ ${#lndErrorFull} -gt 0 ]; then
echo "More Error Detail:"
echo ${lndErrorFull}
fi
echo
echo "-> Use command 'repair' and then choose 'BACKUP-LND' to make a just in case backup."
echo "-> Use command 'debug' for more log output you can use for getting support."
echo "-> Use command 'menu' to open main menu."
echo "-> Have you tried to turn it off and on again? Use command 'restart'"
echo ""
exit 1
else
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
if [ ${wallet} -eq 0 ] || [ ${macaroon} -eq 0 ] || [ ${config} -eq 0 ] || [ ${tls} -eq 0 ]; then
infoStr=" The LND service needs RE-SETUP.\n Login with SSH to continue:"
fi
fi
else
infoStr=" The LND service is starting.\n Login for more details:"
if [ "$USER" == "admin" ]; then
infoStr=" The LND service is starting.\n Please wait up to 5min ..."
fi
fi
# if LND wallet is locked
elif [ ${walletLocked} -gt 0 ]; then
height=5
width=43
if [ "${autoUnlock}" = "on" ]; then
title="Auto Unlock"
infoStr=" Waiting for Wallet Auto-Unlock.\n Please wait up to 5min ..."
else
if [ "$USER" == "admin" ]; then
/home/admin/config.scripts/lnd.unlock.sh
else
title="Action Required"
infoStr=" LND WALLET IS LOCKED !!!\n"
if [ "${rtlWebinterface}" = "on" ]; then
height=6
infoStr="${infoStr} Browser: http://${localip}:3000\n PasswordB=login / PasswordC=unlock"
else
infoStr="${infoStr} Please use SSH to unlock:"
fi
if [ ${startcountLightning} -gt 1 ]; then
width=45
height=$((height+3))
infoStr=" LIGHTNING RESTARTED - login for details\n${infoStr}"
adminStr="${adminStr}\n or choose 'INFO' in main menu\n or type 'raspiblitz' on terminal"
fi
fi
fi
else
####################
# Sync Progress
####################
# check number of peers
source <(sudo -u admin /home/admin/config.scripts/network.monitor.sh peer-status)
# basic dialog info
height=6
width=45
title="Node is Syncing"
actionString="Please wait - this can take some time"
# formatting BLOCKCHAIN SYNC PROGRESS
if [ ${#syncProgress} -eq 0 ]; then
if [ ${startcountBlockchain} -lt 2 ]; then
syncProgress="waiting"
else
syncProgress="${startcountBlockchain} restarts"
actionString="Login with SSH for more details:"
fi
elif [ ${#syncProgress} -lt 6 ]; then
syncProgress=" ${syncProgress} % ${peers} peers"
else
syncProgress="${syncProgress} % ${peers} peers"
fi
# formatting LIGHTNING SCAN PROGRESS
if [ ${#scanProgress} -eq 0 ]; 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"
actionString="Login with SSH for more details:"
# check if a specific error can be identified for restarts
lndSetupErrorCount=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep -c "err=")
if [ ${lndSetupErrorCount} -gt 0 ]; then
scanProgress="possible error"
fi
# unkown cases
else
scanProgress="waiting"
fi
elif [ ${#scanProgress} -lt 6 ]; then
scanProgress=" ${scanProgress} % ${lndPeers} peers"
else
scanProgress="${scanProgress} % ${lndPeers} peers"
fi
# setting info string
infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n ${actionString}"
fi
# display info to user
dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width}

View File

@ -1,65 +0,0 @@
#!/bin/bash
echo ""
# add bonus scripts (auto install deactivated to reduce third party repos)
/home/admin/91addBonus.sh
###### SWAP File
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isSwapExternal} -eq 0 ]; then
echo "No external SWAP found - creating ... "
sudo /home/admin/config.scripts/blitz.datadrive.sh swap on
else
echo "SWAP already OK"
fi
####### FIREWALL - just install (not configure)
echo ""
echo "*** Setting and Activating Firewall ***"
echo "deny incoming connection on other ports"
sudo ufw default deny incoming
echo "allow outgoing connections"
sudo ufw default allow outgoing
echo "allow: ssh"
sudo ufw allow ssh
echo "allow: bitcoin testnet"
sudo ufw allow 18333 comment 'bitcoin testnet'
echo "allow: bitcoin mainnet"
sudo ufw allow 8333 comment 'bitcoin mainnet'
echo "allow: litecoin mainnet"
sudo ufw allow 9333 comment 'litecoin mainnet'
echo 'allow: lightning testnet'
sudo ufw allow 19735 comment 'lightning testnet'
echo "allow: lightning mainnet"
sudo ufw allow 9735 comment 'lightning mainnet'
echo "allow: lightning gRPC"
sudo ufw allow 10009 comment 'lightning gRPC'
echo "allow: lightning REST API"
sudo ufw allow 8080 comment 'lightning REST API'
echo "allow: transmission"
sudo ufw allow 49200:49250/tcp comment 'rtorrent'
echo "allow: public web HTTP"
sudo ufw allow from any to any port 80 comment 'allow public web HTTP'
echo "allow: local web admin HTTPS"
sudo ufw allow from 10.0.0.0/8 to any port 443 comment 'allow local LAN HTTPS'
sudo ufw allow from 172.16.0.0/12 to any port 443 comment 'allow local LAN HTTPS'
sudo ufw allow from 192.168.0.0/16 to any port 443 comment 'allow local LAN HTTPS'
echo "open firewall for auto nat discover (see issue #129)"
sudo ufw allow proto udp from 10.0.0.0/8 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
sudo ufw allow proto udp from 172.16.0.0/12 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
sudo ufw allow proto udp from 192.168.0.0/16 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# update system
echo ""
echo "*** Update System ***"
sudo apt-mark hold raspberrypi-bootloader
sudo apt-get update -y
echo "OK - System is now up to date"
# mark setup is done
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info

View File

@ -1,12 +0,0 @@
mkdir /home/admin/tmpScriptDL
cd /home/admin/tmpScriptDL
echo "installing bash completion for bitcoin-cli and lncli"
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
sudo cp *.bash-completion /etc/bash_completion.d/
echo "OK - bash completion available after next login"
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
rm -r /home/admin/tmpScriptDL
cd

View File

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

View File

@ -155,7 +155,7 @@ clear
echo "creating install info ..." echo "creating install info ..."
case $CHOICE in case $CHOICE in
CLOSE) CLOSE)
exit 1; exit 0;
;; ;;
SPHINX) SPHINX)
if [ "${sphinxrelay}" != "on" ]; then if [ "${sphinxrelay}" != "on" ]; then
@ -173,7 +173,7 @@ case $CHOICE in
fi fi
# make pairing thru sphinx relay script # make pairing thru sphinx relay script
/home/admin/config.scripts/bonus.sphinxrelay.sh menu /home/admin/config.scripts/bonus.sphinxrelay.sh menu
exit 1; exit 0;
;; ;;
ZAP_IOS) ZAP_IOS)
appstoreLink="https://apps.apple.com/us/app/zap-bitcoin-lightning-wallet/id1406311960" appstoreLink="https://apps.apple.com/us/app/zap-bitcoin-lightning-wallet/id1406311960"
@ -206,7 +206,7 @@ Or scan the qr code on the LCD with your mobile phone.
choose_IP_or_TOR choose_IP_or_TOR
fi fi
/home/admin/config.scripts/bonus.lndconnect.sh zap-ios ${connect} /home/admin/config.scripts/bonus.lndconnect.sh zap-ios ${connect}
exit 1; exit 0;
;; ;;
ZAP_ANDROID) ZAP_ANDROID)
appstoreLink="https://play.google.com/store/apps/details?id=zapsolutions.zap" appstoreLink="https://play.google.com/store/apps/details?id=zapsolutions.zap"
@ -229,7 +229,7 @@ Or scan the qr code on the LCD with your mobile phone.
choose_IP_or_TOR choose_IP_or_TOR
fi fi
/home/admin/config.scripts/bonus.lndconnect.sh zap-android ${connect} /home/admin/config.scripts/bonus.lndconnect.sh zap-android ${connect}
exit 1; exit 0;
;; ;;
SENDMANY_ANDROID) SENDMANY_ANDROID)
@ -241,7 +241,7 @@ To use the chat feature of the SendMany app, you need to activate the Keysend fe
Please go to MAINMENU > SERVICES and activate KEYSEND first. Please go to MAINMENU > SERVICES and activate KEYSEND first.
" 12 65 " 12 65
exit 1 exit 0
fi fi
appstoreLink="https://github.com/fusion44/sendmany/releases" appstoreLink="https://github.com/fusion44/sendmany/releases"
@ -256,7 +256,7 @@ Please go to MAINMENU > SERVICES and activate KEYSEND first.
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
checkIP2TOR LND-GRPC-API checkIP2TOR LND-GRPC-API
/home/admin/config.scripts/bonus.lndconnect.sh sendmany-android ${connect} /home/admin/config.scripts/bonus.lndconnect.sh sendmany-android ${connect}
exit 1; exit 0;
;; ;;
ZEUS_IOS) ZEUS_IOS)
appstoreLink="https://testflight.apple.com/join/gpVFzEHN" appstoreLink="https://testflight.apple.com/join/gpVFzEHN"
@ -271,7 +271,7 @@ Please go to MAINMENU > SERVICES and activate KEYSEND first.
fi fi
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
/home/admin/config.scripts/bonus.lndconnect.sh zeus-ios tor /home/admin/config.scripts/bonus.lndconnect.sh zeus-ios tor
exit 1; exit 0;
;; ;;
ZEUS_ANDROID) ZEUS_ANDROID)
appstoreLink="https://play.google.com/store/apps/details?id=app.zeusln.zeus" appstoreLink="https://play.google.com/store/apps/details?id=app.zeusln.zeus"
@ -290,7 +290,7 @@ Or scan the qr code on the LCD with your mobile phone.
fi fi
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
/home/admin/config.scripts/bonus.lndconnect.sh zeus-android tor /home/admin/config.scripts/bonus.lndconnect.sh zeus-android tor
exit 1; exit 0;
;; ;;
FULLY_NODED) FULLY_NODED)
appstoreLink="https://apps.apple.com/us/app/fully-noded/id1436425586" appstoreLink="https://apps.apple.com/us/app/fully-noded/id1436425586"
@ -309,6 +309,6 @@ Or scan the qr code on the LCD with your mobile phone.
fi fi
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
/home/admin/config.scripts/bonus.fullynoded.sh /home/admin/config.scripts/bonus.fullynoded.sh
exit 1; exit 0;
;; ;;
esac esac

View File

@ -26,14 +26,14 @@ elif [ "${CHOICE}" = "RESYNC" ]; then
dialog --pause "OK. System will reboot to activate changes." 8 58 8 dialog --pause "OK. System will reboot to activate changes." 8 58 8
clear clear
echo "rebooting .. (please wait)" echo "rebooting .. (please wait)"
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
elif [ "${CHOICE}" = "REINDEX" ]; then elif [ "${CHOICE}" = "REINDEX" ]; then
echo "Starting REINDEX ..." echo "Starting REINDEX ..."
sudo /home/admin/config.scripts/network.reindex.sh sudo /home/admin/config.scripts/network.reindex.sh
elif [ "${CHOICE}" = "BACKUP" ]; then 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." echo "PRESS ENTER to continue."
read key read key

View File

@ -20,7 +20,7 @@ Download LND Data Backup now?
echo "*************************************" echo "*************************************"
echo "please wait .." echo "please wait .."
sleep 2 sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup /home/admin/config.scripts/lnd.backup.sh lnd-export-gui
echo echo
echo "PRESS ENTER to continue once you are done downloading." echo "PRESS ENTER to continue once you are done downloading."
read key read key
@ -31,7 +31,7 @@ Download LND Data Backup now?
echo "*************************************" echo "*************************************"
echo "please wait .." echo "please wait .."
sleep 2 sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup no-download /home/admin/config.scripts/lnd.backup.sh lnd-export
fi fi
} }
@ -46,123 +46,6 @@ RaspiBlitz image to your SD card.
" 12 40 " 12 40
} }
copyHost()
{
clear
echo
echo "# *** Copy Blockchain Source Modus ***"
echo "# get IP of RaspiBlitz to copy to ..."
targetIP=$(whiptail --inputbox "\nPlease enter the LOCAL IP of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title " Target IP " --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
targetIP=$(echo "${targetIP[0]}")
localIP=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
if [ ${#targetIP} -eq 0 ]; then
return
fi
if [ "${localIP}" == "${targetIP}" ]; then
whiptail --msgbox "Dont type in the local IP of this RaspiBlitz,\nthe LOCAL IP of the other RaspiBlitz is needed." 8 54 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
canPingIP=$(ping ${targetIP} -c 1 | grep -c "1 received")
if [ ${canPingIP} -eq 0 ]; then
whiptail --msgbox "Was not able to contact/ping: ${targetIP}\n\n- check if IP of target RaspiBlitz is correct.\n- check to be on the same local network.\n- try again ..." 11 58 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
echo "# get Password of RaspiBlitz to copy to ..."
targetPassword=$(whiptail --passwordbox "\nPlease enter the PASSWORD A of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title "Target Password" --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
if [ ${#targetPassword} -eq 0 ]; then
return
fi
sudo rm /root/.ssh/known_hosts 2>/dev/null
canLogin=$(sudo sshpass -p "${targetPassword}" ssh -t -o StrictHostKeyChecking=no bitcoin@${targetIP} "echo 'working'" 2>/dev/null | grep -c 'working')
if [ ${canLogin} -eq 0 ]; then
whiptail --msgbox "Password was not working for IP: ${targetIP}\n\n- check thats the correct IP for correct RaspiBlitz\n- check that you used PASSWORD A and had no typo\n- If you tried too often, wait 1h try again" 11 58 "" --title " Testing Target Password " --backtitle "RaspiBlitz - Copy Blockchain"
return
fi
echo "# stopping services ..."
sudo systemctl stop background
sudo systemctl stop lnd
sudo systemctl stop ${network}d
sudo systemctl disable ${network}d
sleep 5
sudo systemctl stop bitcoind 2>/dev/null
clear
echo
echo "# Starting copy over LAN (around 4-6 hours) ..."
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
cd /mnt/hdd/${network}
# transfere beginning flag
date +%s > /home/admin/copy_begin.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_begin.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
sudo rm -f /home/admin/copy_begin.time
# repeat the syncing of directories until
# a) there are no files left to transfere (be robust against failing connections, etc)
# b) the user hits a key to break loop after report
while :
do
# transfere blockchain data
rm -f ./transferred.rsync
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 --log-file=./transferred.rsync ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
# check result
# the idea is even after successfull transfer the loop will run a second time
# but on the second time there will be no files transfered (log lines are below 4)
# thats the signal that its done
linesInLogFile=$(wc -l ./transferred.rsync | cut -d " " -f 1)
if [ ${linesInLogFile} -lt 4 ]; then
echo ""
echo "OK all files transfered. DONE"
sleep 2
break
fi
# wait 20 seconds for user exiting loop
echo ""
echo -en "OK on sync loop done ... will test in another if all was transferred."
echo -en "PRESS X TO MANUALLY FINISH SYNCING"
read -n 1 -t 6 keyPressed
if [ "${keyPressed}" = "x" ]; then
echo ""
echo "Ending Sync ..."
sleep 2
break
fi
done
# transfere end flag
sed -i "s/^state=.*/state=/g" /home/admin/raspiblitz.info
date +%s > /home/admin/copy_end.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_end.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
sudo rm -f /home/admin/copy_end.time
echo "# start services again ..."
sudo systemctl enable ${network}d
sudo systemctl start ${network}d
sudo systemctl start lnd
sudo systemctl start background
echo "# show final message"
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"
}
# when called with parameter "sourcemode"
if [ "$1" == "sourcemode" ]; then
copyHost
raspiblitz
exit 0
fi
# Basic Options # Basic Options
#OPTIONS=(HARDWARE "Run Hardwaretest" \ #OPTIONS=(HARDWARE "Run Hardwaretest" \
OPTIONS=(SOFTWARE "Run Softwaretest (DebugReport)" \ OPTIONS=(SOFTWARE "Run Softwaretest (DebugReport)" \
@ -184,16 +67,16 @@ case $CHOICE in
# HARDWARE) # HARDWARE)
# ;; # ;;
SOFTWARE) SOFTWARE)
sudo /home/admin/XXdebugLogs.sh sudo /home/admin/config.scripts/blitz.debug.sh
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key
;; ;;
BACKUP-LND) BACKUP-LND)
sudo /home/admin/config.scripts/lnd.rescue.sh backup sudo /home/admin/config.scripts/lnd.backup.sh lnd-export-gui
echo echo
echo "Press ENTER when your backup download is done to shutdown." echo "Press ENTER when your backup download is done to shutdown."
read key read key
/home/admin/XXshutdown.sh /home/admin/config.scripts/blitz.shutdown.sh
;; ;;
MIGRATION) MIGRATION)
sudo /home/admin/config.scripts/blitz.migration.sh "export-gui" sudo /home/admin/config.scripts/blitz.migration.sh "export-gui"
@ -225,7 +108,7 @@ case $CHOICE in
# make sure host is named like in the raspiblitz config # make sure host is named like in the raspiblitz config
echo "Setting the Name/Alias/Hostname .." echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh ${result} sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${result}
sudo sed -i "s/^hostname=.*/hostname=${result}/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^hostname=.*/hostname=${result}/g" /mnt/hdd/raspiblitz.conf
echo "stopping lnd ..." echo "stopping lnd ..."
@ -235,7 +118,7 @@ case $CHOICE in
# go back to main menu (and show) # go back to main menu (and show)
/home/admin/00raspiblitz.sh /home/admin/00raspiblitz.sh
exit 1; exit 0;
;; ;;
RESET-HDD) RESET-HDD)
askBackupCopy askBackupCopy
@ -253,14 +136,14 @@ case $CHOICE in
;; ;;
DELETE-ELEC) DELETE-ELEC)
/home/admin/config.scripts/bonus.electrs.sh off deleteindex /home/admin/config.scripts/bonus.electrs.sh off deleteindex
exit 1; exit 0;
;; ;;
DELETE-INDEX) DELETE-INDEX)
/home/admin/config.scripts/network.txindex.sh delete /home/admin/config.scripts/network.txindex.sh delete
exit 1; exit 0;
;; ;;
COPY-SOURCE) COPY-SOURCE)
copyHost /home/admin/config.scripts/blitz.copychain.sh source
/home/admin/config.scripts/lnd.unlock.sh /home/admin/config.scripts/lnd.unlock.sh
;; ;;
esac esac

117
home.admin/99clnMenu.sh Normal file
View File

@ -0,0 +1,117 @@
#!/bin/bash
# get raspiblitz config
echo "# get raspiblitz config"
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1)
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO
HEIGHT=14
WIDTH=64
CHOICE_HEIGHT=8
BACKTITLE="RaspiBlitz"
TITLE="C-Lightning Options"
MENU=""
OPTIONS=()
OPTIONS+=(FUNDING "Fund your C-Lightning Wallet")
OPTIONS+=(PEERING "Connect to a Peer")
OPTIONS+=(CHANNEL "Open a Channel with Peer")
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
OPTIONS+=(SUMMARY "Information about this node")
OPTIONS+=(NAME "Change Name/Alias of the Node")
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
cln_num_inactive_channels="$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')" 2>/dev/null
openChannels=$((ln_channels_online+cln_num_inactive_channels))
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
OPTIONS+=(SUEZ "Visualize channels")
OPTIONS+=(CLOSEALL "Close all open Channels on $CHAIN")
HEIGHT=$((HEIGHT+2))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+2))
fi
if [ ${#LNdefault} -gt 0 ]&&[ $LNdefault = lnd ];then
OPTIONS+=(SWITCHLN "Use C-lightning as default")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
OPTIONS+=(CASHOUT "Withdraw all funds from C-lightning on $CHAIN")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "Main menu" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
SUMMARY)
clear
/home/admin/config.scripts/cln-plugin.summary.sh $CHAIN
echo "Press ENTER to return to main menu."
read key
;;
PEERING)
/home/admin/BBconnectPeer.sh cln $CHAIN
;;
FUNDING)
/home/admin/BBfundWallet.sh cln $CHAIN
;;
CASHOUT)
/home/admin/BBcashoutWallet.sh cln $CHAIN
;;
CHANNEL)
/home/admin/BBopenChannel.sh cln $CHAIN
;;
SEND)
/home/admin/BBpayInvoice.sh cln $CHAIN
;;
RECEIVE)
/home/admin/BBcreateInvoice.sh cln $CHAIN
;;
NAME)
sudo /home/admin/config.scripts/cln.setname.sh $CHAIN
;;
SUEZ)
clear
if [ ! -f /home/bitcoin/suez/suez ];then
/home/admin/config.scripts/bonus.suez.sh on
fi
cd /home/bitcoin/suez || exit 0
sudo -u bitcoin /home/bitcoin/.local/bin/poetry run ./suez \
--client=c-lightning \
--client-args=--conf=/home/bitcoin/.lightning/${netprefix}config
echo
echo "Press ENTER to return to main menu."
read key
;;
CLOSEALL)
/home/admin/BBcloseAllChannels.sh cln $CHAIN
echo "Press ENTER to return to main menu."
read key
;;
SWITCHLN)
clear
echo
# setting value in raspi blitz config
sudo sed -i "s/^LNdefault=.*/LNdefault=cln/g" /mnt/hdd/raspiblitz.conf
echo "# OK - LNdefault=cln is set in /mnt/hdd/raspiblitz.conf"
echo
echo "Press ENTER to return to main menu."
read key
;;
esac
exit 0

View File

@ -58,7 +58,7 @@ case $CHOICE in
RESET) RESET)
sudo /home/admin/config.scripts/lnd.credentials.sh reset sudo /home/admin/config.scripts/lnd.credentials.sh reset
sudo /home/admin/config.scripts/lnd.credentials.sh sync sudo /home/admin/config.scripts/lnd.credentials.sh sync
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0;; exit 0;;
SYNC) SYNC)
sudo /home/admin/config.scripts/lnd.credentials.sh sync sudo /home/admin/config.scripts/lnd.credentials.sh sync
@ -166,12 +166,11 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
echo "# Running on ${chain}net" echo "# Running on ${chain}net"
echo echo
localIPrange=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\ localIPrange=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\
grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' |\ grep 'eth0\|wlan0\|enp0\|inet' | tail -n1 | awk '{print $2}' |\
awk -F. '{print $1"."$2"."$3".0/24"}') awk -F. '{print $1"."$2"."$3".0/24"}')
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\ localIP=$(hostname -I | awk '{print $1}')
grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf) allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf)
bindIP=$(grep -c "rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf) bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc) rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc)
TorRPCaddress=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname) TorRPCaddress=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname)
@ -239,7 +238,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
restartCore=1 restartCore=1
fi fi
if [ $bindIP -eq 0 ]; then if [ $bindIP -eq 0 ]; then
echo "rpcbind=$localIP" | sudo tee -a /mnt/hdd/${network}/${network}.conf echo "${chain}.rpcbind=$localIP" | sudo tee -a /mnt/hdd/${network}/${network}.conf
restartCore=1 restartCore=1
fi fi
if [ $restartCore = 1 ];then if [ $restartCore = 1 ];then
@ -286,7 +285,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
restartCore=1 restartCore=1
fi fi
if [ $bindIP -gt 0 ]; then if [ $bindIP -gt 0 ]; then
sudo sed -i "/^rpcbind=$localIP/d" /mnt/hdd/${network}/${network}.conf sudo sed -i "/^${chain}.rpcbind=$localIP/d" /mnt/hdd/${network}/${network}.conf
restartCore=1 restartCore=1
fi fi
if [ $restartCore = 1 ];then if [ $restartCore = 1 ];then

View File

@ -1,116 +0,0 @@
#!/bin/bash
# get raspiblitz config
echo "get raspiblitz config"
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=7
BACKTITLE="RaspiBlitz"
TITLE="Lightning Options"
MENU=""
OPTIONS=()
OPTIONS+=(FUNDING "Fund your LND Wallet")
OPTIONS+=(PEERING "Connect to a Peer")
OPTIONS+=(CHANNEL "Open a Channel with Peer")
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances")
OPTIONS+=(lnchannels "Lightning Channel List")
OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report")
HEIGHT=$((HEIGHT+3))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
fi
OPTIONS+=(NAME "Change Name/Alias of Node")
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
OPTIONS+=(CASHOUT "Remove Funds from LND")
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "Main menu" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
lnbalance)
clear
echo "*** YOUR SATOSHI BALANCES ***"
/home/admin/config.scripts/lnd.balance.sh ${network}
echo "Press ENTER to return to main menu."
read key
;;
lnchannels)
clear
echo "*** YOUR LIGHTNING CHANNELS ***"
echo ""
echo "Capacity -> total sats in the channel (their side + your side)"
echo "Commit-Fee -> the fee that's charged if either side of the channel closes"
echo "Balance-Local -> sats on your side of the channel (outbound liquidity)"
echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)"
echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel"
echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding"
/home/admin/config.scripts/lnd.channels.sh ${network}
echo "Press ENTER to return to main menu."
read key
;;
lnfwdreport)
/home/admin/config.scripts/lnd.fwdreport.sh -menu
echo "Press ENTER to return to main menu."
read key
;;
PEERING)
/home/admin/BBconnectPeer.sh
;;
FUNDING)
/home/admin/BBfundWallet.sh
;;
CASHOUT)
/home/admin/BBcashoutWallet.sh
;;
CHANNEL)
/home/admin/BBopenChannel.sh
;;
SEND)
/home/admin/BBpayInvoice.sh
;;
RECEIVE)
/home/admin/BBcreateInvoice.sh
;;
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop
echo "Press ENTER to Reboot."
read key
sudo /home/admin/XXshutdown.sh reboot
exit 0
fi
;;
CLOSEALL)
/home/admin/BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
;;
esac

147
home.admin/99lndMenu.sh Normal file
View File

@ -0,0 +1,147 @@
#!/bin/bash
# get raspiblitz config
echo "get raspiblitz config"
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd $1)
# BASIC MENU INFO
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=7
BACKTITLE="RaspiBlitz"
TITLE="Lightning Options"
MENU=""
OPTIONS=()
OPTIONS+=(FUNDING "Fund your LND Wallet")
OPTIONS+=(PEERING "Connect to a Peer")
OPTIONS+=(CHANNEL "Open a Channel with Peer")
OPTIONS+=(SEND "Pay an Invoice/PaymentRequest")
OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest")
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances")
OPTIONS+=(lnchannels "Lightning Channel List")
OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report")
HEIGHT=$((HEIGHT+3))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+3))
fi
OPTIONS+=(NAME "Change Name/Alias of Node")
openChannels=$($lncli_alias listchannels 2>/dev/null | jq '.[] | length')
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
OPTIONS+=(SUEZ "Visualize channels")
OPTIONS+=(CLOSEALL "Close all open Channels on $CHAIN")
HEIGHT=$((HEIGHT+2))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+2))
fi
OPTIONS+=(CASHOUT "Withdraw all funds from LND on $CHAIN")
if [ ${#LNdefault} -gt 0 ]&&[ $LNdefault = cln ];then
OPTIONS+=(SWITCHLN "Use LND as default")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "Main menu" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
lnbalance)
clear
echo "*** YOUR SATOSHI BALANCES ***"
/home/admin/config.scripts/lnd.balance.sh ${network}
echo "Press ENTER to return to main menu."
read key
;;
lnchannels)
clear
echo "*** YOUR LIGHTNING CHANNELS ***"
echo ""
echo "Capacity -> total sats in the channel (their side + your side)"
echo "Commit-Fee -> the fee that's charged if either side of the channel closes"
echo "Balance-Local -> sats on your side of the channel (outbound liquidity)"
echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)"
echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel"
echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding"
/home/admin/config.scripts/lnd.channels.sh ${network}
echo "Press ENTER to return to main menu."
read key
;;
lnfwdreport)
/home/admin/config.scripts/lnd.fwdreport.sh -menu
echo "Press ENTER to return to main menu."
read key
;;
PEERING)
/home/admin/BBconnectPeer.sh lnd $CHAIN
;;
FUNDING)
/home/admin/BBfundWallet.sh lnd $CHAIN
;;
CASHOUT)
/home/admin/BBcashoutWallet.sh lnd $CHAIN
;;
CHANNEL)
/home/admin/BBopenChannel.sh lnd $CHAIN
;;
SEND)
/home/admin/BBpayInvoice.sh lnd $CHAIN
;;
RECEIVE)
/home/admin/BBcreateInvoice.sh lnd $CHAIN
;;
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh $CHAIN
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop
echo "Press ENTER to Reboot."
read key
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
exit 0
fi
;;
SUEZ)
clear
if [ ! -f /home/bitcoin/suez/suez ];then
/home/admin/config.scripts/bonus.suez.sh on
fi
cd /home/bitcoin/suez || exit 1
sudo -u bitcoin /home/bitcoin/.local/bin/poetry run ./suez \
--client-args=-n=${CHAIN} \
--client-args=--rpcserver=localhost:1${L2rpcportmod}009
echo
echo "Press ENTER to return to main menu."
read key
;;
CLOSEALL)
/home/admin/BBcloseAllChannels.sh lnd $CHAIN
echo "Press ENTER to return to main menu."
read key
;;
SWITCHLN)
clear
echo
# setting value in raspi blitz config
sudo sed -i "s/^LNdefault=.*/LNdefault=lnd/g" /mnt/hdd/raspiblitz.conf
echo "# OK - LNdefault=lnd is set in /mnt/hdd/raspiblitz.conf"
echo
echo "Press ENTER to return to main menu."
read key
;;
esac

View File

@ -5,19 +5,29 @@ echo "get raspiblitz config"
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# source <(/home/admin/config.scripts/network.aliases.sh getvars <lnd|cln> <mainnet|testnet|signet>)
source <(/home/admin/config.scripts/network.aliases.sh getvars cln $1)
# BASIC MENU INFO # BASIC MENU INFO
HEIGHT=12 # add 6 to CHOICE_HEIGHT + MENU lines HEIGHT=12 # add 6 to CHOICE_HEIGHT + MENU lines
WIDTH=64 WIDTH=64
CHOICE_HEIGHT=6 # 1 line / OPTIONS CHOICE_HEIGHT=6 # 1 line / OPTIONS
BACKTITLE="RaspiBlitz" BACKTITLE="RaspiBlitz"
TITLE="System Options" TITLE="${CHAIN} System Options"
MENU="" # adds lines to HEIGHT MENU="" # adds lines to HEIGHT
OPTIONS=() # adds lines to HEIGHt + CHOICE_HEIGHT OPTIONS=() # adds lines to HEIGHt + CHOICE_HEIGHT
OPTIONS+=(${network}LOG "Monitor the debug.log") OPTIONS+=(${network}LOG "Monitor the debug.log for ${CHAIN}")
OPTIONS+=(${network}CONF "Edit the bitcoin.conf") OPTIONS+=(${network}CONF "Edit the bitcoin.conf")
OPTIONS+=(LNDLOG "Monitor the lnd.log") OPTIONS+=(LNDLOG "Monitor the lnd.log for ${CHAIN}")
OPTIONS+=(LNDCONF "Edit the lnd.conf") OPTIONS+=(LNDCONF "Edit the lnd.conf for ${CHAIN}")
if grep "^${netprefix}cln=on" /mnt/hdd/raspiblitz.conf;then
OPTIONS+=(CLNLOG "Monitor the CLN log for ${CHAIN}")
OPTIONS+=(CLNCONF "Edit the CLN config for ${CHAIN}")
HEIGHT=$((HEIGHT+2))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+2))
fi
if [ "${runBehindTor}" == "on" ]; then if [ "${runBehindTor}" == "on" ]; then
OPTIONS+=(TORLOG "Monitor the Tor Service with Nyx") OPTIONS+=(TORLOG "Monitor the Tor Service with Nyx")
@ -39,26 +49,33 @@ CHOICE=$(dialog --clear \
case $CHOICE in case $CHOICE in
${network}LOG) ${network}LOG)
if [ ${CHAIN} = signet ]; then
bitcoinlogpath="/mnt/hdd/bitcoin/signet/debug.log"
elif [ ${CHAIN} = testnet ]; then
bitcoinlogpath="/mnt/hdd/bitcoin/testnet3/debug.log"
elif [ ${CHAIN} = mainnet ]; then
bitcoinlogpath="/mnt/hdd/bitcoin/debug.log"
fi
clear clear
echo echo
echo "Will follow the /mnt/hdd/${network}/debug.log" echo "Will follow the ${bitcoinlogpath}"
echo "running: 'sudo tail -n 30 -f /mnt/hdd/${network}/debug.log'" echo "running: 'sudo tail -n 30 -f ${bitcoinlogpath}'"
echo echo
echo "Press ENTER to continue" echo "Press ENTER to continue"
echo "use CTRL+C any time to abort .. then use command 'raspiblitz' to return to menu" echo "use CTRL+C any time to abort .. then use command 'raspiblitz' to return to menu"
echo "###############################################################################" echo "###############################################################################"
read key read key
sudo tail -n 30 -f /mnt/hdd/${network}/debug.log;; sudo tail -n 30 -f ${bitcoinlogpath};;
${network}CONF) ${network}CONF)
if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/${network}/${network}.conf" "root" if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/${network}/${network}.conf" "root"
then then
whiptail \ whiptail \
--title "Restart" --yes-button "Restart" --no-button "Not now" \ --title "Restart" --yes-button "Restart" --no-button "Not now" \
--yesno "To apply the new settings ${network}d needs to restart. --yesno "To apply the new settings ${netprefix}${network}d needs to restart.
Do you want to restart ${network}d now?" 10 55 Do you want to restart ${netprefix}${network}d now?" 10 55
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# Restarting ${network}d" echo "# Restarting ${netprefix}${network}d"
sudo systemctl restart ${network}d sudo systemctl restart ${netprefix}${network}d
else else
echo "# Continue without restarting." echo "# Continue without restarting."
fi fi
@ -77,7 +94,7 @@ case $CHOICE in
read key read key
sudo tail -n 30 -f /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log;; sudo tail -n 30 -f /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log;;
LNDCONF) LNDCONF)
if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/lnd/lnd.conf" "root" if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/lnd/${netprefix}lnd.conf" "root"
then then
whiptail \ whiptail \
--title "Restart" --yes-button "Restart" --no-button "Not now" \ --title "Restart" --yes-button "Restart" --no-button "Not now" \
@ -85,13 +102,40 @@ case $CHOICE in
Do you want to restart LND now?" 10 55 Do you want to restart LND now?" 10 55
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# Restarting LND" echo "# Restarting LND"
sudo systemctl restart lnd sudo systemctl restart ${netprefix}lnd
else else
echo "# Continue without restarting." echo "# Continue without restarting."
fi fi
else else
echo "# No change made" echo "# No change made"
fi;; fi;;
CLNLOG)
clear
echo
echo "Will follow the /home/bitcoin/.lightning/${CLNETWORK}/cl.log"
echo "running 'sudo tail -n 30 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log'"
echo
echo "Press ENTER to continue"
echo "use CTRL+C any time to abort .. then use command 'raspiblitz' to return to menu"
echo "###############################################################################"
read key
sudo tail -n 30 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log;;
CLNCONF)
if /home/admin/config.scripts/blitz.setconf.sh "/home/bitcoin/.lightning/${netprefix}config" "root"
then
whiptail \
--title "Restart" --yes-button "Restart" --no-button "Not now" \
--yesno "To apply the new settings C-lightning needs to restart.
Do you want to restart C-lightning now?" 0 0
if [ $? -eq 0 ]; then
echo "# Restarting C-lightning"
sudo systemctl restart ${netprefix}lightningd
else
echo "# Continue without restarting."
fi
else
echo "# No change made"
fi;;
TORLOG) TORLOG)
sudo -u debian-tor nyx;; sudo -u debian-tor nyx;;
TORRC) TORRC)

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
# load raspiblitz config data # load raspiblitz config data
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
source /home/admin/_version.info source /home/admin/_version.info
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf 2>/dev/null
## PROCEDURES ## PROCEDURES
@ -21,35 +21,51 @@ No need to close channels or download blockchain again.
Do you want to start the Update now? Do you want to start the Update now?
" 16 62 " 16 62
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
exit 1 exit 0
fi fi
whiptail --title "LND Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno " if [ "${lightning}" != "" ]; then
Before we start the RaspiBlitz Update process,
its recommended to make a backup of all your LND Data
and download that file to your laptop.
Do you want to download LND Data Backup now? whiptail --title "Lightning Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno "
Before we start the RaspiBlitz Update process,
its recommended to make a backup of all your Lightning
Channel Data and download that file to your laptop.
Do you want to download Lightning Data Backup now?
" 12 58 " 12 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
clear clear
echo "*************************************" echo "*************************************"
echo "* PREPARING LND BACKUP DOWNLOAD" echo "* PREPARING LIGHTNING BACKUP DOWNLOAD"
echo "*************************************" echo "*************************************"
echo "please wait .." echo "please wait .."
sleep 2 sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup if [ "${lightning}" == "lnd" ]; then
echo /home/admin/config.scripts/lnd.backup.sh lnd-export-gui
echo "PRESS ENTER to continue once you're done downloading." elif [ "${lightning}" == "cln" ]; then
read key /home/admin/config.scripts/cln.backup.sh cln-export-gui
else else
clear echo "TODO: Implement Data Backup for '${lightning}'"
echo "*************************************" fi
echo "* JUST MAKING BACKUP TO OLD SD CARD" echo
echo "*************************************" echo "PRESS ENTER to continue once you're done downloading."
echo "please wait .." read key
sleep 2 else
/home/admin/config.scripts/lnd.rescue.sh backup no-download clear
echo "*************************************"
echo "* JUST MAKING BACKUP TO OLD SD CARD"
echo "*************************************"
echo "please wait .."
sleep 2
if [ "${lightning}" == "lnd" ]; then
/home/admin/config.scripts/lnd.backup.sh lnd-export
elif [ "${lightning}" == "cln" ]; then
/home/admin/config.scripts/cln.backup.sh cln-export
else
echo "TODO: Implement Data Backup for '${lightning}'"
sleep 3
fi
fi
fi fi
whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down. whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down.
@ -68,8 +84,9 @@ and do you WANT TO START UPDATE NOW?
dialog --title " Update Canceled " --msgbox " dialog --title " Update Canceled " --msgbox "
OK. RaspiBlitz will NOT update now. OK. RaspiBlitz will NOT update now.
" 7 39 " 7 39
sudo systemctl start lnd sudo systemctl start lnd 2>/dev/null
exit 1 sudo systemctl start lightningd 2>/dev/null
exit 0
fi fi
clear clear
@ -93,7 +110,7 @@ hotfix the code and might compromise your security.
Do you want to Patch your RaspiBlitz now? Do you want to Patch your RaspiBlitz now?
" 18 58 " 18 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
exit 1 exit 0
fi fi
} }
@ -101,7 +118,7 @@ patch()
{ {
# get sync info # get sync info
source <(sudo /home/admin/XXsyncScripts.sh info) source <(sudo /home/admin/config.scripts/blitz.github.sh info)
# Patch Options # Patch Options
OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \ OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \
@ -115,7 +132,7 @@ patch()
clear clear
case $CHOICE in case $CHOICE in
PATCH) PATCH)
sudo -u admin /home/admin/XXsyncScripts.sh -run sudo -u admin /home/admin/config.scripts/blitz.github.sh -run
sleep 4 sleep 4
whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done. whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done.
@ -126,12 +143,13 @@ patch()
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
clear clear
echo "REBOOT .." echo "REBOOT .."
/home/admin/XXshutdown.sh reboot /home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8 sleep 8
exit 1
else else
echo "SKIP REBOOT .." echo "SKIP REBOOT .."
exit 0
fi fi
exit 1
;; ;;
REPO) REPO)
clear clear
@ -142,13 +160,13 @@ patch()
newGitHubUser=$(echo "${newGitHubUser}" | cut -d " " -f1) newGitHubUser=$(echo "${newGitHubUser}" | cut -d " " -f1)
echo "--> " ${newGitHubUser} echo "--> " ${newGitHubUser}
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh -clean ${activeBranch} ${newGitHubUser}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh -clean ${activeBranch} ${newGitHubUser})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
fi fi
fi fi
patch patch
exit 1 exit 0
;; ;;
BRANCH) BRANCH)
clear clear
@ -159,13 +177,13 @@ patch()
newGitHubBranch=$(echo "${newGitHubBranch}" | cut -d " " -f1) newGitHubBranch=$(echo "${newGitHubBranch}" | cut -d " " -f1)
echo "--> " $newGitHubBranch echo "--> " $newGitHubBranch
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh ${newGitHubBranch}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh ${newGitHubBranch})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
fi fi
fi fi
patch patch
exit 1 exit 0
;; ;;
PR) PR)
clear clear
@ -178,15 +196,15 @@ patch()
cd /home/admin/raspiblitz cd /home/admin/raspiblitz
git fetch origin pull/${pullRequestID}/head:pr${pullRequestID} git fetch origin pull/${pullRequestID}/head:pr${pullRequestID}
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh pr${pullRequestID}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh pr${pullRequestID})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
else else
echo "# update installs .." echo "# update installs .."
/home/admin/XXsyncScripts.sh -justinstall /home/admin/config.scripts/blitz.github.sh -justinstall
fi fi
fi fi
exit 1 exit 0
;; ;;
esac esac
@ -212,7 +230,7 @@ lnd()
VERIFIED) VERIFIED)
if [ ${lndUpdateInstalled} -eq 1 ]; then if [ ${lndUpdateInstalled} -eq 1 ]; then
whiptail --title "ALREADY INSTALLED" --msgbox "The LND version ${lndUpdateVersion} is already installed." 8 30 whiptail --title "ALREADY INSTALLED" --msgbox "The LND version ${lndUpdateVersion} is already installed." 8 30
exit 1 exit 0
fi fi
whiptail --title "OPTIONAL LND UPDATE" --yes-button "Cancel" --no-button "Update" --yesno "BEWARE on updating to LND v${lndUpdateVersion}: whiptail --title "OPTIONAL LND UPDATE" --yes-button "Cancel" --no-button "Update" --yesno "BEWARE on updating to LND v${lndUpdateVersion}:
@ -222,7 +240,7 @@ Do you really want to update LND now?
" 16 58 " 16 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# cancel update" echo "# cancel update"
exit 1 exit 0
fi fi
# if loop is installed remove # if loop is installed remove
if [ "${loop}" == "on" ]; then if [ "${loop}" == "on" ]; then
@ -238,7 +256,7 @@ Do you really want to update LND now?
if [ "${loop}" == "on" ]; then if [ "${loop}" == "on" ]; then
sudo -u admin /home/admin/config.scripts/bonus.loop.sh on sudo -u admin /home/admin/config.scripts/bonus.loop.sh on
fi fi
/home/admin/XXshutdown.sh reboot /home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8 sleep 8
fi fi
;; ;;
@ -255,14 +273,14 @@ Do you really want to update LND now?
" 16 58 " 16 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# cancel update" echo "# cancel update"
exit 1 exit 0
fi fi
error="" error=""
source <(sudo -u admin /home/admin/config.scripts/lnd.update.sh reckless) source <(sudo -u admin /home/admin/config.scripts/lnd.update.sh reckless)
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
else else
/home/admin/XXshutdown.sh reboot /home/admin/config.scripts/blitz.shutdown.sh reboot
sleep 8 sleep 8
fi fi
;; ;;
@ -296,7 +314,7 @@ bitcoinUpdate() {
if [ ${bitcoinUpdateInstalled} -eq 1 ]; then if [ ${bitcoinUpdateInstalled} -eq 1 ]; then
whiptail --title "ALREADY INSTALLED" \ whiptail --title "ALREADY INSTALLED" \
--msgbox "The Bitcoin Core version ${bitcoinUpdateVersion} is already installed." 8 30 --msgbox "The Bitcoin Core version ${bitcoinUpdateVersion} is already installed." 8 30
exit 1 exit 0
fi fi
whiptail --title "OPTIONAL Bitcoin Core update" --yes-button "Cancel" --no-button "Update" \ whiptail --title "OPTIONAL Bitcoin Core update" --yes-button "Cancel" --no-button "Update" \
--yesno "Info on updating to Bitcoin Core v${bitcoinVersion}: --yesno "Info on updating to Bitcoin Core v${bitcoinVersion}:
@ -308,7 +326,7 @@ Do you really want to update Bitcoin Core now?
" 12 58 " 12 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# cancel update" echo "# cancel update"
exit 1 exit 0
fi fi
error="" error=""
@ -332,7 +350,7 @@ Do you really want to update Bitcoin Core now?
" 16 58 " 16 58
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "# cancel update" echo "# cancel update"
exit 1 exit 0
fi fi
error="" error=""
source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh reckless) source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh reckless)
@ -358,52 +376,49 @@ fi
HEIGHT=10 # add 6 to CHOICE_HEIGHT + MENU lines HEIGHT=10 # add 6 to CHOICE_HEIGHT + MENU lines
WIDTH=55 WIDTH=55
CHOICE_HEIGHT=4 # 1 line / OPTIONS CHOICE_HEIGHT=4 # 1 line / OPTIONS
OPTIONS=( OPTIONS=()
RELEASE "RaspiBlitz Release Update/Recovery" OPTIONS+=(RELEASE "RaspiBlitz Release Update/Recovery")
PATCH "Patch RaspiBlitz v${codeVersion}" OPTIONS+=(PATCH "Patch RaspiBlitz v${codeVersion}")
LND "Interim LND Update Options" OPTIONS+=(BITCOIN "Bitcoin Core Update Options")
BITCOIN "Bitcoin Core Update Options"
) if [ "${lightning}" == "lnd" ]; then
OPTIONS+=(LND "Interim LND Update Options")
fi
if [ "${bos}" == "on" ]; then if [ "${bos}" == "on" ]; then
OPTIONS+=(BOS "Update Balance of Satoshis") OPTIONS+=(BOS "Update Balance of Satoshis")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${thunderhub}" == "on" ]; then if [ "${thunderhub}" == "on" ]; then
OPTIONS+=(THUB "Update ThunderHub") OPTIONS+=(THUB "Update ThunderHub")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${specter}" == "on" ]; then if [ "${specter}" == "on" ]; then
OPTIONS+=(SPECTER "Update Cryptoadvance Specter") OPTIONS+=(SPECTER "Update Cryptoadvance Specter")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${rtlWebinterface}" == "on" ]; then if [ "${rtlWebinterface}" == "on" ]; then
OPTIONS+=(RTL "Update RTL") OPTIONS+=(RTL "Update RTL")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${sphinxrelay}" == "on" ]; then if [ "${sphinxrelay}" == "on" ]; then
OPTIONS+=(SPHINX "Update Sphinx Server Relay") OPTIONS+=(SPHINX "Update Sphinx Server Relay")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${pyblock}" == "on" ]; then if [ "${pyblock}" == "on" ]; then
OPTIONS+=(PYBLOCK "Update PyBLOCK") OPTIONS+=(PYBLOCK "Update PyBLOCK")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
if [ "${mempoolExplorer}" == "on" ]; then if [ "${mempoolExplorer}" == "on" ]; then
OPTIONS+=(MEMPOOL "Update Mempool Explorer") OPTIONS+=(MEMPOOL "Update Mempool Explorer")
fi fi
if [ "${runBehindTor}" == "on" ]; then if [ "${runBehindTor}" == "on" ]; then
OPTIONS+=(TOR "Update Tor from the source code") OPTIONS+=(TOR "Update Tor from the source code")
HEIGHT=$((HEIGHT+1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT+1))
fi fi
CHOICE_HEIGHT=$(("${#OPTIONS[@]}"))
HEIGHT=$((CHOICE_HEIGHT+6))
CHOICE=$(dialog --clear \ CHOICE=$(dialog --clear \
--backtitle "" \ --backtitle "" \
--title "Update Options" \ --title "Update Options" \

View File

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

View File

@ -7,40 +7,59 @@ echo "please wait ..."
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') chain=$($bitcoincli_alias getblockchaininfo | jq -r '.chain')
fi fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
# check if user has money in lightning channels - info about close all # check if user has money in lightning channels - info about close all
openChannels=$(lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') if [ $LNTYPE = cln ];then
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
cln_num_inactive_channels="$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')" 2>/dev/null
openChannels=$((ln_channels_online+cln_num_inactive_channels))
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | jq '.[] | length')
fi
if [ ${#openChannels} -eq 0 ]; then if [ ${#openChannels} -eq 0 ]; then
clear clear
echo "*** IMPORTANT **********************************" echo "*** IMPORTANT **********************************"
echo "It looks like LND is not responding." echo "It looks like $LNTYPE is not responding."
echo "Still starting up, is locked or is not running?" echo "Still starting up, is locked or is not running?"
echo "Try later, try reboot or check ./XXdebugLogs.sh" echo "Try later, try reboot or run command: debug"
echo "************************************************" echo "************************************************"
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key
exit 1 exit 0
fi fi
if [ ${openChannels} -gt 0 ]; then if [ ${openChannels} -gt 0 ]; then
whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno 'You still have funds in open Lightning Channels.\nUse CLOSEALL first if you want to cashout all funds.\nNOTICE: Just confirmed on-chain funds can be moved.' 10 56 whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno 'You still have funds in open Lightning Channels.\nUse CLOSEALL first if you want to cashout all funds.\nNOTICE: Just confirmed on-chain funds can be moved.' 10 56
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
exit 1 exit 0
fi fi
echo "..." echo "..."
fi fi
# check if money is waiting to get confirmed # check if money is waiting to get confirmed
unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4) if [ $LNTYPE = cln ];then
ln_walletbalance_wait=0
cln_listfunds=$($lightningcli_alias listfunds 2>/dev/null)
for i in $(echo "$cln_listfunds" \
|jq .outputs[]|jq 'select(.status=="unconfirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
done
unconfirmed=$ln_walletbalance_wait
elif [ $LNTYPE = lnd ];then
unconfirmed=$($lncli_alias walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
fi
if [ ${unconfirmed} -gt 0 ]; then if [ ${unconfirmed} -gt 0 ]; then
whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for (some of) your funds.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58 whiptail --title 'Info' --yes-button='Cashout Anyway' --no-button='Go Back' --yesno "Still waiting confirmation for (some of) your funds.\nNOTICE: Just confirmed on-chain funds can be moved." 8 58
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
exit 1 exit 0
fi fi
echo "..." echo "..."
fi fi
@ -53,7 +72,7 @@ then
echo "ok pressed" echo "ok pressed"
else else
echo "cancel pressed" echo "cancel pressed"
exit 1 exit 0
fi fi
address=$(cat $_temp | xargs) address=$(cat $_temp | xargs)
shred -u $_temp shred -u $_temp
@ -61,7 +80,7 @@ if [ ${#address} -eq 0 ]; then
echo "FAIL - not a valid address (${address})" echo "FAIL - not a valid address (${address})"
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key
exit 1 exit 0
fi fi
clear clear
@ -70,22 +89,27 @@ echo "Sweep all possible Funds"
echo "******************************" echo "******************************"
# execute command # execute command
command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=36" if [ ${LNTYPE} = "cln" ];then
# withdraw destination satoshi [feerate] [minconf] [utxos]
command="$lightningcli_alias withdraw ${address} all slow"
elif [ ${LNTYPE} = "lnd" ];then
command="$lncli_alias sendcoins --sweepall --addr=${address} --conf_target=36"
fi
echo "$command" echo "$command"
result=$($command 2>$_error) result=$($command 2>$_error)
error=`cat ${_error}` error=$(cat ${_error})
echo "" echo
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo "FAIL: $error" echo "FAIL: $error"
echo "" echo
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL --> Was not able to send transaction (see error above)" echo "FAIL --> Was not able to send transaction (see error above)"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
else else
echo "Result: $result" echo "Result: $result"
echo "" echo
echo "********************************************************************" echo "********************************************************************"
fi fi
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key

View File

@ -3,42 +3,88 @@
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
# precheck: AutoPilot source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
if [ "${autoPilot}" = "on" ]; then
dialog --title 'Info' --msgbox 'You need to turn OFF the LND AutoPilot first,\nso that closed channels are not opening up again.\nYou find the AutoPilot -----> SERVICES section' 7 55
exit 1
fi
command="lncli --chain=${network} --network=${chain}net closeallchannels --force" if [ $LNTYPE = cln ];then
# https://lightning.readthedocs.io/lightning-close.7.html
peerlist=$($lightningcli_alias listpeers|grep '"id":'|awk '{print $2}'|cut -d, -f1)
# to display
function cln_closeall_command {
for i in $peerlist; do
# close id [unilateraltimeout] [destination] [fee_negotiation_step] [*wrong_funding*]
echo "$lightningcli_alias close $i 30;"
done
}
command=$(cln_closeall_command)
# to run
function cln_closeall {
for i in $peerlist; do
# close id [unilateraltimeout] [destination] [fee_negotiation_step] [*wrong_funding*]
echo "# Attempting a mutual close one-by-one with a 30 seconds timeout"
$lightningcli_alias close $i 30
done
}
elif [ $LNTYPE = lnd ];then
# precheck: AutoPilot
if [ "${autoPilot}" = "on" ]; then
dialog --title 'Info' --msgbox 'You need to turn OFF the LND AutoPilot first,\nso that closed channels are not opening up again.\nYou find the AutoPilot -----> SERVICES section' 7 55
exit 0
fi
command="$lncli_alias closeallchannels --force"
fi
clear clear
echo "***********************************" echo
echo "Closing All Channels (EXPERIMENTAL)" echo "# Precheck" # PRECHECK) check if chain is in sync
echo "***********************************" if [ $LNTYPE = cln ];then
echo "" BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
echo "COMMAND LINE: " CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
echo $command if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
echo "" chainOutSync=0
echo "RESULT:" else
chainOutSync=1
# PRECHECK) check if chain is in sync fi
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c) elif [ $LNTYPE = lnd ];then
if [ ${chainInSync} -eq 0 ]; then chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi fi
if [ ${chainOutSync} -eq 1 ]; then
if [ $LNTYPE = cln ];then
echo "# FAIL PRECHECK - '${netprefix}lightning-cli getinfo' blockheight is different from '${netprefix}bitcoind getblockchaininfo' - wait until chain is sync "
elif [ $LNTYPE = lnd ];then
echo "# FAIL PRECHECK - ${netprefix}lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
echo
echo "# PRESS ENTER to return to menu"
read key
exit 0
else
echo "# OK - the chain is synced"
fi
echo "#####################################"
echo "# Closing All Channels (EXPERIMENTAL)"
echo "#####################################"
echo
echo "# COMMAND LINE: "
echo $command
echo
echo "# RESULT:"
# execute command # execute command
if [ ${#command} -gt 0 ]; then if [ ${#command} -gt 0 ]; then
${command} if [ $LNTYPE = cln ];then
cln_closeall
elif [ $LNTYPE = lnd ];then
${command}
fi
fi fi
echo "" echo
echo "OK - please recheck if channels really closed" echo "# OK - please recheck if channels really closed"
sleep 5 sleep 5

View File

@ -5,26 +5,23 @@ _error=$(mktemp -p /dev/shm/)
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait" echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
# set ntwork map info source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
networkMap="https://lnmainnet.gaben.win"
if [ "$network" = "litecoin" ]; then
networkMap="https://lnexplorer.hcwong.me"
fi
if [ "$chain" = "test" ]; then
networkMap="https://explorer.acinq.co"
fi
# let user enter a <pubkey>@host # let user enter a <pubkey>@host
l1="Enter the node pubkey address with host information:" l1="Enter the node pubkey address with host information:"
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735" l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735"
l3="node directory -> 1ml.com" if [ "$chain" = "main" ]; then
l3="node directory -> https://1ml.com"
elif [ "$chain" = "test" ]; then
l3="node directory -> https://1ml.com/testnet"
fi
dialog --title "Open a Connection to a Peer" \ dialog --title "Open a Connection to a Peer" \
--backtitle "Lightning ( ${network} | ${chain} )" \ --backtitle "Lightning ( ${network} | ${chain} )" \
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp --inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
@ -35,21 +32,29 @@ if [ ${#_input} -eq 0 ]; then
echo echo
echo "no peer entered - returning to menu ..." echo "no peer entered - returning to menu ..."
sleep 2 sleep 2
exit 1 exit 0
fi fi
pubkey=$(echo "${_input}"|cut -d@ -f1)
# address=$(echo "${_input}"|cut -d@ -f2|cut -d: -f1)
# port=$(echo "${_input}"|cut -d: -f2)
# build command # build command
command="lncli --chain=${network} --network=${chain}net connect ${_input}" if [ $LNTYPE = cln ];then
# connect id [host port]
command="$lightningcli_alias connect ${_input}"
elif [ $LNTYPE = lnd ];then
command="$lncli_alias connect ${_input}"
fi
# info output # info output
clear clear
echo "******************************" echo "******************************"
echo "Connect to A Lightning Node" echo "Connect to a Lightning Node"
echo "******************************" echo "******************************"
echo "" echo
echo "COMMAND LINE: " echo "COMMAND LINE: "
echo $command echo $command
echo "" echo
echo "RESULT (might have to wait for timeout):" echo "RESULT (might have to wait for timeout):"
win=1 win=1
@ -59,7 +64,7 @@ info=""
if [ ${#_input} -lt 10 ]; then if [ ${#_input} -lt 10 ]; then
win=0 win=0
info="node pubkey@host info is too short" info="node pubkey@host info is too short"
else elif [ $LNTYPE = lnd ];then
gotAt=$(echo $_input | grep '@' -c) gotAt=$(echo $_input | grep '@' -c)
if [ ${gotAt} -eq 0 ]; then if [ ${gotAt} -eq 0 ]; then
win=0 win=0
@ -82,13 +87,13 @@ if [ ${#result} -eq 0 ]; then
info="No return value. Error not known." info="No return value. Error not known."
# try to get error output # try to get error output
result=`cat ${_error}` result=$(cat "${_error}")
echo "$result" echo "$result"
# basic cli error # basic cli error
cliError=$(echo "${result}" | grep "[lncli]" -c ) cliError=$(echo "${result}" | grep "[lncli]" -c )
if [ ${cliError} -gt 0 ]; then if [ ${cliError} -gt 0 ]; then
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli." info="It's possible that the lightning daemon is not running, not configured correct or not connected to the cli."
fi fi
else else
@ -97,8 +102,11 @@ else
echo "$result" echo "$result"
# check if the node is now in peer list # check if the node is now in peer list
pubkey=$(echo $_input | cut -d '@' -f1) if [ $LNTYPE = cln ];then
isPeer=$(lncli --chain=${network} --network=${chain}net listpeers 2>/dev/null| grep "${pubkey}" -c) isPeer=$($lightningcli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
elif [ $LNTYPE = lnd ];then
isPeer=$($lncli_alias listpeers 2>/dev/null| grep "${pubkey}" -c)
fi
if [ ${isPeer} -eq 0 ]; then if [ ${isPeer} -eq 0 ]; then
# basic error message # basic error message
@ -108,20 +116,21 @@ else
# TODO: try to find out more details from cli output # TODO: try to find out more details from cli output
else else
win=1
info="Perfect - a connection to that node got established :)" info="Perfect - a connection to that node got established :)"
fi fi
fi fi
# output info # output info
echo "" echo
if [ ${win} -eq 1 ]; then if [ ${win} -eq 1 ]; then
echo "******************************" echo "******************************"
echo "WIN" echo "WIN"
echo "******************************" echo "******************************"
echo "${info}" echo "${info}"
echo "" echo
echo "Whats next? --> Open a channel with that node." echo "What's next? --> Open a channel with that node."
else else
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL" echo "FAIL"
@ -129,6 +138,6 @@ else
echo "${info}" echo "${info}"
fi fi
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key

View File

@ -7,23 +7,64 @@ sudo chmod 7777 ${_error} 2>/dev/null
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait" echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
# Check if ready (chain in sync and channels open) source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
./XXchainInSync.sh $network $chain
if [ $? != 0 ]; then source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
exit 1
# check if chain is in sync
if [ $LNTYPE = cln ];then
lncommand="${netprefix}lightning-cli"
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
cmdChainInSync=1
else
cmdChainInSync=0
fi
elif [ $LNTYPE = lnd ];then
lncommand="${netprefix}lncli"
cmdChainInSync="$lncli_alias getinfo | grep '"synced_to_chain": true' -c"
fi
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 0
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
if [ $LNTYPE = cln ];then
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
fi
if [ ${openChannels} -eq 0 ]; then
echo
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
sleep 3
exit 0
fi fi
# let user enter the invoice # let user enter the invoice
l1="Enter the AMOUNT IN SATOSHI of the invoice:" l1="Enter the AMOUNT IN SATOSHIS to invoice:"
l2="1 ${network} = 100 000 000 SAT" l2="1 ${network} = 100 000 000 SAT"
dialog --title "Pay thru Lightning Network" \ dialog --title "Request payment through Lightning" \
--inputbox "$l1\n$l2" 9 50 2>$_temp --inputbox "$l1\n$l2" 9 50 2>$_temp
amount=$(cat $_temp | xargs | tr -dc '0-9') amount=$(cat $_temp | xargs | tr -dc '0-9')
shred -u $_temp shred -u $_temp
@ -31,30 +72,37 @@ if [ ${#amount} -eq 0 ]; then
clear clear
echo echo
echo "no amount entered - returning to menu ..." echo "no amount entered - returning to menu ..."
sleep 2 sleep 3
exit 1 exit 0
fi fi
# TODO let user enter a description # TODO let user enter a description
# build command # build command
command="lncli --chain=${network} --network=${chain}net addinvoice ${amount}" if [ $LNTYPE = cln ];then
label=$(date +%s) # seconds since 1970-01-01 00:00:00 UTC
# invoice msatoshi label description [expiry] [fallbacks] [preimage] [exposeprivatechannels] [cltv]
command="$lightningcli_alias invoice ${amount}sat $label ''"
# TODO warn about insufficient liquidity
elif [ $LNTYPE = lnd ];then
command="$lncli_alias addinvoice ${amount}"
fi
# info output # info output
clear clear
echo "******************************" echo "******************************"
echo "Create Invoice / Payment Request" echo "Create Invoice / Payment Request"
echo "******************************" echo "******************************"
echo "" echo
echo "COMMAND LINE: " echo "COMMAND LINE: "
echo $command echo $command
echo "" echo
echo "RESULT:" echo "RESULT:"
sleep 2 sleep 2
# execute command # execute command
result=$($command 2>$_error) result=$($command 2>$_error)
error=`cat ${_error} 2>/dev/null` error=$(cat ${_error} 2>/dev/null)
#echo "result(${result})" #echo "result(${result})"
#echo "error(${error})" #echo "error(${error})"
@ -65,9 +113,12 @@ if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}" echo "${error}"
else else
if [ $LNTYPE = cln ];then
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4) payReq=$(echo "$result" | grep bolt11 | cut -d '"' -f4)
payReq=$(echo "$result" | grep payment_request | cut -d '"' -f4) elif [ $LNTYPE = lnd ];then
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
payReq=$(echo "$result" | grep payment_request | cut -d '"' -f4)
fi
/home/admin/config.scripts/blitz.display.sh qr "${payReq}" /home/admin/config.scripts/blitz.display.sh qr "${payReq}"
if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then
@ -86,19 +137,27 @@ else
echo "${payReq}" echo "${payReq}"
echo echo
echo "Monitoring the Incoming Payment with:" echo "Monitoring the Incoming Payment with:"
echo "lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}" if [ $LNTYPE = cln ];then
echo "$lightningcli_alias waitinvoice $label"
elif [ $LNTYPE = lnd ];then
echo "$lncli_alias lookupinvoice ${rhash}"
fi
echo "Press x and hold to skip to menu." echo "Press x and hold to skip to menu."
while : while :
do do
if [ $LNTYPE = cln ];then
result=$(lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}) result=$($lightningcli_alias waitinvoice $label)
wasPayed=$(echo $result | grep -c '"settled": true') wasPayed=$(echo $result | grep -c 'paid')
elif [ $LNTYPE = lnd ];then
result=$($lncli_alias lookupinvoice ${rhash})
wasPayed=$(echo $result | grep -c '"settled": true')
fi
if [ ${wasPayed} -gt 0 ]; then if [ ${wasPayed} -gt 0 ]; then
echo echo
echo $result echo $result
echo echo
echo "Returning to menu - OK Invoice payed." echo "OK the Invoice was paid - returning to menu."
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
/home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/ok.png /home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/ok.png
sleep 2 sleep 2

View File

@ -4,41 +4,68 @@ clear
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait" echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
# PRECHECK) check if chain is in sync # PRECHECK) check if chain is in sync
chainOutSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": false' -c) if [ $LNTYPE = cln ];then
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
chainOutSync=0
else
chainOutSync=1
fi
elif [ $LNTYPE = lnd ];then
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
fi
if [ ${chainOutSync} -eq 1 ]; then if [ ${chainOutSync} -eq 1 ]; then
echo "FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " if [ $LNTYPE = cln ];then
echo "" echo "# FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
echo "PRESS ENTER to return to menu" else
echo "# FAIL PRECHECK - 'lightning-cli getinfo' blockheight is different from 'bitcoind getblockchaininfo' - wait until chain is sync "
fi
echo
echo "# PRESS ENTER to return to menu"
read key read key
exit 1 exit 0
else
echo "# OK - the chain is synced"
fi fi
# execute command # execute command
echo "calling lncli ... please wait" if [ $LNTYPE = cln ];then
command="lncli --chain=${network} --network=${chain}net newaddress p2wkh" command="$lightningcli_alias newaddr bech32"
elif [ $LNTYPE = lnd ];then
command="$lncli_alias newaddress p2wkh"
fi
echo "# Calling:"
echo "${command}" echo "${command}"
echo
result=$($command) result=$($command)
echo "$result" echo "$result"
# on no result # on no result
if [ ${#result} -eq 0 ]; then if [ ${#result} -eq 0 ]; then
echo "Empty result - sorry something went wrong - thats unusual." echo "# Empty result - sorry something went wrong - that is unusual."
echo "" echo
echo "PRESS ENTER to return to menu" echo "# Press ENTER to return to menu"
read key read key
exit 1 exit 1
fi fi
# parse address from result # parse address from result
address=$( echo "$result" | grep "address" | cut -d '"' -f4) if [ $LNTYPE = cln ];then
address=$( echo "$result" | grep "bech32" | cut -d '"' -f4)
elif [ $LNTYPE = lnd ];then
address=$( echo "$result" | grep "address" | cut -d '"' -f4)
fi
# prepare coin info # prepare coin info
coininfo="Bitcoin" coininfo="Bitcoin"
@ -58,7 +85,7 @@ echo "generating QR code ... please wait"
/home/admin/config.scripts/blitz.display.sh qr "$network:${address}" /home/admin/config.scripts/blitz.display.sh qr "$network:${address}"
# dialog with instructions while QR code is shown on LCD # dialog with instructions while QR code is shown on LCD
whiptail --backtitle "Fund your on chain wallet" \ whiptail --backtitle "Fund your onchain wallet" \
--title "Send ${coininfo}" \ --title "Send ${coininfo}" \
--yes-button "DONE" \ --yes-button "DONE" \
--no-button "Console QRcode" \ --no-button "Console QRcode" \
@ -73,6 +100,11 @@ fi
/home/admin/config.scripts/blitz.display.sh hide /home/admin/config.scripts/blitz.display.sh hide
# follow up info # follow up info
whiptail --backtitle "Fund your on chain wallet" \ if [ $LNTYPE = cln ];then
string="Wait for confirmations."
elif [ $LNTYPE = lnd ];then
string="Wait for confirmations. \n\nYou can use info on LCD to check if funds have arrived. \n\nIf you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'"
fi
whiptail --backtitle "Fund your onchain wallet" \
--title "What's next?" \ --title "What's next?" \
--msgbox "Wait for confirmations. \n\nYou can use info on LCD to check if funds have arrived. \n\nIf you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'" 0 0 --msgbox "$string" 0 0

View File

@ -5,58 +5,95 @@ _error=$(mktemp -p /dev/shm/)
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait" echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
echo "" source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
echo "*** Precheck ***"
# check if chain is in sync echo
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c) echo "# Precheck" # PRECHECK) check if chain is in sync
if [ ${chainInSync} -eq 0 ]; then if [ $LNTYPE = cln ];then
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
echo "Wait until chain is sync with LND and try again." CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
echo "" if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
echo "Press ENTER to return to main menu." chainOutSync=0
else
chainOutSync=1
fi
elif [ $LNTYPE = lnd ];then
chainOutSync=$($lncli_alias getinfo | grep '"synced_to_chain": false' -c)
fi
if [ ${chainOutSync} -eq 1 ]; then
if [ $LNTYPE = cln ];then
echo "# FAIL PRECHECK - 'lightning-cli getinfo' blockheight is different from 'bitcoind getblockchaininfo' - wait until chain is sync "
elif [ $LNTYPE = lnd ];then
echo "# FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
echo
echo "# PRESS ENTER to return to menu"
read key read key
exit 1 exit 0
else
echo "# OK - the chain is synced"
fi fi
# check available funding # check available funding
confirmedBalance=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) if [ $LNTYPE = cln ];then
for i in $($lightningcli_alias \
listfunds|jq .outputs[]|jq 'select(.status=="confirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
confirmedBalance=$((confirmedBalance+i))
done
elif [ $LNTYPE = lnd ];then
confirmedBalance=$($lncli_alias walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
fi
if [ ${confirmedBalance} -eq 0 ]; then if [ ${confirmedBalance} -eq 0 ]; then
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet." echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet."
echo "Please fund your on-chain wallet first and wait until confirmed." echo "Please fund your on-chain wallet first and wait until confirmed."
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key
exit 1 exit 0
fi fi
# check number of connected peers # check number of connected peers
numConnectedPeers=$(lncli --chain=${network} --network=${chain}net listpeers | grep pub_key -c) if [ $LNTYPE = cln ];then
numConnectedPeers=$($lightningcli_alias listpeers | grep -c '"id":')
elif [ $LNTYPE = lnd ];then
numConnectedPeers=$($lncli_alias listpeers | grep pub_key -c)
fi
if [ ${numConnectedPeers} -eq 0 ]; then if [ ${numConnectedPeers} -eq 0 ]; then
echo "FAIL - no peers connected on lightning network" echo "FAIL - no peers connected on the lightning network"
echo "You can only open channels to peer nodes to connected to first." echo "You can only open channels to peer nodes to connected to first."
echo "Use CONNECT peer option in main menu first." echo "Use CONNECT peer option in main menu first."
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key
exit 1 exit 0
fi fi
# let user pick a peer to open a channels with # let user pick a peer to open a channels with
OPTIONS=() OPTIONS=()
while IFS= read -r grepLine if [ $LNTYPE = cln ];then
do while IFS= read -r grepLine
pubKey=$(echo ${grepLine} | cut -d '"' -f4) do
#echo "grepLine(${pubKey})" pubKey=$(echo ${grepLine} | cut -d '"' -f4)
OPTIONS+=(${pubKey} "") # echo "grepLine(${pubKey})"
done < <(lncli --chain=${network} --network=${chain}net listpeers | grep pub_key) OPTIONS+=(${pubKey} "")
done < <($lightningcli_alias listpeers | grep '"id":')
elif [ $LNTYPE = lnd ];then
while IFS= read -r grepLine
do
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
# echo "grepLine(${pubKey})"
OPTIONS+=(${pubKey} "")
done < <($lncli_alias listpeers | grep pub_key)
fi
TITLE="Open (Payment) Channel" TITLE="Open (Payment) Channel"
MENU="\nChoose a peer you connected to, to open the channel with: \n " MENU="\nChoose a peer you connected to, to open the channel with: \n "
pubKey=$(dialog --clear \ pubKey=$(dialog --clear \
@ -68,11 +105,11 @@ pubKey=$(dialog --clear \
clear clear
if [ ${#pubKey} -eq 0 ]; then if [ ${#pubKey} -eq 0 ]; then
clear clear
echo echo
echo "no channel selected - returning to menu ..." echo "no channel selected - returning to menu ..."
sleep 4 sleep 4
exit 1 exit 0
fi fi
# find out what is the minimum amount # find out what is the minimum amount
@ -82,15 +119,17 @@ minSat=20000
if [ "${network}" = "bitcoin" ]; then if [ "${network}" = "bitcoin" ]; then
minSat=50000 minSat=50000
fi fi
_error="./.error.out" if [ $LNTYPE = lnd ];then
lncli --chain=${network} openchannel --network=${chain}net ${CHOICE} 1 0 2>$_error _error="./.error.out"
error=`cat ${_error}` $lncli_alias openchannel ${pubkey} 1 0 2>$_error
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then error=$(cat ${_error})
minSat=$(echo "${error}" | tr -dc '0-9') if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
minSat=$(echo "${error}" | tr -dc '0-9')
fi
fi fi
# let user enter an amount # let user enter an amount
l1="Amount in SATOSHI to fund this channel:" l1="Amount in satoshis to fund this channel:"
l2="min required : ${minSat}" l2="min required : ${minSat}"
l3="max available : ${confirmedBalance}" l3="max available : ${confirmedBalance}"
dialog --title "Funding of Channel" \ dialog --title "Funding of Channel" \
@ -101,7 +140,7 @@ if [ ${#amount} -eq 0 ]; then
echo echo
echo "no valid amount entered - returning to menu ..." echo "no valid amount entered - returning to menu ..."
sleep 4 sleep 4
exit 1 exit 0
fi fi
# let user enter a confirmation target # let user enter a confirmation target
@ -115,26 +154,31 @@ if [ ${#conf_target} -eq 0 ]; then
echo echo
echo "no valid target entered - returning to menu ..." echo "no valid target entered - returning to menu ..."
sleep 4 sleep 4
exit 1 exit 0
fi fi
# build command # build command
command="lncli --chain=${network} --network=${chain}net openchannel --conf_target=${conf_target} ${pubKey} ${amount} 0" if [ $LNTYPE = cln ];then
# fundchannel id amount [feerate] [announce] [minconf] [utxos] [push_msat] [close_to]
feerate=$($bitcoincli_alias estimatesmartfee $conf_target |grep feerate|awk '{print $2}'|cut -c 5-7|bc)
command="$lightningcli_alias fundchannel ${pubKey} ${amount} $feerate"
elif [ $LNTYPE = lnd ];then
command="$lncli_alias openchannel --conf_target=${conf_target} ${pubKey} ${amount} 0"
fi
# info output # info output
clear clear
echo "******************************" echo "******************************"
echo "Open Channel" echo "Open Channel"
echo "******************************" echo "******************************"
echo "" echo
echo "COMMAND LINE: " echo "COMMAND LINE: "
echo $command echo $command
echo "" echo
echo "RESULT:" echo "RESULT:"
# execute command # execute command
result=$($command 2>$_error) result=$(eval $command 2>$_error)
error=`cat ${_error}` error=$(cat ${_error})
#echo "result(${result})" #echo "result(${result})"
#echo "error(${error})" #echo "error(${error})"
@ -149,20 +193,33 @@ else
echo "WIN" echo "WIN"
echo "******************************" echo "******************************"
echo "${result}" echo "${result}"
echo "" echo
echo "Whats next? --> You need to wait 3 confirmations, for the channel to be ready." echo "What's next? --> You need to wait 3 confirmations for the channel to be ready."
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4) if [ $LNTYPE = cln ];then
fundingTX=$(echo "${result}" | grep 'txid' | cut -d '"' -f4)
elif [ $LNTYPE = lnd ];then
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
fi
echo
if [ "${network}" = "bitcoin" ]; then if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then if [ "${chain}" = "main" ]; then
echo "https://live.blockcypher.com/btc/tx/${fundingTX}" #echo "https://live.blockcypher.com/btc/tx/${fundingTX}"
else echo "https://mempool.space/tx/${fundingTX}"
echo "https://live.blockcypher.com/btc-testnet/tx/${fundingTX}" elif [ "${chain}" = "test" ]||[ "${chain}" = "sig" ]; then
echo "https://mempool.space/${chain}net/tx/${fundingTX}"
fi
echo
echo "In the Tor Browser:"
if [ "${chain}" = "main" ]; then
echo "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/tx/${fundingTX}"
elif [ "${chain}" = "test" ]||[ "${chain}" = "sig" ]; then
echo "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/${chain}net/tx/${fundingTX}"
fi fi
fi fi
if [ "${network}" = "litecoin" ]; then if [ "${network}" = "litecoin" ]; then
echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/" echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/"
fi fi
fi fi
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key

View File

@ -7,17 +7,59 @@ sudo chmod 7777 ${_error} 2>/dev/null
# load raspiblitz config data (with backup from old config) # load raspiblitz config data (with backup from old config)
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi if [ ${#network} -eq 0 ]; then network=$(cat .network); fi
if [ ${#network} -eq 0 ]; then network="bitcoin"; fi if [ ${#network} -eq 0 ]; then network="bitcoin"; fi
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "gathering chain info ... please wait" echo "gathering chain info ... please wait"
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
# Check if ready (chain in sync and channels open) source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
./XXchainInSync.sh $network $chain
if [ $? != 0 ]; then source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
exit 1
# check if chain is in sync
if [ $LNTYPE = cln ];then
lncommand="${netprefix}lightning-cli"
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
cmdChainInSync=1
else
cmdChainInSync=0
fi
elif [ $LNTYPE = lnd ];then
lncommand="${netprefix}lncli"
cmdChainInSync="$lncli_alias getinfo | grep '"synced_to_chain": true' -c"
fi
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 0
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
if [ $LNTYPE = cln ];then
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
fi
if [ ${openChannels} -eq 0 ]; then
echo
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
sleep 3
echo
exit 0
fi fi
paymentRequestStart="???" paymentRequestStart="???"
@ -36,7 +78,7 @@ if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then if [ "${chain}" = "main" ]; then
testSite="https://satoshis.place" testSite="https://satoshis.place"
else else
testSite="https://testnet.satoshis.place" testSite="https://starblocks.acinq.co/"
fi fi
elif [ "${network}" = "litecoin" ]; then elif [ "${network}" = "litecoin" ]; then
testSite="https://millionlitecoinhomepage.net" testSite="https://millionlitecoinhomepage.net"
@ -46,7 +88,7 @@ fi
l1="Copy the LightningInvoice/PaymentRequest into here:" l1="Copy the LightningInvoice/PaymentRequest into here:"
l2="Its a long string starting with '${paymentRequestStart}'" l2="Its a long string starting with '${paymentRequestStart}'"
l3="To try it out go to: ${testSite}" l3="To try it out go to: ${testSite}"
dialog --title "Pay thru Lightning Network" \ dialog --title "Pay through the Lightning Network" \
--inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp --inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp
invoice=$(cat $_temp | xargs) invoice=$(cat $_temp | xargs)
shred -u $_temp shred -u $_temp
@ -54,14 +96,19 @@ if [ ${#invoice} -eq 0 ]; then
clear clear
echo echo
echo "no invoice entered - returning to menu ..." echo "no invoice entered - returning to menu ..."
sleep 2 sleep 3
exit 1 exit 0
fi fi
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq # TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq
# build command # build command
command="lncli --chain=${network} --network=${chain}net sendpayment --force --pay_req=${invoice}" if [ $LNTYPE = cln ];then
# pay bolt11 [msatoshi] [label] [riskfactor] [maxfeepercent] [retry_for] [maxdelay] [exemptfee]
command="$lightningcli_alias pay ${invoice}"
elif [ $LNTYPE = lnd ];then
command="$lncli_alias sendpayment --force --pay_req=${invoice}"
fi
# info output # info output
clear clear
@ -70,20 +117,24 @@ echo "Pay Invoice / Payment Request"
echo "This script is as an example how to use the lncli interface." echo "This script is as an example how to use the lncli interface."
echo "Its not optimized for performance or error handling." echo "Its not optimized for performance or error handling."
echo "************************************************************" echo "************************************************************"
echo "" echo
echo "COMMAND LINE: " echo "COMMAND LINE: "
echo $command echo $command
echo "" echo
echo "RESULT (may wait in case of timeout):" echo "RESULT (may wait in case of timeout):"
# execute command # execute command
result=$($command 2>$_error) result=$($command 2>$_error)
error=`cat ${_error}` error=$(cat ${_error})
#echo "result(${result})" #echo "result(${result})"
#echo "error(${error})" #echo "error(${error})"
resultIsError=$(echo "${result}" | grep -c "payment_error") if [ $LNTYPE = cln ];then
resultIsError=$(echo "${result}" | grep -c '"code":')
elif [ $LNTYPE = lnd ];then
resultIsError=$(echo "${result}" | grep -c "payment_error")
fi
if [ ${resultIsError} -gt 0 ]; then if [ ${resultIsError} -gt 0 ]; then
error="${result}" error="${result}"
fi fi
@ -99,8 +150,8 @@ else
echo "******************************" echo "******************************"
echo "WIN" echo "WIN"
echo "******************************" echo "******************************"
echo "It worked :) - check out the service you were paying." echo "It worked :) - check the service you were paying."
fi fi
echo "" echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
read key read key

View File

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

View File

@ -1,37 +0,0 @@
#!/bin/bash
# Check if lnd is synced to chain and channels are open
# If it isn't, wait until it is
# exits with 1 if it isn't.
network=$1
chain=$2
# check if chain is in sync
cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c"
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'lncli getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 1
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -eq 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
echo ""
exit 1
fi
exit 0

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# TODO: check & update localip in raspiblitz info for display (only write on change)
# This script runs on after start in background # This script runs on after start in background
# as a service and gets restarted on failure # as a service and gets restarted on failure
# it runs ALMOST every seconds # it runs ALMOST every seconds
@ -37,15 +39,47 @@ do
# count up # count up
counter=$(($counter+1)) 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 # gather the uptime seconds
upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+') upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+')
# prevent restart if COPY OVER LAN is running # source info file fresh on every loop
# see: https://github.com/rootzoll/raspiblitz/issues/1179#issuecomment-646079467 source ${infoFile} 2>/dev/null
source ${infoFile}
if [ "${state}" == "copysource" ]; then ####################################################
echo "copysource mode: skipping background loop" # SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES
sleep 10 # https://github.com/rootzoll/raspiblitz/issues/160
####################################################
if [ "${state}" == "" ] || [ "${state}" == "copysource" ] || [ "${state}" == "copytarget" ]; 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 continue
fi fi
@ -60,13 +94,13 @@ do
echo "*** RECHECK DHCP-SERVER ***" echo "*** RECHECK DHCP-SERVER ***"
# get the local network IP # get the local network IP
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(hostname -I | awk '{print $1}')
echo "localip(${localip})" echo "localip(${localip})"
# detect a missing DHCP config # detect a missing DHCP config
if [ "${localip:0:4}" = "169." ]; then if [ "${localip:0:4}" = "169." ]; then
echo "Missing DHCP detected ... trying emergency reboot" echo "Missing DHCP detected ... trying emergency reboot"
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
else else
echo "DHCP OK" echo "DHCP OK"
fi fi
@ -183,9 +217,9 @@ do
# check every 1min # check every 1min
recheckSync=$(($counter % 60)) recheckSync=$(($counter % 60))
if [ ${recheckSync} -eq 1 ]; then if [ ${recheckSync} -eq 1 ]; then
source <(sudo -u admin /home/admin/config.scripts/network.monitor.sh peer-status) source <(sudo /home/admin/config.scripts/network.monitor.sh peer-status)
echo "Blockchain Sync Monitoring: peers=${peers}" echo "Blockchain Sync Monitoring: peers=${peers}"
if [ "${peers}" == "0" ]; then if [ "${peers}" == "0" ] && [ "${running}" == "1" ]; then
echo "Blockchain Sync Monitoring: ZERO PEERS DETECTED .. doing out-of-band kickstart" echo "Blockchain Sync Monitoring: ZERO PEERS DETECTED .. doing out-of-band kickstart"
sudo /home/admin/config.scripts/network.monitor.sh peer-kickstart sudo /home/admin/config.scripts/network.monitor.sh peer-kickstart
fi fi
@ -354,7 +388,6 @@ do
fi fi
############################### ###############################
# LND AUTO-UNLOCK # LND AUTO-UNLOCK
############################### ###############################
@ -367,8 +400,8 @@ do
if [ "${autoUnlock}" = "on" ]; then if [ "${autoUnlock}" = "on" ]; then
# check if lnd is locked # check if lnd is locked
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock) source <(/home/admin/config.scripts/lnd.unlock.sh status)
if [ ${locked} -gt 0 ]; then if [ "${locked}" != "0" ]; then
echo "STARTING AUTO-UNLOCK ..." echo "STARTING AUTO-UNLOCK ..."
sudo /home/admin/config.scripts/lnd.unlock.sh sudo /home/admin/config.scripts/lnd.unlock.sh
@ -406,9 +439,10 @@ do
recheckIBD=$((($counter % 60)+1)) recheckIBD=$((($counter % 60)+1))
if [ ${recheckIBD} -eq 1 ]; then if [ ${recheckIBD} -eq 1 ]; then
# check if flag exists (got created on 50syncHDD.sh) # 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 if [ ${flagExists} -eq 1 ]; then
finishedIBD=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep "initialblockdownload" | grep -c "false") source <(/home/admin/config.scripts/network.aliases.sh getvars)
finishedIBD=$($bitcoincli_alias getblockchaininfo | grep "initialblockdownload" | grep -c "false")
if [ ${finishedIBD} -eq 1 ]; then if [ ${finishedIBD} -eq 1 ]; then
echo "CHECK FOR END OF IBD --> reduce RAM, check TOR and restart ${network}d" echo "CHECK FOR END OF IBD --> reduce RAM, check TOR and restart ${network}d"
@ -463,12 +497,5 @@ do
# sleep 1 sec # sleep 1 sec
sleep 1 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 done

View File

@ -1,252 +0,0 @@
#!/bin/bash
# LOGFILE - store debug logs of bootstrap
logFile="/home/admin/raspiblitz.log"
# INFOFILE - state data from bootstrap
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}
# HDD BTRFS RAID REPAIR IF NEEDED
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isBTRFS} -eq 1 ] && [ ${isMounted} -eq 1 ]; then
echo "CHECK BTRFS RAID" >> ${logFile}
if [ ${isRaid} -eq 1 ] && [ ${#raidUsbDev} -eq 0 ]; then
echo "HDD was set to work in RAID, but RAID drive is not connected" >> ${logFile}
echo "Trying to set HDD back to single mode." >> ${logFile}
sudo /home/admin/config.scripts/blitz.datadrive.sh raid off >> ${logFile}
else
echo "OK" >> ${logFile}
fi
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
echo "FAIL see ${logFile}"
echo "FAIL: missing hostname in (${configFile})!" >> ${logFile}
exit 1
fi
# load codeVersion
source /home/admin/_version.info
# check if code version was loaded
if [ ${#codeVersion} -eq 0 ]; then
echo "FAIL see ${logFile}"
echo "FAIL: no code version (/home/admin/_version.info) found!" >> ${logFile}
exit 1
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
# if old bitcoin.conf exists ...
configExists=$(sudo ls /mnt/hdd/bitcoin/bitcoin.conf | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "Checking old bitcoin.conf ..." >> ${logFile}
# make sure to fix bitcoind RPC port if not done in old version
# https://github.com/rootzoll/raspiblitz/issues/217
# https://github.com/rootzoll/raspiblitz/issues/950
if ! grep -Eq "^rpcallowip=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding rpcallowip=127.0.0.1" >> ${logFile}
echo "rpcallowip=127.0.0.1" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok rpcallow exists" >> ${logFile}
fi
# check whether "main." needs to be added to rpcport and rpcbind
if grep -Eq "^rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> change rpcport to main.rpcport" >> ${logFile}
sudo sed -i -E 's/^(rpcport=.*)/main.\1/g' /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok ^rpcport does not exist" >> ${logFile}
fi
if grep -Eq "^rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> change rpcbind to main.rpcbind" >> ${logFile}
sudo sed -i -E 's/^(rpcbind=.*)/main.\1/g' /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok ^rpcbind does not exist" >> ${logFile}
fi
# check whether right settings are there ("main.")
if ! grep -Eq "^main.rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding main.rpcport=8332" >> ${logFile}
echo "main.rpcport=8332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok main.rpcport exists" >> ${logFile}
fi
if ! grep -Eq "^main.rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding main.rpcbind=127.0.0.1:8332" >> ${logFile}
echo "main.rpcbind=127.0.0.1:8332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok main.rpcbind exists" >> ${logFile}
fi
# same for testnet
if ! grep -Eq "^test.rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> adding test.rpcport=18332" >> ${logFile}
echo "test.rpcport=18332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok test.rpcport exists" >> ${logFile}
fi
if ! grep -Eq "^test.rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> adding test.rpcbind=127.0.0.1:18332" >> ${logFile}
echo "test.rpcbind=127.0.0.1:18332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok test.rpcbind exists" >> ${logFile}
fi
else
echo "WARN: /mnt/hdd/bitcoin/bitcoin.conf not found" >> ${logFile}
fi
# if old lnd.conf exists ...
configExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
# remove RPC user & pass from lnd.conf ... since v1.7
# https://github.com/rootzoll/raspiblitz/issues/2160
echo "- #2160 lnd.conf --> make sure contains no RPC user/pass for bitcoind" >> ${logFile}
sudo sed -i '/^\[Bitcoind\]/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpchost=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpcpass=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpcuser=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.zmqpubrawblock=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.zmqpubrawtx=/d' /mnt/hdd/lnd/lnd.conf
# make sure additional values are added to [Application Options] since v1.7
echo "- lnd.conf --> checking additional [Application Options] since v1.7" >> ${logFile}
applicationOptionsLineNumber=$(sudo grep -n "\[Application Options\]" /mnt/hdd/lnd/lnd.conf | cut -d ":" -f1)
if [ "${applicationOptionsLineNumber}" != "" ]; then
applicationOptionsLineNumber="$(($applicationOptionsLineNumber+1))"
# Avoid historical graph data sync
# ignore-historical-gossip-filters=1
configParamExists=$(sudo grep -c "^ignore-historical-gossip-filters=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'ignore-historical-gossip-filters'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}iignore-historical-gossip-filters=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'ignore-historical-gossip-filters' exists (${configParamExists})" >> ${logFile}
fi
# Avoid slow startup time
# sync-freelist=1
configParamExists=$(sudo grep -c "^sync-freelist=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'sync-freelist'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}isync-freelist=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'sync-freelist' exists (${configParamExists})" >> ${logFile}
fi
# Avoid high startup overhead
# stagger-initial-reconnect=1
configParamExists=$(sudo grep -c "^stagger-initial-reconnect=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'stagger-initial-reconnect'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}istagger-initial-reconnect=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'stagger-initial-reconnect' exists (${configParamExists})" >> ${logFile}
fi
# Delete and recreate RPC TLS certificate when details change or cert expires
# tlsautorefresh=1
configParamExists=$(sudo grep -c "^tlsautorefresh=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsautorefresh'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsautorefresh=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'tlsautorefresh' exists (${configParamExists})" >> ${logFile}
fi
# Do not include IPs in the RPC TLS certificate
# tlsdisableautofill=1
configParamExists=$(sudo grep -c "^tlsdisableautofill=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsdisableautofill'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsdisableautofill=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'tlsdisableautofill' exists (${configParamExists})" >> ${logFile}
fi
else
echo " - WARN: section '[Application Options]' not found in lnd.conf" >> ${logFile}
fi
else
echo "WARN: /mnt/hdd/lnd/lnd.conf not found" >> ${logFile}
fi
echo "Version Code: ${codeVersion}" >> ${logFile}
echo "Version Data: ${raspiBlitzVersion}" >> ${logFile}
if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script" >> ${logFile}
# nothing specific here yet
echo "OK Done - Updating version in config"
sudo sed -i "s/^raspiBlitzVersion=.*/raspiBlitzVersion='${codeVersion}'/g" ${configFile}
else
echo "OK - version of config data is up to date" >> ${logFile}
fi
echo "END Migration/Init" >> ${logFile}
exit 0

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
# source aliases from /home/admin/_aliases
if [ -f /home/admin/_aliases ];then
source /home/admin/_aliases
fi
# SHORTCUT COMMANDS you can call as user 'admin' from terminal # SHORTCUT COMMANDS you can call as user 'admin' from terminal
# command: raspiblitz # command: raspiblitz
@ -32,14 +37,12 @@ function repair() {
# command: restart # command: restart
function restart() { function restart() {
cd /home/admin /home/admin/config.scripts/blitz.shutdown.sh reboot
./XXshutdown.sh reboot
} }
# command: sourcemode # command: sourcemode
function sourcemode() { function sourcemode() {
cd /home/admin /home/admin/config.scripts/blitz.copychain.sh source
./98repairMenu.sh sourcemode
} }
# command: check # command: check
@ -47,23 +50,27 @@ function check() {
/home/admin/config.scripts/blitz.configcheck.py /home/admin/config.scripts/blitz.configcheck.py
} }
# command: release
function release() {
/home/admin/config.scripts/blitz.preparerelease.sh
}
# command: debug # command: debug
function debug() { function debug() {
cd /home/admin cd /home/admin
./XXdebugLogs.sh /home/admin/config.scripts/blitz.debug.sh
} }
# command: patch # command: patch
# syncs script with latest set github and branch # syncs script with latest set github and branch
function patch() { function patch() {
cd /home/admin cd /home/admin
./XXsyncScripts.sh -run /home/admin/config.scripts/blitz.github.sh -run
} }
# command: off # command: off
function off() { function off() {
cd /home/admin /home/admin/config.scripts/blitz.shutdown.sh
./XXshutdown.sh
} }
# command: github # command: github
@ -123,7 +130,24 @@ function torthistx() {
# start the status screen in the terminal # start the status screen in the terminal
function status() { function status() {
echo "Gathering data - please wait a moment..." echo "Gathering data - please wait a moment..."
sudo -u pi /home/admin/00infoLCD.sh --pause 0 while :
do
# show the same info as on LCD screen
# 00infoBlitz.sh <cln|lnd> <testnet|mainnet|signet>
/home/admin/00infoBlitz.sh $1 $2
# wait 6 seconds for user exiting loop
#echo
#echo -en "Screen is updating in a loop .... press 'x' now to get back to menu."
read -n 1 -t 6 keyPressed
#echo -en "\rGathering information to update info ... please wait. \n"
# check if user wants to abort session
if [ "${keyPressed}" = "x" ]; then
echo
echo "Returning to menu ....."
sleep 4
break
fi
done
} }
# command: lnbalance # command: lnbalance

View 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

421
home.admin/_provision.setup.sh Executable file
View File

@ -0,0 +1,421 @@
#!/bin/bash
# this provision file is just executed on fresh setups
# not on recoveries or updates
# 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}
###################################
# 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 systemctl stop ${network}d.service
sudo systemctl disable ${network}d.service
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
sudo systemctl enable ${network}d.service
sudo systemctl start ${network}d.service
# check if bitcoin has started
bitcoinRunning=0
loopcount=0
while [ ${bitcoinRunning} -eq 0 ]
do
>&2 echo "# (${loopcount}/200) checking if ${network}d is running ... " >> ${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 successful " >> ${logFile}
###################################
# Prepare Lightning
echo "Prepare Lightning (${lightning})" >> ${logFile}
if [ "${lightning}" != "lnd" ]; then
###################################
# Remove LND from systemd
echo "Remove LND" >> ${logFile}
sudo sed -i "s/^message=.*/message='Deactivate Lightning'/g" ${infoFile}
sudo systemctl disable lnd
sudo rm /etc/systemd/system/lnd.service 2>/dev/null
sudo systemctl daemon-reload
fi
if [ "${lightning}" == "lnd" ]; then
###################################
# LND
echo "############## Setup LND" >> ${logFile}
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.chain.sh on mainnet
sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${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
echo "WALLET --> SEED + SCB " >> ${logFile}
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
echo "WALLET --> SEED" >> ${logFile}
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
echo "WALLET --> NEW" >> ${logFile}
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}
# 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}
# 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
echo "############## c-lightning" >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Install'/g" ${infoFile}
sudo /home/admin/config.scripts/cln.install.sh on mainnet >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Setup'/g" ${infoFile}
# OLD WALLET FROM CLIGHTNING RESCUE
if [ "${clnrescue}" != "" ]; then
echo "Restore CLN data from uploaded rescue file ${lndrescue} ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/cln.backup.sh cln-import ${lndrescue})
if [ "${error}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: cln import backup failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: cln import backup failed" >> ${logFile}
echo "${error}" >> ${logFile}
exit 1
fi
# OLD WALLET FROM SEEDWORDS
elif [ "${seedWords}" != "" ]; then
echo "Restore CLN wallet from seedWords ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/cln.hsmtool.sh seed-force mainnet "${seedWords}" "${seedPassword}")
# check if wallet really got created
walletExistsNow=$(sudo ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret")
if [ $walletExistsNow -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: seed maybe wrong'/g" ${infoFile}
echo "FAIL: setup: no cln wallet created - seed maybe wrong" >> ${logFile}
exit 1
fi
# NEW WALLET
else
echo "Generate new CLN wallet ..." >> ${logFile}
# generate new wallet
source <(sudo /home/admin/config.scripts/cln.hsmtool.sh new-force mainnet)
# check if got new seedwords
if [ "${seedwords}" == "" ] || [ "${seedwords6x4}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: no cln seedwords'/g" ${infoFile}
echo "FAIL: setup: no cln seedwords" >> ${logFile}
exit 1
fi
# check if wallet really got created
walletExistsNow=$(sudo ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret")
if [ $walletExistsNow -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='setup: no cln wallet created'/g" ${infoFile}
echo "FAIL: setup: no cln wallet created" >> ${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
fi
sudo sed -i "s/^message=.*/message='Provision Setup Finish'/g" ${infoFile}
echo "END Setup" >> ${logFile}
exit 0

277
home.admin/_provision.update.sh Executable file
View File

@ -0,0 +1,277 @@
#!/bin/bash
# LOGFILE - store debug logs of bootstrap
logFile="/home/admin/raspiblitz.log"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# SETUPFILE - - setup data of RaspiBlitz
setupFile="/var/cache/raspiblitz/temp/raspiblitz.setup"
source ${setupFile}
# 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)
if [ ${isBTRFS} -eq 1 ] && [ ${isMounted} -eq 1 ]; then
echo "CHECK BTRFS RAID" >> ${logFile}
if [ ${isRaid} -eq 1 ] && [ ${#raidUsbDev} -eq 0 ]; then
echo "HDD was set to work in RAID, but RAID drive is not connected" >> ${logFile}
echo "Trying to set HDD back to single mode." >> ${logFile}
sudo /home/admin/config.scripts/blitz.datadrive.sh raid off >> ${logFile}
else
echo "OK" >> ${logFile}
fi
fi
# LOAD DATA & PRECHECK
# 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
fi
# check if config files contain lightning (lnd is default)
if [ "${lightning}" == "" ]; then
lightning="lnd"
echo "lightning=${lightning}" >> ${configFile}
fi
# load codeVersion
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
fi
echo "prechecks 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
# if old bitcoin.conf exists ...
configExists=$(sudo ls /mnt/hdd/bitcoin/bitcoin.conf | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "Checking old bitcoin.conf ..." >> ${logFile}
# make sure to fix bitcoind RPC port if not done in old version
# https://github.com/rootzoll/raspiblitz/issues/217
# https://github.com/rootzoll/raspiblitz/issues/950
if ! grep -Eq "^rpcallowip=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding rpcallowip=127.0.0.1" >> ${logFile}
echo "rpcallowip=127.0.0.1" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok rpcallow exists" >> ${logFile}
fi
# check whether "main." needs to be added to rpcport and rpcbind
if grep -Eq "^rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> change rpcport to main.rpcport" >> ${logFile}
sudo sed -i -E 's/^(rpcport=.*)/main.\1/g' /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok ^rpcport does not exist" >> ${logFile}
fi
if grep -Eq "^rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> change rpcbind to main.rpcbind" >> ${logFile}
sudo sed -i -E 's/^(rpcbind=.*)/main.\1/g' /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok ^rpcbind does not exist" >> ${logFile}
fi
# check whether right settings are there ("main.")
if ! grep -Eq "^main.rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding main.rpcport=8332" >> ${logFile}
echo "main.rpcport=8332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok main.rpcport exists" >> ${logFile}
fi
if ! grep -Eq "^main.rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #217 -> adding main.rpcbind=127.0.0.1:8332" >> ${logFile}
echo "main.rpcbind=127.0.0.1:8332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #217 -> ok main.rpcbind exists" >> ${logFile}
fi
# same for testnet
if ! grep -Eq "^test.rpcport=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> adding test.rpcport=18332" >> ${logFile}
echo "test.rpcport=18332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok test.rpcport exists" >> ${logFile}
fi
if ! grep -Eq "^test.rpcbind=.*" /mnt/hdd/${network}/${network}.conf; then
echo "fix issue #950 -> adding test.rpcbind=127.0.0.1:18332" >> ${logFile}
echo "test.rpcbind=127.0.0.1:18332" >> /mnt/hdd/${network}/${network}.conf
else
echo "check issue #950 -> ok test.rpcbind exists" >> ${logFile}
fi
else
echo "WARN: /mnt/hdd/bitcoin/bitcoin.conf not found" >> ${logFile}
fi
echo "Version Code: ${codeVersion}" >> ${logFile}
echo "Version Data: ${raspiBlitzVersion}" >> ${logFile}
if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script" >> ${logFile}
# nothing specific here yet
echo "OK Done - Updating version in config"
sudo sed -i "s/^raspiBlitzVersion=.*/raspiBlitzVersion='${codeVersion}'/g" ${configFile}
else
echo "OK - version of config data is up to date" >> ${logFile}
fi
# start network service
echo ""
echo "*** Start ${network} ***" >> ${logFile}
sudo sed -i "s/^message=.*/message='Blockchain Testrun'/g" ${infoFile}
echo "- This can take a while .." >> ${logFile}
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
#sudo chmod +x /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload >> ${logFile}
sudo systemctl enable ${network}d.service >> ${logFile}
sudo systemctl start ${network}d.service >> ${logFile}
# INSTALL LND on Upadte/Recovery
if [ "${lightning}" == "lnd" ]; then
# prepare lnd service
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
# if old lnd.conf exists ...
configExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
# remove RPC user & pass from lnd.conf ... since v1.7
# https://github.com/rootzoll/raspiblitz/issues/2160
echo "- #2160 lnd.conf --> make sure contains no RPC user/pass for bitcoind" >> ${logFile}
sudo sed -i '/^\[Bitcoind\]/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpchost=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpcpass=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.rpcuser=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.zmqpubrawblock=/d' /mnt/hdd/lnd/lnd.conf
sudo sed -i '/^bitcoind.zmqpubrawtx=/d' /mnt/hdd/lnd/lnd.conf
# make sure additional values are added to [Application Options] since v1.7
echo "- lnd.conf --> checking additional [Application Options] since v1.7" >> ${logFile}
applicationOptionsLineNumber=$(sudo grep -n "\[Application Options\]" /mnt/hdd/lnd/lnd.conf | cut -d ":" -f1)
if [ "${applicationOptionsLineNumber}" != "" ]; then
applicationOptionsLineNumber="$(($applicationOptionsLineNumber+1))"
# Avoid historical graph data sync
# ignore-historical-gossip-filters=1
configParamExists=$(sudo grep -c "^ignore-historical-gossip-filters=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'ignore-historical-gossip-filters'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}iignore-historical-gossip-filters=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'ignore-historical-gossip-filters' exists (${configParamExists})" >> ${logFile}
fi
# Avoid slow startup time
# sync-freelist=1
configParamExists=$(sudo grep -c "^sync-freelist=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'sync-freelist'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}isync-freelist=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'sync-freelist' exists (${configParamExists})" >> ${logFile}
fi
# Avoid high startup overhead
# stagger-initial-reconnect=1
configParamExists=$(sudo grep -c "^stagger-initial-reconnect=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'stagger-initial-reconnect'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}istagger-initial-reconnect=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'stagger-initial-reconnect' exists (${configParamExists})" >> ${logFile}
fi
# Delete and recreate RPC TLS certificate when details change or cert expires
# tlsautorefresh=1
configParamExists=$(sudo grep -c "^tlsautorefresh=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsautorefresh'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsautorefresh=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'tlsautorefresh' exists (${configParamExists})" >> ${logFile}
fi
# Do not include IPs in the RPC TLS certificate
# tlsdisableautofill=1
configParamExists=$(sudo grep -c "^tlsdisableautofill=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsdisableautofill'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsdisableautofill=1" /mnt/hdd/lnd/lnd.conf
else
echo " - OK 'tlsdisableautofill' exists (${configParamExists})" >> ${logFile}
fi
else
echo " - WARN: section '[Application Options]' not found in lnd.conf" >> ${logFile}
fi
else
echo "WARN: /mnt/hdd/lnd/lnd.conf not found" >> ${logFile}
fi
# start LND service
echo "Starting LND Service ..." >> ${logFile}
sudo systemctl enable lnd >> ${logFile}
sudo systemctl start lnd >> ${logFile}
elif [ "${lightning}" == "cln" ]; then
echo "Install C-lightning on update" >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Install'/g" ${infoFile}
sudo /home/admin/config.scripts/cln.install.sh on mainnet >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Setup'/g" ${infoFile}
elif [ "${lightning}" == "none" ]; then
echo "No Lightnig" >> ${logFile}
else
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='unknown lightning (${lightning})'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: unknown lightning (${lightning}) in (${configFile})!" >> ${logFile}
exit 1
fi
echo "END Migration/Init" >> ${logFile}
exit 0

View File

@ -14,9 +14,11 @@ infoFile="/home/admin/raspiblitz.info"
# CONFIGFILE - configuration of RaspiBlitz # CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf" configFile="/mnt/hdd/raspiblitz.conf"
# debug info # log header
echo "STARTED Provisioning --> see logs in ${logFile}" echo "" >> ${logFile}
echo "STARTED Provisioning from preset config file" >> ${logFile} echo "###################################" >> ${logFile}
echo "# _provision_.sh" >> ${logFile}
echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile}
# check if there is a config file # check if there is a config file
@ -32,80 +34,7 @@ if [ ${parameterExists} -eq 0 ]; then
echo "lndExtraParameter=''" >> ${configFile} echo "lndExtraParameter=''" >> ${configFile}
fi 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 # import config values
sudo chmod 777 ${configFile}
source ${configFile} source ${configFile}
########################## ##########################
@ -175,6 +104,9 @@ if [ "${network}" = "litecoin" ]; then
/home/admin/config.scripts/blitz.litecoin.sh on >> ${logFile} /home/admin/config.scripts/blitz.litecoin.sh on >> ${logFile}
fi fi
echo "# Make sure the user bitcoin is in the debian-tor group"
sudo usermod -a -G debian-tor bitcoin
# set hostname data # set hostname data
echo "Setting lightning alias: ${hostname}" >> ${logFile} echo "Setting lightning alias: ${hostname}" >> ${logFile}
sudo sed -i "s/^alias=.*/alias=${hostname}/g" /home/admin/assets/lnd.${network}.conf >> ${logFile} 2>&1 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 ln -s /mnt/hdd/ssh /etc/ssh >> ${logFile} 2>&1
#sudo /home/admin/config.scripts/blitz.systemd.sh update-sshd >> ${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') kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then if [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >1GB --> optimizing ${network}.conf" 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 sudo sed -i "s/^maxmempool=.*/maxmempool=300/g" /mnt/hdd/${network}/${network}.conf
fi fi
if [ ${kbSizeRAM} -gt 3500000 ]; then if [ ${kbSizeRAM} -gt 3500000 ]; then
@ -218,18 +149,15 @@ sudo cp -r /mnt/hdd/lnd/data/chain /home/admin/.lnd/data/chain >> ${logFile} 2>&
sudo chown -R admin:admin /home/admin/.${network} >> ${logFile} 2>&1 sudo chown -R admin:admin /home/admin/.${network} >> ${logFile} 2>&1
sudo chown -R admin:admin /home/admin/.lnd >> ${logFile} 2>&1 sudo chown -R admin:admin /home/admin/.lnd >> ${logFile} 2>&1
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1 sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
sudo cp /home/admin/assets/tmux.conf.local /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1 sudo cp /home/admin/assets/tmux.conf.local /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1
sudo chown admin:admin /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1 sudo chown admin:admin /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1
sudo ln -s -f /mnt/hdd/.tmux.conf.local /home/admin/.tmux.conf.local >> ${logFile} 2>&1 sudo ln -s -f /mnt/hdd/.tmux.conf.local /home/admin/.tmux.conf.local >> ${logFile} 2>&1
# backup LND dir (especially for macaroons and tlscerts) # backup LND dir (especially for macaroons and tlscerts)
# https://github.com/rootzoll/raspiblitz/issues/324 # https://github.com/rootzoll/raspiblitz/issues/324
echo "*** Make backup of LND directory" >> ${logFile} 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 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") numOfDiffers=$(sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd | grep -c "differ")
if [ ${numOfDiffers} -gt 0 ]; then if [ ${numOfDiffers} -gt 0 ]; then
@ -241,9 +169,82 @@ else
fi fi
echo "" >> ${logFile} echo "" >> ${logFile}
##########################
# FINISH SETUP
##########################
# finish setup (SWAP, Benus, Firewall, Update, ..) # finish setup (SWAP, Benus, Firewall, Update, ..)
sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile}
/home/admin/90finishSetup.sh >> ${logFile} 2>&1
# add bonus scripts (auto install deactivated to reduce third party repos)
mkdir /home/admin/tmpScriptDL
cd /home/admin/tmpScriptDL
echo "installing bash completion for bitcoin-cli and lncli"
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
sudo cp *.bash-completion /etc/bash_completion.d/
echo "OK - bash completion available after next login"
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
rm -r /home/admin/tmpScriptDL
cd
###### SWAP File
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isSwapExternal} -eq 0 ]; then
echo "No external SWAP found - creating ... "
sudo /home/admin/config.scripts/blitz.datadrive.sh swap on
else
echo "SWAP already OK"
fi
####### FIREWALL - just install (not configure)
echo ""
echo "*** Setting and Activating Firewall ***"
echo "deny incoming connection on other ports"
sudo ufw default deny incoming
echo "allow outgoing connections"
sudo ufw default allow outgoing
echo "allow: ssh"
sudo ufw allow ssh
echo "allow: bitcoin testnet"
sudo ufw allow 18333 comment 'bitcoin testnet'
echo "allow: bitcoin mainnet"
sudo ufw allow 8333 comment 'bitcoin mainnet'
echo "allow: litecoin mainnet"
sudo ufw allow 9333 comment 'litecoin mainnet'
echo 'allow: lightning testnet'
sudo ufw allow 19735 comment 'lightning testnet'
echo "allow: lightning mainnet"
sudo ufw allow 9735 comment 'lightning mainnet'
echo "allow: lightning gRPC"
sudo ufw allow 10009 comment 'lightning gRPC'
echo "allow: lightning REST API"
sudo ufw allow 8080 comment 'lightning REST API'
echo "allow: transmission"
sudo ufw allow 49200:49250/tcp comment 'rtorrent'
echo "allow: public web HTTP"
sudo ufw allow from any to any port 80 comment 'allow public web HTTP'
echo "allow: local web admin HTTPS"
sudo ufw allow from 10.0.0.0/8 to any port 443 comment 'allow local LAN HTTPS'
sudo ufw allow from 172.16.0.0/12 to any port 443 comment 'allow local LAN HTTPS'
sudo ufw allow from 192.168.0.0/16 to any port 443 comment 'allow local LAN HTTPS'
echo "open firewall for auto nat discover (see issue #129)"
sudo ufw allow proto udp from 10.0.0.0/8 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
sudo ufw allow proto udp from 172.16.0.0/12 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
sudo ufw allow proto udp from 192.168.0.0/16 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# update system
echo ""
echo "*** Update System ***"
sudo apt-mark hold raspberrypi-bootloader
sudo apt-get update -y
echo "OK - System is now up to date"
# mark setup is done
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
########################## ##########################
# PROVISIONING SERVICES # PROVISIONING SERVICES
@ -302,7 +303,7 @@ else
fi fi
# TOR # TOR
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" == "on" ]; then
echo "Provisioning TOR - run config script" >> ${logFile} echo "Provisioning TOR - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Tor (takes time)'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Setup Tor (takes time)'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
@ -346,14 +347,34 @@ else
echo "Provisioning DYNAMIC DOMAIN - keep default" >> ${logFile} echo "Provisioning DYNAMIC DOMAIN - keep default" >> ${logFile}
fi fi
# RTL # RTL (LND)
if [ "${rtlWebinterface}" = "on" ]; then if [ "${rtlWebinterface}" = "on" ]; then
echo "Provisioning RTL - run config script" >> ${logFile} echo "Provisioning RTL LND - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile}
sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on lnd mainnet >> ${logFile} 2>&1
sudo systemctl disable RTL # will get enabled after recover dialog sudo systemctl disable RTL # will get enabled after recover dialog
else else
echo "Provisioning RTL - keep default" >> ${logFile} echo "Provisioning RTL LND - keep default" >> ${logFile}
fi
# RTL (CLN)
if [ "${crtlWebinterface}" = "on" ]; then
echo "Provisioning RTL CLN - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile}
sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on cln mainnet >> ${logFile} 2>&1
sudo systemctl disable cRTL # will get enabled after recover dialog
else
echo "Provisioning RTL CLN - keep default" >> ${logFile}
fi
# SPARKO
if [ "${sparko}" = "on" ]; then
echo "Provisioning Sparko - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup SPARKO (takes time)'/g" ${infoFile}
sudo -u admin /home/admin/config.scripts/cln-plugin.sparko.sh on mainnet >> ${logFile} 2>&1
sudo systemctl disable cRTL # will get enabled after recover dialog
else
echo "Provisioning RTL CLN - keep default" >> ${logFile}
fi fi
#LOOP #LOOP
@ -392,13 +413,7 @@ if [ "${BTCPayServer}" = "on" ]; then
echo "Provisioning BTCPAYSERVER on TOR - running setup" >> ${logFile} echo "Provisioning BTCPAYSERVER on TOR - running setup" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup BTCPay (takes time)'/g" ${infoFile} 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 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 else
echo "Provisioning BTCPayServer - keep default" >> ${logFile} echo "Provisioning BTCPayServer - keep default" >> ${logFile}
fi fi
@ -720,6 +735,15 @@ else
sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${datadisk} >> ${logFile} sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${datadisk} >> ${logFile}
fi fi
# MAKE SURE SERVICES ARE RUNNING
echo "Make sure main services are running .." >> ${logFile}
sudo systemctl start ${network}d
if [ "${lightning}" == "lnd" ];then
sudo systemctl start lnd
elif [ "${lightning}" == "cln" ];then
sudo systemctl start lightningd
fi
echo "DONE - Give raspi some cool off time after hard building .... 5 secs sleep" >> ${logFile} echo "DONE - Give raspi some cool off time after hard building .... 5 secs sleep" >> ${logFile}
sleep 5 sleep 5

View File

@ -14,11 +14,16 @@ User=root
Group=root Group=root
Type=simple Type=simple
ExecStart=/home/admin/_background.sh ExecStart=/home/admin/_background.sh
KillMode=process
Restart=always Restart=always
TimeoutSec=10 TimeoutSec=10
RestartSec=10 RestartSec=10
StandardOutput=journal StandardOutput=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -13,9 +13,11 @@ peerbloomfilters=1
# Connection settings # Connection settings
rpcuser=raspibolt rpcuser=raspibolt
rpcpassword=passwordB rpcpassword=passwordB
rpcport=8332 main.rpcport=8332
test.rpcport=18332
rpcallowip=127.0.0.1 rpcallowip=127.0.0.1
rpcbind=127.0.0.1:8332 main.rpcbind=127.0.0.1:8332
test.rpcbind=127.0.0.1:18332
zmqpubrawblock=tcp://127.0.0.1:28332 zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333 zmqpubrawtx=tcp://127.0.0.1:28333
@ -27,3 +29,11 @@ maxconnections=40
maxuploadtarget=5000 maxuploadtarget=5000
datadir=/mnt/hdd/bitcoin 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

View File

@ -1,11 +1,12 @@
# RaspiBlitz: systemd unit for bitcoind # RaspiBlitz: systemd unit for bitcoind
# edit final Wants/After when provision is done
Wants=network.target
After=network.target
[Unit] [Unit]
Description=Bitcoin daemon Description=Bitcoin-Daemon
Wants=bootstrap.service
After=bootstrap.service
# for use with sendmail alert (coming soon) # for use with sendmail alert
#OnFailure=systemd-sendmail@%n #OnFailure=systemd-sendmail@%n
[Service] [Service]
@ -14,13 +15,18 @@ Group=bitcoin
Type=forking Type=forking
PIDFile=/mnt/hdd/bitcoin/bitcoind.pid PIDFile=/mnt/hdd/bitcoin/bitcoind.pid
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED 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 Restart=always
TimeoutSec=120 TimeoutSec=120
RestartSec=30 RestartSec=30
StandardOutput=null StandardOutput=null
StandardError=journal StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -1,44 +0,0 @@
## RaspiBlitz NGINX config: blitzweb.conf
server {
# localhost only
listen 127.0.0.1:443 ssl default_server;
listen [::1]:443 ssl default_server;
# any interface
#listen 443 ssl default_server;
#listen [::]:443 ssl default_server;
server_name _;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";
add_header Strict-Transport-Security "max-age=31536000";
# ToDo(frennkie) if /mnt/hdd/app-data is missing (e.g. no disk) this will cause nginx to fail!
ssl_certificate /mnt/hdd/app-data/nginx/tls.cert;
ssl_certificate_key /mnt/hdd/app-data/nginx/tls.key;
##
# Logging Settings
##
access_log /var/log/nginx/access_raspiblitz.log;
error_log /var/log/nginx/error_raspiblitz.log;
root /var/www/blitzweb;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /info/ {
auth_basic "BlitzWeb (admin:Password B)";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}

View File

@ -14,5 +14,11 @@ ExecStart=/home/admin/_bootstrap.sh
StandardOutput=journal StandardOutput=journal
StandardError=journal StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -27,3 +27,11 @@ discardfee=0.00000001
mintxfee=0.00000001 mintxfee=0.00000001
minrelaytxfee=0.00000001 minrelaytxfee=0.00000001
datadir=/mnt/hdd/litecoin 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

View File

@ -1,7 +1,10 @@
# RaspiBlitz: systemd unit for bitcoind
# edit final Wants/After when provision is done
Wants=network.target
After=network.target
[Unit] [Unit]
Description=Litecoin daemon Description=Litecoin-Daemon
Wants=bootstrap.service
After=bootstrap.service
# for use with sendmail alert (coming soon) # for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n #OnFailure=systemd-sendmail@%n
@ -13,12 +16,17 @@ Type=forking
PIDFile=/home/bitcoin/.litecoin/litecoind.pid PIDFile=/home/bitcoin/.litecoin/litecoind.pid
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf -pid=/home/bitcoin/.litecoin/litecoind.pid ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf -pid=/home/bitcoin/.litecoin/litecoind.pid
KillMode=process
Restart=always Restart=always
TimeoutSec=120 TimeoutSec=120
RestartSec=30 RestartSec=30
StandardOutput=null StandardOutput=null
StandardError=journal StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -17,12 +17,17 @@ User=bitcoin
Group=bitcoin Group=bitcoin
LimitNOFILE=128000 LimitNOFILE=128000
Type=simple Type=simple
KillMode=process
TimeoutSec=180 TimeoutSec=180
Restart=always Restart=always
RestartSec=60 RestartSec=60
StandardOutput=null StandardOutput=null
StandardError=journal StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -4,17 +4,23 @@ server {
listen 80 default_server; listen 80 default_server;
listen [::]:80 default_server; listen [::]:80 default_server;
root /var/www/public;
index index.html;
server_name _;
# proxy for API
location /api/ {
proxy_pass http://127.0.0.1:11111/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
}
# directory for acme challenge
location ^~ /.well-known/acme-challenge/ { location ^~ /.well-known/acme-challenge/ {
default_type "text/plain"; default_type "text/plain";
root /var/www/letsencrypt; root /var/www/letsencrypt;
} }
root /var/www/public;
index index.html;
server_name _;
location / { location / {
# make sure to have https link to exact same host that was called # make sure to have https link to exact same host that was called
sub_filter '<a href="https://HOST_SET_BY_NGINX/' '<a href="https://$host/'; sub_filter '<a href="https://HOST_SET_BY_NGINX/' '<a href="https://$host/';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -1 +0,0 @@
/var/cache/raspiblitz/info.html

View File

@ -1,48 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>RaspiBlitz Status</title>
<link rel="stylesheet" href="status.css">
</head>
<body>
<div class="grid-container" id="regular">
<div class="header">
<p>Info Dashboard (Updated: {{ datetime }})</p>
</div>
<div class="logo">
<img src="RaspiBlitz_Logo_Icon_Negative_Cut.png" height="310" width="196" />
</div>
<div class="main">
<p>RaspiBlitz v{{ codeVersion }} {{ hostname }}</p>
<p>{{ network }} Fullnode + Lightning Network {{ torInfo }}</p>
<p>&nbsp;<p>
<p>CPU load {{ load }}, temp {{ tempC }}°C {{ tempF }}°F</p>
<p>Free Mem {{ ram }} HDDuse {{ hddUsedInfo }}</p>
<p>{{ uptime }}</p>
<p>ssh admin@{{ local_ip }} ▼{{ network_rx }} ▲{{ network_tx }}</p>
{% if runningRTL == '1' %}
<p>web admin --> <a href="http://{{ local_ip }}:3000">http://{{ local_ip }}:3000</a></p>
{% endif %}
<p>&nbsp;<p>
<p>{{ network }} {{ networkVersion }} {{ chain }}net Sync OK {{ sync_percentage }}</p> <!-- ToDo(frennkie) this doesn't cover all cases-->
<p>{{ public_addr_pre }} {{ public_addr }} {{ networkConnections }} peers</p>
<p>&nbsp;<p>
<p>LND {{ ln_version }} {{ ln_baseInfo }} <p>
{% if ln_version|length %}
<p>{{ ln_channelInfo }} {{ ln_peers }} peers <p>
{% endif %}
</div>
<div class="footer">
{% if ln_version|length %}
<p>{{ ln_external }}</p>
{% endif %}
</div>
</div>
</body>
</html>

View File

@ -1,48 +0,0 @@
#regular {
/* The size of the LCD on shopping list */
width: 920px;
height: 440px;
}
.header {
grid-area: header;
text-align: center;
}
.logo {
grid-area: logo;
text-align: center;
}
.main {
grid-area: main;
}
.footer {
grid-area: footer;
}
.grid-container {
display: grid;
grid-template-areas: 'header header header header' 'logo main main main' 'footer footer footer footer';
grid-gap: 1px;
background-color: #02192b;
padding: 1px;
}
.grid-container > div {
background-color: rgba(0, 0, 0, 0.8);
padding: 4px 8px;
font-size: 30px;
}
body {
background-color: black;
font-family: monospace, monospace;
color: LightSteelBlue;
}
p {
font-size: 12px;
margin: 4px;
}

View File

@ -17,9 +17,23 @@
<img src="img/RaspiBlitz_Logo_Main.png" class="rb_logo" alt="RaspiBlitz Logo"/> <img src="img/RaspiBlitz_Logo_Main.png" class="rb_logo" alt="RaspiBlitz Logo"/>
<h2 class="text-center"> <h2 class="text-center">
Welcome Welcome Node Operator
</h2> </h2>
<p id="userinfo">Please Wait ...</p>
<script>
document.getElementById("userinfo").innerHTML=window.location.hostname;
if (window.location.hostname.endsWith(".onion")) {
document.getElementById("userinfo").innerHTML="onion domain address TODO: redirect on same address to subfolder of /ui"
}
else if ((window.location.hostname.endsWith(".local")) || (window.location.hostname.split(".").length>2)) {
document.getElementById("userinfo").innerHTML="local domain/IP address TODO: give info on download/use Tor and offer onion address for easy copy & paste"
}
else {
document.getElementById("userinfo").innerHTML="unknown hostname: "+window.location.hostname
}
</script>
<h4>Use one the following link to access your RaspiBlitz</h4> <h4>Use one the following link to access your RaspiBlitz</h4>
<p> <p>
Please be aware about HTTPS Certificate Warning! Here is some useful information on that... Please be aware about HTTPS Certificate Warning! Here is some useful information on that...

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>RaspiBlitz Welcome</title> <title>WebUI</title>
</head> </head>
<body> <body>

View File

@ -0,0 +1,243 @@
#!/bin/bash
# command info
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
echo
echo "Install or remove parallel chains for Bitcoin Core"
echo "network.bitcoinchains.sh [on|off] [signet|testnet|mainnet]"
echo
exit 1
fi
# CHAIN is signet | testnet | mainnet
CHAIN=$2
if [ "${CHAIN}" != signet ]&&[ "${CHAIN}" != testnet ]&&[ "${CHAIN}" != mainnet ];then
echo "# ${CHAIN} is not supported"
exit 1
fi
# prefix for parallel services
if [ ${CHAIN} = testnet ];then
prefix="t"
bitcoinprefix="test"
zmqprefix=21 # zmqpubrawblock=21332 zmqpubrawtx=21333
rpcprefix=1 # rpcport=18332
elif [ ${CHAIN} = signet ];then
prefix="s"
bitcoinprefix="signet"
zmqprefix=23
rpcprefix=3
elif [ ${CHAIN} = mainnet ];then
prefix=""
bitcoinprefix="main"
zmqprefix=28
rpcprefix=""
fi
function removeParallelService() {
if [ -f "/etc/systemd/system/${prefix}bitcoind.service" ];then
if [ ${CHAIN} != mainnet ];then
/usr/local/bin/bitcoin-cli -${CHAIN} stop
else
/usr/local/bin/bitcoin-cli stop
fi
sudo systemctl stop ${prefix}bitcoind
sudo systemctl disable ${prefix}bitcoind
if [ ${bitcoinprefix} = signet ];then
# check for signet service set up by joininbox
if [ -f "/etc/systemd/system/signetd.service" ];then
sudo systemctl stop signetd
sudo systemctl disable signetd
echo "# The signetd.service is stopped and disabled"
fi
fi
echo "# Bitcoin Core on ${CHAIN} service is stopped and disabled"
fi
}
function installParallelService() {
echo "# Installing Bitcoin Core instance on ${CHAIN}"
# bitcoin.conf
if [ ! -f /home/bitcoin/.bitcoin/bitcoin.conf ];then
# add minimal config
randomRPCpass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8)
echo "
# bitcoind configuration for ${CHAIN}
# Connection settings
rpcuser=raspiblitz
rpcpassword=$randomRPCpass
${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333
onlynet=onion
proxy=127.0.0.1:9050
datadir=/mnt/hdd/bitcoin
" | sudo -u bitcoin tee /home/bitcoin/.bitcoin/bitcoin.conf
else
echo "# /home/bitcoin/.bitcoin/bitcoin.conf is present"
fi
# make sure rpcbind is correctly configured
sudo sed -i s/^rpcbind=/main.rpcbind=/g /mnt/hdd/${network}/${network}.conf
if [ $(grep -c "rpcallowip" < /mnt/hdd/${network}/${network}.conf) -gt 0 ];then
if [ $(grep -c "${bitcoinprefix}.rpcbind=" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
echo "\
${bitcoinprefix}.rpcbind=127.0.0.1"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf
fi
fi
# correct rpcport entry
sudo sed -i s/^rpcport=/main.rpcport=/g /mnt/hdd/${network}/${network}.conf
if [ $(grep -c "${bitcoinprefix}.rpcport" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
echo "\
${bitcoinprefix}.rpcport=${rpcprefix}8332"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf
fi
# correct zmq entry
sudo sed -i s/^zmqpubraw/main.zmqpubraw/g /mnt/hdd/${network}/${network}.conf
if [ $(grep -c "${bitcoinprefix}.zmqpubrawblock" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
echo "\
${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf
fi
if [ -f /mnt/hdd/lnd/lnd.conf ];then
echo "# Check mainnet lnd.conf"
RPCUSER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-)
RPCPSW=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
# it does not pick up main.zmqpubraw entries from bitcoin.conf, need to set manually
if [ $(grep -c zmqpubrawblock /mnt/hdd/lnd/lnd.conf) -eq 0 ];then
echo "
[bitcoind]
bitcoind.rpcuser=$RPCUSER
bitcoind.rpcpass=$RPCPSW
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
" | sudo tee -a /mnt/hdd/lnd/lnd.conf
fi
fi
# addnode
if [ ${bitcoinprefix} = signet ];then
if [ $(grep -c "${bitcoinprefix}.addnode" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then
echo "\
signet.addnode=s7fcvn5rblem7tiquhhr7acjdhu7wsawcph7ck44uxyd6sismumemcyd.onion:38333
signet.addnode=6megrst422lxzsqvshkqkg6z2zhunywhyrhy3ltezaeyfspfyjdzr3qd.onion:38333
signet.addnode=jahtu4veqnvjldtbyxjiibdrltqiiighauai7hmvknwxhptsb4xat4qd.onion:38333
signet.addnode=f4kwoin7kk5a5kqpni7yqe25z66ckqu6bv37sqeluon24yne5rodzkqd.onion:38333
signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38333"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf
fi
fi
removeParallelService
if [ ${CHAIN} = mainnet ];then
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
else
# /etc/systemd/system/${prefix}bitcoind.service
echo "
[Unit]
Description=Bitcoin daemon on ${CHAIN}
[Service]
User=bitcoin
Group=bitcoin
Type=forking
PIDFile=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
ExecStart=/usr/local/bin/bitcoind -${CHAIN} -daemon\
-pid=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
Restart=always
TimeoutSec=120
RestartSec=30
StandardOutput=null
StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/${prefix}bitcoind.service
fi
sudo systemctl daemon-reload
sudo systemctl enable ${prefix}bitcoind
echo "# OK - the bitcoin daemon on ${CHAIN} service is now enabled"
# add aliases
if [ ${CHAIN} != mainnet ];then
if [ $(alias | grep -c ${prefix}bitcoin) -eq 0 ];then
bash -c "echo 'alias ${prefix}bitcoin-cli=\"/usr/local/bin/bitcoin-cli\
-rpcport=${rpcprefix}8332\"' \
>> /home/admin/_aliases"
bash -c "echo 'alias ${prefix}bitcoind=\"/usr/local/bin/bitcoind\
-${CHAIN}\"' \
>> /home/admin/_aliases"
fi
fi
source /home/admin/raspiblitz.info
if [ "${state}" == "ready" ]; then
echo "# OK - the ${prefix}bitcoind.service is enabled, system is ready so starting service"
sudo systemctl start ${prefix}bitcoind
else
echo "# OK - the ${prefix}bitcoindservice is enabled, to start manually use:"
echo "sudo systemctl start ${prefix}bitcoind"
fi
isInstalled=$(systemctl status ${prefix}bitcoind | grep -c active)
if [ $isInstalled -gt 0 ];then
echo "# Installed $(bitcoind --version | grep version)"
echo
echo "# Monitor the ${prefix}bitcoind with:"
if [ ${CHAIN} = signet ]; then
echo "sudo tail -f /mnt/hdd/bitcoin/signet/debug.log"
elif [ ${CHAIN} = testnet ]; then
echo "sudo tail -f /mnt/hdd/bitcoin/testnet3/debug.log"
elif [ ${CHAIN} = mainnet ]; then
echo "sudo tail -f /mnt/hdd/bitcoin/debug.log"
fi
echo
else
echo "# Installation failed"
echo "# See:"
echo "# sudo journalctl -fu ${prefix}bitcoind"
exit 1
fi
}
source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^${CHAIN}=" /mnt/hdd/raspiblitz.conf; then
NEWENTRY="${CHAIN}=off"
sudo /bin/sh -c "echo '$NEWENTRY' >> /mnt/hdd/raspiblitz.conf"
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
installParallelService
# setting value in raspi blitz config
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=on/g" /mnt/hdd/raspiblitz.conf
exit 0
fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# Uninstall Bitcoin Core instance on ${CHAIN}"
removeParallelService
# setting value in raspi blitz config
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=off/g" /mnt/hdd/raspiblitz.conf
exit 0
fi
echo "# FAIL - Unknown Parameter $1"
echo "# may need reboot to run"
exit 1

View 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

View File

@ -1,57 +0,0 @@
#!/bin/bash
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# managing the copy of blockchain data over LAN"
echo "# blitz.copyblockchain.sh [status]"
echo "error='missing parameters'"
exit 1
fi
# load basic system settings
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# check that blockchain is set & supported
if [ "${network}" != "bitcoin" ] && [ "${network}" != "litecoin" ]; then
echo "blockchain='{$network}'"
echo "error='blockchain type missing or not supported'"
exit 1
fi
# check that HDD is available
isMounted=$(sudo df | grep -c /mnt/hdd)
if [ "${isMounted}" != "1" ]; then
echo "error='no datadrive is mounted'"
exit 1
fi
###################
# STATUS
###################
# check if copy is in progress
copyBeginTime=$(cat /mnt/hdd/${network}/copy_begin.time 2>/dev/null | tr -cd '[[:digit:]]')
if [ ${#copyBeginTime} -eq 0 ]; then
copyBeginTime=0
fi
copyEndTime=$(cat /mnt/hdd/${network}/copy_end.time 2>/dev/null | tr -cd '[[:digit:]]')
if [ ${#copyEndTime} -eq 0 ]; then
copyEndTime=0
fi
copyInProgress=0
if [ ${copyBeginTime} -gt ${copyEndTime} ]; then
copyInProgress=1
fi
# output status data & exit
if [ "$1" = "status" ]; then
echo "# blitz.copyblockchain.sh"
echo "copyInProgress=${copyInProgress}"
echo "copyBeginTime=${copyBeginTime}"
echo "copyEndTime=${copyEndTime}"
exit 1
fi
# if no other
echo "error='unknown command'"
exit 1

View File

@ -0,0 +1,397 @@
#!/bin/bash
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# managing the copy of blockchain data over LAN"
echo "# blitz.copychain.sh [status|target|source]"
echo "error='missing parameters'"
exit 1
fi
# load basic system settings
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# check that blockchain is set & supported
if [ "${network}" != "bitcoin" ] && [ "${network}" != "litecoin" ]; then
echo "blockchain='{$network}'"
echo "error='blockchain type missing or not supported'"
exit 1
fi
# check that HDD is available
isMounted=$(sudo df | grep -c /mnt/hdd)
if [ "${isMounted}" != "1" ]; then
echo "error='no datadrive is mounted'"
exit 1
fi
###################
# STATUS
###################
# check if copy is in progress
copyBeginTime=$(cat /mnt/hdd/${network}/copy_begin.time 2>/dev/null | tr -cd '[[:digit:]]')
if [ ${#copyBeginTime} -eq 0 ]; then
copyBeginTime=0
fi
copyEndTime=$(cat /mnt/hdd/${network}/copy_end.time 2>/dev/null | tr -cd '[[:digit:]]')
if [ ${#copyEndTime} -eq 0 ]; then
copyEndTime=0
fi
copyInProgress=0
if [ ${copyBeginTime} -gt ${copyEndTime} ]; then
copyInProgress=1
fi
# output status data & exit
if [ "$1" = "status" ]; then
echo "# blitz.copychain.sh"
echo "copyInProgress=${copyInProgress}"
echo "copyBeginTime=${copyBeginTime}"
echo "copyEndTime=${copyEndTime}"
exit 1
fi
###################
# COPYTARGET
###################
# output status data & exit
if [ "$1" = "target" ]; then
# Basic Options
OPTIONS=(WINDOWS "Windows" \
MACOS "Apple MacOSX" \
LINUX "Linux" \
BLITZ "RaspiBlitz"
)
CHOICE=$(dialog --clear --title " Copy Blockchain from another laptop/node over LAN " --menu "\nWhich system is running on the other laptop/node you want to copy the blockchain from?\n " 14 60 9 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
case $CHOICE in
MACOS) echo "Steve";;
LINUX) echo "Linus";;
WINDOWS) echo "Bill";;
BLITZ) echo "Satoshi";;
*) exit 1;;
esac
# setting copy state
sed -i "s/^state=.*/state=copytarget/g" /home/admin/raspiblitz.info
sed -i "s/^message=.*/message='Receiving Blockchain over LAN'/g" /home/admin/raspiblitz.info
echo "stopping services ..."
sudo systemctl stop bitcoind <2 /dev/null
# check if old blockchain data exists
hasOldBlockchainData=0
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then
hasOldBlockchainData=1
fi
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]')
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
hasOldBlockchainData=1
fi
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
response=$?
clear
echo "response(${response})"
if [ "${response}" = "1" ]; then
echo "OK - keep old blockchain - just try to repair by copying over it"
sleep 3
else
echo "OK - delete old blockchain"
sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null
sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null
sleep 3
fi
# make sure /mnt/hdd/bitcoin exists
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
# allow all users write to it
sudo chmod 777 /mnt/hdd/bitcoin
echo
clear
if [ "${CHOICE}" = "WINDOWS" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a WINDOWS computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR WINDOWS COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your Windows computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your Windows computer & change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on Windows thats: C:\Users\YourUserName\Appdata\Roaming\Bitcoin"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your Windows computer terminal:"
echo "scp -r ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "If asked for a password use PASSWORD A (or 'raspiblitz')."
fi
if [ "${CHOICE}" = "MACOS" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a MacOSX computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR MacOSX COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your MacOSX computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your MacOSX computer and change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on MacOSX thats: cd ~/Library/Application Support/Bitcoin/"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your MacOSX terminal:"
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "You will be asked for passwords. First can be the user password of your MacOSX"
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
fi
if [ "${CHOICE}" = "LINUX" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from a LINUX computer"
echo "****************************************************************************"
echo ""
echo "ON YOUR LINUX COMPUTER download and validate the blockchain with the Bitcoin"
echo "Core wallet software (>=0.17.1) from: bitcoincore.org/en/download"
echo "If the Bitcoin Blockchain is synced up - make sure that your Linux computer &"
echo "your RaspiBlitz are in the same local network."
echo ""
echo "Open a fresh terminal on your Linux computer and change into the directory that"
echo "contains the blockchain data - should see folders named 'blocks' & 'chainstate'"
echo "there. Normally on Linux thats: cd ~/.bitcoin/"
echo "Make sure that the Bitcoin Core Wallet is not running in the background anymore."
echo ""
echo "COPY, PASTE & EXECUTE the following command on your Linux terminal:"
echo "sudo rsync -avhW --progress ./chainstate ./blocks bitcoin@${localip}:/mnt/hdd/bitcoin"
echo ""
echo "You will be asked for passwords. First can be the user password of your Linux"
echo "computer and the last is the PASSWORD A (or 'raspiblitz') of this RaspiBlitz."
fi
if [ "${CHOICE}" = "BLITZ" ]; then
echo "****************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another RaspiBlitz"
echo "****************************************************************************"
echo ""
echo "The other RaspiBlitz needs a minimum version of 1.6 (if lower, update first)."
echo "Make sure that the other RaspiBlitz is on the same local network."
echo ""
echo "Open a fresh terminal and login per SSH into that other RaspiBlitz."
echo "Once in the main menu go: MAINMENU > REPAIR > COPY-SOURCE"
echo "Follow the given instructions ..."
echo ""
echo "The LOCAL IP of this target RaspiBlitz is: ${localip}"
fi
echo ""
echo "It can take multiple hours until transfer is complete - be patient."
echo "****************************************************************************"
echo "PRESS ENTER if transfers is done OR if you want to choose another option."
sleep 2
read key
# make quick check if data is there
anyDataAtAll=0
quickCheckOK=1
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.dat -type f | wc -l)
if [ ${count} -gt 0 ]; then
echo "Found data in /mnt/hdd/bitcoin/blocks"
anyDataAtAll=1
fi
if [ ${count} -lt 300 ]; then
echo "FAIL: transfer seems invalid - less then 300 .dat files (${count})"
quickCheckOK=0
fi
count=$(sudo find /mnt/hdd/bitcoin/ -iname *.ldb -type f | wc -l)
if [ ${count} -gt 0 ]; then
echo "Found data in /mnt/hdd/bitcoin/chainstate"
anyDataAtAll=1
fi
if [ ${count} -lt 700 ]; then
echo "FAIL: transfer seems invalid - less then 700 .ldb files (${count})"
quickCheckOK=0
fi
echo "*********************************************"
echo "QUICK CHECK RESULT"
echo "*********************************************"
# just if any data transferred ..
if [ ${anyDataAtAll} -eq 1 ]; then
# data was invalid - ask user to keep?
if [ ${quickCheckOK} -eq 0 ]; then
echo "FAIL -> DATA seems incomplete."
else
echo "OK -> DATA LOOKS GOOD :D"
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
fi
else
echo "CANCEL -> NO DATA was copied."
quickCheckOK=0
fi
echo "*********************************************"
# REACT ON QUICK CHECK DURING INITAL SETUP
if [ ${quickCheckOK} -eq 0 ]; then
echo "*********************************************"
echo "There seems to be an invalid transfer."
echo "Wait 5 secs ..."
sleep 5
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
response=$?
echo "response(${response})"
if [ "${response}" == "0" ]; then
/home/admin/config.scripts/blitz.copychain.sh
exit 0
fi
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data?" 8 60
response=$?
echo "response(${response})"
case $response in
1) quickCheckOK=1 ;;
esac
fi
if [ ${quickCheckOK} -eq 0 ]; then
echo "Deleting invalid Data ... "
sudo rm -rf /mnt/hdd/bitcoin
sleep 2
fi
echo "restarting services ... (please wait)"
sudo systemctl start bitcoind
sleep 10
# setting copy state
sed -i "s/^state=.*/state=ready/g" /home/admin/raspiblitz.info
sed -i "s/^message=.*/message='Node Running'/g" /home/admin/raspiblitz.info
fi
###################
# COPYSOURCE
###################
if [ "$1" = "source" ]; then
clear
echo
echo "# *** Copy Blockchain Source Modus ***"
echo "# get IP of RaspiBlitz to copy to ..."
targetIP=$(whiptail --inputbox "\nPlease enter the LOCAL IP of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title " Target IP " --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
targetIP=$(echo "${targetIP[0]}")
localIP=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
if [ ${#targetIP} -eq 0 ]; then
exit 1
fi
if [ "${localIP}" == "${targetIP}" ]; then
whiptail --msgbox "Dont type in the local IP of this RaspiBlitz,\nthe LOCAL IP of the other RaspiBlitz is needed." 8 54 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
exit 1
fi
canPingIP=$(ping ${targetIP} -c 1 | grep -c "1 received")
if [ ${canPingIP} -eq 0 ]; then
whiptail --msgbox "Was not able to contact/ping: ${targetIP}\n\n- check if IP of target RaspiBlitz is correct.\n- check to be on the same local network.\n- try again ..." 11 58 "" --title " Testing Target IP " --backtitle "RaspiBlitz - Copy Blockchain"
exit 1
fi
echo "# get Password of RaspiBlitz to copy to ..."
targetPassword=$(whiptail --passwordbox "\nPlease enter the PASSWORD A of the\nRaspiBlitz to copy Blockchain to:" 10 38 "" --title "Target Password" --backtitle "RaspiBlitz - Copy Blockchain" 3>&1 1>&2 2>&3)
if [ ${#targetPassword} -eq 0 ]; then
exit 1
fi
sudo rm /root/.ssh/known_hosts 2>/dev/null
canLogin=$(sudo sshpass -p "${targetPassword}" ssh -t -o StrictHostKeyChecking=no bitcoin@${targetIP} "echo 'working'" 2>/dev/null | grep -c 'working')
if [ ${canLogin} -eq 0 ]; then
whiptail --msgbox "Password was not working for IP: ${targetIP}\n\n- check thats the correct IP for correct RaspiBlitz\n- check that you used PASSWORD A and had no typo\n- If you tried too often, wait 1h try again" 11 58 "" --title " Testing Target Password " --backtitle "RaspiBlitz - Copy Blockchain"
exit 1
fi
echo "# stopping services ..."
sudo systemctl stop background
sudo systemctl stop lnd
sudo systemctl stop ${network}d
sudo systemctl disable ${network}d
sleep 5
sudo systemctl stop bitcoind 2>/dev/null
clear
echo
echo "# Starting copy over LAN (around 4-6 hours) ..."
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
cd /mnt/hdd/${network}
# transfere beginning flag
date +%s > /home/admin/copy_begin.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_begin.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
sudo rm -f /home/admin/copy_begin.time
# repeat the syncing of directories until
# a) there are no files left to transfere (be robust against failing connections, etc)
# b) the user hits a key to break loop after report
while :
do
# transfere blockchain data
rm -f ./transferred.rsync
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 --log-file=./transferred.rsync ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
# check result
# the idea is even after successfull transfer the loop will run a second time
# but on the second time there will be no files transfered (log lines are below 4)
# thats the signal that its done
linesInLogFile=$(wc -l ./transferred.rsync | cut -d " " -f 1)
if [ ${linesInLogFile} -lt 4 ]; then
echo ""
echo "OK all files transfered. DONE"
sleep 2
break
fi
# wait 20 seconds for user exiting loop
echo ""
echo -en "OK one sync loop done ... will test in next loop if all was transferred."
echo -en "PRESS X TO MANUALLY FINISH SYNCING"
read -n 1 -t 6 keyPressed
if [ "${keyPressed}" = "x" ]; then
echo ""
echo "Ending Sync ..."
sleep 2
break
fi
done
# transfere end flag
sed -i "s/^state=.*/state=ready/g" /home/admin/raspiblitz.info
date +%s > /home/admin/copy_end.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' /home/admin/copy_end.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
sudo rm -f /home/admin/copy_end.time
echo "# start services again ..."
sudo systemctl enable ${network}d
sudo systemctl start ${network}d
sudo systemctl start lnd
sudo systemctl start background
echo "# show final message"
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"
fi

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
>&2 echo "# managing the data drive(s) with old EXT4 or new BTRFS" >&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'" echo "error='missing parameters'"
exit 1 exit 1
fi fi
@ -49,7 +49,7 @@ fi
isMounted=$(sudo df | grep -c /mnt/hdd) isMounted=$(sudo df | grep -c /mnt/hdd)
isBTRFS=$(sudo btrfs filesystem show 2>/dev/null| grep -c 'BLITZSTORAGE') isBTRFS=$(sudo btrfs filesystem show 2>/dev/null| grep -c 'BLITZSTORAGE')
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1") 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 # determine if swap is external on or not
externalSwapPath="/mnt/hdd/swapfile" externalSwapPath="/mnt/hdd/swapfile"
@ -71,7 +71,7 @@ if [ "$1" = "status" ]; then
echo "isMounted=${isMounted}" echo "isMounted=${isMounted}"
echo "isBTRFS=${isBTRFS}" 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 # deliver all the detailes needed about the data drive
# and it content for the setup dialogs # and it content for the setup dialogs
if [ ${isMounted} -eq 0 ]; then if [ ${isMounted} -eq 0 ]; then
@ -79,11 +79,11 @@ if [ "$1" = "status" ]; then
echo "# SETUP INFO" echo "# SETUP INFO"
# find the HDD (biggest single partition) # find the HDD (biggest single partition)
# will then be used to offer formatting and permanent mounting
hdd="" hdd=""
sizeDataPartition=0 sizeDataPartition=0
OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g") OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g")
lsblk -o NAME,SIZE -b | grep -P "[s|vn][dv][a-z][0-9]?" > .lsblk.tmp
lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp
while read line; do while read line; do
# cut line info into different informations # cut line info into different informations
@ -141,14 +141,17 @@ if [ "$1" = "status" ]; then
done < .lsblk.tmp done < .lsblk.tmp
rm -f .lsblk.tmp 1>/dev/null 2>/dev/null rm -f .lsblk.tmp 1>/dev/null 2>/dev/null
# display possible warnings from hdd partition detection
if [ "${hddPartitionCandidate}" != "" ] && [ ${#hddDataPartition} -lt 4 ]; then if [ "${hddPartitionCandidate}" != "" ] && [ ${#hddDataPartition} -lt 4 ]; then
echo "# WARNING: found invalid partition (${hddDataPartition}) - redacting" echo "# WARNING: found invalid partition (${hddDataPartition}) - redacting"
hddDataPartition="" hddDataPartition=""
fi fi
# try to detect if its an SSD
isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0) isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
echo "isSSD=${isSSD}" echo "isSSD=${isSSD}"
# display results from hdd & partition detection
echo "hddCandidate='${hdd}'" echo "hddCandidate='${hdd}'"
hddBytes=0 hddBytes=0
hddGigaBytes=0 hddGigaBytes=0
@ -158,9 +161,9 @@ if [ "$1" = "status" ]; then
fi fi
echo "hddBytes=${hddBytes}" echo "hddBytes=${hddBytes}"
echo "hddGigaBytes=${hddGigaBytes}" echo "hddGigaBytes=${hddGigaBytes}"
echo "hddPartitionCandidate='${hddDataPartition}'" echo "hddPartitionCandidate='${hddDataPartition}'"
# if positive deliver more data
if [ ${#hddDataPartition} -gt 0 ]; then if [ ${#hddDataPartition} -gt 0 ]; then
# check partition size in bytes and GBs # 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) hddDataPartitionGigaBytes=$(echo "scale=0; ${sizeDataPartition}/1024/1024/1024" | bc -l)
echo "hddPartitionGigaBytes=${hddDataPartitionGigaBytes}" 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 # check format of devices partition
hddFormat=$(lsblk -o FSTYPE,NAME,TYPE | grep part | grep "${hddDataPartition}" | cut -d " " -f 1) hddFormat=$(lsblk -o FSTYPE,NAME,TYPE | grep part | grep "${hddDataPartition}" | cut -d " " -f 1)
echo "hddFormat='${hddFormat}'" echo "hddFormat='${hddFormat}'"
@ -182,7 +178,7 @@ if [ "$1" = "status" ]; then
# if 'ext4' or 'btrfs' then temp mount and investigate content # if 'ext4' or 'btrfs' then temp mount and investigate content
if [ "${hddFormat}" = "ext4" ] || [ "${hddFormat}" = "btrfs" ]; then 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="" subVolumeDir=""
if [ "${hddFormat}" = "btrfs" ]; then if [ "${hddFormat}" = "btrfs" ]; then
subVolumeDir="/WORKINGDIR" subVolumeDir="/WORKINGDIR"
@ -206,11 +202,30 @@ if [ "$1" = "status" ]; then
echo "hddError='data mount failed'" echo "hddError='data mount failed'"
else 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) # Pre-Setup Investigation of DATA-PART
isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
echo "hddRaspiData=${hddRaspiData}" # check for recoverable RaspiBlitz data (if config file exists) and raid
sudo umount /mnt/hdd 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 fi
# temp storage data drive # temp storage data drive
@ -228,6 +243,9 @@ if [ "$1" = "status" ]; then
echo "hddError='storage mount failed'" echo "hddError='storage mount failed'"
else else
########################################
# Pre-Setup Invetigation of STORAGE-PART
# check for blockchain data on storage # check for blockchain data on storage
hddBlocksBitcoin=$(sudo ls /mnt/storage${subVolumeDir}/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat') hddBlocksBitcoin=$(sudo ls /mnt/storage${subVolumeDir}/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
echo "hddBlocksBitcoin=${hddBlocksBitcoin}" echo "hddBlocksBitcoin=${hddBlocksBitcoin}"
@ -252,7 +270,7 @@ if [ "$1" = "status" ]; then
echo "hddDataFreeKB=${hdd_data_free1Kblocks}" echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
# check if its another fullnode implementation data disk # check if its another fullnode implementation data disk
hddGotMigrationData="none" hddGotMigrationData=""
if [ "${hddFormat}" = "ext4" ]; then if [ "${hddFormat}" = "ext4" ]; then
# check for umbrel # check for umbrel
isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json') isUmbrelHDD=$(sudo ls /mnt/storage/umbrel/info.json 2>/dev/null | grep -c '.json')
@ -268,7 +286,7 @@ if [ "$1" = "status" ]; then
fi fi
echo "hddGotMigrationData='${hddGotMigrationData}'" echo "hddGotMigrationData='${hddGotMigrationData}'"
# unmount # comment this line out if case to study the contect of the storage section
sudo umount /mnt/storage sudo umount /mnt/storage
fi fi
else else
@ -298,6 +316,12 @@ if [ "$1" = "status" ]; then
fi fi
hddRaspiData=$(sudo ls -l /mnt/hdd | grep -c raspiblitz.conf) hddRaspiData=$(sudo ls -l /mnt/hdd | grep -c raspiblitz.conf)
echo "hddRaspiData=${hddRaspiData}" 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) isSSD=$(sudo cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
echo "isSSD=${isSSD}" echo "isSSD=${isSSD}"
@ -346,6 +370,7 @@ if [ "$1" = "status" ]; then
fi fi
# HDD Adpater UASP support --> https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/ # 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 if [ ${#hdd} -gt 0 ]; then
# determine USB HDD adapter model ID # determine USB HDD adapter model ID
@ -1174,17 +1199,28 @@ fi
if [ "$1" = "tempmount" ]; then if [ "$1" = "tempmount" ]; then
# get HDD status and candidates
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isMounted} -eq 1 ]; then if [ ${isMounted} -eq 1 ]; then
echo "error='already mounted'" echo "error='already mounted'"
exit 1 exit 1
fi fi
# get device to temp mount # get device to temp mount from parameter (optional)
hdd=$2 hdd=$2
if [ ${#hdd} -eq 0 ]; then # automount if no parameter the hddcandinate
>&2 echo "# FAIL which device should be temp mounted (e.g. sda)" if [ "${hdd}" == "" ]; then
>&2 echo "# run 'status' to see device candidates" if [ "${hddFormat}" != "btrfs" ]; then
echo "error='missing second parameter'" 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 exit 1
fi fi
@ -1264,6 +1300,14 @@ if [ "$1" = "tempmount" ]; then
fi 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 # LINKING all directories with ln
######################################## ########################################
@ -1482,6 +1526,9 @@ if [ "$1" = "clean" ]; then
>&2 echo "# RASPIBLITZ DATA DRIVES - CLEANING" >&2 echo "# RASPIBLITZ DATA DRIVES - CLEANING"
# get HDD status
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isMounted} -eq 0 ]; then if [ ${isMounted} -eq 0 ]; then
>&2 echo "# FAIL: cannot clean - the drive is not mounted'" >&2 echo "# FAIL: cannot clean - the drive is not mounted'"
echo "error='not mounted'" echo "error='not mounted'"
@ -1492,9 +1539,9 @@ if [ "$1" = "clean" ]; then
sudo apt-get install -y secure-delete 1>/dev/null sudo apt-get install -y secure-delete 1>/dev/null
>&2 echo >&2 echo
>&2 echo "# IMPORTANT: There is no 100% guarantee that sensitive data is completely deleted!" >&2 echo "# IMPORTANT: No 100% guarantee that sensitive data is completely deleted!"
>&2 echo "# see: https://www.davescomputers.com/securely-deleting-files-solid-state-drive/" # 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" # 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 "# --> Dont resell or gift data drive. Destroy physically if needed."
>&2 echo >&2 echo
@ -1537,7 +1584,7 @@ if [ "$1" = "clean" ]; then
fi fi
# on SSDs never shredd # on SSDs never shredd
# https://www.davescomputers.com/securely-deleting-files-solid-state-drive/ # https://www.davescomputers.com/securely-deleting-files-solid-state-drive/
if [ ${isSSD} -eq 1 ]; then if [ "${isSSD}" == "1" ]; then
whenDeleteSchredd=0 whenDeleteSchredd=0
fi fi
@ -1578,12 +1625,13 @@ if [ "$1" = "clean" ]; then
# take extra care if wallet.db exists # take extra care if wallet.db exists
sudo srm /mnt/hdd/${chain}/wallet.db 2>/dev/null sudo srm /mnt/hdd/${chain}/wallet.db 2>/dev/null
# the rest just delete (keep blocks and chainstate) # the rest just delete (keep blocks and chainstate and testnet3)
for entry in $(ls -A1 /mnt/hdd/${chain} 2>/dev/null) for entry in $(ls -A1 /mnt/hdd/${chain} 2>/dev/null)
do do
# sorting file # sorting file
delete=1 delete=1
if [ "${entry}" = "blocks" ] || [ "${entry}" = "chainstate" ]; then if [ "${entry}" = "blocks" ] || [ "${entry}" = "chainstate" ]\
|| [ "${entry}" = "testnet3" ] ; then
delete=0 delete=0
fi fi
# delete or keep # delete or keep
@ -1599,6 +1647,30 @@ if [ "$1" = "clean" ]; then
>&2 echo "# keeping: ${entry}" >&2 echo "# keeping: ${entry}"
fi fi
done done
# keep blocks and chainstate in testnet3 if exists
if [ -d /mnt/hdd/bitcoin/testnet3 ];then
for entry in $(ls -A1 /mnt/hdd/bitcoin/testnet3 2>/dev/null)
do
# sorting file
delete=1
if [ "${entry}" = "blocks" ] || [ "${entry}" = "chainstate" ]; then
delete=0
fi
# delete or keep
if [ ${delete} -eq 1 ]; then
if [ -d "/mnt/hdd/bitcoin/testnet3/$entry" ]; then
>&2 echo "# Deleting DIR : /mnt/hdd/bitcoin/testnet3/${entry}"
sudo rm -r /mnt/hdd/bitcoin/testnet3/$entry
else
>&2 echo "# deleting FILE : /mnt/hdd/bitcoin/testnet3/${entry}"
sudo rm /mnt/hdd/bitcoin/testnet3/$entry
fi
else
>&2 echo "# keeping: ${entry}"
fi
done
fi
done done
fi fi
@ -1672,5 +1744,43 @@ if [ "$1" = "clean" ]; then
fi 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'" echo "error='unkown command'"
exit 1 exit 1

View File

@ -39,10 +39,22 @@ echo "chainnetwork: ${network} / ${chain}"
uptime uptime
echo "" echo ""
echo "*** SETUPPHASE / BOOTSTRAP ***"
echo "see logs: cat /home/admin/raspiblitz.log"
echo "setupPhase--> ${setupPhase}"
echo "state--> ${state}"
if [ "${setupPhase}" != "done" ]; then
sudo tail -n 20 /home/admin/raspiblitz.log
fi
echo ""
echo "*** BACKGROUNDSERVICE ***"
echo "to monitor Background service call: sudo journalctl -f -u background"
echo ""
echo "*** BLOCKCHAIN SYSTEMD STATUS ***" echo "*** BLOCKCHAIN SYSTEMD STATUS ***"
sudo systemctl status ${network}d -n2 --no-pager sudo systemctl status ${network}d -n2 --no-pager
echo "" echo ""
echo "*** LAST BLOCKCHAIN ERROR LOGS ***" echo "*** LAST BLOCKCHAIN ERROR LOGS ***"
echo "sudo journalctl -u ${network}d -b --no-pager -n8" echo "sudo journalctl -u ${network}d -b --no-pager -n8"
sudo journalctl -u ${network}d -b --no-pager -n8 sudo journalctl -u ${network}d -b --no-pager -n8
@ -60,7 +72,6 @@ echo ""
echo "*** LND SYSTEMD STATUS ***" echo "*** LND SYSTEMD STATUS ***"
sudo systemctl status lnd -n2 --no-pager sudo systemctl status lnd -n2 --no-pager
echo "" echo ""
echo "*** LAST LND ERROR LOGS ***" echo "*** LAST LND ERROR LOGS ***"
echo "sudo journalctl -u lnd -b --no-pager -n12" echo "sudo journalctl -u lnd -b --no-pager -n12"
sudo journalctl -u lnd -b --no-pager -n12 sudo journalctl -u lnd -b --no-pager -n12
@ -71,6 +82,14 @@ echo "sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log"
sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log
echo "" echo ""
echo "*** C-LIGHTNING SYSTEMD STATUS ***"
sudo systemctl status lightningd -n2 --no-pager
echo ""
echo "*** LAST 30 C-LIGHTNING INFO LOGS ***"
echo "sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log"
sudo tail -n 30 /home/bitcoin/.lightning/${network}/cl.log
echo ""
echo "*** NGINX SYSTEMD STATUS ***" echo "*** NGINX SYSTEMD STATUS ***"
sudo systemctl status nginx -n2 --no-pager sudo systemctl status nginx -n2 --no-pager
echo "" echo ""
@ -82,7 +101,18 @@ echo "--> CHECK CONFIG: sudo nginx -t"
sudo nginx -t sudo nginx -t
echo "" echo ""
if [ "${touchscreen}" = "0" ]; then echo "*** BLITZAPI SYSTEMD STATUS ***"
sudo systemctl status blitzapi -n2 --no-pager
echo ""
echo "*** LAST BLITZAPI LOGS ***"
echo "sudo journalctl -u blitzapi -b --no-pager -n20"
sudo journalctl -u nginx -b --no-pager -n20
echo "--> CHECK CONFIG: sudo nginx -t"
sudo nginx -t
echo ""
if [ "${touchscreen}" = "" ] || [ "${touchscreen}" = "0" ]; then
echo "- TOUCHSCREEN is OFF by config" echo "- TOUCHSCREEN is OFF by config"
else else
echo "" echo ""
@ -92,7 +122,7 @@ else
echo "" echo ""
fi fi
if [ "${loop}" = "off" ]; then if [ "${loop}" = "" ] || [ "${loop}" = "off" ]; then
echo "- Loop is OFF by config" echo "- Loop is OFF by config"
else else
echo "" echo ""
@ -102,7 +132,7 @@ else
echo "" echo ""
fi fi
if [ "${rtlWebinterface}" = "off" ]; then if [ "${rtlWebinterface}" = "" ] || [ "${rtlWebinterface}" = "off" ]; then
echo "- RTL is OFF by config" echo "- RTL is OFF by config"
else else
echo "" echo ""
@ -112,7 +142,7 @@ else
echo "" echo ""
fi fi
if [ "${ElectRS}" = "off" ]; then if [ "${ElectRS}" = "" ] || [ "${ElectRS}" = "off" ]; then
echo "- Electrum Rust Server is OFF by config" echo "- Electrum Rust Server is OFF by config"
else else
echo "" echo ""
@ -125,7 +155,7 @@ else
echo "" echo ""
fi fi
if [ "${lit}" = "off" ]; then if [ "${lit}" = "" ] || [ "${lit}" = "off" ]; then
echo "- LIT is OFF by config" echo "- LIT is OFF by config"
else else
echo "" echo ""
@ -135,7 +165,7 @@ else
echo "" echo ""
fi fi
if [ "${BTCPayServer}" = "off" ]; then if [ "${BTCPayServer}" = "" ] || [ "${BTCPayServer}" = "off" ]; then
echo "- BTCPayServer is OFF by config" echo "- BTCPayServer is OFF by config"
else else
echo "" echo ""
@ -145,7 +175,7 @@ else
echo "" echo ""
fi fi
if [ "${LNBits}" = "off" ]; then if [ "${LNBits}" = "" ] || [ "${LNBits}" = "off" ]; then
echo "- LNbits is OFF by config" echo "- LNbits is OFF by config"
else else
echo "" echo ""
@ -155,7 +185,7 @@ else
echo "" echo ""
fi fi
if [ "${thunderhub}" = "off" ]; then if [ "${thunderhub}" = "" ] || [ "${thunderhub}" = "off" ]; then
echo "- Thunderhub is OFF by config" echo "- Thunderhub is OFF by config"
else else
echo "" echo ""
@ -165,7 +195,7 @@ else
echo "" echo ""
fi fi
if [ "${specter}" = "off" ]; then if [ "${specter}" = "" ] || [ "${specter}" = "off" ]; then
echo "- SPECTER is OFF by config" echo "- SPECTER is OFF by config"
else else
echo "" echo ""
@ -175,7 +205,7 @@ else
echo "" echo ""
fi fi
if [ "${sphinxrelay}" = "off" ]; then if [ "${sphinxrelay}" = "" ] || [ "${sphinxrelay}" = "off" ]; then
echo "- SPHINX is OFF by config" echo "- SPHINX is OFF by config"
else else
echo "" echo ""
@ -216,5 +246,5 @@ echo ""
echo "*** OPTION: SHARE THIS DEBUG OUTPUT ***" echo "*** OPTION: SHARE THIS DEBUG OUTPUT ***"
echo "An easy way to share this debug output on GitHub or on a support chat" echo "An easy way to share this debug output on GitHub or on a support chat"
echo "use the following command and share the resulting link:" echo "use the following command and share the resulting link:"
echo "/home/admin/XXdebugLogs.sh | nc termbin.com 9999" echo "debug | nc termbin.com 9999"
echo "" echo ""

View File

@ -158,14 +158,17 @@ fi
echo "# COPYING from GIT-Directory to /home/admin/" echo "# COPYING from GIT-Directory to /home/admin/"
sudo rm -r /home/admin/config.scripts 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/* /home/admin
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/assets /home/admin sudo -u admin chmod -R +x /home/admin/config.scripts
sudo -u admin chmod +x /home/admin/*.sh sudo -u admin chmod -R +x /home/admin/setup.scripts
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
echo "# ******************************************" echo "# ******************************************"
echo "# Syncing Webcontent .."
if [ -d /var/www/public ]; then
sudo cp -a /home/admin/assets/nginx/www_public/* /var/www/public
sudo chown www-data:www-data /var/www/public
fi
echo "# Checking if the content of BlitzPy changed .." echo "# Checking if the content of BlitzPy changed .."
checkSumBlitzPyAfter=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum) checkSumBlitzPyAfter=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum)
echo "# checkSumBlitzPyBefore = ${checkSumBlitzPyBefore}" echo "# checkSumBlitzPyBefore = ${checkSumBlitzPyBefore}"

View 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

View File

@ -1,10 +1,8 @@
#!/bin/bash #!/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 if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# managing the RaspiBlitz data - import, export, backup." 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'" echo "error='missing parameters'"
exit 1 exit 1
fi fi
@ -22,25 +20,23 @@ fi
# check if data drive is mounted - other wise cannot operate # check if data drive is mounted - other wise cannot operate
isMounted=$(sudo df | grep -c /mnt/hdd) 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 # set place where zipped TAR file gets stored
defaultZipPath="/mnt/hdd/temp" defaultUploadPath="/mnt/hdd/temp/migration"
# get local ip # get local ip
source <(/home/admin/config.scripts/internet.sh status local) source <(/home/admin/config.scripts/internet.sh status local)
# SCP download and upload links # SCP download and upload links
scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz' ./" scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz' ./"
scpDownloadWin="scp -r bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz ." scpDownloadWin="scp -r bitcoin@${localip}:${defaultUploadPath}/raspiblitz-*.tar.gz ."
scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}" scpUploadUnix="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}" scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultUploadPath}"
# output status data & exit # output status data & exit
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
echo "# RASPIBLITZ Data Import & Export" echo "# RASPIBLITZ Data Import & Export"
echo "isBTRFS=${isBTRFS}" echo "localip=\"${localip}\""
echo "defaultUploadPath=\"${defaultUploadPath}\""
echo "scpDownloadUnix=\"${scpDownloadUnix}\"" echo "scpDownloadUnix=\"${scpDownloadUnix}\""
echo "scpUploadUnix=\"${scpUploadUnix}\"" echo "scpUploadUnix=\"${scpUploadUnix}\""
echo "scpDownloadWin=\"${scpDownloadWin}\"" echo "scpDownloadWin=\"${scpDownloadWin}\""
@ -310,23 +306,23 @@ if [ "$1" = "export" ]; then
# zip it # zip it
echo "# Building the Export File (this can take some time) .." 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 # get md5 checksum
echo "# Building checksum (can take also a while) ..." 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}" echo "md5checksum=${md5checksum}"
# get byte size # 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}" echo "bytesize=${bytesize}"
# final renaming # final renaming
name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz" name="raspiblitz${blitzname}${datestamp}-${md5checksum}.tar.gz"
echo "exportpath='${defaultZipPath}'" echo "exportpath='${defaultUploadPath}'"
echo "filename='${name}'" echo "filename='${name}'"
sudo mv ${defaultZipPath}/raspiblitz-export-temp.tar.gz ${defaultZipPath}/${name} sudo mv ${defaultUploadPath}/raspiblitz-export-temp.tar.gz ${defaultUploadPath}/${name}
sudo chown bitcoin:bitcoin ${defaultZipPath}/${name} sudo chown bitcoin:bitcoin ${defaultUploadPath}/${name}
# delete temp files # delete temp files
rm ~/.exclude.temp rm ~/.exclude.temp
@ -341,7 +337,7 @@ fi
if [ "$1" = "export-gui" ]; then if [ "$1" = "export-gui" ]; then
# cleaning old migration files from blitz # 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 # stopping lnd / bitcoin
echo "--> stopping services ..." echo "--> stopping services ..."
@ -351,7 +347,7 @@ if [ "$1" = "export-gui" ]; then
# create new migration file # create new migration file
clear clear
echo "--> creating blitz migration file ... (please wait)" 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 if [ ${#filename} -eq 0 ]; then
echo "# FAIL: was not able to create migration file" echo "# FAIL: was not able to create migration file"
exit 0 exit 0
@ -381,7 +377,7 @@ if [ "$1" = "export-gui" ]; then
read key read key
echo "Shutting down ...." echo "Shutting down ...."
sleep 4 sleep 4
/home/admin/XXshutdown.sh /home/admin/config.scripts/blitz.shutdown.sh
exit 0 exit 0
fi fi
@ -391,71 +387,29 @@ fi
if [ "$1" = "import" ]; then if [ "$1" = "import" ]; then
# check second parameter for path and/or filename of import # BACKGROUND:
importFile="${defaultZipPath}/raspiblitz-*.tar.gz" # the migration import is only called during setup phase - assume a prepared but clean HDD
if [ ${#2} -gt 0 ]; then
# check if and/or filename of import # 2nd PARAMETER: file to import (expect that the file was valid checked from calling script)
containsPath=$(echo $2 | grep -c '/') importFile=$2
if [ ${containsPath} -gt 0 ]; then if [ "${importFile}" == "" ]; then
startsOnPath=$(echo $2 | grep -c '^/') echo "error='filename missing'"
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'"
exit 1 exit 1
elif [ ${countZips} -eq 1 ]; then fi
importFile=$(sudo ls ${importFile}) fileExists=$(sudo ls ${importFile} 2>/dev/null | grep -c "${importFile}")
else if [ "${fileExists}" != "1" ]; then
echo "# Multiple files found. Not sure which to use." echo "error='filename not found'"
echo "# Please use absolut-path+file as second parameter."
echo "error='file not unique'"
exit 1 exit 1
fi fi
echo "importFile='${importFile}'" 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) .." echo "# Importing (overwrite) (can take some time) .."
sudo tar -xf ${importFile} -C / 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) # copy bitcoin/litecoin data backups back to orgplaces (if part of backup)
if [ -d "/mnt/hdd/backup_bitcoin" ]; then 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 sudo chown bitcoin:bitcoin -R /mnt/storage/litecoin 2>/dev/null
fi fi
echo "# OK done - you may now want to:" # check migration
echo "# make sure that HDD is not registered in /etc/fstab & reboot" raspiblitzConfExists=$(sudo ls /mnt/hdd/raspiblitz.conf | grep -c "raspiblitz.conf")
echo "# to kickstart recovering system based in imported data" if [ "${raspiblitzConfExists}" != "1" ]; then
echo "error='no raspiblitz.conf after unzip migration file'"
exit 0 echo "# reboot system ... HDD will offer fresh formating"
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"
exit 1 exit 1
fi fi
# make sure a HDD/SSD is connected # correcting all user rights on data will be done by provisioning process
if [ ${#hddCandidate} -eq 0 ]; then echo "# OK import done - provisioning process needed"
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
exit 0 exit 0
fi fi
echo "error='unkown command'" echo "error='unkown command'"
exit 1 exit 1

View File

@ -0,0 +1,63 @@
#!/usr/bin/python3
import sys
from mnemonic import Mnemonic
# display config script info
if len(sys.argv) <= 1 or sys.argv[1] == "-h" or sys.argv[1] == "help":
print("tool for seed words")
print("blitz.mnemonic.py generate")
print("blitz.mnemonic.py test \"[SEEDWORDS-SPACE-SEPERATED]\"")
sys.exit(1)
def dump(obj):
for attr in dir(obj):
print("obj.%s = %r" % (attr, getattr(obj, attr)))
#######################
# GENERATE SEED WORDS
#######################
def generate():
mnemo = Mnemonic("english")
seedwords = mnemo.generate(strength=256)
print("seedwords='" + seedwords + "'")
# add a 6x4 formatted version to the output
wordlist = list(seedwords.split(" "))
seed_words_6x4 = ""
for i in range(0, len(wordlist)):
if i % 6 == 0 and i != 0:
seed_words_6x4 = seed_words_6x4 + "\n"
single_word = str(i + 1) + ":" + wordlist[i]
while len(single_word) < 12:
single_word = single_word + " "
seed_words_6x4 = seed_words_6x4 + single_word
print("seedwords6x4='" + seed_words_6x4 + "'")
#######################
# TEST SEED WORDS
#######################
def test(words):
mnemo = Mnemonic("english")
if mnemo.check(words):
print("valid=1")
else:
print("valid=0")
def main():
if sys.argv[1] == "generate":
generate()
elif sys.argv[1] == "test":
test(sys.argv[2])
else:
# UNKNOWN PARAMETER
print("error='unknown parameter'")
if __name__ == '__main__':
main()

View File

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

View File

@ -4,7 +4,7 @@
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a passwords A,B,C & D" echo "small config script to set a passwords A,B,C & D"
echo "blitz.setpassword.sh a [?newpassword] " 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 "blitz.setpassword.sh c [?oldpassword] [?newpassword] "
echo "or just as a password enter dialog (result as file)" echo "or just as a password enter dialog (result as file)"
echo "blitz.setpassword.sh [x] [text] [result-file] [?empty-allowed]" echo "blitz.setpassword.sh [x] [text] [result-file] [?empty-allowed]"
@ -64,14 +64,11 @@ if [ ${#abcd} -eq 0 ]; then
abcd='d'; abcd='d';
;; ;;
*) *)
exit 1 exit 0
;; ;;
esac esac
fi fi
echo "Changing Password ${abcd} ..."
echo ""
############################ ############################
# PASSWORD A # PASSWORD A
if [ "${abcd}" = "a" ]; then if [ "${abcd}" = "a" ]; then
@ -89,7 +86,7 @@ if [ "${abcd}" = "a" ]; then
echo "CANCEL not possible" echo "CANCEL not possible"
sleep 2 sleep 2
else else
exit 1 exit 0
fi fi
fi fi
@ -100,7 +97,7 @@ if [ "${abcd}" = "a" ]; then
echo "CANCEL not possible" echo "CANCEL not possible"
sleep 2 sleep 2
else else
exit 1 exit 0
fi fi
fi fi
@ -108,14 +105,14 @@ if [ "${abcd}" = "a" ]; then
if [ "${password1}" != "${password2}" ]; then if [ "${password1}" != "${password2}" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh a sudo /home/admin/config.scripts/blitz.setpassword.sh a
exit 1 exit 0
fi fi
# password zero # password zero
if [ ${#password1} -eq 0 ]; then if [ ${#password1} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh a sudo /home/admin/config.scripts/blitz.setpassword.sh a
exit 1 exit 0
fi fi
# check that password does not contain bad characters # check that password does not contain bad characters
@ -123,14 +120,14 @@ if [ "${abcd}" = "a" ]; then
if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh a sudo /home/admin/config.scripts/blitz.setpassword.sh a
exit 1 exit 0
fi fi
# password longer than 8 # password longer than 8
if [ ${#password1} -lt 8 ]; then if [ ${#password1} -lt 8 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh a sudo /home/admin/config.scripts/blitz.setpassword.sh a
exit 1 exit 0
fi fi
# use entred password now as parameter # use entred password now as parameter
@ -165,7 +162,7 @@ elif [ "${abcd}" = "b" ]; then
echo "CANCEL not possible" echo "CANCEL not possible"
sleep 2 sleep 2
else else
exit 1 exit 0
fi fi
fi fi
@ -176,7 +173,7 @@ elif [ "${abcd}" = "b" ]; then
echo "CANCEL not possible" echo "CANCEL not possible"
sleep 2 sleep 2
else else
exit 1 exit 0
fi fi
fi fi
@ -184,14 +181,14 @@ elif [ "${abcd}" = "b" ]; then
if [ "${password1}" != "${password2}" ]; then if [ "${password1}" != "${password2}" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b sudo /home/admin/config.scripts/blitz.setpassword.sh b
exit 1 exit 0
fi fi
# password zero # password zero
if [ ${#password1} -eq 0 ]; then if [ ${#password1} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b sudo /home/admin/config.scripts/blitz.setpassword.sh b
exit 1 exit 0
fi fi
# check that password does not contain bad characters # check that password does not contain bad characters
@ -199,14 +196,14 @@ elif [ "${abcd}" = "b" ]; then
if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b sudo /home/admin/config.scripts/blitz.setpassword.sh b
exit 1 exit 0
fi fi
# password longer than 8 # password longer than 8
if [ ${#password1} -lt 8 ]; then if [ ${#password1} -lt 8 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b sudo /home/admin/config.scripts/blitz.setpassword.sh b
exit 1 exit 0
fi fi
# use entred password now as parameter # use entred password now as parameter
@ -333,7 +330,7 @@ elif [ "${abcd}" = "c" ]; then
if [ ${#newPassword} -lt 8 ]; then if [ ${#newPassword} -lt 8 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8" 6 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword} sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 1 exit 0
fi fi
# ask user to retype new password c # ask user to retype new password c
@ -368,7 +365,7 @@ elif [ "${abcd}" = "c" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Was not able to change password\n\n${err}\n${errMore}" 10 52 dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Was not able to change password\n\n${err}\n${errMore}" 10 52
clear clear
echo "# FAIL: Was not able to change password" echo "# FAIL: Was not able to change password"
exit 1 exit 0
fi fi
# old manual way # old manual way
@ -415,7 +412,7 @@ elif [ "${abcd}" = "x" ]; then
if [ "${password1}" != "${password2}" ]; then if [ "${password1}" != "${password2}" ]; then
dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4" sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4"
exit 1 exit 0
fi fi
if [ ${emptyAllowed} -eq 0 ]; then if [ ${emptyAllowed} -eq 0 ]; then
@ -424,7 +421,7 @@ elif [ "${abcd}" = "x" ]; then
if [ ${#password1} -eq 0 ]; then if [ ${#password1} -eq 0 ]; then
dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4" sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4"
exit 1 exit 0
fi fi
# check that password does not contain bad characters # check that password does not contain bad characters
@ -432,14 +429,14 @@ elif [ "${abcd}" = "x" ]; then
if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then
dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 62 dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Contains bad characters (spaces, special chars)\nPlease try again ..." 6 62
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4" sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4"
exit 1 exit 0
fi fi
# password longer than 8 # password longer than 8
if [ ${#password1} -lt 8 ]; then if [ ${#password1} -lt 8 ]; then
dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52 dialog --backtitle "RaspiBlitz" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4" sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3" "$4"
exit 1 exit 0
fi fi
fi fi
@ -450,13 +447,13 @@ elif [ "${abcd}" = "x" ]; then
# everything else # everything else
else else
echo "FAIL: there is no password '${abcd}' (reminder: use lower case)" echo "FAIL: there is no password '${abcd}' (reminder: use lower case)"
exit 1 exit 0
fi fi
# when started with menu ... reboot when done # when started with menu ... reboot when done
if [ "${reboot}" == "1" ]; then if [ "${reboot}" == "1" ]; then
echo "Now rebooting to activate changes ..." echo "Now rebooting to activate changes ..."
sudo /home/admin/XXshutdown.sh reboot sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
else else
echo "..." echo "..."
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# for reboot call: sudo /home/admin/XXshutdown.sh reboot # for reboot call: sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
# use this script instead of dirct shutdown command to: # use this script instead of dirct shutdown command to:
# 1) give UI the info that a reboot/shutdown is now happening # 1) give UI the info that a reboot/shutdown is now happening
@ -38,8 +38,9 @@ echo "stop electrs - please wait .."
sudo systemctl stop electrs 2>/dev/null sudo systemctl stop electrs 2>/dev/null
# stopping lnd # stopping lnd
echo "stop lnd - please wait .." echo "stop lightning - please wait .."
sudo systemctl stop lnd 2>/dev/null sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop lightningd 2>/dev/null
# stopping bitcoin (thru cli) # stopping bitcoin (thru cli)
echo "stop ${network}d (1) - please wait .." echo "stop ${network}d (1) - please wait .."

View File

@ -1,7 +1,16 @@
#!/bin/bash #!/bin/bash
source /home/admin/raspiblitz.info 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
LNTYPE=$1
else
LNTYPE=lnd
fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
# command info # command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@ -17,7 +26,7 @@ sudo mkdir /mnt/hdd/temp 2>/dev/null
sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null
# localIP # localIP
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | egrep -i '(*[eth|ens|enp|eno|wlan|wlp][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(hostname -I | awk '{print $1}')
echo "localIP='${localip}'" echo "localIP='${localip}'"
# temp - no measurement in a VM # temp - no measurement in a VM
@ -45,7 +54,7 @@ echo "bitcoinActive=${bitcoinRunning}"
if [ ${bitcoinRunning} -eq 1 ]; then if [ ${bitcoinRunning} -eq 1 ]; then
# get blockchain info # get blockchain info
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/mnt/hdd/temp/.bitcoind.out 2>/mnt/hdd/temp/.bitcoind.error $bitcoincli_alias getblockchaininfo 1>/mnt/hdd/temp/.bitcoind.out 2>/mnt/hdd/temp/.bitcoind.error
# check if error on request # check if error on request
blockchaininfo=$(cat /mnt/hdd/temp/.bitcoind.out 2>/dev/null) blockchaininfo=$(cat /mnt/hdd/temp/.bitcoind.out 2>/dev/null)
bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null) bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null)
@ -57,6 +66,13 @@ if [ ${bitcoinRunning} -eq 1 ]; then
echo "bitcoinErrorFull='${bitcoinErrorFull}'" echo "bitcoinErrorFull='${bitcoinErrorFull}'"
else 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 # Get data from blockchaininfo
############################## ##############################
@ -120,15 +136,15 @@ startcountLightning=$(cat /home/admin/systemd.lightning.log 2>/dev/null | grep -
echo "startcountLightning=${startcountLightning}" echo "startcountLightning=${startcountLightning}"
# is LND running # is LND running
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running) lndRunning=$(systemctl status ${netprefix}lnd.service 2>/dev/null | grep -c running)
echo "lndActive=${lndRunning}" echo "lndActive=${lndRunning}"
if [ ${lndRunning} -eq 1 ]; then if [ ${lndRunning} -eq 1 ]; then
# get LND info # get LND info
lndRPCReady=1 lndRPCReady=1
lndinfo=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>/mnt/hdd/temp/.lnd.error) lndinfo=$($lncli_alias getinfo 2>/mnt/hdd/temp/.lnd.error)
# check if error on request # check if error on request
lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null) lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null)
lndErrorShort='' lndErrorShort=''
@ -252,6 +268,22 @@ if [ ${lndRunning} -eq 1 ]; then
fi fi
# is CLN running
clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
echo "clnActive=${clnRunning}"
if [ ${clnRunning} -eq 1 ]; then
clnInfo=$(sudo -u bitcoin lightning-cli getinfo)
clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')
scanProgress=$(echo "scale=2; $clnBlockHeight*100/$total" | bc)
echo "scanProgress=${scanProgress}"
clnBlockHeightPlusOne=$(expr $clnBlockHeight + 1)
if [ "${total}" == "${clnBlockHeight}" ] || [ "${total}" == "${clnBlockHeightPlusOne}" ]; then
echo "syncedToChain=1"
else
echo "syncedToChain=0"
fi
fi
# touchscreen statistics # touchscreen statistics
if [ "${touchscreen}" == "1" ]; then if [ "${touchscreen}" == "1" ]; then
echo "blitzTUIActive=1" echo "blitzTUIActive=1"
@ -265,6 +297,9 @@ else
echo "blitzTUIRestarts=0" echo "blitzTUIRestarts=0"
fi fi
# check if runnig in vagrant
vagrant=$(df | grep -c "/vagrant")
echo "vagrant=${vagrant}"
# check if online if problem with other stuff # check if online if problem with other stuff

View 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

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf 2>/dev/null
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@ -44,7 +44,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# some APC UPS were not running stable below 90% Battery - so start shutdown at 95% remaining # some APC UPS were not running stable below 90% Battery - so start shutdown at 95% remaining
sudo sed -i "s/^BATTERYLEVEL.*/BATTERYLEVEL 95/g" /etc/apcupsd/apcupsd.conf sudo sed -i "s/^BATTERYLEVEL.*/BATTERYLEVEL 95/g" /etc/apcupsd/apcupsd.conf
sudo sed -i "s/^ISCONFIGURED=.*/ISCONFIGURED=yes/g" /etc/default/apcupsd sudo sed -i "s/^ISCONFIGURED=.*/ISCONFIGURED=yes/g" /etc/default/apcupsd
sudo sed -i "s/^SHUTDOWN=.*/SHUTDOWN=\/home\/admin\/XXshutdown.sh/g" /etc/apcupsd/apccontrol sudo sed -i "s/^SHUTDOWN=.*/SHUTDOWN=\/home\/admin\/config.scripts\/blitz.shutdown.sh/g" /etc/apcupsd/apccontrol
sudo sed -i "s/^WALL=.*/#WALL=wall/g" /etc/apcupsd/apccontrol sudo sed -i "s/^WALL=.*/#WALL=wall/g" /etc/apcupsd/apccontrol
sudo systemctl enable apcupsd sudo systemctl enable apcupsd
sudo systemctl start apcupsd sudo systemctl start apcupsd

View File

@ -0,0 +1,190 @@
#!/usr/bin/env bash
# main repo: https://github.com/fusion44/blitz_api
# restart the systemd `blitzapi` when credentials of lnd or bitcoind are changeing and it will
# excute the `update-config` automatically before restarting
# TODO: On sd card install there might be no Bitcoin & Lightning confs - make sure backend runs without
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "Manage RaspiBlitz Web API"
echo "blitz.web.api.sh on [?GITHUBUSER] [?REPO] [?BRANCH]"
echo "blitz.web.api.sh update-config"
echo "blitz.web.api.sh update-code"
echo "blitz.web.api.sh off"
exit 1
fi
DEFAULT_GITHUB_USER="fusion44"
DEFAULT_GITHUB_REPO="blitz_api"
DEFAULT_GITHUB_BRANCH="main"
###################
# ON / INSTALL
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ "$2" != "" ]; then
DEFAULT_GITHUB_USER="$2"
fi
if [ "$3" != "" ]; then
DEFAULT_GITHUB_REPO="$3"
fi
if [ "$4" != "" ]; then
DEFAULT_GITHUB_BRANCH="$4"
fi
echo "# INSTALL Web API ..."
sudo apt install -y redis
sudo rm -r /home/admin/blitz_api 2>/dev/null
cd /home/admin
# git clone https://github.com/fusion44/blitz_api.git /home/admin/blitz_api
git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /home/admin/blitz_api
cd blitz_api
git checkout ${DEFAULT_GITHUB_BRANCH}
pip install -r requirements.txt
# TODO: check if that manual install is still needed in a future version
pip install sse_starlette
# build the config and set unique secret (its OK to be a new secret every install/upadte)
/home/admin/config.scripts/blitz.web.api.sh update-config
secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 64 ; echo '')
sed -i "s/^secret=.*/secret=${secret}/g" ./.env
# prepare systemd service
echo "
[Unit]
Description=BlitzBackendAPI
Wants=network.target
After=network.target
[Service]
WorkingDirectory=/home/admin/blitz_api
# before every start update the config with latest credentials/settings
ExecStartPre=-/home/admin/config.scripts/blitz.web.api.sh update-config
ExecStart=sudo -admin /usr/bin/python -m uvicorn main:app --reload --port 11111 --host=0.0.0.0 --root-path /api
User=root
Group=root
Type=simple
Restart=always
StandardOutput=journal
StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/blitzapi.service
sudo systemctl enable blitzapi
sudo systemctl start blitzapi
# TODO: remove after experimental step
sudo ufw allow 11111 comment 'WebAPI Develop'
# install info
echo "# the API should new be available under http://[LOCALHOST]/api and port 11111 for testing"
echo "# check for systemd: sudo systemctl status blitzapi"
echo "# check for logs: sudo journalctl -f -u blitzapi"
exit 0
fi
###################
# UPDATE CONFIG
###################
if [ "$1" = "update-config" ]; then
# prepare configs data
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ "${network}" = "" ]; then
network="bitcoin"
chain="main"
fi
cd /home/admin/blitz_api
dateStr=$(date)
echo "# Update Web API CONFIG (${dateStr})"
RPCUSER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-)
RPCPASS=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
if [ "${RPCUSER}" == "" ]; then
RPCUSER="raspibolt"
fi
if [ "${RPCPASS}" == "" ]; then
RPCPASS="passwordB"
fi
sed -i "s/^network=.*/network=mainnet/g" ./.env
sed -i "s/^bitcoind_ip_mainnet=.*/bitcoind_ip_mainnet=127.0.0.1/g" ./.env
sed -i "s/^bitcoind_ip_testnet=.*/bitcoind_ip_testnet=127.0.0.1/g" ./.env
sed -i "s/^bitcoind_user=.*/bitcoind_user=${RPCUSER}/g" ./.env
sed -i "s/^bitcoind_pw=.*/bitcoind_pw=${RPCPASS}/g" ./.env
# configure LND
if [ "${lightning}" == "lnd" ]; then
echo "# CONFIG Web API Lightning --> LND"
tlsCert=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/tls.cert)
adminMacaroon=$(sudo xxd -ps -u -c 1000 /mnt/hdd/lnd/data/chain/bitcoin/mainnet/admin.macaroon)
sed -i "s/^ln_node=.*/ln_node=lnd/g" ./.env
sed -i "s/^lnd_grpc_ip=.*/lnd_grpc_ip=127.0.0.1/g" ./.env
sed -i "s/^lnd_macaroon=.*/lnd_macaroon=${adminMacaroon}/g" ./.env
sed -i "s/^lnd_cert=.*/lnd_cert=${tlsCert}/g" ./.env
# configure CLN
elif [ "${lightning}" == "cln" ]; then
echo "# CONFIG Web API Lightning --> CLN"
sed -i "s/^ln_node=.*/ln_node=cln/g" ./.env
# TODO: ADD C-Lightning config as soon as available
echo "# MISSING CLN CONFIG YET"
else
echo "# CONFIG Web API Lightning --> OFF"
sed -i "s/^ln_node=.*/ln_node=/g" ./.env
fi
echo "# '.env' config updates - blitzapi maybe needs to be restarted"
exit 0
fi
###################
# UPDATE CODE
###################
if [ "$1" = "update-code" ]; then
echo "# Update Web API CODE"
sudo systemctl stop blitzapi
cd /home/admin/blitz_api
git fetch
git pull
pip install -r requirements.txt
sudo systemctl start blitzapi
echo "# blitzapi updates and restarted"
exit 0
fi
###################
# OFF / UNINSTALL
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# UNINSTALL Web API"
sudo systemctl stop blitzapi
sudo systemctl disable blitzapi
sudo rm /etc/systemd/system/blitzapi.service
sudo rm -r /home/admin/blitz_api
exit 0
fi

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# TODO: later on this script will be run on build sdcard - make sure that the self-signed tls cert get created fresh on every new RaspiBlitz
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# command info # command info
@ -8,98 +10,9 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ];
printf "blitz.web.sh check \t\tprint operational nginx listen status (lsof)\n" printf "blitz.web.sh check \t\tprint operational nginx listen status (lsof)\n"
printf "blitz.web.sh on \t\tturn on\n" printf "blitz.web.sh on \t\tturn on\n"
printf "blitz.web.sh off \t\tturn off\n" printf "blitz.web.sh off \t\tturn off\n"
printf "blitz.web.sh listen localhost \tset port 443 to localhost only\n"
printf "blitz.web.sh listen any \tset port 443 to any\n"
exit 1 exit 1
fi fi
# using ${APOST} is a workaround to be able to use sed with '
APOST=\' # close tag for linters: '
###################
# FUNCTIONS
###################
function set_nginx_blitzweb_listen() {
# first parameter to function should be either "localhost" or "any"
listen_to=${1}
if [ -f "/etc/nginx/sites-available/blitzweb.conf" ]; then
if ! grep -Eq '^\s*#?\s*listen 127.0.0.1:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
echo "Error: missing expected line for: lo:v4 https"
exit 1
else
if grep -Eq '^\s*#\s*listen 127.0.0.1:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
#echo "found: lo:v4 https (disabled line)"
if [ ${listen_to} = "localhost" ]; then
sudo sed -i -E 's/#\s*(listen 127.0.0.1:443 ssl default_server;)/\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
else
#echo "found: lo:v4 https (enabled line)"
if [ ${listen_to} = "any" ]; then
sudo sed -i -E 's/(listen 127.0.0.1:443 ssl default_server;)/#\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
fi
fi
if ! grep -Eq '^\s*#?\s*listen \[::1\]:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
echo "Error: missing expected line for: lo:v6 https"
exit 1
else
if grep -Eq '^\s*#\s*listen \[::1\]:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
#echo "found: lo:v6 https (disabled line)"
if [ ${listen_to} = "localhost" ]; then
sudo sed -i -E 's/#\s*(listen \[::1\]:443 ssl default_server;)/\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
else
#echo "found: lo:v6 https (enabled line)"
if [ ${listen_to} = "any" ]; then
sudo sed -i -E 's/(listen \[::1\]:443 ssl default_server;)/#\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
fi
fi
if ! grep -Eq '^\s*#?\s*listen 443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
echo "Error: missing expected line for: any:v4 https"
exit 1
else
if grep -Eq '^\s*#\s*listen 443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
#echo "found: any:v4 https (disabled line)"
if [ ${listen_to} = "any" ]; then
sudo sed -i -E 's/#\s*(listen 443 ssl default_server;)/\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
else
#echo "found: any:v4 https (enabled line)"
if [ ${listen_to} = "localhost" ]; then
sudo sed -i -E 's/(listen 443 ssl default_server;)/#\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
fi
fi
if ! grep -Eq '^\s*#?\s*listen \[::\]:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
echo "Error: missing expected line for: any:v6 https"
exit 1
else
if grep -Eq '^\s*#\s*listen \[::\]:443 ssl default_server;$' /etc/nginx/sites-available/blitzweb.conf; then
#echo "found: any:v6 https (disabled line)"
if [ ${listen_to} = "any" ]; then
sudo sed -i -E 's/#\s*(listen \[::\]:443 ssl default_server;)/\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
else
#echo "found: any:v6 https (enabled line)"
if [ ${listen_to} = "localhost" ]; then
sudo sed -i -E 's/(listen \[::\]:443 ssl default_server;)/#\1/g' /etc/nginx/sites-available/blitzweb.conf
fi
fi
fi
fi
}
################### ###################
# CHECK # CHECK
################### ###################
@ -145,6 +58,7 @@ EOF
sudo sed -i -E '/^.*server_names_hash_bucket_size [0-9]*;$/a \\tserver_names_hash_bucket_size 128;' /etc/nginx/nginx.conf sudo sed -i -E '/^.*server_names_hash_bucket_size [0-9]*;$/a \\tserver_names_hash_bucket_size 128;' /etc/nginx/nginx.conf
fi fi
echo "# Checking dhparam.pem ..."
if [ ! -f /etc/ssl/certs/dhparam.pem ]; then if [ ! -f /etc/ssl/certs/dhparam.pem ]; then
# check if there is a user generated dhparam.pem on the HDD to use # check if there is a user generated dhparam.pem on the HDD to use
@ -162,6 +76,8 @@ EOF
sudo cp /mnt/hdd/app-data/nginx/dhparam.pem /etc/ssl/certs/dhparam.pem sudo cp /mnt/hdd/app-data/nginx/dhparam.pem /etc/ssl/certs/dhparam.pem
fi fi
else
echo "# skip - dhparam.pem exists"
fi fi
sudo cp /home/admin/assets/nginx/snippets/* /etc/nginx/snippets/ sudo cp /home/admin/assets/nginx/snippets/* /etc/nginx/snippets/
@ -171,7 +87,10 @@ EOF
sudo rm -f /var/www/html/index.nginx-debian.html sudo rm -f /var/www/html/index.nginx-debian.html
if ! [ -f /etc/nginx/sites-available/public.conf ]; then if ! [ -f /etc/nginx/sites-available/public.conf ]; then
echo "# copy /etc/nginx/sites-available/public.conf"
sudo cp /home/admin/assets/nginx/sites-available/public.conf /etc/nginx/sites-available/public.conf sudo cp /home/admin/assets/nginx/sites-available/public.conf /etc/nginx/sites-available/public.conf
else
echo "# exists /etc/nginx/sites-available/public.conf"
fi fi
if ! [ -d /var/www/letsencrypt/.well-known/acme-challenge ]; then if ! [ -d /var/www/letsencrypt/.well-known/acme-challenge ]; then
@ -183,43 +102,52 @@ EOF
# copy webroot # copy webroot
if ! [ -d /var/www/public ]; then if ! [ -d /var/www/public ]; then
echo "# copy /var/www/public"
sudo cp -a /home/admin/assets/nginx/www_public/ /var/www/public sudo cp -a /home/admin/assets/nginx/www_public/ /var/www/public
sudo chown www-data:www-data /var/www/public sudo chown www-data:www-data /var/www/public
else
echo "# exists /var/www/public"
fi fi
sudo ln -sf /etc/nginx/sites-available/public.conf /etc/nginx/sites-enabled/public.conf sudo ln -sf /etc/nginx/sites-available/public.conf /etc/nginx/sites-enabled/public.conf
### RaspiBlitz Webserver on HTTPS 443 ### RaspiBlitz Webserver on HTTPS 443
# copy webroot # copy compiled webUI (TODO: do later)
if ! [ -d /var/www/blitzweb ]; then if ! [ -d /var/www/public/ui ]; then
sudo cp -a /home/admin/assets/nginx/www_blitzweb/ /var/www/blitzweb echo "# copy precompiled webui TODO: implement"
sudo chown www-data:www-data /var/www/blitzweb sudo cp -a /home/admin/blitz_web_compiled /var/www/public/ui
sudo chown www-data:www-data /var/www/public/ui
else
echo "# exists /var/www/public/ui"
fi fi
# make sure jinja2 is installed and install j2cli if ! [ -f /mnt/hdd/app-data/nginx/tls.cert ];then
sudo apt-get install -y python3-jinja2
sudo -H python3 -m pip install j2cli
# use LND cert by default if [ -f /mnt/hdd/lnd/tls.cert ]; then
sudo ln -sf /mnt/hdd/lnd/tls.cert /mnt/hdd/app-data/nginx/tls.cert # use LND cert by default
sudo ln -sf /mnt/hdd/lnd/tls.key /mnt/hdd/app-data/nginx/tls.key echo "# use LND cert for: /mnt/hdd/app-data/nginx/tls.cert"
sudo ln -sf /mnt/hdd/lnd/tls.cert /mnt/hdd/app-data/nginx/tor_tls.cert sudo ln -sf /mnt/hdd/lnd/tls.cert /mnt/hdd/app-data/nginx/tls.cert
sudo ln -sf /mnt/hdd/lnd/tls.key /mnt/hdd/app-data/nginx/tor_tls.key sudo ln -sf /mnt/hdd/lnd/tls.key /mnt/hdd/app-data/nginx/tls.key
sudo ln -sf /mnt/hdd/lnd/tls.cert /mnt/hdd/app-data/nginx/tor_tls.cert
# config sudo ln -sf /mnt/hdd/lnd/tls.key /mnt/hdd/app-data/nginx/tor_tls.key
sudo cp /home/admin/assets/blitzweb.conf /etc/nginx/sites-available/blitzweb.conf else
sudo ln -sf /etc/nginx/sites-available/blitzweb.conf /etc/nginx/sites-enabled/ echo "# exists /mnt/hdd/app-data/nginx/tls.cert"
if ! [ -f /etc/nginx/.htpasswd ]; then
PASSWORD_B=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
echo "${PASSWORD_B}" | sudo htpasswd -c -i /etc/nginx/.htpasswd admin
sudo chown www-data:www-data /etc/nginx/.htpasswd
sudo chmod 640 /etc/nginx/.htpasswd
# create a self-signed cert if the LND cert is not present
/home/admin/config.scripts/internet.selfsignedcert.sh
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.cert \
/mnt/hdd/app-data/nginx/tls.cert
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.key \
/mnt/hdd/app-data/nginx/tls.key
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.cert \
/mnt/hdd/app-data/nginx/tor_tls.cert
sudo ln -sf /mnt/hdd/app-data/selfsignedcert/selfsigned.key \
/mnt/hdd/app-data/nginx/tor_tls.key
fi
else else
sudo chown www-data:www-data /etc/nginx/.htpasswd echo "# exists /mnt/hdd/app-data/nginx/tls.cert"
sudo chmod 640 /etc/nginx/.htpasswd
fi fi
# restart NGINX # restart NGINX
@ -236,19 +164,6 @@ elif [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo systemctl stop nginx sudo systemctl stop nginx
sudo systemctl disable nginx >/dev/null sudo systemctl disable nginx >/dev/null
###################
# LISTEN
###################
elif [ "$1" = "listen" ]; then
if [ "$2" = "localhost" ] || [ "$2" = "any" ]; then
echo "Setting NGINX to listen on: ${2}"
set_nginx_blitzweb_listen "${2}"
else
echo "# FAIL: parameter not known - run with -h for help"
fi
else else
echo "# FAIL: parameter not known - run with -h for help" echo "# FAIL: parameter not known - run with -h for help"
fi fi

View File

@ -0,0 +1,96 @@
#!/usr/bin/env bash
# TODO: Later use for default install (when no github parameters are given) a precompiled version
# that comes with the repo so that the user does not need to install node
# use fro that then: yarn build:production & yarn licenses generate-disclaimer
# TODO: Put WebUI into / base directory of nginx and let the index.html of the webUI handle
# the Tor detection or build it directly into the WebUI
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "Manage RaspiBlitz Web UI"
echo "blitz.web.ui.sh on [?GITHUBUSER] [?REPO] [?BRANCH]"
echo "blitz.web.ui.sh update"
echo "blitz.web.ui.sh off"
exit 1
fi
DEFAULT_GITHUB_USER="cstenglein"
DEFAULT_GITHUB_REPO="raspiblitz-web"
DEFAULT_GITHUB_BRANCH="master"
###################
# ON / INSTALL
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ "$2" != "" ]; then
DEFAULT_GITHUB_USER="$2"
fi
if [ "$3" != "" ]; then
DEFAULT_GITHUB_REPO="$3"
fi
if [ "$4" != "" ]; then
DEFAULT_GITHUB_BRANCH="$4"
fi
echo "# INSTALL WebUI"
sudo rm -r /home/admin/blitz_web 2>/dev/null
cd /home/admin
# git clone https://github.com/cstenglein/raspiblitz-web.git /home/admin/blitz_web
git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git /home/admin/blitz_web
cd blitz_web
git checkout ${DEFAULT_GITHUB_BRANCH}
echo "# Compile WebUI"
/home/admin/config.scripts/bonus.nodejs.sh on
source <(/home/admin/config.scripts/bonus.nodejs.sh info)
sudo npm install --global yarn
${NODEPATH}/yarn install
${NODEPATH}/yarn build
sudo rm -r /var/www/public/* 2>/dev/null
sudo cp -r /home/admin/blitz_web/build/* /var/www/public
sudo chown www-data:www-data -R /var/www/public
exit 1
fi
###################
# UPDATE
###################
if [ "$1" = "update" ]; then
echo "# Update Web API"
cd /home/admin/blitz_web
git fetch
git pull
source <(/home/admin/config.scripts/bonus.nodejs.sh info)
${NODEPATH}/yarn install
${NODEPATH}/yarn build
sudo rm -r /var/www/public/* 2>/dev/null
sudo cp -r /home/admin/blitz_web/build/* /var/www/public
sudo chown www-data:www-data -R /var/www/public
echo "# blitzapi updates and restarted"
exit 0
fi
###################
# OFF / UNINSTALL
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# UNINSTALL WebUI"
sudo rm -r /home/admin/blitz_web 2>/dev/null
sudo rm -r /var/www/public/* 2>/dev/null
exit 0
fi

View File

@ -31,7 +31,7 @@ This can take multiple hours.
fi fi
# get network info # get network info
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
toraddress=$(sudo cat /mnt/hdd/tor/btc-rpc-explorer/hostname 2>/dev/null) toraddress=$(sudo cat /mnt/hdd/tor/btc-rpc-explorer/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2) fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
@ -207,6 +207,12 @@ User=btcrpcexplorer
Restart=on-failure Restart=on-failure
RestartSec=600 RestartSec=600
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF

View File

@ -27,7 +27,7 @@ if [ "$1" = "status" ]; then
isInstalled=$(sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service') isInstalled=$(sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service')
echo "installed=${isInstalled}" echo "installed=${isInstalled}"
localIP=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localIP=$(hostname -I | awk '{print $1}')
echo "localIP='${localIP}'" echo "localIP='${localIP}'"
echo "httpsPort='23001'" echo "httpsPort='23001'"
echo "publicIP='${publicIP}'" echo "publicIP='${publicIP}'"
@ -379,6 +379,7 @@ Type=simple
PIDFile=/run/nbxplorer/nbxplorer.pid PIDFile=/run/nbxplorer/nbxplorer.pid
Restart=on-failure Restart=on-failure
# Hardening measures
PrivateTmp=true PrivateTmp=true
ProtectSystem=full ProtectSystem=full
NoNewPrivileges=true NoNewPrivileges=true
@ -461,6 +462,12 @@ Type=simple
PIDFile=/run/btcpayserver/btcpayserver.pid PIDFile=/run/btcpayserver/btcpayserver.pid
Restart=on-failure Restart=on-failure
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/btcpayserver.service " | sudo tee /etc/systemd/system/btcpayserver.service

View File

@ -101,11 +101,16 @@ ExecStart=/home/circuitbreaker/go/bin/circuitbreaker --network=${chain}net
User=circuitbreaker User=circuitbreaker
Group=circuitbreaker Group=circuitbreaker
Type=simple Type=simple
KillMode=process
TimeoutSec=60 TimeoutSec=60
Restart=always Restart=always
RestartSec=60 RestartSec=60
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
" | sudo tee -a /etc/systemd/system/circuitbreaker.service " | sudo tee -a /etc/systemd/system/circuitbreaker.service

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# https://github.com/cryptoadvance/specter-desktop # https://github.com/cryptoadvance/specter-desktop
pinnedVersion="1.3.0" pinnedVersion="1.4.2"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@ -22,7 +22,7 @@ if [ "$1" = "status" ]; then
echo "configured=1" echo "configured=1"
# get network info # get network info
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/cryptoadvance-specter/hostname 2>/dev/null) toraddress=$(sudo cat /mnt/hdd/tor/cryptoadvance-specter/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /home/specter/.specter/cert.pem -fingerprint -noout | cut -d"=" -f2) fingerprint=$(openssl x509 -in /home/specter/.specter/cert.pem -fingerprint -noout | cut -d"=" -f2)
echo "localip='${localip}'" echo "localip='${localip}'"
@ -289,6 +289,12 @@ RestartSec=30
StandardOutput=null StandardOutput=null
StandardError=journal StandardError=journal
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF

View File

@ -137,7 +137,7 @@ if [ "$1" = "menu" ]; then
The electrum system service is not running. The electrum system service is not running.
Please check the following debug info. Please check the following debug info.
" 8 48 " 8 48
/home/admin/XXdebugLogs.sh /home/admin/config.scripts/blitz.debug.sh
echo "Press ENTER to get back to main menu." echo "Press ENTER to get back to main menu."
read key read key
exit 0 exit 0
@ -403,11 +403,16 @@ ExecStart=/home/electrs/electrs/target/release/electrs --index-batch-size=10 --e
User=electrs User=electrs
Group=electrs Group=electrs
Type=simple Type=simple
KillMode=process
TimeoutSec=60 TimeoutSec=60
Restart=always Restart=always
RestartSec=60 RestartSec=60
# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
" | sudo tee -a /etc/systemd/system/electrs.service " | sudo tee -a /etc/systemd/system/electrs.service

Some files were not shown because too many files have changed in this diff Show More