Browse Source

Merge branch 'master' into master

master
Christian Rotzoll 6 years ago
committed by GitHub
parent
commit
2a31645af3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 314
      FAQ.md
  2. 240
      README.md
  3. 3
      WORKSHOP.md
  4. 93
      alternative.platforms/README.md
  5. 60
      alternative.platforms/hw_comparison.md
  6. 289
      build_sdcard.sh
  7. 56
      dietpi/Odroid_HC1_XU4.md
  8. 100
      dietpi/README.md
  9. 40
      dietpi/RaspberryPi.md
  10. 262
      dietpi/RaspiBlitz1.0_OdroidHC1_DietPi6.21.1.torrent
  11. 15
      dietpi/boot/Automation_Custom_Script.sh
  12. 15
      dietpi/boot/dietpi.txt
  13. 210
      dietpi/dietpi.display.sh
  14. 77
      home.admin/00infoBlitz.sh
  15. 2
      home.admin/00infoBlitz2.sh
  16. 64
      home.admin/00infoLCD.sh
  17. 496
      home.admin/00mainMenu.sh
  18. 469
      home.admin/00raspiblitz.sh
  19. 45
      home.admin/00settingsMenuServices.sh
  20. 177
      home.admin/05hardwareTest.sh
  21. 44
      home.admin/10setupBlitz.sh
  22. 1
      home.admin/20recoverDialog.sh
  23. 16
      home.admin/30initHDD.sh
  24. 6
      home.admin/40addHDD.sh
  25. 2
      home.admin/50downloadHDD.sh
  26. 165
      home.admin/50torrentHDD.sh
  27. 384
      home.admin/70initLND.sh
  28. 269
      home.admin/80scanLND.sh
  29. 10
      home.admin/90finishSetup.sh
  30. 4
      home.admin/91addBonus.sh
  31. 6
      home.admin/95finalSetup.sh
  32. 146
      home.admin/97addMobileWallet.sh
  33. 141
      home.admin/97addMobileWalletLNDconnect.sh
  34. 94
      home.admin/97addMobileWalletShango.sh
  35. 54
      home.admin/97addMobileWalletZeus.sh
  36. 133
      home.admin/99checkUpdate.sh
  37. 2
      home.admin/AAunlockLND.sh
  38. 103
      home.admin/BBcashoutWallet.sh
  39. 96
      home.admin/BBcreateInvoice.sh
  40. 83
      home.admin/BBfundWallet.sh
  41. 32
      home.admin/BBpayInvoice.sh
  42. 4
      home.admin/XXaptInstall.sh
  43. 37
      home.admin/XXchainInSync.sh
  44. 3
      home.admin/XXcleanHDD.sh
  45. 65
      home.admin/XXdebugLogs.sh
  46. 8
      home.admin/XXdisplayLCD.sh
  47. 24
      home.admin/XXdisplayQR.sh
  48. 10
      home.admin/XXdisplayQRlcd.sh
  49. 4
      home.admin/XXdisplayQRlcd_hide.sh
  50. 9
      home.admin/XXsyncScripts.sh
  51. 166
      home.admin/_background.sh
  52. 96
      home.admin/_bootstrap.provision.sh
  53. 130
      home.admin/_bootstrap.sh
  54. 2
      home.admin/_commands.sh
  55. 2
      home.admin/_version.info
  56. 1
      home.admin/assets/bitcoind.service
  57. BIN
      home.admin/assets/install_shango.jpg
  58. 1
      home.admin/assets/litecoind.service
  59. 2
      home.admin/assets/lnd.bitcoin.conf
  60. 2
      home.admin/assets/lnd.litecoin.conf
  61. 3
      home.admin/assets/lnd.service
  62. 2136
      home.admin/assets/raspiblitz-bitcoin1-2019-04-09-update.torrent
  63. 139
      home.admin/config.scripts/blitz.datadrive.sh
  64. 59
      home.admin/config.scripts/blitz.setpassword.sh
  65. 246
      home.admin/config.scripts/blitz.statusscan.sh
  66. 104
      home.admin/config.scripts/blitz.stresstest.sh
  67. 19
      home.admin/config.scripts/blitz.systemd.sh
  68. 4
      home.admin/config.scripts/bonus.rtl.sh
  69. 99
      home.admin/config.scripts/dropbox.upload.sh
  70. 43
      home.admin/config.scripts/internet.dns.sh
  71. 2
      home.admin/config.scripts/internet.dyndomain.sh
  72. 43
      home.admin/config.scripts/internet.sshpubkey.sh
  73. 245
      home.admin/config.scripts/internet.sshtunnel.py
  74. 2
      home.admin/config.scripts/internet.tor.sh
  75. 2
      home.admin/config.scripts/lnd.autonat.sh
  76. 42
      home.admin/config.scripts/lnd.autounlock.sh
  77. 178
      home.admin/config.scripts/lnd.check.sh
  78. 204
      home.admin/config.scripts/lnd.initwallet.py
  79. 119
      home.admin/config.scripts/lnd.rescue.sh
  80. 98
      home.admin/config.scripts/lnd.setaddress.sh
  81. 2
      home.admin/config.scripts/lnd.setname.sh
  82. 13
      home.admin/config.scripts/lnd.setport.sh
  83. 28
      home.admin/config.scripts/lndlibs/README.md
  84. 0
      home.admin/config.scripts/lndlibs/__init__.py
  85. 2367
      home.admin/config.scripts/lndlibs/rpc.proto
  86. 8039
      home.admin/config.scripts/lndlibs/rpc_pb2.py
  87. BIN
      home.admin/config.scripts/lndlibs/rpc_pb2.pyc
  88. 1226
      home.admin/config.scripts/lndlibs/rpc_pb2_grpc.py
  89. BIN
      home.admin/config.scripts/lndlibs/rpc_pb2_grpc.pyc
  90. 3
      home.admin/config.scripts/network.reindex.sh
  91. 1584
      home.admin/infoblitzd.py
  92. BIN
      pictures/bitcoin512.png
  93. BIN
      pictures/hardwaresetup.jpg
  94. BIN
      pictures/mainmenu-services.png
  95. BIN
      pictures/mainmenu.png
  96. BIN
      pictures/mainmenu1.png
  97. BIN
      pictures/mainmenu2.png
  98. BIN
      pictures/mainmenu3.png
  99. BIN
      pictures/mobile.png
  100. BIN
      pictures/ok.png

314
FAQ.md

@ -1,5 +1,69 @@
# FAQ - Frequently Asked Questions # FAQ - Frequently Asked Questions
## Whats new in Version 1.2 of RaspiBlitz?
Version 1.2 packs some more fixes and enhancements to make the RaspiBlitz more stable, protect HDD data better and support you better in case of data corruption of the blockchain data.
- Update: LND version 0.6-beta
- Update: RTL (Ride the Lightning) Web UI version 0.2.16-beta
- Update: Shopping Lists (new Heatsink Case lowers 10°)
- Update: New Torrent Update file (reducing blockchain sync time)
- Fix: LND scanning stuck on ? (better error handling)
- Fix: Cash out all funds
- Fix: Keep TLS certs stable on update
- New: Support Zeus Mobile Wallet
- New: Show QR codes on LCD
- New: Support LND Static Channel Backup
- New: Remote-Backup of channel.backup file (SCP & Dropbox)
- New: Recover Node from LND rescue backup file
- New: Run Hardware Test on setup and main menu
- New: Run Software Test (DebugLogs) from main manu
- New: SSH-Forward Tunneling (commandline)
- New: Set fixed IP/domain for RaspiBlitz (commandline)
- New: Set DNS server (commandline)
- New: Run LND on different port (commandline)
- New: Ask before formatting HDD
- New: Better Update support (from main menu)
- New: Temp in Fahrenheit on the LCD
- Experimental: Backup Torrent Seeding (Service)
For full details see issue list of [Release 1.2 Milestone](https://github.com/rootzoll/raspiblitz/milestone/5?closed=1).
## How to update my RaspiBlitz from v1.0 and v1.1?
For update you DONT NEED to close any channels, remove funding or download the blockchain again.
Here is a YouTube video tutorial on how to update: https://www.youtube.com/watch?v=Xvn0WQfHUdI
Simply [Download the new RaspiBlitz SD card image](https://github.com/rootzoll/raspiblitz#installing-the-software) to your laptop and have an sd card writer ready. Then login into your RaspiBlitz with SSH and:
- main menu > OFF
- remove power
- remove SD card
Write the new image it to your SD card .. yes you simply overwrite the old one, it's OK, all your personal data is on the HDD. If you want to be extra safe you can make a image backup of your old sd card first - but that is optional. If you made manual changes to your RaspiBlitz with scripts on the sd card you might wanna check on this FAQ question first: [Why do I need to re-burn my SD card for an update?](FAQ.md#why-do-i-need-to-re-burn-my-sd-card-for-an-update).
- insert new sd card image
- power on the RaspiBlitz again
You should see that it switched into recover/backup mode. Its now provisioning the fresh OS on the sd card your old settings and data. This process can take some while especially if you had RTL Web UI activated. Follow the instructions on the display ... if it takes longer then an hour .. [get support](https://github.com/rootzoll/raspiblitz#support).
When update/recover process is ready you will see a `FINAL RECOVER LOGIN NEEDED` message on the display. Login per SSH by using the password `raspiblitz` and set your Password A again. It can be the same as the old one, but maybe use the occasion to make password change for security reasons. If you had auto-unlock activated you might also be asked to enter your old Password C again. Then it wil make a final reboot.
After your RaspiBlitz is done with catching up the latest blockchain data you should see your status screen displaying your funds and channels. Your backup is complete.
## How to update my RaspiBlitz from v1.2 and up?
If you have a RaspiBlitz v1.2 or higher - just follow the `UPDATE Check/Prepare RaspiBlitz Update` option from the main menu.
## Can I downgrade from v1.1 to v1.0?
Yes - it was tested one time and worked. Just follow the normal update mechanism - just use the old v1.0 image or your own backup image of the old sd card.
## Can I downgrade from v1.2 to v1.1?
Not tested - but LND 0.6 changed some data structure - so its not recommended.
## Whats new in Version 1.1 of RaspiBlitz? ## Whats new in Version 1.1 of RaspiBlitz?
Version 1.1 packs some first fixes and enhancements to make the RaspiBlitz more stable, protect HDD data better and support you better in case of data corruption of the blockchain data. Version 1.1 packs some first fixes and enhancements to make the RaspiBlitz more stable, protect HDD data better and support you better in case of data corruption of the blockchain data.
@ -21,44 +85,27 @@ For full details see issue list of [Release 1.1 Milestone](https://github.com/ro
Instructions on how to update see FAQ info below. Instructions on how to update see FAQ info below.
## How to update my RaspiBlitz (AFTER version 0.98)? ## Can I still get version 1.1 of RaspiBlitz?
For update you dont need to close any channels, remove funding or download the blockchain again.
Simply [Ddwnload the new RaspiBlitz SD card image](https://github.com/rootzoll/raspiblitz#installing-the-software) to your laptop and have an sd card writer ready. Then login into your RaspiBlitz with SSH and:
- main menu > OFF
- remove power
- remove SD card
Write the new image it to your SD card .. yes you simply overwrite the old one, it's OK, all your personal data is on the HDD. If you want to be extra safe you can make a image backup of your old sd card first - but that is optional. If you made manual changes to your RaspiBlitz with scripts on the sd card you might wanna check on this FAQ question first: [Why do I need to re-burn my SD card for an update?](FAQ.md#why-do-i-need-to-re-burn-my-sd-card-for-an-update).
- insert new sd card image
- power on the RaspiBlitz again
You should see that it switched into recover/backup mode. Its now provisioning the fresh OS on the sd card your old settings and data. This process can take some while especially if you had RTL Web UI activated. Follow the instructions on the display ... if it takes longer then an hour .. [get support](https://github.com/rootzoll/raspiblitz#support).
When update/recover process is ready you will see a `FINAL RECOVER LOGIN NEEDED` message on the display. Login per SSH by using the password `raspiblitz` and set your Password A again. It can be the same as the old one, but maybe use the occasion to make password change for security reasons. If you had auto-unlock activated you might also be asked to enter your old Password C again. Then it wil make a final reboot. HTTP: http://wiki.fulmo.org/downloads/raspiblitz-v1.1-2019-03-18.img.gz
After your RaspiBlitz is done with catching up the latest blockchain data you should see your status screen displaying your funds and channels. Your backup is complete. Torrent: https://github.com/rootzoll/raspiblitz/raw/master/raspiblitz-v1.1-2019-03-18.torrent
## Can I downgrade from v1.1 to v1.0? SHA-256: b7a449ce6444f9e7e9fd05156ff09c70a6e200be0b5e580d3317049eefc4f3b7
Yes - it was tested one time and worked. Just follow the normal update mechanism - just use the old v1.0 image or your own backup image of the old sd card. Code: https://github.com/rootzoll/raspiblitz/tree/v1.1
## Can I still get version 1.0 of RaspiBlitz? ## Can I still get version 1.0 of RaspiBlitz?
Yes here are the links: Yes here are the links:
HTTP: http://wiki.fulmo.org/downloads/raspiblitz-v1.0-2019-02-18.img.gz
Torrent: https://github.com/rootzoll/raspiblitz/raw/master/raspiblitz-v1.0-2019-02-18.torrent Torrent: https://github.com/rootzoll/raspiblitz/raw/master/raspiblitz-v1.0-2019-02-18.torrent
SHA-256: 99ca96d214657388305ca117e2343ead45f9d907f185bef36c712a9a3e75568f SHA-256: 99ca96d214657388305ca117e2343ead45f9d907f185bef36c712a9a3e75568f
Code: https://github.com/rootzoll/raspiblitz/tree/v1.0 Code: https://github.com/rootzoll/raspiblitz/tree/v1.0
## How to update a old RaspiBlitz (BEFORE version 0.98)? ## How to update a old RaspiBlitz BEFORE v1.0?
If your old RaspiBlitz if version 0.98 or higher, just follow the update instructions in the README. If your old RaspiBlitz if version 0.98 or higher, just follow the update instructions in the README.
@ -66,7 +113,7 @@ If you run a version earlier then 0.98 you basically need to setup a new RaspiBl
1. Close all open lightning channels you have (`lncli closeallchannels --force`) or use the menu option 'CLOSE ALL' if available. Wait until all closing transactions are done. 1. Close all open lightning channels you have (`lncli closeallchannels --force`) or use the menu option 'CLOSE ALL' if available. Wait until all closing transactions are done.
2. Move all on-chain funds to a wallet outside raspiblitz (`lncli --conf_target 3 sendcoins [ADDRESS]`) or use the menu option 'CHASH OUT' if available 2. Move all on-chain funds to a wallet outside raspiblitz (`lncli sendcoins --conf_target 3 <ADDRESS> <AMT>`) or use the menu option 'CASHOUT' if available
3. Prepare the HDD for the new setup by running the script `/home/admin/XXcleanHDD.sh` (Blockchain will stay on HDD) 3. Prepare the HDD for the new setup by running the script `/home/admin/XXcleanHDD.sh` (Blockchain will stay on HDD)
@ -74,7 +121,7 @@ If you run a version earlier then 0.98 you basically need to setup a new RaspiBl
## Why do I need to re-burn my SD card for an update? ## Why do I need to re-burn my SD card for an update?
I know it would be nicer to run just an update script and you are ready to go. But then the scripts would need to be written in a much more complex way to be able to work with any versions of LND and Bitcoind (they are already complex enough with all the edge cases) and testing would become even more time consuming than it is now already. That's nothing a single developer can deliver. I know it would be nicer to run just an update script and you are ready to go. But then the scripts would need to be written in a much more complex way to be able to work with any versions of LND and Bitcoind (they are already complex enough with all the edge cases) and testing would become even more time consuming than it is now already. That's nothing a single developer can deliver.
For some, it might be a pain point to make an update by re-burning a new sd card - especially if you added your own scripts or made changes to the system - but thats by design. It's a way to enforce a "clean state" with every update - the same state that I tested and developed the scripts with. The reason for that pain: I simply cannot write and support scripts that run on every modified system forever - that's simply too much work. For some, it might be a pain point to make an update by re-burning a new sd card - especially if you added your own scripts or made changes to the system - but thats by design. It's a way to enforce a "clean state" with every update - the same state that I tested and developed the scripts with. The reason for that pain: I simply cannot write and support scripts that run on every modified system forever - that's simply too much work.
@ -96,16 +143,20 @@ The torrent download use a prepared blockchain to kick start the RaspiBlitz. If
Copying a already synced blockchain from another computer (for example your Laptop) can be a quick way to get the RaspiBlitz started or replacing a corrupted blockchain with a fresh one. Also that way you synced and verified the blockchain yourself and not trusting the RaspiBlitz Torrent downloads (dont trust, verify). Copying a already synced blockchain from another computer (for example your Laptop) can be a quick way to get the RaspiBlitz started or replacing a corrupted blockchain with a fresh one. Also that way you synced and verified the blockchain yourself and not trusting the RaspiBlitz Torrent downloads (dont trust, verify).
One requirement is that the blockchain is from another bitcoin-core client with version greater or equal to 0.17.1 with transaction index switched on (`txindex=1` in the `bitcoin.conf`). One requirement is that the blockchain is from another bitcoin-core client with version greater or equal to 0.17.1 with transaction index switched on (`txindex=1` in the `bitcoin.conf`).
But we dont copy the data via USB to the device, because the HDD needs to be formatted in EXT4 and that is usually not read/writeable by Windows or Mac computers. So I will explain a way to copy the data through your local network. This should work from Windows, Mac, Linux and even from another already synced RaspiBlitz. But we dont copy the data via USB to the device, because the HDD needs to be formatted in EXT4 and that is usually not read/writeable by Windows or Mac computers. So I will explain a way to copy the data through your local network. This should work from Windows, Mac, Linux and even from another already synced RaspiBlitz.
Both computers (your RaspberryPi and the other computer with the full blockchain on) need to be connected to the same local network. Make sure that bitcoin is stoped on the computer containing the blockchain. If your blockchain source is another RaspiBlitz run on the terminal `sudo systemctl stop bitcoind` and then go to the directory where the blockchain data is with `cd /mnt/hdd/bitcoin` - when copy/transfer is done later reboot a RaspiBlitz source with `sudo shutdown -r now`. Both computers (your RaspberryPi and the other computer with the full blockchain on) need to be connected to the same local network. Make sure that bitcoin is stoped on the computer containing the blockchain. If your blockchain source is another RaspiBlitz run on the terminal `sudo systemctl stop bitcoind` and then go to the directory where the blockchain data is with `cd /mnt/hdd/bitcoin` - when copy/transfer is done later reboot a RaspiBlitz source with `sudo shutdown -r now`.
If everything of the above is prepared, start the setup of the new RaspiBlitz with a fresh SD card (like explained in the README) - its OK that there is no blockchain data on your HDD yet - just follow the setup. When you get to the setup-point `Getting the Blockchain` choose the COPY option. Starting from version 1.0 of the RaspiBlitz this will give you further detailed instructions how to transfer the blockchain data onto your RaspiBlitz. In short: On your computer with the blockchain data source you will execute SCP commands, that will copy the data over your Local Network to your RaspiBlitz. If everything of the above is prepared, start the setup of the new RaspiBlitz with a fresh SD card (like explained in the README) - its OK that there is no blockchain data on your HDD yet - just follow the setup. When you get to the setup-point `Getting the Blockchain` choose the COPY option. Starting from version 1.0 of the RaspiBlitz this will give you further detailed instructions how to transfer the blockchain data onto your RaspiBlitz. In short: On your computer with the blockchain data source you will execute SCP commands, that will copy the data over your Local Network to your RaspiBlitz.
Once you finished all the transferes the Raspiblitz will make a quick-check on the data - but that will not guarantee that everything in detail was OK with the transfer. Check further FAQ answeres if you get stuck or see a final sync with a value below 90%. Once you finished all the transferes the Raspiblitz will make a quick-check on the data - but that will not guarantee that everything in detail was OK with the transfer. Check further FAQ answeres if you get stuck or see a final sync with a value below 90%.
## I have downloaded the torrents on another computer. How do I copy them to the RaspiBlitz?
You need both torrents to be downloaded on your laptop for that. You need merge both torrents files now to a full blockchain copy. Stop torrent app. Copy all downloaded data from update torrent into the directory of the base torrent. Not you have a copy of the full blockchain in one directory and you can continue like in the FAQ case above "I have the full blockchain on another computer. How do I copy it to the RaspiBlitz?"
**If you want to replace a corrupted blockchain this way:** *Go to terminal - maybe with CTRL+c. Then call `/home/admin/50copyHDD.sh` use the displayed SCP commands to copy over the fresh blockchain. Press ENTER when all is copied, so that the script can quick check the data. Then make a reboot `sudo shutdown -r now`* **If you want to replace a corrupted blockchain this way:** *Go to terminal - maybe with CTRL+c. Then call `/home/admin/50copyHDD.sh` use the displayed SCP commands to copy over the fresh blockchain. Press ENTER when all is copied, so that the script can quick check the data. Then make a reboot `sudo shutdown -r now`*
## How do I clone the Blockchain from a 2nd HDD? ## How do I clone the Blockchain from a 2nd HDD?
@ -159,13 +210,16 @@ So if something is wrong (like mentioned above) then try again from the beginnin
## How to backup my Lightning Node? ## How to backup my Lightning Node?
CAUTION: Restoring a backup can lead to LOSS OF ALL CHANNEL FUNDS if it's not the latest channel state. There is no perfect backup solution for lightning nodes yet - this topic is in development by the community. There are two ways of Backup:
But there is one safe way to start: Store your LND wallet seed (list of words you got on wallet creation) in a safe place. Its the key to recover access to your on-chain funds - your coins that are not bound in an active channel. ### 1) Securing your On-Chain- and Channel-Funds during Operation
Recovering the coins that you have in an active channel is a bit more complicated. Because you have to be sure that you really have an up to date backup of your channel state data. The problem is: If you post an old state of your channel, to the network this looks like an atempt to cheat, and your channel partner is allowed claim all the funds in the channel. This is best done by auto backuping the 'channel.backup' file to a remote location. But it just secures the funds you have in your on-chain wallet or in your channels. On recovery the channels will get closed. For details on how to setup see the README:
https://github.com/rootzoll/raspiblitz/blob/v1.2/README.md#backup-for-on-chain---channel-funds
To really have a reliable backup, such feature needs to be part of the LND software. Almost every other solution would not be perfect. Thats why RaspiBlitz is not trying to provide a backup feature at the moment. But if you feel experimental and you look for a continues backup you may want to check out the following script to integrate into your RaspiBlitz: https://github.com/vindard/lnd-backup/blob/master/do-lndbackup.sh ### 2) Making a complete LND data backup
This backups all your LND data - including all open channels. But its just inteded to use when you move your LND data between computers, during update situations or in rescue recoveries. Because replaying out-dated backups can lead to losas of all channel funds.
How to backup LND data in a rescue situation see next question "How can I recover my coins from a failing RaspiBlitz?". How to backup LND data in a rescue situation see next question "How can I recover my coins from a failing RaspiBlitz?".
@ -175,11 +229,11 @@ On a RaspiBlitz you have coins in your on-chain wallet (bitcoin wallet) and also
### 1) Recover LND data ### 1) Recover LND data
To recover all your LND data you must still be able to SSH into the RaspiBlitz (minimum v1.1) and the HDD should be still useable/reachable (mounted) - even it shows some errors. If this is not possible anymore you should skip to the second option "Recover from Wallet Seed". Best to recover all your LND data/channels is when you still can SSH into the RaspiBlitz and the HDD is still useable/reachable (mounted) - even it shows some errors. If this is not possible anymore you should skip to the second option "Recover from Wallet Seed" or try to recover the LND data from the HDD (directory `lnd`) from another computer.
If you still can SSH in and HDD is readable, we can try to rescue/export your LND data (funds and channels) from a RaspiBlitz to then be able to restore it back to a fresh one. For this you can use the following procedure ... If you still can SSH in and HDD is readable, we can try to rescue/export your LND data (funds and channels) from a RaspiBlitz to then be able to restore it back to a fresh one. For this you can use the following procedure ...
To rescue/export your Lightning data from a RaspiBlitz: 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.rescue.sh backup`
@ -199,26 +253,17 @@ This script will offer you a way to transfere the lnd-rescue file from your lapt
### 2) Recover from Wallet Seed ### 2) Recover from Wallet Seed
Remember those 24 words you were writing down during the setup? Thats your "cipher seed" - now this words are important to recover your wallet. If you dont have them anymore: skip this chapter and read option 2. If you still have the cypher seed: good, but read the following carefully: Remember those 24 words you were writing down during the setup? Thats your "cipher seed" - now this words are important to recover your wallet. If you dont have them anymore: go back to option "Recover LND data" and check all possible ways to recover data from the HDD. If you still have the word seed: good, but read the following carefully:
With the cypher seed you can recover the bitcoin wallet that LND was managing for you - but it does not contain all the details about the channels you have open - its just the key to your funding wallet. If you were able to close all channels or never opened any channels, then everything is OK and you can go on. If you had open channels with funds in there, the following is to consider:
* You now rely on your channel counter parts to force close the channel at one point. If they do, the coins will be available to use in your funding wallet again at one point in the future - after force close delay (but see also [#278](https://github.com/rootzoll/raspiblitz/issues/278) ). With the word seed you can recover the on-chain funds that LND was managing for you - but it does not contain all the details about the channels you have open - its mostly the key to your funding wallet. If you were able to close all channels or never opened any channels, then everything should be OK and the best esults to recover on-chain funds from wallet seeds are reported to get from installing the Lightning Labs App on your laptop and use the wallet seed (and same wallet passwords): https://github.com/lightninglabs/lightning-app/releases
* If your channel counter parts never force close the channel (because they are offline too) your channel funds can be frozen forever.
So going this way there is a small risk, that you will not recover your funds. But normally if your channel counter parts are still online, see that you will not come back online and they have themselves some funds on their channel side with you: They have an incentive to force close the channel to make use of their funds again. If you had open channels it would be best to check if you have also the `channel.backup` file (Static-Channel-Backup feature) that is available since LND 0.6 (RaspiBlitz v1.2) and use that in the process below ... for more details on the `channel.backup` file see [README.md on backups](README.md#backup-for-on-chain---channel-funds).
So here is what todo if you want to "Recover from Wallet Seed" with RaspiBlitz:
- SetUp a fresh RaspiBlitz (fresh SD-Card image and clean HDD). - SetUp a fresh RaspiBlitz (fresh SD-Card image and clean HDD).
- During the new SetUp you get to the point of creating the LND wallet (see image below). - During the new SetUp you get to the point of creating the LND wallet (see image below).
- Choose `OLD - I had a old Node I want to recover/restore` option and then
![SSH8](pictures/wallet-recover.png) - Choose `SEED+SCB - Seed & channel.backup file` option
- and follow the intructions to upload your `channel.backup` file and enter your seed
- When you get asked "do you have an existing cypher wallet" answere `y` this time.
- Enter the cypher seed - all words in one line seperated by spaces
- If you get asked at the end for the password D to encrypt your cypher seed, use the same as the last time. If you havent entered one last time, just press Enter again.
- When asked about the "address look-ahead" number - use `250000` instead of the default!
Then give LND some time to rescan the blockchain. In the end you will have restored your funding wallet. You maybe need to wait for your old channel counter parts to force close the old channels until you see the coins back displayed. Then give LND some time to rescan the blockchain. In the end you will have restored your funding wallet. You maybe need to wait for your old channel counter parts to force close the old channels until you see the coins back displayed.
@ -226,9 +271,9 @@ Then give LND some time to rescan the blockchain. In the end you will have resto
## What is this mnemonic seed word list? ## What is this mnemonic seed word list?
With the 24 word list given you by LND on wallet creation you can recover your private key (BIP 39). You should write it down and store it at a save place. With the 24 word list given you by LND on wallet creation you can recover your private key. You should write it down and store it at a save place. Bear in mind that *this 24 word mnemonic seed is not based on the BIP 39* and therefore cannot be recovered using a Bitcoin wallet.
For more background on mnemonic seeds see this video: https://www.youtube.com/watch?v=wWCIQFNf_8g For more background on the LND mnemonic seed [read this article](https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md#recovering-funds-from-lnd-funds-are-safu).
## How does PASSWORD D effects the word seed? ## How does PASSWORD D effects the word seed?
@ -236,6 +281,28 @@ On wallet creation you get asked if you want to protect your word seed list with
To use a an additional password for your seed words is optional. If you choose so, you will need the password to recover your private key from your your seed words later on. Without this password your private key cannot be recovered from your seed words. So the password adds an additional layer of security, if someone finds your written down word list. To use a an additional password for your seed words is optional. If you choose so, you will need the password to recover your private key from your your seed words later on. Without this password your private key cannot be recovered from your seed words. So the password adds an additional layer of security, if someone finds your written down word list.
## How to move funds & channels from RaspiBlitz to LND Lightning Desktop App?
Before you start - download a LND-data-rescue file from your RaspiBlitz to your laptop `main menu -> UPDATE -> Update Anyway -> Start Update -> Download Backup -> FOLLOW INSTRUCTIONS and press Enter when ready with download -> START UPDATE`. Now your RaspiBlitz will power down.
Now install the LND Lightning Desktop App for your OS: https://github.com/lightninglabs/lightning-app/releases
Then start the App and create a new wallet - its a trhowaway wallet (will be deleted afterwards with no funds) - so you dont need to keep seeds safe. To get easy thru the setup just make a photo of the seed with your mobile. If you get asked for funding - just click "done" until you reach the basic wallet screen. Then close the LND Desktop App.
Now find out at with path LND stores the wallet data on your computer.
Linux: [USER-DIRECTORY]/.config/lightning-app/lnd
OSX: [USER-DIRECTORY]/Library/Application Support/lightning-app/lnd
Windows: %USERPROFILE%\AppData\Roaming\lightning-app\lnd
Then open that directory on your local file manager and delete all data in the `lnd` directory.
No unkpack the lnd-rescue you made before and copy all the data from the `mnt/hdd/lnd` directory (including sub directories) into the LND-Path lnd directory. Delete the "lnd.conf" file.
Now start the Lightning App again. Your wallet password should now be your RaspIBlitz PasswordC.
**If its working and you have access to your funds/channels on the Desktop App ... dont start the RaspiBlitz anymore. Delete sd card and HDD.**
## How do I change the Name/Alias of my lightning node ## How do I change the Name/Alias of my lightning node
Use the "Change Name/Alias of Node" option in the main menu. The RaspiBlitz will make a reboot after this. Use the "Change Name/Alias of Node" option in the main menu. The RaspiBlitz will make a reboot after this.
@ -270,7 +337,7 @@ Linux/Ubuntu (desktop): https://askubuntu.com/questions/86724/how-do-i-open-the-
Linux/Raspbian (command line): https://www.addictivetips.com/ubuntu-linux-tips/manually-partition-a-hard-drive-command-line-linux/ Linux/Raspbian (command line): https://www.addictivetips.com/ubuntu-linux-tips/manually-partition-a-hard-drive-command-line-linux/
## How do I shrink the QR code for connecting my Shango/Zap mobile phone? ## How do I shrink the QR code for connecting my Shango/Zap/Zeus mobile phone?
Make the fonts smaller until the QR code fits into your (fullscreen) terminal. In OSX use `CMD` + `-` key. In LINUX use `CTRL`+ `-` key. On WINDOWS Putty go into the settings and change the font size: https://globedrill.com/change-font-size-putty Make the fonts smaller until the QR code fits into your (fullscreen) terminal. In OSX use `CMD` + `-` key. In LINUX use `CTRL`+ `-` key. On WINDOWS Putty go into the settings and change the font size: https://globedrill.com/change-font-size-putty
@ -278,17 +345,23 @@ Make the fonts smaller until the QR code fits into your (fullscreen) terminal. I
The bitcoin IP is red, when the RaspiBlitz detects that it cannot reach the port of bitcoin node from the outside. This means the bitcoin node can peer with other bitcoin nodes, but other bitcoin nodes cannot initiate a peering with you. Dont worry, you dont need a publicly reachable bitcoin node to run a (public) lightning node. If you want to change this however, you need to forward port 8333 on your router to the the RaspiBlitz. How to do this is different on every router. The bitcoin IP is red, when the RaspiBlitz detects that it cannot reach the port of bitcoin node from the outside. This means the bitcoin node can peer with other bitcoin nodes, but other bitcoin nodes cannot initiate a peering with you. Dont worry, you dont need a publicly reachable bitcoin node to run a (public) lightning node. If you want to change this however, you need to forward port 8333 on your router to the the RaspiBlitz. How to do this is different on every router.
On details how to set port forwarding on your router model see: https://portforward.com
## Why is my node address on the display red? ## Why is my node address on the display red?
The node address is red, when the RaspiBlitz detects that it cannot reach the port of the LND node from the outside - when the device is behind a NAT or firewall of the the router. Your node is not publicly reachable. This means you can peer+openChannel with other public nodes, but other nodes cannot peer+openChannel with you. To change this you need to forward port 9735 on your router to the the RaspiBlitz. How to do this is different on every router. The node address is red, when the RaspiBlitz detects that it cannot reach the port of the LND node from the outside - when the device is behind a NAT or firewall of the the router. Your node is not publicly reachable. This means you can peer+openChannel with other public nodes, but other nodes cannot peer+openChannel with you. To change this you need to forward port 9735 on your router to the the RaspiBlitz. How to do this is different on every router.
On details how to set port forwarding on your router model see: https://portforward.com
## Why is my node address on the display yellow (not green)? ## Why is my node address on the display yellow (not green)?
Yellow is OK. The RaspiBlitz can detect, that it can reach a service on the port 9735 of your public IP - this is in most cases the LND of your RaspiBlitz. But the RaspiBlitz cannot 100% for sure detect that this is its own LND service on that port - thats why its just yellow, not green. Yellow is OK. The RaspiBlitz can detect, that it can reach a service on the port 9735 of your public IP - this is in most cases the LND of your RaspiBlitz. But the RaspiBlitz cannot 100% for sure detect that this is its own LND service on that port - thats why its just yellow, not green.
On details how to set port forwarding on your router model see: https://portforward.com
## Can I run the RaspiBlitz as Backend for BTCPayServer? ## Can I run the RaspiBlitz as Backend for BTCPayServer?
BTCPay Server is a solution to be your own payment processor to accept Lightning Payments for your online store: https://github.com/btcpayserver/btcpayserver BTCPay Server is a solution to be your own payment processor to accept Lightning Payments for your online store: https://github.com/btcpayserver/btcpayserver
You can find setup instructions for a experimental setup here: https://goo.gl/KnTzLu You can find setup instructions for a experimental setup here: https://goo.gl/KnTzLu
@ -300,12 +373,12 @@ You dont need a LAN port on your laptop as long as you can connect over WLAN to
## 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?
A LAN cable is recommended because it reduces a possible source of error on the network connection side. But how to setup WLAN when you dont have a LAN-Router/Switch available see here: A LAN cable is recommended because it reduces a possible source of error on the network connection side. But how to setup WLAN when you dont have a LAN-Router/Switch available see here:
https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#prepare-wifi https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#prepare-wifi
## Can I directly connect the RaspiBlitz with my laptop? ## Can I directly connect the RaspiBlitz with my laptop?
If you have a LAN port on your laptop - or you have a USB-LAN adapter, you can connect the RaspiBlitz directly (without a router/switch) to your laptop and share the WIFI internet connection. You can follow this [guide for OSX](https://medium.com/@tzhenghao/how-to-ssh-into-your-raspberry-pi-with-a-mac-and-ethernet-cable-636a197d055). If you have a LAN port on your laptop - or you have a USB-LAN adapter, you can connect the RaspiBlitz directly (without a router/switch) to your laptop and share the WIFI internet connection. You can follow this [guide for OSX](https://medium.com/@tzhenghao/how-to-ssh-into-your-raspberry-pi-with-a-mac-and-ethernet-cable-636a197d055).
In short for OSX: In short for OSX:
@ -313,9 +386,9 @@ In short for OSX:
* connect with LAN directly * connect with LAN directly
* Settings > Sharing/Freigaben > activate "internet sharing" from WLAN to Ethernet * Settings > Sharing/Freigaben > activate "internet sharing" from WLAN to Ethernet
* Settings > Network > Ethernet-Adapter > set to DHCP * Settings > Network > Ethernet-Adapter > set to DHCP
* in terminal > `ifconfig` there you should the the IP of the bridge100 * in terminal > `ifconfig` there you should see the IP of the bridge100
* in terminal > `arp -a` and check for an IP of a client to the bridge * in terminal > `arp -a` and check for an IP of a client to the bridge
* in terminal > ssh admin@[clientIP] * in terminal > ssh admin@[clientIP]
If anyone has expirence on doing this in Linux/Win, please share. If anyone has expirence on doing this in Linux/Win, please share.
@ -327,7 +400,7 @@ But if cannot login with SSH and you need to power off at least remove the LAN c
## How can I build an SD card other then the master branch? ## How can I build an SD card other then the master branch?
There might be a new not released features in development that are not yet in the master branch - but you want to try them out. There might be a new not released features in development that are not yet in the master branch - but you want to try them out.
To build a sd card image from another branch than master you follow the [Build the SD Card Image](README.md#build-the-sd-card-image) from the README, but execute the build script from the other branch and add the name of that branch as a parameter to the build script. To build a sd card image from another branch than master you follow the [Build the SD Card Image](README.md#build-the-sd-card-image) from the README, but execute the build script from the other branch and add the name of that branch as a parameter to the build script.
@ -347,6 +420,38 @@ If you fork the RaspiBlitz repo (much welcome) and you want to run that code on
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` - thats OK as long as you dont make changes to the sd card build script - then 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 `/home/admin/XXsyncScripts.sh` - thats OK as long as you dont make changes to the sd card build script - then 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?
You need to have your forked repo checked out on your laptop. There your should see your forked repo as `origin`, when you run `git remote -v`. If you dont see a additional `upstream` remote yet, then it with the following command `git remote add upstream https://github.com/rootzoll/raspiblitz.git`.
So first checkout the new branch namend `BRANCH` from the original RaspBlitz repo to your local computer with: `git fetch upstream` and then `git checkout -b BRANCH upstream/BRANCH`.
Now push the new branch to your forked GitHub repo with `git push -u origin BRANCH`.
Once the branch is available and synced between the RaspiBlitz GitHub repo, your forked GitHub repo and your local computer git repo, you can start developing.
## How can I sync a branch of my forked with my local RaspiBlitz?
You need to know that there is a git copy of the original RaspiBlitz GitHub repo on your physical RaspiBlitz in the folder `/home/admin/raspiblitz`. If you change into that folder and run `git remote -v` you can see the set origin repo.
You need to change that origin repo to your forked repo. You do that with:
```
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 the run:
```
/home/admin/XXsyncScripts.sh BRANCH
```
So your workflow can go: 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.
## How contribute a feature/change from my forked branch back to the RaspiBlitz repo?
Like the way above you can build a new feature or test a change. Once you have something ready you want to contribute back, you make sure its pushed to your forked GitHub repo and start a pull request from the GitHub website there to the RaspiBlitz repo.
See more info: https://yangsu.github.io/pull-request-tutorial/
## How to attach the RaspberryPi to the HDD? ## How to attach the RaspberryPi to the HDD?
There are multiple ways to do it - just remember it should be easy to get to the SD card slot to remove and replace the card. There are multiple ways to do it - just remember it should be easy to get to the SD card slot to remove and replace the card.
@ -367,7 +472,7 @@ Also there are first free 3D open source files in this repo in the directory `ca
## Are those "Under-Voltage detected" warnings a problem? ## Are those "Under-Voltage detected" warnings a problem?
When your USB power adapter for the RaspiBlitz delivers too low power those messages with "Under-Voltage detected" (undervoltage) are shortly seen on the display. This can lead to data loss/corruption on the HDD. If you see those just one or two times that's not OK, but can be in a tolerant window. Nevertheless it make sure your USB power adapter can deliver at least 3A (big and stable is good). If you still see those warnings maybe get a second USB Power adapter just for the HDD and power the HDD through a Y-Cable - see https://en.wikipedia.org/wiki/Y-cable#USB or put a USB Hub with extra power between the raspberry and the HDD. When your USB power adapter for the RaspiBlitz delivers too low power those messages with "Under-Voltage detected" (undervoltage) are shortly seen on the display. This can lead to data loss/corruption on the HDD. If you see those just one or two times that's not OK, but can be in a tolerant window. Nevertheless it make sure your USB power adapter can deliver at least 3A (big and stable is good). If you still see those warnings maybe get a second USB Power adapter just for the HDD and power the HDD through a Y-Cable - see https://en.wikipedia.org/wiki/Y-cable#USB or put a USB Hub with extra power between the raspberry and the HDD.
## Why do we need to download the blockchain and not syncing it? ## Why do we need to download the blockchain and not syncing it?
@ -378,10 +483,10 @@ The RaspiBlitz is powered by the RaspberryPi. The processing power of this Singl
Using pre-built software almost always shifts trust to the one who made the binary. But at least you can check with the SHA checksum after download if the image downloaded is really the one offered by the GitHub Repo. To do so make a quick check if your browser is really in the correct GiutHub page and that your HTTPS of the GitHub page is signed by 'DigiCert'. Then compare the SHA-256 string (always next to the download link of the image on the README) with the result of the command `shasum -a 256 [DOWNLOADED-FILE-TO-CHECK]` (Mac/Linux). Still this is not optimal and if at least some people from the community request it, I will consider signing the download as an author for the future. Using pre-built software almost always shifts trust to the one who made the binary. But at least you can check with the SHA checksum after download if the image downloaded is really the one offered by the GitHub Repo. To do so make a quick check if your browser is really in the correct GiutHub page and that your HTTPS of the GitHub page is signed by 'DigiCert'. Then compare the SHA-256 string (always next to the download link of the image on the README) with the result of the command `shasum -a 256 [DOWNLOADED-FILE-TO-CHECK]` (Mac/Linux). Still this is not optimal and if at least some people from the community request it, I will consider signing the download as an author for the future.
The best way would be to build the sd card yourself. You use the script `build_sdcard.sh` for it. Take some minutes to check if you see anything suspicious in that build script and then follow the [README](README.md#build-the-sd-card-image) on this. The best way would be to build the sd card yourself. You use the script `build_sdcard.sh` for it. Take some minutes to check if you see anything suspicious in that build script and then follow the [README](README.md#build-the-sd-card-image) on this.
## Is downloading the blockchain from a third party secure? ## Is downloading the blockchain from a third party secure?
To download a blockchain from a third party (torrent/ftp) is not optimal and for the future with more cheap & powerfull SingleBoardComputers we could get rid of this 'patch'. To download a blockchain from a third party (torrent/ftp) is not optimal and for the future with more cheap & powerfull SingleBoardComputers we could get rid of this 'patch'.
The downloaded blockchain is pre-indexed and pre-validated. That should be practically secure enough, because if the user gets a "manipulated" blockchain it would not work after setup. The beginning of the downloaded blockchain needs to fit the genesis block (in bitcoind software) and the end of the downloaded blockchain needs not match with the rest of the bitcoin network state - hashes of new block distrubuted within the peer-2-peer network need to match the downloaded blockchain head. So if you downloaded a manipulated blockchain it simply wouldn't work in practice. As long as you are not in a totally hostile environment where someone would be able to fake a whole network of peers and miners around you - this is secure enough for running a small funded full node to try out the lightning network. The downloaded blockchain is pre-indexed and pre-validated. That should be practically secure enough, because if the user gets a "manipulated" blockchain it would not work after setup. The beginning of the downloaded blockchain needs to fit the genesis block (in bitcoind software) and the end of the downloaded blockchain needs not match with the rest of the bitcoin network state - hashes of new block distrubuted within the peer-2-peer network need to match the downloaded blockchain head. So if you downloaded a manipulated blockchain it simply wouldn't work in practice. As long as you are not in a totally hostile environment where someone would be able to fake a whole network of peers and miners around you - this is secure enough for running a small funded full node to try out the lightning network.
@ -389,7 +494,9 @@ If you dont trust the download or you want to run the RaspiBlitz in a more produ
## Why is taking my torrent download of the blockchain so long? ## Why is taking my torrent download of the blockchain so long?
Other users reported that opening up and forwarding the following port from their router to the RaspiBlitz helped speed up and getting started the torrent download: 6881-6889, 6969, 1337 Other users reported that opening up and forwarding the following port from their router to the RaspiBlitz helped speed up and getting started the torrent download: 49200-49250
On details how to set port forwarding on your router model see: https://portforward.com
## What is the "Base Torrent File"? ## What is the "Base Torrent File"?
@ -419,7 +526,7 @@ To create the Update Torrent file, follow the following step ...
Have a almost 100% synced bitcoind MAINNET with txindex=1 on a RaspiBlitz Have a almost 100% synced bitcoind MAINNET with txindex=1 on a RaspiBlitz
(remove all funds from this node - because blockchain get messed with) (remove all funds from this node - because blockchain get messed with)
Stop bitcoind with: Stop bitcoind with:
``` ```
sudo systemctl stop bitcoind sudo systemctl stop bitcoind
``` ```
@ -522,7 +629,7 @@ Work Nodes for the process of producing a new sd card image release:
* Remove `Ubuntu LIVE` USB stick and replace with `Ubuntu AIRGAP` * Remove `Ubuntu LIVE` USB stick and replace with `Ubuntu AIRGAP`
* PowerOn Build Laptop (press F12 for boot menu) * PowerOn Build Laptop (press F12 for boot menu)
* Cut Power of RaspiBlitz, remove sd card and connect with sd card reader to build laptop * Cut Power of RaspiBlitz, remove sd card and connect with sd card reader to build laptop
* Connect and open in Filemenager NTFS - context on white scace -> open terminal * Connect and open in Filemenager NTFS - context on white scace -> open terminal
* run `df`to check on sd card reader device name * run `df`to check on sd card reader device name
* `sudo dd if=/dev/[sdcarddevice] | gzip > ./raspiblitz-vX.X-YEAR-MONTH-DAY.img.gz` * `sudo dd if=/dev/[sdcarddevice] | gzip > ./raspiblitz-vX.X-YEAR-MONTH-DAY.img.gz`
* Delete all IMG files from NTFS (just keep zips/gzs) * Delete all IMG files from NTFS (just keep zips/gzs)
@ -532,12 +639,12 @@ Work Nodes for the process of producing a new sd card image release:
* Connect NTFS USB stick to MacOS (its just readonly) * Connect NTFS USB stick to MacOS (its just readonly)
* Check if file can be unzipped on OSX * Check if file can be unzipped on OSX
* Run tests with new image * Run tests with new image
* Upload new image to Download Server * Upload new image to Download Server
* Copy SHA256-String into GutHub README and update downloadlink * Copy SHA256-String into GutHub README and update downloadlink
## Can I run RaspiBlitz on other computers than RaspberryPi? ## Can I run RaspiBlitz on other computers than RaspberryPi?
There is an experimental section in this GitHub that tries to build for other SingleBoardComputers. Feel free to try it out and share your experience: [dietpi/README.md](dietpi/README.md) There is an experimental section in this GitHub that tries to build for other SingleBoardComputers. Feel free to try it out and share your experience: [alternative.platforms/README.md](alternative.platforms/README.md)
## Can I flip the screen? ## Can I flip the screen?
@ -546,11 +653,11 @@ look for the line `dtoverlay=tft35a:rotate=270` towards the end. To flip the scr
## How to setup fresh/clean/reset and not getting into recovery mode? ## How to setup fresh/clean/reset and not getting into recovery mode?
When you put in a sd card with a new/clean RaspiBlitz image the RaspiBlitz will get into recovery mode because it detects the old data on your HDD and assumes you just want to continue to work with this data. When you put in a sd card with a new/clean RaspiBlitz image the RaspiBlitz will get into recovery mode because it detects the old data on your HDD and assumes you just want to continue to work with this data.
But there might be cases where you want to start a totally fresh/clean RaspiBlitz from the beginning. To do so you need to delete the old data from the HDD. You can do so by formating it on another computer (for example with FAT and name it "NEW"). Or when you can run the script "/home/admin/XXcleanHD.sh -all" on the terminal. But there might be cases where you want to start a totally fresh/clean RaspiBlitz from the beginning. To do so you need to delete the old data from the HDD. You can do so by formating it on another computer (for example with FAT and name it "NEW"). Or when you can run the script "/home/admin/XXcleanHD.sh -all" on the terminal.
When the HDD is clean, then flash a new RaspiBlitz sd card and your setup should start fresh. When the HDD is clean, then flash a new RaspiBlitz sd card and your setup should start fresh.
## My blockchain data is corrupted - what can I do? ## My blockchain data is corrupted - what can I do?
@ -612,15 +719,78 @@ Just replace the file `/home/admin/raspiblitz/pictures/logoraspiblitz.png` with
NOTE: On updates this change will get lost and you might need to redo it. NOTE: On updates this change will get lost and you might need to redo it.
## How can I update LND or bitcoind even before the next RaspiBlitz update?
Try updating before a official RaspiBlitz on your very own risk - you can find some info about that here:
https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_faq.md#how-to-upgrade-bitcoin-core
## I cannot connect per SSH to my RaspiBlitz. What to do? ## I cannot connect per SSH to my RaspiBlitz. What to do?
- Check the command again with how its on the display - do you have it typed in correctly? - Check the command again with how its on the display - do you have it typed in correctly?
- Replace `ssh` with `sudo ssh` and try it (laptop admin password might be required). - Replace `ssh` with `sudo ssh` and try it (laptop admin password might be required).
If that not works ry to ping the IP of the RaspiBlitz with `ping [IP-of-RaspiBlitz]`. If you get no response on the ping requests the device is not reachable try this check list: If that doesn't work, try to ping the IP of the RaspiBlitz with `ping [IP-of-RaspiBlitz]`. If you get no response on the ping requests and the device is not reachable, try this check list:
- Make sure that your RaspiBlitz and your laptop are really on the same local network - Make sure that your RaspiBlitz and your laptop are really on the same local network
- Check if you have a VPN running on your laptop - some VPNs block local network - Check if you have a VPN running on your laptop - some VPNs block local network
- Some Routers have `IP Isolation` switched on - not allowing to devices to connect - Some Routers have `IP Isolation` switched on - not allowing two devices to connect
If that all is not working: Join the conversation on [GitHub Issue #420](https://github.com/rootzoll/raspiblitz/issues/420). If that all is not working: Join the conversation on [GitHub Issue #420](https://github.com/rootzoll/raspiblitz/issues/420).
## How to setup port-forwarding with a SSH tunnel?
To use a public server for port-forwarding thru a SSH tunnel you can use the following experimental script on the RaspiBlitz (since v1.2):
`/home/admin/config.scripts/internet.sshtunnel.py`
But first you need to make sure that the public server you are using is supporting SSH reverse tunneling and authentification by public authorized key. Check the `/etc/ssh/sshd_config` on the public server to contain the following settings:
```
RSAAuthentication yes
PubkeyAuthentication yes
GatewayPorts yes
AllowTcpForwarding yes
```
You can add those at the end of the file, save and reboot.
On the RaspiBlitz you can then setup for example to forward the gRPC port 10009 (internal port) to the port 20009 on the public server (external port) with the user = `test` and server address = `raspiblitz.com` with the following command:
`/home/admin/config.scripts/internet.sshtunnel.py on test@raspiblitz.com "10009<20009"`
You can even set multiple port forwardings like with:
`/home/admin/config.scripts/internet.sshtunnel.py on test@raspiblitz.com "10009<20009" "8080<9090"`
Please beware that after you set such a port forwarding you need to set the domain of the public server as a `DynamicDNS` name (leave update url empty) and then connect mobile wallets fresh or export again the macaroons/certs. When connecting the mobile wallets you may need to adjust ports manually after QR code scan. And if you SSH tunnel the LND node port `9735` you may also need to sun the custom LND port script and maybe also a manual set of the domain in the LND service is needed. This all is very experimental at the moment ... better integration will come in the future.
To switch this SSH tunneling off again use:
`/home/admin/config.scripts/internet.sshtunnel.py off` and also deactivate the DynamicDNS again.
## How to setup just a port-forwarding user on my public server?
Make sure the `/etc/ssh/sshd_config` has the following lines at the end:
```
RSAAuthentication yes
PubkeyAuthentication yes
GatewayPorts yes
AllowTcpForwarding yes
AuthorizedKeysFile /etc/ssh/authorized_keys/%u
```
The last one stores all authorized_keys in one directory with a file per user. See https://serverfault.com/questions/313465/is-a-central-location-for-authorized-keys-a-good-idea#424659 To prepare this run:
```
mkdir /etc/ssh/authorized_keys
groupadd forwardings
```
To add a forwarding user run:
```
useradd -g forwardings -d /home [USERNAME]
echo 'command="date" [CONTENT-OF-RASPIBLITZ-ROOT-SSH-PUBKEY]' > /etc/ssh/authorized_keys/[USERNAME]
passwd [USERNAME]
```
The `[CONTENT-OF-RASPIBLITZ-ROOT-SSH-PUBKEY]` you get when running the `internet.sshtunnel.py` script on the RaspiBlitz (see above).

240
README.md

@ -1,7 +1,7 @@
# RaspiBlitz # RaspiBlitz
*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.1 with lnd 0.5.2-beta and bitcoin 0.17.0.1 or litecoin 0.16.3.` `Version 1.2 with lnd 0.6-beta and bitcoin 0.17.1 or litecoin 0.16.3.`
![RaspiBlitz](pictures/raspiblitz.jpg) ![RaspiBlitz](pictures/raspiblitz.jpg)
@ -19,7 +19,7 @@ There are additional services that can be switched on:
![MainMenu-Services](pictures/mainmenu-services.png) ![MainMenu-Services](pictures/mainmenu-services.png)
As an parallel alternative to the SSH menu there is also the RTL WebUI available (LND API Coverage at 57%): As an parallel alternative to the SSH menu there is also the RTL WebUI available (LND API Coverage at 57%):
![RTL-preview](pictures/RTL-dashboard.png) ![RTL-preview](pictures/RTL-dashboard.png)
@ -29,7 +29,7 @@ See more details in the [Feature Documentation](#feature-documentation) & of cou
The RaspiBlitz is optimized for being setup during a workshop at a hackday or conference (see [detailed workshop tutorial](WORKSHOP.md)). When it comes ready assembled together with a up-to-date synced blockchain its possible to have it ready in about 2 to 3 hours - most is waiting time. The RaspiBlitz is optimized for being setup during a workshop at a hackday or conference (see [detailed workshop tutorial](WORKSHOP.md)). When it comes ready assembled together with a up-to-date synced blockchain its possible to have it ready in about 2 to 3 hours - most is waiting time.
If you start at home ordering the parts from Amazon (see shopping list below) then its a weekend project with a lot of download and syncing time where you can do other stuff while checking on the progress from time to time. If you start at home ordering the parts from Amazon (see shopping list below) then its a weekend project with a lot of download and syncing time where you can do other stuff while checking on the progress from time to time.
## Hardware Needed ## Hardware Needed
@ -40,9 +40,9 @@ The RaspiBlitz is build from the following parts:
* LCD-Display * LCD-Display
* Micro SD-Card (min 16GB - go for quality) * Micro SD-Card (min 16GB - go for quality)
* Powersupply >=3A (choose big & stable output) * Powersupply >=3A (choose big & stable output)
* Cheap Casing * Case with Heatsink
**All single parts together under 150 USD / 130 EUR ... depending on country & shop, see shopping lists below.** **All together under 160 USD / 140 EUR (depending on country & shop)**
### Buy a ready-2-go RaspiBlitz (Germany, EU and International) ### Buy a ready-2-go RaspiBlitz (Germany, EU and International)
@ -70,13 +70,9 @@ The cheapest way is to buy ans assemble the single parts yourself. These are the
## Assemble your RaspiBlitz ## Assemble your RaspiBlitz
If your RaspiBlitz is not assembled yet, put the RaspberryPi board into the case and add the display like in picture below: If your RaspiBlitz is not assembled yet, put the RaspberryPi board into the case. If you have the Geekworm Heatsink-Case - [see video on how to install](https://www.youtube.com/watch?v=2QDlbAorJKw).
![LCD](pictures/lcdassm.png) Add the display on top with the pins like in picture below. Connect the HDD to one of the USB ports. PlugIn the network cable. In the end your RaspiBlitz should look like this:
*Some cases from the shopping lists contain a topping for smaller displays - you can ignore that topping.*
Connect the HDD to one of the USB ports. In the end your RaspiBlitz should look like this:
![HardwareSetup](pictures/hardwaresetup.jpg) ![HardwareSetup](pictures/hardwaresetup.jpg)
@ -84,15 +80,15 @@ Connect the HDD to one of the USB ports. In the end your RaspiBlitz should look
## Installing the Software ## Installing the Software
Your SD-card needs to contain the RaspiBlitz software. You can take the long road by [building the SD-card image yourself](#build-the-sd-card-image) or use the already prepared SD-Card image: Your SD-card needs to contain the RaspiBlitz software. You can take the long road by [building the SD-card image yourself](#build-the-sd-card-image) or use the already prepared SD-Card image:
**Download SD-Card image - Version 1.1:** **Download SD-Card image - Version 1.2:**
HTTP: http://wiki.fulmo.org/downloads/raspiblitz-v1.1-2019-03-18.img.gz HTTP: http://wiki.fulmo.org/downloads/raspiblitz-v1.2-2019-05-02.img.gz
Torrent: https://github.com/rootzoll/raspiblitz/raw/master/raspiblitz-v1.1-2019-03-18.torrent Torrent: https://github.com/rootzoll/raspiblitz/raw/v1.2/raspiblitz-v1.2-2019-05-02.torrent
SHA-256: b7a449ce6444f9e7e9fd05156ff09c70a6e200be0b5e580d3317049eefc4f3b7 SHA-256: ae9910bb99b7a992d14e920696183b6e494cc9b52db7b9c03dd02fd739d47659
**Write the SD-Card image to your SD Card** **Write the SD-Card image to your SD Card**
@ -138,17 +134,21 @@ If you run into a problem or you have still a question, follow the steps below t
3. 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. 3. 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.
4. If you havent found an answere yet, open a new issue on the RaspiBlitz GitHub. You may have to register an account with GitHub for this. If its a bug with the RaspiBlitz, please add (copy+paste) a Debug Report to your issue (see [FAQ](FAQ.md) how to generate) and/or add some screenshots/photos so the community gets more insight into your problem. 4. Check the RaspiBlot Troubleshoort guide: https://stadicus.github.io/RaspiBolt/raspibolt_70_troubleshooting.html (RaspiBolt is very similar to the RaspiBlitz)
5. If you havent found an answere yet, open a new issue on the RaspiBlitz GitHub. You may have to register an account with GitHub for this. If its a bug with the RaspiBlitz, please add (copy+paste) a Debug Report to your issue (see [FAQ](FAQ.md) how to generate) and/or add some screenshots/photos so the community gets more insight into your problem.
## Setup Process (Detailed Documentation) ## Setup Process (Detailed Documentation)
*The goal is, that all information needed is provided from the interaction with the RaspiBlitz itself during the setup. Documentation in this chapter is for background, comments for educators and to mention edge cases.* *The goal is, that all information needed during setup is provided from the interaction with the RaspiBlitz itself during the setup. Documentation in this chapter is for background, comments for educators and to mention edge cases.*
If you are looking for a tutorial on how to oragnise a workshop to build the RaspiBlitz, [see here](WORKSHOP.md). If you are looking for a tutorial on how to oragnise a workshop to build the RaspiBlitz, [see here](WORKSHOP.md).
### Init ### Init
Automatically after login per SSH as admin to the RaspiBlitz, the user can choose if the RaspiBlitz should run Bitcoin or Litecoin with Lightning: Automatically after login per SSH as admin to the RaspiBlitz, it will run a hardware test. If you see a warning there, please read carefully, because a lot of things that go wrong later (errors and even loss of funds) relate of problems with the hardware. If you get an OK here ... you are good to go :)
In the beginning you can choose to run on Bitcoin or Litecoin with Lightning:
![SSH0](pictures/ssh0-welcome2.png) ![SSH0](pictures/ssh0-welcome2.png)
@ -186,15 +186,17 @@ After this the setup process will need some time and the user will see a lot of
![SSH4](pictures/ssh4-scripts.png) ![SSH4](pictures/ssh4-scripts.png)
*Background: After the user interaction the following scripts are started to automatically setup the RaspiBlitz:*
### Getting the Blockchain ### Getting the Blockchain
*If you have a HDD with a prepared blockchain (e.g. a ready2go-set or you are at a workshop) you can skip to the [next chapter](#setup-lightning). If you started with an empty HDD - you will see the following screen:* *If you have a HDD with a prepared blockchain (e.g. a ready2go-set or you are at a workshop) you can skip to the [next chapter](#setup-lightning). If you started with an empty HDD - you will see the following screen:*
If you connected a fresh Hard Drive Disc to the RaspiBlitz it might now ask you if its OK to format the HDD.
<img src="pictures/ssh4-formatHDD.png" alt="format-HDD" width="366">
To get a copy of the blockchain, the RaspiBlitz offers the following options: To get a copy of the blockchain, the RaspiBlitz offers the following options:
<img src="pictures/ssh5-blockchain2.png" alt="blockchain-options" width="600"> <img src="pictures/ssh5-blockchain2.png" alt="blockchain-options" width="551">
The options - and when to choose which - will be explained here shortly: The options - and when to choose which - will be explained here shortly:
@ -206,11 +208,11 @@ This is the default way to download the blockchain data for the RaspiBlitz. If y
*This can take a while - normally it should be done if you keep it running over night, but some users reported that it took up to 3 days. If it takes longer than that or you cannot see any progress (downloading starting) for over an hour after you started this option consider to cancel the download and go with the COPY option or retry fresh.* *This can take a while - normally it should be done if you keep it running over night, but some users reported that it took up to 3 days. If it takes longer than that or you cannot see any progress (downloading starting) for over an hour after you started this option consider to cancel the download and go with the COPY option or retry fresh.*
It is safe to close the terminal window (shutdown your laptop) while the RaspiBlitz is doing the torrent download. To check on progress and to continue the setup you need to ssh back in again. It is safe to close the terminal window (and shutingdown your laptop) while the RaspiBlitz is doing the torrent download. To check on progress and to continue the setup you need to ssh back in again.
You can cancel the torrent download by keeping the key `x` pressed. Then the download will stop and you will be asked if you want to keep the progress so far. This makes sense if you need to shutdown the RaspiBlitz and you want to continue later or when you want to try another download option but want to keep the option to continue on torrent if the other option is slower or not working. You can cancel the torrent download by keeping the key `x` pressed. Then the download will stop and you will be asked if you want to keep the progress so far. This makes sense if you need to shutdown the RaspiBlitz and you want to continue later or when you want to try another download option but want to keep the option to continue on torrent if the other option is slower or not working.
* [How can I avoid using a prepared blockchain and validate myself?](FAQ.md#how-can-i-avoid-using-a-prepared-blockchain-and-validate-myself) * [I dont trust a torrent blockchain, how can I validate myself?](FAQ.md#how-can-i-avoid-using-a-prepared-blockchain-and-validate-myself)
* [Why is taking my torrent download of the blockchain so long?](FAQ.md#why-is-taking-my-torrent-download-of-the-blockchain-so-long) * [Why is taking my torrent download of the blockchain so long?](FAQ.md#why-is-taking-my-torrent-download-of-the-blockchain-so-long)
@ -218,13 +220,13 @@ You can cancel the torrent download by keeping the key `x` pressed. Then the dow
If you have another computer available (laptop, desktop or another raspiblitz) that already runs a working blockchain (with txindex=1) you can use this option to copy it over to the RaspiBlitz. This will be done over the local network by SCP (SSH file transfere). Choose this option and follow the given instructions. If you have another computer available (laptop, desktop or another raspiblitz) that already runs a working blockchain (with txindex=1) you can use this option to copy it over to the RaspiBlitz. This will be done over the local network by SCP (SSH file transfere). Choose this option and follow the given instructions.
This is also the best option if you dont like to run your RaspiBlitz with a prepared blockchain by a third party. Then install bitcoin-core in a more powerful computer, sync+validate the blockchain (with txindex=1) there by yourself and copy it over after that thru the local network. This is also the best option if you dont like to run your RaspiBlitz with a prepared blockchain by a third party. Then install bitcoin-core on a more powerful computer, sync+validate the blockchain (with txindex=1) there by yourself and copy it over after that thru the local network.
More details: [I have the full blockchain on another computer. How do I copy it to the RaspiBlitz?](FAQ.md#i-have-the-full-blockchain-on-another-computer-how-do-i-copy-it-to-the-raspiblitz) More details: [I have the full blockchain on another computer. How do I copy it to the RaspiBlitz?](FAQ.md#i-have-the-full-blockchain-on-another-computer-how-do-i-copy-it-to-the-raspiblitz)
#### 3. Cloning from a 2nd HDD #### 3. Cloning from a 2nd HDD
If is a backup way to transfere a blockchain from another computer if copying over the network is not working. More details on the setup can be found [here](FAQ.md#how-do-i-clone-the-blockchain-from-a-2nd-hdd). This is a backup way to transfere a blockchain from another computer if copying over the network is not working. More details on the setup can be found [here](FAQ.md#how-do-i-clone-the-blockchain-from-a-2nd-hdd).
#### 4. Sync from Bitcoin-Network #### 4. Sync from Bitcoin-Network
@ -236,19 +238,43 @@ Lightning is installed and waiting for your setup if you see this screen.
![SSH7](pictures/ssh7-lndinit.png) ![SSH7](pictures/ssh7-lndinit.png)
The RaspiBlitz calling the LND wallet creation command for you: You now decide if you want to setup a fresh new wallet or if you want to recover an old wallet from a RaspiBlitz you had before.
#### Setup a NEW Wallet
This is the default if you setup a RaspiBlitz the first time.
![SSH8](pictures/ssh8-wallet.png) ![SSH8](pictures/ssh8-wallet.png)
First it will ask you to set your wallet unlock password - use your choosen PASSWORD C here and confirm it by inputting it a second time. RaspiBlitz will ask you to set your wallet unlock password - use your choosen PASSWORD C here and confirm it by inputting it a second time.
LND will now generate a fresh cipher seed (word list) for you.
![SSH8](pictures/ssh8-walletb.png)
WRITE YOUR PERSONAL WORDS DOWN before you continue - without you limit your chances to recover funds in case of failing hardware etc. If you just want to try/experiment with the RaspiBlitz at least take a photo with your smartphone just in case. If you might plan to keep your RaspiBlitz running after trying it out store this word list offline or in a password safe.
#### Recover a OLD Wallet
Choose this option if you had an old RaspiBlitz you want to recover. You have three options to do that:
![SSH7](pictures/ssh7-lndrecover.png)
The RaspiBlitz calling the LND wallet creation command for you:
##### LNDRESCUE LND tar.gz-Backupfile (BEST)
Second it will ask you if you have an existing "cipher seed mnemonic" - if this is your first RaspiBlitz/LND just ansere `n`. Choose this option if you have made a complete backup of the LND data and have a tar.gz file available. It will recover all your on-chain funds and open channels you had. But you have to be shure, that the LND backup you have is reaklly the latest version - otherwise you might loose channel funds.
*The "cipher seed mnemonic" is the word list that contains the backup of your private key. If you dont have one from a former RaspiBlitz setup it will be created for you. If you want to recovcer on old LND wallet, thats the point in the setup to enter it.* ##### SEED+SCB Words Seed & channel.backup file (OK)
Third it will ask you if you want to protect your backup word list with an additional password. You can simple keep this empty and just press ENTER to continue. If you want to go for this extra protection use your chossen PASSWORD D here. Next best option is, if you have the channel.backup file and the word seed. This is the best cahnce to recover your on-chain funds and funds you had in open channels. But all channels you had open before will be closed in this procedure.
LND will now generate a fresh cipher seed (word list) for you. WRITE THIS DOWN before you continue - without you limit your chances to recover funds in case of failing hardware etc. If you just want to try/experiment with the RaspiBlitz at least take a photo with your smartphone just in case. If you might plan to keep your RaspiBlitz running after trying it out store this word list offline or in a password safe. Hit ENTER once your done. ##### ONLY SEED Only Seed Word List (Fallback)
If you just have the word list (RaspiBlitz 1.1 and older) you can at least try to recover your on-chain funds. Recover of channel funds is not very likely in this scenario.
### Final LND Setup
It will now make sure your wallet is initialized correctly and may ask you to unlock it with your just set PASSWORD C. It will now make sure your wallet is initialized correctly and may ask you to unlock it with your just set PASSWORD C.
@ -260,11 +286,11 @@ The RaspiBlitz will now do final setup configuration like installing tools, movi
![SSH9b](pictures/ssh9b-reboot.png) ![SSH9b](pictures/ssh9b-reboot.png)
The basic setup is done - hooray ... but still prepare for some long waiting time after this before you can play around with your new RaspiBlitz. Press OK to make a reboot. Your terminal session will get disconnected and the raspberry pi restarts. The basic setup is done - hooray ... but it can now take still some time before everything is ready and you can play around with your new RaspiBlitz. Press OK to make a reboot. Your terminal session will get disconnected and the raspberry pi restarts.
### First Start: Syncing & Scanning ### First Start: Syncing & Scanning
After the reboot is done it takes a while for all services to start up - wait until you see on the LCD/display that LND wallet needs to get unlocked. Then SSH in again with the same command like in the beginning (check LCD/display) but this time (and every following login) use your PASSWORD A. After the reboot is done it takes a while for all services to start up - wait until you see on the LCD/display that LND wallet needs to get unlocked. Then SSH in again with the same command like in the beginning (check LCD/display) but this time (and every following login) use your PASSWORD A.
After terminal login LND will ask you (like on every start/reboot) to unlock the wallet again - use PASSWORD C: After terminal login LND will ask you (like on every start/reboot) to unlock the wallet again - use PASSWORD C:
@ -274,19 +300,17 @@ Now on first start you will habe a longer waiting time (between 1 hour and 2-3 d
To understand what is taking so long .. its two things: To understand what is taking so long .. its two things:
1. Blockchain Sync ![SSH9d1](pictures/ssh9d-sync.png)
![SSH9d1](pictures/ssh9d-blockchainsync.png) 1. Blockchain Sync
The blockchain on you HDD is not absolutly up-to-date. Depending how you got it transferred to your RaspiBlitz it will be some hours, days or even weeks behind. Now the RaspiBlitz needs to catch-up the rest by directly syncing with the peer-2-peer network until it reaches almost 100%. But even if you see in the beginning a 99.8% this can take time - gaining 1% can be up to 4 hours (depending on network speed). So be patient here.
* [Why is my "final sync" taking so long?](FAQ.md#why-is-my-final-sync-taking-so-long) The blockchain on your HDD is not absolutly up-to-date. Depending how you got it transferred to your RaspiBlitz it will be some hours, days or even weeks behind. Now the RaspiBlitz needs to catch-up the rest by directly syncing with the peer-2-peer network until it reaches almost 100%. But even if you see in the beginning a 99.8% this can take time - gaining 1% can be up to 4 hours (depending on network speed). So be patient here.
2. LND Scanning 2. Lightning Scanning
![SSH9d2](pictures/ssh9d-lndscan.png) Automatically if the Blockchain Sync is progressing LND will start to scan the blockchain and collect information. The Lightning scanning alone normally just take around 1 hour until the waiting time is over. Can take much longer if you recover on old wallet from seed.
Automatically if the Blockchain Sync is done LND will start to scan the blockchain and collect information. If you reached this point it should normally just take around 1 hour until the waiting time is over. * [Why is my "final sync" taking so long?](FAQ.md#why-is-my-final-sync-taking-so-long)
Once all is done you should see this status screen on the RaspiBlitz LCD/display: Once all is done you should see this status screen on the RaspiBlitz LCD/display:
@ -298,7 +322,7 @@ If you now login by SSH in your RaspiBlitz (or you are still logged in) you will
![SSH9e1](pictures/mainmenu1.png) ![SSH9e1](pictures/mainmenu1.png)
And if you scroll down .. you see even more options. All options of the main menu will be explained below in the feature documentation. And if you scroll down .. you see even more options. All options of the main menu will be explained below in the feature documentation.
*OK .. so from here on your RaspiBlitz is ready to play with.* *OK .. so from here on your RaspiBlitz is ready to play with.*
@ -310,7 +334,7 @@ If you need an idea what the most basic next steps to experience Lightning would
If you like to do this all from a webbrowser with a dashboard UI instead from an SSH terminal, go to `SERVICES`, activate the `RTL Webinterface` and after the reboot open in your webbrowser: http://[LOCAL-IP-OF-YOU-NODE]:3000 (PASSWORD B is your RPC password). If you like to do this all from a webbrowser with a dashboard UI instead from an SSH terminal, go to `SERVICES`, activate the `RTL Webinterface` and after the reboot open in your webbrowser: http://[LOCAL-IP-OF-YOU-NODE]:3000 (PASSWORD B is your RPC password).
Have fun and riding the lightning :D Have fun riding the lightning :D
*BTW always love seeing photos of new RaspBlitzes added to the network on twitter @rootzoll* *BTW always love seeing photos of new RaspBlitzes added to the network on twitter @rootzoll*
@ -318,7 +342,7 @@ Have fun and riding the lightning :D
### Feature Documentation ### Feature Documentation
These are the features available thru the RaspiBlitz SSH main menu and services. They have the goal to offer some basic/fallback functionality & configurations to you. More complex or user-friendly tasks are best to be done with wallets, apps and scripts you connect to your Lightning Node via [APIs](#interface--apis) - because you have a full Bitcoin- and Lightning-Node on the RaspiBlitz. These are the features available thru the RaspiBlitz SSH main menu and services. They have the goal to offer some basic/fallback functionality & configurations. More complex or user-friendly tasks are best to be done with wallets, apps and scripts you connect to your Lightning Node via [APIs](#interface--apis) - because you have a full Bitcoin- and Lightning-Node on the RaspiBlitz.
So lets take a look at the SSH main menu (3 pages to scroll down): So lets take a look at the SSH main menu (3 pages to scroll down):
@ -342,9 +366,11 @@ Before you can open channels with other nodes you need to put some coins onto yo
*Reminder: RaspiBlitz & LND is still experimental software. With funding your LND node you accept the risk of loosing funds. So just play with small amounts - something in then area of 20 EUR/USD should be enough to make your first experiences.* *Reminder: RaspiBlitz & LND is still experimental software. With funding your LND node you accept the risk of loosing funds. So just play with small amounts - something in then area of 20 EUR/USD should be enough to make your first experiences.*
You can make multiple fundings - so you can start with small amounts first to test. LND will generate always a different address, but all funds you send will get into the same LND on-chain wallet.
#### CONNECT: Connect to a Peer #### CONNECT: Connect to a Peer
Before you can open a channel with another node on the network you need to connect this node as a peer to your node. Before you can open a channel with another node on the network you need to connect this node as a peer to your node.
Opening a channel with a peer is just optional. Having another node a peer helps your node to receive information about the network thru the gossip protocol. It will help your node to find better routes thru the network. Opening a channel with a peer is just optional. Having another node a peer helps your node to receive information about the network thru the gossip protocol. It will help your node to find better routes thru the network.
@ -352,7 +378,7 @@ Opening a channel with a peer is just optional. Having another node a peer helps
To open a payment channel with another node you can use this option. To open a payment channel with another node you can use this option.
Find interessting nodes to open channels with on online directories like [1ML.com](https://1ml.com/). Find interessting nodes to open channels with on online directories like [1ML.com](https://1ml.com/) or join the RaspiBlitz NodeManager telegram group to meat prople to open channels with: https://t.me/raspiblitz
*This is just a very basic shell script. For more usability try the RTL Webinterface (under Services) or connect a (mobile) wallet with your RaspiBlitz.* *This is just a very basic shell script. For more usability try the RTL Webinterface (under Services) or connect a (mobile) wallet with your RaspiBlitz.*
@ -392,12 +418,15 @@ To do so you can register at an DynamicDomain service like freedns.afraid.org an
* 8333 (Bitcoin/mainnet) * 8333 (Bitcoin/mainnet)
* 9735 (LND Node) * 9735 (LND Node)
* 10009 (LND RPC) * 10009 (LND RPC)
* 8080 (LND REST API)
... from your internet router to the local IP of your RaspiBlitz and then activate unter "Services" the "DynamicDNS" option. ... from your internet router to the local IP of your RaspiBlitz and then activate unter "Services" the "DynamicDNS" option.
You will be asked for your dynamic domain name such like "mynode.crabdance.org" and you can also optionally set an URL that will be called regularly to update your routers IP with the dynnamic domain service. At freedns.afraid.org this URL is called "Direct URL" under the menu "Dynamic DNS" once you added one. You will be asked for your dynamic domain name such like "mynode.crabdance.org" and you can also optionally set an URL that will be called regularly to update your routers IP with the dynnamic domain service. At freedns.afraid.org this URL is called "Direct URL" under the menu "Dynamic DNS" once you added one.
*NOTE: DynamicDNS just works if you can forward ports on your router and you have a temporary public IP address (your ISP is not running you behind a NAT - like on most mobile connections). Another solution to make your ports reachable from the public internet is to use reverse ssh tunneling - see FAQ on ['How to setup port-forwarding with a SSH tunnel?'](FAQ.md#how-to-setup-port-forwarding-with-a-ssh-tunnel)*
##### Run behind TOR ##### Run behind TOR
You can run your Bitcoin- and Lightning-Node as a TOR hidden service - replacing your IP with an .onion-address You can run your Bitcoin- and Lightning-Node as a TOR hidden service - replacing your IP with an .onion-address
@ -427,23 +456,34 @@ Feedback is welcome by the RTL programmer: https://github.com/ShahanaFarooqui/RT
##### LND Auto-Unlock ##### LND Auto-Unlock
The RaspiBlitz will automatically unlock the LND wallet on every start.
This feature is based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_6A_auto-unlock.md This feature is based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_6A_auto-unlock.md
It can be activated under "Services" -> "Auto-unlock LND". Its recommended to be turned on, when DynamicDNS is used. Because on a public IP change of your router, LND gets restarted automatically and without Auto-Unlock it will stay inactive/unreachbale until you manually unlock it. It can be activated under "Services" -> "Auto-unlock LND". Its recommended to be turned on, when DynamicDNS is used. Because on a public IP change of your router, LND gets restarted automatically and without Auto-Unlock it will stay inactive/unreachbale until you manually unlock it.
* [When using Auto-Unlock, how much security do I lose?](FAQ.md#when-using-auto-unlock-how-much-security-do-i-lose) * [When using Auto-Unlock, how much security do I lose?](FAQ.md#when-using-auto-unlock-how-much-security-do-i-lose)
##### Backup Torrent Seeding
*THIS SERVICE IS STILL VERY EXPERIMENTAL AND CAN SLOW DOWN YOUR RASPBLITZ*
Activating this feature you can help with your RaspiBlitz to upload the Blockchain Torrent files and help new RaspiBlitz users with a faster download of the blockchain.
But also having this feature activated you always have a backup copy of the blockchain ready in case you run into data corruption on your main blockchain. So this will reduce your lightning node down-time on recovering of blockchain data.
#### MOBILE: Connect Mobile Wallet #### MOBILE: Connect Mobile Wallet
This feature should support you in connecting your RaspiBlitz to a mobile wallet on your smartphone. This feature should support you in connecting your RaspiBlitz to a mobile wallet on your smartphone.
<img src="pictures/mobile.png" alt="mobile-wallets"> <img src="pictures/mobile.png" alt="mobile-wallets">
At the moment [ZAP (iOS)](https://github.com/LN-Zap/zap-iOS) and [Shango (iOS/Android)](https://github.com/neogeno/shango-lightning-wallet) are available. At the moment [ZAP (iOS)](https://github.com/LN-Zap/zap-iOS), [Shango (iOS/Android)](https://github.com/neogeno/shango-lightning-wallet),
and [Zeus (iOS/Android)](https://github.com/ZeusLN/zeus) are available.
Please keep in mind that if you also want to connect to your smartphone also from the outside (thru LTE, 3G, ..) with your RaspiBlitz you might need to open/forward ports on your router and should look into the DynamicDNS features to handle changeing IP of our Home-DSL. Please keep in mind that if you also want to connect to your smartphone also from the outside (when you are outside of your local network) with your RaspiBlitz you might need to open/forward ports on your router and should look into the DynamicDNS features to handle changeing IP of our Home-DSL.
* [How do I shrink the QR code for connecting my Shango/Zap mobile phone?](FAQ.md#how-do-i-shrink-the-qr-code-for-connecting-my-shangozap-mobile-phone) * [How do I shrink the QR code for connecting my Shango/Zap/Zeus mobile phone?](FAQ.md#how-do-i-shrink-the-qr-code-for-connecting-my-shangozap-mobile-phone)
#### EXPORT: Macaroons and TLS.cert #### EXPORT: Macaroons and TLS.cert
@ -487,12 +527,12 @@ Change the name of your node.
Change you passwords for security. Change you passwords for security.
![MainMenu-C](pictures/mainmenu3.png)
#### CHASHOUT: Remove Funds fro, on-chain Wallet #### CHASHOUT: Remove Funds fro, on-chain Wallet
Use if the want to remove all funds from the RaspiBlitz. Use if the want to remove all funds from the RaspiBlitz.
![MainMenu-C](pictures/mainmenu3.png)
#### lnbalance: Detailed Wallet Balances #### lnbalance: Detailed Wallet Balances
<img src="pictures/bonus-lnbalance.png" alt="bonus-lnbalance" width="600"> <img src="pictures/bonus-lnbalance.png" alt="bonus-lnbalance" width="600">
@ -501,13 +541,35 @@ Use if the want to remove all funds from the RaspiBlitz.
<img src="pictures/bonus-lnchannels.png" alt="bonus-lnchannels" width="600"> <img src="pictures/bonus-lnchannels.png" alt="bonus-lnchannels" width="600">
#### CLOSE ALL: Closing all open Channels
With this feature you can close down all open channels and get funds locked up in those channels back to your on-chain wallet.
It mioght even offer you to force close some channels where the channel-partner is no longer reachable. Keep in mind that those force closings can take a much longer time until your funds are available again on your on-chain wallet.
#### HARDWARE: Run Hardware Test
This will start the hardware test and indentify if your RaspiBlitz is in good shape and can provide a stable service.
Use this option is you see under-voltage reports on your LCD display or you think your RaspiBlitz gets very hot.
#### SOFTWARE: Run Software Tests (DebugReport)
This will print out a lot of information that can be used to find software problems.
Use this if you want to report a software problem with your RaspiBlitz so that others can have a look at the details and help you better.
#### UPDATE: Check/Prepare RaspiBlitz Update
You can test if a update for RaspiBlitz is available. If so you can follow the instructions to make the update.
#### OFF: PowerOff RaspiBlitz #### OFF: PowerOff RaspiBlitz
A safe way to shutdown the RaspiBlitz. If then a reboot/restart is needed - un/replug the power. A safe way to shutdown the RaspiBlitz. If then a reboot/restart is needed - un/replug the power.
#### X: Console Terminal #### X: Console Terminal
Closes the SSH main menu and exits to the terminal - where the user can make use of the CLI clients `bitcoin-cli` & `lncli` directly to make use of the Bitcoin- and Lightningnode. Closes the SSH main menu and exits to the terminal - where the user can make use of the CLI clients `bitcoin-cli` & `lncli` directly to make use of the Bitcoin- and Lightningnode.
With the command `raspiblitz` it's possible to return to the main menu. With the command `raspiblitz` it's possible to return to the main menu.
@ -528,11 +590,65 @@ To develop your own scripts/apps and to connect other servcies/apps to your Rasp
* `gRPC` running on port 10009 (public) [DOC](https://api.lightning.community/) * `gRPC` running on port 10009 (public) [DOC](https://api.lightning.community/)
* `REST` running on port 8080 (public) [DOC](https://api.lightning.community/rest/index.html) * `REST` running on port 8080 (public) [DOC](https://api.lightning.community/rest/index.html)
## Updating to new Version ### Backup for On-Chain- & Channel-Funds
Since LND v.06 (and RaspiBlitz v1.2) a feature called Static-Channel-Backups is available. Within RaspiBlitz this is used when a `channel.backup` file is mentioned.
Its the best backup to protect the funds you put on your RaspiBlitz and into channel available yet - so its recommended to make use of it.
To recover your funds you need two things:
- the 24 words seed
- the latest `channel.backup` file
The word seed you got during wallet setup, to write it down and to keep it at a safe (offline) location. The `channel.backup` is stored on the HDD and updated by LND everytime a new channel is opened or closed. The lastest version of this file is needed to recover all your funds (if possible). In case your HDD gets damaged, RaspiBlitz always keeps a copy of the latest version of the `channel.backup` file on the SD card within the subdirectories of: `/home/admin/.lnd/data/chain/`.
If you want to get one step further in securing your funds against total fall-out of the RaspiBlitz (gets completly damaged, stolen or lost) then you can additional setup an off-loctaion or cloud backup of the `channel.backup` file. The file itself is encrypted by your word seed - so its OK to store the file to untrusted third parties for backup (if you want). The feature is still new ... here is how you can set it up -a t the moment the following two off-loctaion options are available (and/or):
*For the v1.2 Release this Off-Site Backup options you need to manually editing the raspiblitz config: `nano mnt/hdd/raspiblitz.conf` (CTRL+o = save & CTRL+x = exit) So this is more for expert users at the moment. If this feature is valided as OK by expert users - in the following versions it should be more easy to set these Offsite-Backups by menu. Open to more Off-Site Backup options by PR in the future - but they should work without adding more dependencies on other libaries (that are not part of standard debian).*
#### A) SCP Backup Target
In the `/mnt/hdd/raspiblitz.conf` the parameter `scpBackupTarget='[USER]@[SERVER]:[DIRPATH-WITHOUT-ENDING-/]'` can be set to activate this feature. On that remote server the publickey of the RaspiBlitz root user needs to be part of the authorized keys - so that no password is needed for the background script to make the backup.
The script `/home/admin/config.scripts/internet.sshpubkey.sh` helps on init, show and transfer ssh-pubkey to a remote server.
If you have a RaspiBlitz older then verison 0.98 please [see here](FAQ.md). To test it - open or close a channel and check if you find a copy of `channel.backup` on your remote server. You can check the background-script logs to see details on errors: `sudo journalctl -f -u background`
If you have a RaspiBlitz version 0.98 or newer do the following: #### B) DropBox Backup Target
In the `/mnt/hdd/raspiblitz.conf` the parameter `dropboxBackupTarget='YOUR-DROPBOX-AUTHTOKEN'` can be set to your personal a Dropbox-Authtoken.
Go get your Dropbox-Authtoken, go to your web browser, do the following:
1. Go to https://www.dropbox.com/developers/apps/create and sign in
1. Choose **Dropbox Api**
![Dropbox API 1](https://raw.githubusercontent.com/vindard/lnd-backup/master/images/dropbox-1.png)
1. Choose **App Folder**
![Dropbox API 2](https://raw.githubusercontent.com/vindard/lnd-backup/master/images/dropbox-2.png)
1. Name your app and click **Create App** to proceed
![Dropbox API 3](https://raw.githubusercontent.com/vindard/lnd-backup/master/images/dropbox-3.png)
1. On the settings page for your new app, scroll down to **OAuth 2** and click **Generate**
![Dropbox API 4](https://raw.githubusercontent.com/vindard/lnd-backup/master/images/dropbox-4.png)
1. You will now see a string of letters and numbers appear. This is your **Dropbox-Authtoken**.
To test it - open or close a channel and check if you find a copy of `channel.backup` in your dropbox. You can check the background-script logs to see details on errors: `sudo journalctl -f -u background`
## Updating RaspiBlitz to new Version
If you have a RaspiBlitz v1.2 or higher - just follow the `UPDATE Check/Prepare RaspiBlitz Update` option from the main menu.
If you have a RaspiBlitz older then verison v1.0 please [see here](FAQ.md).
If you have a RaspiBlitz v1.0 or v1.1 or newer do the following:
* Main menu > OFF * Main menu > OFF
* Remove power * Remove power
@ -551,7 +667,7 @@ If done successfully, simply put the SD card into the RaspiBlitz and power on ag
A ready to use SD card image of the RaspiBlitz for your RaspberryPi is provided as download by us to get everybody started quickly (see above). But if you want to build that image yourself - here is a quick guide: A ready to use SD card image of the RaspiBlitz for your RaspberryPi is provided as download by us to get everybody started quickly (see above). But if you want to build that image yourself - here is a quick guide:
* Get a fresh Rasbian RASPBIAN STRETCH WITH DESKTOP card image: [DOWNLOAD](https://www.raspberrypi.org/downloads/raspbian/) * Get a fresh Rasbian RASPBIAN STRETCH WITH DESKTOP card image: [DOWNLOAD](https://www.raspberrypi.org/downloads/raspbian/)
* Write image to a SD card: [TUTORIAL](https://www.raspberrypi.org/documentation/installation/installing-images/README.md) * Write image to a SD card: [TUTORIAL](https://www.raspberrypi.org/documentation/installation/installing-images/README.md)
* Add a file called `ssh` to the root of the SD card when mounted to enable SSH login * Add a file called `ssh` to the root of the SD card when mounted to enable SSH login
* Start card in Raspi and login per SSH with `ssh pi@[IP-OF-YOUR-RASPI]` password is `raspberry` * Start card in Raspi and login per SSH with `ssh pi@[IP-OF-YOUR-RASPI]` password is `raspberry`
@ -561,7 +677,7 @@ Now you are ready to start the SD card build script - copy the following command
As you can see from the URL you find the build script in this Git repo under `build_sdcard.sh` - there 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 find the build script in this Git repo under `build_sdcard.sh` - there 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]`. An installer of the SD card image should automatically launch. 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 RaspiBlitze, 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]`. An installer of the SD card image should automatically launch. 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 RaspiBlitze, 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.
*Note: If you plan to use your self build sd card as a MASTER copy to backup image and distribute it. Use a smaller 8GB card for that. This way its 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 to backup image and distribute it. Use a smaller 8GB card for that. This way its ensured that it will fit on every 16 GB card recommended for RaspiBlitz later on.*
@ -584,10 +700,8 @@ You have still more questions? Check the [RaspiBlitz-FAQ-Archive](FAQ.md).
Everybody is welcome to join, improve and extend the RaspiBlitz - its a work in progress. [Check the issues](https://github.com/rootzoll/raspiblitz/issues) if you wanna help out or add new ideas. You find the scripts used for RaspiBlitz interactions on the device at `/home/admin` or in this git repo in the subfolder `home.admin`. Everybody is welcome to join, improve and extend the RaspiBlitz - its a work in progress. [Check the issues](https://github.com/rootzoll/raspiblitz/issues) if you wanna help out or add new ideas. You find the scripts used for RaspiBlitz interactions on the device at `/home/admin` or in this git repo in the subfolder `home.admin`.
Also get inspired for a deep-dive with the original "[RaspiBolt](https://github.com/Stadicus/guides/tree/master/raspibolt)" tutorial on how to build a lightning node on the RaspberryPi which was the base work the RaspiBlitz was developed on - so much thx to Stadicus :) Also get inspired for a deep-dive with the original "[RaspiBolt](https://stadicus.github.io/RaspiBolt/)" tutorial on how to build a lightning node on the RaspberryPi which was the base work the RaspiBlitz was developed on - so much thx to Stadicus :)
Join me on twitter [@rootzoll](https://twitter.com/rootzoll), visit us at a upcomming [#lightninghackday](https://twitter.com/hashtag/LightningHackday?src=hash) or check by on of our bitcoin meetups in Berlin ... every 1st Thursday evening a month at the room77 bar - feel free to buy me a beer with lightning there :) Join me on twitter [@rootzoll](https://twitter.com/rootzoll), visit us at a upcomming [#lightninghackday](https://twitter.com/hashtag/LightningHackday?src=hash) or check by on of our bitcoin meetups in Berlin ... every 1st Thursday evening a month at the room77 bar - feel free to buy me a beer with lightning there :)
* [How can I get further help/support?](#support) * [How can I get further help/support?](#support)
IRC channel on Freenode `irc://irc.freenode.net/raspiblitz` (unmoderated)

3
WORKSHOP.md

@ -108,6 +108,9 @@ Check how much time is left to go thru the next steps of connecting to peers, fu
Its also nice to add casual social open-end segment to the end of the workshop. So people can already go into personal conversations, music and beverages while some last nodes sync up, confirmations come in and people sending their first satoshis on some lightning chess or from node to node. Its also nice to add casual social open-end segment to the end of the workshop. So people can already go into personal conversations, music and beverages while some last nodes sync up, confirmations come in and people sending their first satoshis on some lightning chess or from node to node.
Here are some videos that show what else is possible with the RaspiBlitz:
- [Lightning Network LND API - Buying Stickers using Commandline](https://youtu.be/tocJFPU8sAc) 24min
# Organisation Tasks # Organisation Tasks
*Which of the follwoing organisation tasks are relevant for you depends on which starting scenario you choose (see above). Here is the complete possible list with details:* *Which of the follwoing organisation tasks are relevant for you depends on which starting scenario you choose (see above). Here is the complete possible list with details:*

93
alternative.platforms/README.md

@ -0,0 +1,93 @@
# ⚡️ Alternative platforms for the RaspiBlitz ⚡️
Minimum requirements:
* ARM V7 or V8 processor architecture (32 or 64 bit)
* 1 GB RAM
* \> 300 GB HDD
Desirable:
* \> 2GB DDR3 RAM
* USB 3.0 or SATA connector
* SSD
* Compact case with efficient cooling (heatsink / fan)
* HDMI / GPIO screen
Specifications of the tested hardware: [hw_comparison.md](hw_comparison.md)
All testers are welcome. Open an issue for your specific board to collaborate and share your experience.
---
## Armbian
Many SBC-s are supported:
https://www.armbian.com/download/
Tested on:
* Odroid XU4 with the Armbian Stretch image from https://www.armbian.com/odroid-xu4/
Burn the image to the SDCard with [Etcher](https://www.balena.io/etcher/).
Assemble and boot.
`ssh root@192.168.1.122`
password: 1234
Follow the instructions in the terminal.
Continue with building the SDcard: https://github.com/rootzoll/raspiblitz#build-the-sd-card-image
---
## Ubuntu
A common distro to be supplied by the manufacturer for various boards.
Tested on:
* Odroid XU4 with ubuntu-18.04.1-4.14-minimal image from https://de.eu.odroid.in/ubuntu_18.04lts/XU3_XU4_MC1_HC1_HC2
Burn the image to the SDCard with [Etcher](https://www.balena.io/etcher/).
Assemble and boot.
`ssh root@192.168.1.122`
password: odroid
`apt-get update`
`apt-get upgrade`
if there is an error:
>E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
>E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
run:
`reboot` and update as above
Continue with building the SDcard: https://github.com/rootzoll/raspiblitz#build-the-sd-card-image
---
## DietPi
Many SBC-s are supported:
https://dietpi.com/#download
Tested on:
* Odroid HC1
* Odroid HC2 (the same board with a 3.5" 12V HDD)
* Odroid XU4 (with HDMI screen)
* Raspberry Pi 3 B+ (with the default GPIO or HDMI display)
The HDMI screen tested: https://www.aliexpress.com/item/3-5-inch-LCD-HDMI-USB-Touch-Screen-Real-HD-1920x1080-LCD-Display-Py-for-Raspberri/32818537950.html
Detailed instructions for the RaspiBlitz-on-DietPi: [/dietpi/README.md](/dietpi/README.md)
---
Extras for advanced users and powerful hardware:
https://github.com/openoms/bitcoin-tutorials/

60
dietpi/hw_comparison.md → alternative.platforms/hw_comparison.md

@ -1,30 +1,8 @@
### ODROID-HC1 ## SBC benchmarks:
Key features https://github.com/ThomasKaiser/sbc-bench/blob/master/Results.md
* Samsung Exynos5422 Cortex-A15 2Ghz and Cortex-A7 Octa core CPUs
* 2Gbyte LPDDR3 RAM PoP stacked
* SATA-3 port for 2.5inch HDD/SSD storage up to 15mm thickness
* Gigabit Ethernet port
* USB 2.0 Host
* UHS-1 capable micro-SD card slot for boot media
* Size : 147 x 85 x 29 mm approx.(including Aluminium cooling frame)
* Linux server OS images based on modern Kernel 4.14 LTS
### ROCK64 4K60P HDR Single Board Computer https://dietpi.com/survey/#benchmark
ROCK64 is a credit card size 4K60P HDR Single Board Computer powered by
* Rockchip RK3328 Quad-Core ARM Cortex A53 64-Bit Processor and support up to
* 4GB 1600MHz LPDDR3 memory. It provides
* eMMC module socket,
* MicroSD Card slot,
* Pi-2 Bus,
* Pi-P5+ Bus, U
* SB 3.0 and many others peripheral devices interface for makers to integrate with sensors and devices. Various Operating System (OS) are made available by open source community such
* Android 7.1,
* Debian,
* BSD and many more to come.
The ROCK64 4GB board designated as LTS (long Term Supply) model, PINE64 committed to supply at least for 5 years until year 2022 and beyond.
### Raspberry Pi 3 Model B+ ### Raspberry Pi 3 Model B+
@ -41,3 +19,35 @@ The ROCK64 4GB board designated as LTS (long Term Supply) model, PINE64 committe
* Micro SD port for loading your operating system and storing data * Micro SD port for loading your operating system and storing data
* 5V/2.5A DC power input * 5V/2.5A DC power input
* Power-over-Ethernet (PoE) support (requires separate PoE HAT) * Power-over-Ethernet (PoE) support (requires separate PoE HAT)
### Odroid HC1
* Samsung Exynos5422 Octa core CPU 4x Cortex-A15 2Ghz and 4x Cortex-A7 1.5GHz
* 2 Gbyte LPDDR3 RAM
* SATA-3 port for 2.5inch HDD/SSD storage up to 15mm thickness
* Gigabit Ethernet port
* USB 2.0 Host
* UHS-1 capable micro-SD card slot for boot media
* Size : 147 x 85 x 29 mm approx.(including Aluminium cooling frame)
* Linux server OS images based on modern Kernel 4.14 LTS
### Odroid XU4
* Samsung Exynos5422 Octa core CPU 4x Cortex-A15 2Ghz and 4x Cortex-A7 1.5GHz
* 2 Gbyte LPDDR3 RAM
* Graphics: Samsung S2MPS11
* Storage: eMMC5.0 HS400 Flash Storage or SD Card
* I/O Connectors: HDMI-A x 1, USB 3.0 Host x 2, USB 2.0 Host x 1, PWM for * Cooler Fan, UART for serial console 30Pin : GPIO/IRQ/SPI/ADC, 12Pin : GPIO/I2S/I2C
* Network Ethernet RJ-45
* Input Power 5V
### Rock64
ROCK64 is a credit card size 4K60P HDR Single Board Computer powered by
* Rockchip RK3328 Quad-Core ARM Cortex A53 64-Bit CPU
* 1 - 4GB 1600MHz LPDDR3 RAM
* eMMC module socket
* MicroSD Card slot
* Pi-2 Bus
* Pi-P5+ Bus

289
build_sdcard.sh

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
######################################################################### #########################################################################
# Build your SD card image based on: # Build your SD card image based on:
# RASPBIAN STRETCH WITH DESKTOP (2018-11-13) # RASPBIAN STRETCH WITH DESKTOP (2019-04-09)
# https://www.raspberrypi.org/downloads/raspbian/ # https://www.raspberrypi.org/downloads/raspbian/
# SHA256: a121652937ccde1c2583fe77d1caec407f2cd248327df2901e4716649ac9bc97 # SHA256: 7e10a446f8e57210d0e9ad02f0c833aabb86e58187b4dc02431aff5a3f1ccb83
# #
# or download the image for your ARM based SBC on https://DietPi.com # or download the image for your ARM based SBC on https://DietPi.com
########################################################################## ##########################################################################
@ -12,7 +12,7 @@
echo "" echo ""
echo "*****************************************" echo "*****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v1.1 *" echo "* RASPIBLITZ SD CARD IMAGE SETUP v1.2 *"
echo "*****************************************" echo "*****************************************"
echo "" echo ""
@ -43,22 +43,32 @@ echo "*** CHECK BASE IMAGE ***"
# armv7=32Bit , armv8=64Bit # armv7=32Bit , armv8=64Bit
echo "Check if Linux ARM based ..." echo "Check if Linux ARM based ..."
isARM=$(uname -m | grep -c 'arm') isARM=$(uname -m | grep -c 'arm')
if [ ${isARM} -eq 0 ]; then isAARCH64=$(uname -m | grep -c 'aarch64')
if [ ${isARM} -eq 0 ] && [ ${isAARCH64} -eq 0 ] ; then
echo "!!! FAIL !!!" echo "!!! FAIL !!!"
echo "Can just build on ARM Linux, not on:" echo "Can only build on ARM or aarch64, not on:"
uname -m uname -m
exit 1 exit 1
else
echo "OK running on $(uname -m) architecture."
fi fi
echo "OK running on Linux ARM architecture."
# keep in mind that DietPi for Raspberry is also a stripped down Raspbian # keep in mind that DietPi for Raspberry is also a stripped down Raspbian
echo "Detect Base Image ..." echo "Detect Base Image ..."
baseImage="?" baseImage="?"
isDietPi=$(uname -n | grep -c 'DietPi') isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian') isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
isArmbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Debian')
isUbuntu=$(cat /etc/os-release 2>/dev/null | grep -c 'Ubuntu')
if [ ${isRaspbian} -gt 0 ]; then if [ ${isRaspbian} -gt 0 ]; then
baseImage="raspbian" baseImage="raspbian"
fi fi
if [ ${isArmbian} -gt 0 ]; then
baseImage="armbian"
fi
if [ ${isUbuntu} -gt 0 ]; then
baseImage="ubuntu"
fi
if [ ${isDietPi} -gt 0 ]; then if [ ${isDietPi} -gt 0 ]; then
baseImage="dietpi" baseImage="dietpi"
fi fi
@ -73,21 +83,30 @@ fi
# setting static DNS server # setting static DNS server
# see https://github.com/rootzoll/raspiblitz/issues/322#issuecomment-466733550 # see https://github.com/rootzoll/raspiblitz/issues/322#issuecomment-466733550
sudo sed -i "s/^#static domain_name_servers=192.168.0.1*/static domain_name_servers=1.1.1.1/g" /etc/dhcpcd.conf # check /etc/dhcpd.conf and /etc/dhcp/dhcpd.conf
systemctl daemon-reload if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ] ; then
sudo sed -i "s/^#static domain_name_servers=192.168.0.1*/static domain_name_servers=1.1.1.1/g" /etc/dhcpcd.conf
systemctl daemon-reload
fi
if [ "${baseImage}" = "ubuntu" ]; then
sudo sed -i "s/^#static domain_name_servers=192.168.0.1*/static domain_name_servers=1.1.1.1/g" /etc/dhcp/dhcpd.conf
systemctl daemon-reload
fi
# fixing locales for build if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "dietpi" ] ; then
# https://github.com/rootzoll/raspiblitz/issues/138 # fixing locales for build
# https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html # https://github.com/rootzoll/raspiblitz/issues/138
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image # https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html
echo "" # https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
echo "*** FIXING LOCALES FOR BUILD ***" echo ""
sudo sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen echo "*** FIXING LOCALES FOR BUILD ***"
sudo sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen sudo sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sudo locale-gen sudo sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
export LANGUAGE=en_GB.UTF-8 sudo locale-gen
export LANG=en_GB.UTF-8 export LANGUAGE=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8 export LANG=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8
fi
# update debian # update debian
echo "" echo ""
@ -95,37 +114,17 @@ echo "*** UPDATE DEBIAN ***"
sudo apt-get update sudo apt-get update
sudo apt-get upgrade -f -y --allow-change-held-packages sudo apt-get upgrade -f -y --allow-change-held-packages
echo ""
echo "*** PREPARE ${baseImage} ***"
# special prepare when DietPi # special prepare when DietPi
if [ "${baseImage}" = "dietpi" ]; then if [ "${baseImage}" = "dietpi" ]; then
echo ""
echo "*** PREPARE DietPi ***"
echo "renaming dietpi user to pi" echo "renaming dietpi user to pi"
sudo usermod -l pi dietpi sudo usermod -l pi dietpi
echo "install pip"
sudo apt-get update
sudo apt-get remove -y fail2ban
sudo apt-get install -y build-essential
sudo apt-get install -y python-pip
# rsync is needed to copy from HDD
sudo apt install -y rsync
# install ifconfig
sudo apt install -y net-tools
#to display hex codes
sudo apt install -y xxd
# setuptools needed for Nyx
sudo pip install setuptools
# netcat for 00infoBlitz.sh
sudo apt install -y netcat
# install OpenSSH client + server
sudo apt install -y openssh-client
sudo apt install -y openssh-sftp-server
fi fi
# special prepare when Raspbian # special prepare when Raspbian
if [ "${baseImage}" = "raspbian" ]; then if [ "${baseImage}" = "raspbian" ]; then
echo ""
echo "*** PREPARE Raspbian ***"
# do memory split (16MB) # do memory split (16MB)
sudo raspi-config nonint do_memory_split 16 sudo raspi-config nonint do_memory_split 16
# set to wait until network is available on boot (0 seems to yes) # set to wait until network is available on boot (0 seems to yes)
@ -140,6 +139,13 @@ if [ "${baseImage}" = "raspbian" ]; then
sudo apt-get -y autoremove sudo apt-get -y autoremove
fi fi
# special prepare when Ubuntu or Armbian
if [ "${baseImage}" = "ubuntu" ] || [ "${baseImage}" = "armbian" ]; then
# make user pi and add to sudo
sudo adduser --disabled-password --gecos "" pi
sudo adduser pi sudo
fi
echo "" echo ""
echo "*** CONFIG ***" echo "*** CONFIG ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config # based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config
@ -148,12 +154,27 @@ echo "*** CONFIG ***"
echo "root:raspiblitz" | sudo chpasswd echo "root:raspiblitz" | sudo chpasswd
echo "pi:raspiblitz" | sudo chpasswd echo "pi:raspiblitz" | sudo chpasswd
# set Raspi to boot up automatically with user pi (for the LCD) if [ "${baseImage}" = "raspbian" ]; then
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632 # set Raspi to boot up automatically with user pi (for the LCD)
sudo raspi-config nonint do_boot_behaviour B2 # https://www.raspberrypi.org/forums/viewtopic.php?t=21632
sudo bash -c "echo '[Service]' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" sudo raspi-config nonint do_boot_behaviour B2
sudo bash -c "echo 'ExecStart=' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" sudo bash -c "echo '[Service]' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf" sudo bash -c "echo 'ExecStart=' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /etc/systemd/system/getty@tty1.service.d/autologin.conf"
fi
if [ "${baseImage}" = "dietpi" ]; then
# set DietPi to boot up automatically with user pi (for the LCD)
# requires AUTO_SETUP_AUTOSTART_TARGET_INDEX=7 in the dietpi.txt
# /DietPi/dietpi/dietpi-autostart overwrites /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf on reboot
sudo sed -i 's/agetty --autologin root %I $TERM/agetty --autologin pi --noclear %I 38400 linux/' /DietPi/dietpi/dietpi-autostart
fi
if [ "${baseImage}" = "ubuntu" ] || [ "${baseImage}" = "armbian" ]; then
sudo bash -c "echo '[Service]' >> /lib/systemd/system/getty@.service"
sudo bash -c "echo 'ExecStart=' >> /lib/systemd/system/getty@.service"
sudo bash -c "echo 'ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux' >> /lib/systemd/system/getty@.service"
fi
# change log rotates # change log rotates
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483 # see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
@ -237,15 +258,42 @@ sudo apt-get install -y vnstat
# prepare for BTRFS data drive raid # prepare for BTRFS data drive raid
sudo apt-get install -y btrfs-tools sudo apt-get install -y btrfs-tools
# prepare for ssh reverse tunneling
sudo apt-get install -y autossh
# prepare for display graphics mode # prepare for display graphics mode
# see https://github.com/rootzoll/raspiblitz/pull/334 # see https://github.com/rootzoll/raspiblitz/pull/334
sudo apt-get install -y fbi sudo apt-get install -y fbi
# prepare for powertest
sudo apt install -y sysbench
# prepare dor display service # prepare dor display service
# see https://github.com/rootzoll/raspiblitz/issues/88#issuecomment-471342311 # see https://github.com/rootzoll/raspiblitz/issues/88#issuecomment-471342311
sudo apt-get install -y redis-server sudo apt-get install -y redis-server
sudo -H pip3 install redis sudo -H pip3 install redis
# check for dependencies on DietPi, Ubuntu, Armbian
sudo apt-get install -y build-essential
sudo apt-get install -y python-pip
# rsync is needed to copy from HDD
sudo apt install -y rsync
# install ifconfig
sudo apt install -y net-tools
#to display hex codes
sudo apt install -y xxd
# setuptools needed for Nyx
sudo pip install setuptools
# netcat for 00infoBlitz.sh
sudo apt install -y netcat
# install OpenSSH client + server
sudo apt install -y openssh-client
sudo apt install -y openssh-sftp-server
# install killall, fuser
sudo apt-get install -y psmisc
sudo apt-get clean
sudo apt-get -y autoremove
echo "" echo ""
echo "*** ADDING MAIN USER admin ***" echo "*** ADDING MAIN USER admin ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin # based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin
@ -259,6 +307,7 @@ sudo chsh admin -s /bin/bash
# configure sudo for usage without password entry # configure sudo for usage without password entry
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
echo ""
echo "*** ADDING SERVICE USER bitcoin" echo "*** ADDING SERVICE USER bitcoin"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin # based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
@ -294,21 +343,30 @@ echo "*** BITCOIN ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md#installation # based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md#installation
# set version (change if update is available) # set version (change if update is available)
bitcoinVersion="0.17.0.1" bitcoinVersion="0.17.1"
# needed to make sure download is not changed # set OS version
# calulate with sha256sum and also check with SHA256SUMS.asc if [ ${isARM} -eq 1 ] ; then
bitcoinSHA256="1b9cdf29a9eada239e26bf4471c432389c2f2784362fc8ef0267ba7f48602292" bitcoinOSversion="arm-linux-gnueabihf"
# needed to make sure download is not changed
# calulate with sha256sum and also check with SHA256SUMS.asc
bitcoinSHA256="aab3c1fb92e47734fadded1d3f9ccf0ac5a59e3cdc28c43a52fcab9f0cb395bc"
fi
if [ ${isAARCH64} -eq 1 ] ; then
bitcoinOSversion="aarch64-linux-gnu"
bitcoinSHA256="5659c436ca92eed8ef42d5b2d162ff6283feba220748f9a373a5a53968975e34"
fi
# needed to check code signing # needed to check code signing
laanwjPGP="01EA5486DE18A882D4C2684590C8019E36C2E964" laanwjPGP="01EA5486DE18A882D4C2684590C8019E36C2E964"
# prepare directories # prepare directories
sudo rm -r /home/admin/download
sudo -u admin mkdir /home/admin/download sudo -u admin mkdir /home/admin/download
cd /home/admin/download cd /home/admin/download
# download resources # download resources
binaryName="bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz" binaryName="bitcoin-${bitcoinVersion}-${bitcoinOSversion}.tar.gz"
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/${binaryName} sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/${binaryName}
if [ ! -f "./${binaryName}" ] if [ ! -f "./${binaryName}" ]
then then
@ -323,7 +381,6 @@ if [ "${binaryChecksum}" != "${bitcoinSHA256}" ]; then
exit 1 exit 1
fi fi
# check gpg finger print # check gpg finger print
sudo -u admin wget https://bitcoin.org/laanwj-releases.asc sudo -u admin wget https://bitcoin.org/laanwj-releases.asc
if [ ! -f "./laanwj-releases.asc" ] if [ ! -f "./laanwj-releases.asc" ]
@ -354,9 +411,10 @@ if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
fi fi
# correct versions for install if needed # correct versions for install if needed
# just if an small update shows a different formatted version number
if [ "${bitcoinVersion}" = "0.17.0.1" ]; then if [ "${bitcoinVersion}" = "0.17.0.1" ]; then
bitcoinVersion="0.17.0" bitcoinVersion="0.17.0"
fi fi
# install # install
sudo -u admin tar -xvf ${binaryName} sudo -u admin tar -xvf ${binaryName}
@ -403,17 +461,32 @@ echo ""
echo "*** LND ***" echo "*** LND ***"
## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd ## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd
lndVersion="0.5.2-beta" ## see LND releases: https://github.com/lightningnetwork/lnd/releases
lndSHA256="9adf9f3d0b8a62942f68d75ffe043f9255319209f751dee4eac82375ec0a86cd" lndVersion="0.6-beta"
olaoluwaPGP="BD599672C804AF2770869A048B80CD2BB8BD8132"
if [ ${isARM} -eq 1 ] ; then
lndOSversion="armv7"
lndSHA256="effea372c207293fd42b0cc27800da3a70c22f8c9a0e7b5eb8dbe56b5b98e1a3"
fi
if [ ${isAARCH64} -eq 1 ] ; then
lndOSversion="arm64"
lndSHA256="2f31b13a4da6217ed7e27a44e1705103d7ed846aa2f599b7e5de0e6033a66c19"
fi
# olaoluwa
PGPpkeys="https://keybase.io/roasbeef/pgp_keys.asc"
PGPcheck="BD599672C804AF2770869A048B80CD2BB8BD8132"
# bitconner
#PGPpkeys="https://keybase.io/bitconner/pgp_keys.asc"
#PGPcheck="9C8D61868A7C492003B2744EE7D737B67FA592C7"
# get LND resources # get LND resources
cd /home/admin/download cd /home/admin/download
binaryName="lnd-linux-armv7-v${lndVersion}.tar.gz" binaryName="lnd-linux-${lndOSversion}-v${lndVersion}.tar.gz"
sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/${binaryName} sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/${binaryName}
sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt
sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt.sig sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/manifest-v${lndVersion}.txt.sig
sudo -u admin wget https://keybase.io/roasbeef/pgp_keys.asc sudo -u admin wget -O /home/admin/download/pgp_keys.asc ${PGPpkeys}
# check binary is was not manipulated (checksum test) # check binary is was not manipulated (checksum test)
binaryChecksum=$(sha256sum ${binaryName} | cut -d " " -f1) binaryChecksum=$(sha256sum ${binaryName} | cut -d " " -f1)
@ -424,11 +497,11 @@ fi
# check gpg finger print # check gpg finger print
gpg ./pgp_keys.asc gpg ./pgp_keys.asc
fingerprint=$(gpg ./pgp_keys.asc 2>/dev/null | grep "${olaoluwaPGP}" -c) fingerprint=$(sudo gpg /home/admin/download/pgp_keys.asc 2>/dev/null | grep "${PGPcheck}" -c)
if [ ${fingerprint} -lt 1 ]; then if [ ${fingerprint} -lt 1 ]; then
echo "" echo ""
echo "!!! BUILD WARNING --> Bitcoin PGP author not as expected" echo "!!! BUILD WARNING --> LND PGP author not as expected"
echo "Should contain olaoluwaPGP: ${olaoluwaPGP}" echo "Should contain PGP: ${PGPcheck}"
echo "PRESS ENTER to TAKE THE RISK if you think all is OK" echo "PRESS ENTER to TAKE THE RISK if you think all is OK"
read key read key
fi fi
@ -447,7 +520,7 @@ fi
# install # install
sudo -u admin tar -xzf ${binaryName} sudo -u admin tar -xzf ${binaryName}
sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-armv7-v${lndVersion}/* sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-${lndOSversion}-v${lndVersion}/*
sleep 3 sleep 3
installed=$(sudo -u admin lnd --version) installed=$(sudo -u admin lnd --version)
if [ ${#installed} -eq 0 ]; then if [ ${#installed} -eq 0 ]; then
@ -456,6 +529,18 @@ if [ ${#installed} -eq 0 ]; then
exit 1 exit 1
fi fi
# prepare python for lnd api use
# https://dev.lightning.community/guides/python-grpc/
#
echo ""
echo "*** LND API for Python ***"
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
echo "to switch between python2/3: sudo update-alternatives --config python"
sudo apt-get -f -y install virtualenv
sudo -u admin bash -c "cd; virtualenv python-env-lnd; source /home/admin/python-env-lnd/bin/activate; pip install grpcio grpcio-tools googleapis-common-protos pathlib2"
echo ""
# Go is needed for ZAP connect later # Go is needed for ZAP connect later
echo "*** Installing Go ***" echo "*** Installing Go ***"
wget https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz wget https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz
@ -531,6 +616,7 @@ sudo apt-get -y install exfat-fuse
# for blockchain torrent download # for blockchain torrent download
sudo apt-get -y install transmission-cli sudo apt-get -y install transmission-cli
sudo apt-get -y install rtorrent sudo apt-get -y install rtorrent
sudo apt-get -y install cpulimit
# for background downloading # for background downloading
sudo apt-get -y install screen sudo apt-get -y install screen
@ -564,24 +650,35 @@ sudo bash -c "echo 'PATH=\$PATH:\$GOPATH/bin' >> /home/admin/.profile"
sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc" sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc"
sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc" sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc"
sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc" sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc"
sudo bash -c "echo './00mainMenu.sh' >> /home/admin/.bashrc" sudo bash -c "echo './00raspiblitz.sh' >> /home/admin/.bashrc"
# bash autostart for pi if [ "${baseImage}" = "raspbian" ] || [ "${baseImage}" = "armbian" ] || [ "${baseImage}" = "ubuntu" ]; then
# run as exec to dont allow easy physical access by keyboard # bash autostart for pi
# see https://github.com/rootzoll/raspiblitz/issues/54 # run as exec to dont allow easy physical access by keyboard
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc' # see https://github.com/rootzoll/raspiblitz/issues/54
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc' sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc' sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc' sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc'
# create /home/admin/setup.sh - which will get executed after reboot by autologin pi user fi
cat > /home/admin/setup.sh <<EOF if [ "${baseImage}" = "raspbian" ]; then
# create /home/admin/setup.sh - which will get executed after reboot by autologin pi user
cat > /home/admin/setup.sh <<EOF
# make LCD screen rotation correct # make LCD screen rotation correct
sudo sed --in-place -i "57s/.*/dtoverlay=tft35a:rotate=270/" /boot/config.txt sudo sed --in-place -i "57s/.*/dtoverlay=tft35a:rotate=270/" /boot/config.txt
EOF EOF
sudo chmod +x /home/admin/setup.sh sudo chmod +x /home/admin/setup.sh
fi
if [ "${baseImage}" = "dietpi" ]; then
# bash autostart for dietpi
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/dietpi/.bashrc'
fi
echo "" echo ""
echo "*** HARDENING ***" echo "*** HARDENING ***"
@ -630,9 +727,35 @@ 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 "login once after reboot without HDD and run 'XXprepareRelease.sh'" echo "login once after reboot without HDD and run 'XXprepareRelease.sh'"
echo "" echo ""
echo "to continue reboot with sudo shutdown -r now and login with admin" echo "to continue: reboot with \`sudo shutdown -r now\` and login with user:admin password:raspiblitz"
echo ""
# install default LCD on DietPi without reboot to allow automatic build
if [ "${baseImage}" = "dietpi" ]; then
echo "Installing the default display available from Amazon"
# based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip
cd /home/admin/
# sudo apt-mark hold raspberrypi-bootloader
git clone https://github.com/goodtft/LCD-show.git
sudo chmod -R 755 LCD-show
sudo chown -R admin:admin LCD-show
cd LCD-show/
# sudo ./LCD35-show
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
sudo mkdir /etc/X11/xorg.conf.d
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/tft35a.dtbo
sudo cp -rf ./usr/99-calibration.conf-35 /etc/X11/xorg.conf.d/99-calibration.conf
sudo cp -rf ./usr/99-fbturbo.conf /usr/share/X11/xorg.conf.d/
sudo cp ./usr/cmdline.txt /DietPi/
sudo cp ./usr/inittab /etc/
sudo cp ./boot/config-35.txt /DietPi/config.txt
# make LCD screen rotation correct
sudo sed -i "s/dtoverlay=tft35a/dtoverlay=tft35a:rotate=270/" /DietPi/config.txt
echo "to continue reboot with \`sudo shutdown -r now \` and login with admin"
fi
# install LCD only on an rPI running Raspbian # ask about LCD only on Raspbian
if [ "${baseImage}" = "raspbian" ]; then if [ "${baseImage}" = "raspbian" ]; then
echo "Press ENTER to install LCD and reboot ..." echo "Press ENTER to install LCD and reboot ..."
read key read key

56
dietpi/Odroid_HC1_HC2.md → dietpi/Odroid_HC1_XU4.md

@ -6,11 +6,11 @@
## There are 3 options provided: ## There are 3 options provided:
* a trusted fully prebuilt SDcard image * a trusted fully prebuilt SDcard image
* building your own SDcard from an updated DietPi image. * Automated building process.
* Build your own SDcard from the image downloaded from [Dietpi.com](dietpi.com#download) * Build your own SDcard from the image downloaded from [Dietpi.com](dietpi.com#download)
--- ---
### Download the fully prebuilt RaspiBlitz-on-DietPi SDcard image ### Download the fully prebuilt RaspiBlitz-on-DietPi SDcard image
* [torrent](https://github.com/openoms/raspiblitz/blob/raspiblitz-dev/dietpi/RaspiBlitz1.0_OdroidHC1_DietPi6.21.1.torrent)
* [mega.nz link](https://mega.nz/#F!EVNAAQiB!ZyLHP2dJMRSVjZOTCQMIYA) * [mega.nz link](https://mega.nz/#F!EVNAAQiB!ZyLHP2dJMRSVjZOTCQMIYA)
sha256sum RaspiBlitz1.0_OdroidHC1_DietPi6.21.1.img: 96ee8700f52a12fb5b13fab3fffcdcf5d364c6dd16c580d969e421cef2cd7cc2 sha256sum RaspiBlitz1.0_OdroidHC1_DietPi6.21.1.img: 96ee8700f52a12fb5b13fab3fffcdcf5d364c6dd16c580d969e421cef2cd7cc2
@ -23,35 +23,63 @@ Steps to run:
- login with `ssh admin@at.your.raspiblitz.ip` - login with `ssh admin@at.your.raspiblitz.ip`
password: `raspiblitz` password: `raspiblitz`
Using this image you can skip the rest of this guide as it is mostly about how this image was built. Using this image you can skip the rest of this page.
The setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation) The setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation)
--- ---
### Download the updated DietPi image ### The automated building process:
1) Download the DietPi image for the Odroid HC1 / HC2 / XU3 / XU4:
https://dietpi.com/downloads/images/DietPi_OdroidXU4-ARMv7-Stretch.7z
2) Burn it to the SD card with [Etcher](https://www.balena.io/etcher/)
3) Right click and download the following two files: [DietPi.txt](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/dietpi.txt), [Automation_Custom_Script.sh](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/Automation_Custom_Script.sh)
4) Copy them to the /boot directory of the DietPi SDcard
[DietPi.txt](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/dietpi.txt): Overwrites the default dietpi.txt. Modified the settings to automate the DietPi setup. (see the details [here](https://github.com/rootzoll/raspiblitz/tree/dev/dietpi#excerpts-from-the-customized-dietpitxt))
For the Odroid HC1 / HC2 / XU3 / XU4 a v6.20.6 DietPi image with fail2ban installed is uploaded [here]( [Automation_Custom_Script.sh](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/Automation_Custom_Script.sh): Runs after DietPi installation is completed. Contains the link to download and run the build_sdcard.sh from the dev branch of @rootzoll.
https://mega.nz/#!AcdVBAbR!O-W3jP5LUgw7lMY8S9XcBWcKX3IhRNAAFmaYzDXIUC0). (Optionally open the file with a text editor and uncomment (remove the `#` from the front of) the line with the branch you want to build the SDcard from.)
sha256sum DietPi_v6.20.6_OdroidXU4-ARMv7-Stretch.img:
1459b91f66b9db98f3437c31231e44497b7b7dcd9146d2cc41a3da653f9a9215
* Burn the image to the SDCard with [Etcher](https://www.balena.io/etcher/) and extend the rootfs partition to the size of your card with a partition manager (disks, Gparted, etc). 5) Assemble and boot the Odroid
* Insert the SDcard into the Odroid. Insert the SDcard, connect the HDD, network cable and power supply to boot.
The automated setup will continue and the Odroid will restart at least twice during the process.
To follow the logs during the automated building process login with `root` and press CTRL+C.
`tail -n1000 -f /tmp/DietPi-Update/dietpi-update.log` - follow the dietpi-update process
`tail -n1000 -f /var/tmp/dietpi/logs/dietpi-automation_custom_script.log` follow the output of the build_sdcard.sh
Starting from a v6.14 DietPi image is causing a bootloop after the first restart. See the issue: https://github.com/MichaIng/DietPi/issues/2495. This will be sorted out once a new image version is uploaded for the Odroids to dietpi.com.
To get past it:
* Log in with root after the first restart (when the loop is ongoing - without any output to the HDMI screen)
* CTRL+C, run `dietpi-update` and update
* `reboot` once finished
* from then the Automation_Custom_Script.sh is carrying on
6) When the setup is finished log in as `admin`:
`ssh admin@[IP-OF-RASPIBLITZ]`
password: `raspiblitz`
* Power up and continue with [running the RaspiBlitz build_sdcard.sh script](#Run-the-RaspiBlitz-build_sdcard.sh-script) The setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation)
--- ---
### Build your own DietPi image: ### Build your own DietPi image:
Watch out this is an ardous process. Watch out this is an ardous process.
Updating from a v6.14 DietPi image is causing a bootloop under some circumstances. Will be sorted once the current, >6.2 version is uploaded for the Odroids. Updating from a v6.14 DietPi image is causing a bootloop after the first restart. See the issue: https://github.com/MichaIng/DietPi/issues/2495.
This will be sorted out once a new image version is uploaded for the Odroids to dietpi.com
* For the Odroid HC1 / HC2 / XU3 / XU4 the start is this image: * For the Odroid HC1 / HC2 / XU3 / XU4 the start is this image:
https://dietpi.com/downloads/images/DietPi_OdroidXU4-ARMv7-Stretch.7z https://dietpi.com/downloads/images/DietPi_OdroidXU4-ARMv7-Stretch.7z
* Burn it to the SD with [Etcher](https://www.balena.io/etcher/) * Burn it to the SD with [Etcher](https://www.balena.io/etcher/)
* Insert the SD card, connect the HDD, the network cable and power supply to boot up the Odroid:
* In the desktop terminal on Linux / MacOS or Putty on Windows: * In the desktop terminal on Linux / MacOS or Putty on Windows:
`ssh root@[IP-OF-DIETPI]` `ssh root@[IP-OF-DIETPI]`
@ -109,8 +137,8 @@ Changing the SSH server will change the SSH keys again. To clear:
`wget https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh [BRANCH] [GITHUB-USERNAME]` `wget https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh [BRANCH] [GITHUB-USERNAME]`
If you are working from a forked repo be aware of that the fork needs to be called `raspiblitz` for the git downloads to work. If you are working from a forked repo be aware of that the fork needs to be called `raspiblitz` for the git downloads to work.
* Run the forked version of @openoms: * Example: run from the dev branch @rootzoll:
`wget https://raw.githubusercontent.com/openoms/raspiblitz/raspiblitz-dev/build_sdcard.sh && sudo bash build_sdcard.sh raspiblitz-dev openoms` `wget https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/build_sdcard.sh && sudo bash build_sdcard.sh dev rootzoll`
This will take a couple minutes depending on your internet ceonnection and the processing power of the SBC. This will take a couple minutes depending on your internet ceonnection and the processing power of the SBC.
* Restart when done and log back in now as `admin`: * Restart when done and log back in now as `admin`:

100
dietpi/README.md

@ -1,21 +1,27 @@
# ⚡️ RaspiBlitz-on-DietPi ⚡️ # ⚡️ RaspiBlitz-on-DietPi ⚡️
# A hardware agnostic platform
This guide was tested on: This guide was tested on:
* Odroid HC1 * Odroid HC1
* Odroid HC2 (the same board except it accommodates a 3.5" 12V HDD) * Odroid HC2 (the same board with a 3.5" 12V HDD)
* Raspberry Pi 3 B Plus - no LCD support so far * Odroid XU4 (with HDMI screen)
* hoping to extend this list with more compatible boards especially the ROCK64 * Raspberry Pi 3 B+ (with the default GPIO or HDMI display)
See the [hardware comparison](/alternative.platforms/hw_comparison.md).
See the [hardware comparison](hw_comparison.md). The HDMI screen tested: https://www.aliexpress.com/item/3-5-inch-LCD-HDMI-USB-Touch-Screen-Real-HD-1920x1080-LCD-Display-Py-for-Raspberri/32818537950.html
--- ---
## Specific instructions and downloads:
[Odroid HC1 / HC2 / XU3 / XU4](Odroid_HC1_HC2.md)
[Raspberry Pi](RaspberryPi.md)
[Display install script](dietpi.display.sh)
### Downloads and walkthrough for the [Odroid HC1 / HC2 / XU3 / XU4](Odroid_HC1_HC2.md)
--- ---
## General guide for the RaspiBlitz-on-DietPi ## General guide for the RaspiBlitz-on-DietPi
### Setting up the DietPi OS ### Setting up the DietPi OS
@ -26,24 +32,23 @@ Getting started with DietPi: https://dietpi.com/phpbb/viewtopic.php?f=8&t=9#p9
At least 1GB RAM is recommended. At least 1GB RAM is recommended.
Look for the SD card image for the specific SBC in the [download section](https://dietpi.com/#download). Look for the SD card image for the specific SBC in the [download section](https://dietpi.com/#download).
* Burn the image to the SDCard with [Etcher](https://www.balena.io/etcher/) and extend the rootfs partition to the size of your card with a partition manager. * Burn the image to the SDCard with [Etcher](https://www.balena.io/etcher/).
* Insert the SDcard into your SBC. * Insert the SDcard into your SBC.
* Connect the HDD with a powered suitably powered adapter. * Connect the HDD with a suitably powered adapter.
A USB 2.0 port will not be able to power an HDD so you will need extra cable Aim to use 2 USB ports or a separate power supply to power the HDD for a more reliable setup.
If you are connecting the HDD to a USB 3.0 port and have an at least 2A power supply, you might be able to run without an extra cable.
* Power up and log in with the desktop terminal on Linux / MacOS or Putty on Windows: * Power up and log in with the desktop terminal on Linux / MacOS or Putty on Windows:
`ssh root@[IP-OF-DIETPI]` `ssh root@[IP-OF-DIETPI]`
password: `dietpi` password: `dietpi`
* If you are asked about updating DietPi, go ahead with it. This is not always a straightforward process, but it is best to build on the latest version.
* You might be asked about updating DietPi. This is not a straightforward process if starting from a version <6.20. Try to update, it is best to build on the latest version.
* In the DietPi software menu install `fail2ban` and make `OpenSSH server` the default SSH server. * In the DietPi software menu install `fail2ban` and make `OpenSSH server` the default SSH server.
Changing the SSH server will change the SSH keys again. To clear: If there is a screen installed: within the Dietpi-Config menu set the Autostart to `7: Automatic login. `
`ssh-keygen -f "/home/[your-linux-username]/.ssh/known_hosts" -R "dietpi.IP"`
Changing the SSH server will change the SSH keys again. To clear:
`ssh-keygen -f "/home/[your-linux-username]/.ssh/known_hosts" -R "dietpi.IP"`
* After every reboot log back in: * After every reboot log back in:
`ssh root@[IP-OF-DIETPI]` `ssh root@[IP-OF-DIETPI]`
@ -59,50 +64,49 @@ password: `dietpi`
`wget https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh [BRANCH] [GITHUB-USERNAME]` `wget https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh [BRANCH] [GITHUB-USERNAME]`
If you are working from a forked repo be aware of that the fork needs to be called `raspiblitz` for the git downloads to work. If you are working from a forked repo be aware of that the fork needs to be called `raspiblitz` for the git downloads to work.
* Run the forked version of @openoms: Example to run the dev branch of @rootzoll:
`wget https://raw.githubusercontent.com/openoms/raspiblitz/raspiblitz-dev/build_sdcard.sh && sudo bash build_sdcard.sh raspiblitz-dev openoms` `wget https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/build_sdcard.sh && sudo bash build_sdcard.sh dev rootzoll`
This will take a couple minutes depending on your internet connection and the processing power of the SBC. This will take a couple minutes depending on your internet connection and the processing power of the SBC.
* Restart when done and log back in now as `admin`: * After the automatic restart log back in now as `admin`:
`ssh admin@[IP-OF-DROIDBLITZ]` `ssh admin@[IP-OF-RASPIBLITZ]`
password: `raspiblitz` password: `raspiblitz`
* From here he setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation) * From here he setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation)
--- ---
### Useful commands for debugging: ### Useful commands for debugging:
To test a new configuration run XXcleanHDD.sh and strictly restart During the Automated setup:
(this makes _bootstrap.sh and 00mainMenu.sh run in the right order) `tail -n1000 -f /tmp/DietPi-Update/dietpi-update.log` - follow the dietpi-update process
`tail -n1000 -f /var/tmp/dietpi/logs/dietpi-automation_custom_script.log` follow the output of the build_sdcard.sh
`tail -n1000 -f /var/tmp/dietpi/logs/dietpi-automation_custom_script.log` follow startup setup script log During the RaspiBlitz setup process:
`lsblk` see the partitions `lsblk` check the disk partitions
`tail -n1000 -f raspiblitz.log` - debug logs of bootstrap.sh `tail -n1000 -f raspiblitz.log` - debug logs of bootstrap.sh
`sudo tail -f /mnt/hdd/bitcoin/debug.log` - continuous monitoring `sudo tail -f /mnt/hdd/bitcoin/debug.log` - continuous monitoring of bitcoind
`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` `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 `./home/admin/XXdebugLogs.sh` - debug log collection on the RaspiBlitz
--- ---
## Excerpts from the [customized dietpi.txt](/dietpi/boot/dietpi.txt)
## Excerpts from the default [dietpi.txt](https://github.com/Fourdee/DietPi/blob/master/dietpi.txt)
to be used for a fully automatic SDcard building process. to be used for a fully automatic SDcard building process.
### Automate installation with the dietpi.txt ### Automate installation with the dietpi.txt
Need to copy to SDcard /boot/dietpi.txt after burning the image with Etcher. Need to copy to SDcard /boot/dietpi.txt after burning the image with Etcher.
IMPORTANT: IMPORTANT:
- Modifications to /boot/dietpi.txt will not be preserved on reboot. - Modifications to /boot/dietpi.txt will not be preserved on reboot .
- Please ensure you edit from the DietPi-RAMdisk location: /DietPi/dietpi.txt - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/dietpi.txt
NB: This is intended for advanced users, unless you know what you are doing, do not edit this file. ease use the DietPi programs instead.
NB: This is intended for advanced users, unless you know what you are doing, do not edit this file. ease use the DietPi programs instead.
NB: Do not remove uncommented lines, as the items are scraped by DietPi programs, on demand. NB: Do not remove uncommented lines, as the items are scraped by DietPi programs, on demand.
DietPi-Automation settings, applied on the 1st boot of DietPi, ONCE DietPi-Automation settings, applied on the 1st boot of DietPi, ONCE
Sample: Sample:
https://github.com/Fourdee/DietPi/blob/master/dietpi.txt https://github.com/Fourdee/DietPi/blob/master/dietpi.txt
### DietPi-Software to automatically install. #### DietPi-Software to be installed automatically
Requires `AUTO_SETUP_AUTOMATED=1 ` Requires `AUTO_SETUP_AUTOMATED=1 `
For a list of software index's (ID's), run '/DietPi/dietpi/dietpi-software list' For a list of software index's (ID's), run '/DietPi/dietpi/dietpi-software list'
No limit on number entries, add as many as you need and uncomment the line. No limit on number entries, add as many as you need and uncomment the line.
@ -110,17 +114,23 @@ DietPi will automatically install all pre-reqs (eg: ALSA/XSERVER for desktops et
>install fail2ban >install fail2ban
AUTO_SETUP_INSTALL_SOFTWARE_ID=73 AUTO_SETUP_INSTALL_SOFTWARE_ID=73
install OpenSSH Client install OpenSSH Client
AUTO_SETUP_INSTALL_SOFTWARE_ID=0
install OpenSSH Server
AUTO_SETUP_INSTALL_SOFTWARE_ID=105
#### SSH Server Selection:
>0=none
-1=dropbear
-2=opensshserver
AUTO_SETUP_SSH_SERVER_INDEX=-2
### Custom Script (post-networking and post-DietPi install) ---
Runs after DietPi installation is completed ## Custom Script (post-networking and post-DietPi install)
Runs after DietPi installation is completed.
Allows you to automatically execute a custom script at the end of DietPi installation. Allows you to automatically execute a custom script at the end of DietPi installation.
Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically. Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically.
Option 2 = Host your script online, then use AUTO_SETUP_CUSTOM_SCRIPT_EXEC=http://myweb.com/myscript.sh, it will be downloaded and executed automatically. | 0=disabled Option 2 = Host your script online, then use AUTO_SETUP_CUSTOM_SCRIPT_EXEC=http://myweb.com/myscript.sh, it will be downloaded and executed automatically. | 0=disabled
NB: Executed script log /var/tmp/dietpi/logs/dietpi-automation_custom_script.log NB: Executed script log /var/tmp/dietpi/logs/dietpi-automation_custom_script.log
### Guide to clone your SD-cards in Windows, MacOS and Linux and shrink the image in Linux: Find the Automation_Custom_Script.sh loaded with the build_sdcard.sh [here](/dietpi/boot/Automation_Custom_Script.sh)
---
## Guide to clone your SD-cards in Windows, MacOS and Linux and shrink the image in Linux:
https://beebom.com/how-clone-raspberry-pi-sd-card-windows-linux-macos/ https://beebom.com/how-clone-raspberry-pi-sd-card-windows-linux-macos/

40
dietpi/RaspberryPi.md

@ -0,0 +1,40 @@
# ⚡️ RaspiBlitz-on-DietPi ⚡️
## Tested on the Raspberry Pi 3 B +
### The automated building process:
1) Download the DietPi image for the Raspberry Pi:
https://dietpi.com/downloads/images/DietPi_RPi-ARMv6-Stretch.7z
2) Burn it to the SD card with [Etcher](https://www.balena.io/etcher/)
3) Right click and download the following two files: [DietPi.txt](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/dietpi.txt), [Automation_Custom_Script.sh](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/Automation_Custom_Script.sh)
4) Copy them to the /boot directory of the DietPi SDcard
[DietPi.txt](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/dietpi.txt): Overwrites the default dietpi.txt. Modified the settings to automate the DietPi setup. (see the details [here](https://github.com/rootzoll/raspiblitz/tree/dev/dietpi#excerpts-from-the-customized-dietpitxt))
[Automation_Custom_Script.sh](https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/dietpi/boot/Automation_Custom_Script.sh): Runs after DietPi installation is completed. Contains the link to download and run the build_sdcard.sh from the dev branch of @rootzoll.
(Optionally open the file with a text editor and uncomment (remove the `#` from the front of) the line with the branch you want to build the SDcard from.)
5) Assemble and boot the Raspberry Pi
Insert the SDcard, connect the HDD, network cable and power supply to boot.
(The default LCD will be set up automatically)
The automated setup will continue and the Raspberry Pi will restart at least twice during the process. This will take up to an hour.
To follow the logs during the automated building process login with `root` and press CTRL+C.
`tail -n1000 -f /tmp/DietPi-Update/dietpi-update.log` - follow the dietpi-update process
`tail -n1000 -f /var/tmp/dietpi/logs/dietpi-automation_custom_script.log` follow the output of the build_sdcard.sh
6) When the setup is finished log in as `admin`:
`ssh admin@[IP-OF-RASPIBLITZ]`
password: `raspiblitz`
The setup continues with the [RaspiBlitz Setup Process](https://github.com/rootzoll/raspiblitz/blob/master/README.md#setup-process-detailed-documentation)
---
### To build manually:
[Follow the generic DietPi install process.](https://github.com/rootzoll/raspiblitz/tree/dev/dietpi#general-guide-for-the-raspiblitz-on-dietpi)

262
dietpi/RaspiBlitz1.0_OdroidHC1_DietPi6.21.1.torrent

File diff suppressed because one or more lines are too long

15
dietpi/boot/Automation_Custom_Script.sh

@ -1 +1,14 @@
wget https://raw.githubusercontent.com/openoms/raspiblitz/raspiblitz-dev/build.sdcard/raspbianStretchDesktop.sh && sudo bash raspbianStretchDesktop.sh raspiblitz-dev openoms # Use this format to build the SDcard with the Raspiblitz script:
# wget https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh [BRANCH] [GITHUB-USERNAME]`
# If you are working from a forked repo be aware of that the fork needs to be called `raspiblitz` for the git downloads to work.
# Uncomment the line with the branch you want to build the SDcard from:
# @rootzoll master branch:
# wget https://raw.githubusercontent.com/rootzoll/raspiblitz/master/build_sdcard.sh && sudo bash build_sdcard.sh
# @rootzoll dev branch:
wget https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/build_sdcard.sh && sudo bash build_sdcard.sh dev
# @openoms DietPi branch:
# wget https://raw.githubusercontent.com/openoms/raspiblitz/DietPi/build_sdcard.sh && sudo bash build_sdcard.sh DietPi openoms

15
dietpi/boot/dietpi.txt

@ -68,21 +68,14 @@ AUTO_SETUP_GLOBAL_PASSWORD=dietpi
#AUTO_SETUP_INSTALL_SOFTWARE_ID=23 #will install Desktop LXDE #AUTO_SETUP_INSTALL_SOFTWARE_ID=23 #will install Desktop LXDE
#AUTO_SETUP_INSTALL_SOFTWARE_ID=74 #will install LAMP webserver stack #AUTO_SETUP_INSTALL_SOFTWARE_ID=74 #will install LAMP webserver stack
#AUTO_SETUP_INSTALL_SOFTWARE_ID=44 #will install Bittorrent transmission #AUTO_SETUP_INSTALL_SOFTWARE_ID=44 #will install Bittorrent transmission
# install fail2ban AUTO_SETUP_INSTALL_SOFTWARE_ID=73 # install fail2ban
AUTO_SETUP_INSTALL_SOFTWARE_ID=73
# install OpenSSH Client
# AUTO_SETUP_INSTALL_SOFTWARE_ID=0
# install OpenSSH Server
# AUTO_SETUP_INSTALL_SOFTWARE_ID=105
# DietPi-Software Choice System # DietPi-Software Choice System
# SSH Server Selection: # SSH Server Selection:
# 0=none # 0=none
# -1=dropbear # -1=dropbear
# -2=opensshserver # -2=opensshserver
AUTO_SETUP_SSH_SERVER_INDEX=-1 AUTO_SETUP_SSH_SERVER_INDEX=-2
# File Server Selection: # File Server Selection:
# 0=none/manual # 0=none/manual
@ -109,7 +102,7 @@ AUTO_SETUP_WEB_SERVER_INDEX=-2
# DietPi-Autostart | Requires AUTO_SETUP_AUTOMATED=1 # DietPi-Autostart | Requires AUTO_SETUP_AUTOMATED=1
# After installation is completed, which program should the system boot to? # After installation is completed, which program should the system boot to?
# 0=Console 7=Console+auto root login | 1=Kodi 2=Desktops (LXDE/MATE etc) 5=DietPi-Cloudshell 6=Uae4ARM (Fastboot) 8=Uae4ARM (standard boot) 9=dxx-rebirth # 0=Console 7=Console+auto root login | 1=Kodi 2=Desktops (LXDE/MATE etc) 5=DietPi-Cloudshell 6=Uae4ARM (Fastboot) 8=Uae4ARM (standard boot) 9=dxx-rebirth
AUTO_SETUP_AUTOSTART_TARGET_INDEX=0 AUTO_SETUP_AUTOSTART_TARGET_INDEX=7 # 7=Console+auto root login is changed to pi in build_sdcard.sh
# Language/Regional settings | Requires AUTO_SETUP_AUTOMATED=1 # Language/Regional settings | Requires AUTO_SETUP_AUTOMATED=1
# Timezone eg: Europe/London America/New_York | Full list (TZ*): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones # Timezone eg: Europe/London America/New_York | Full list (TZ*): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
@ -261,4 +254,4 @@ DEV_GITOWNER=Fourdee
#------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------
# D I E T - P I # D I E T - P I
# Settings, automatically added by dietpi-update # Settings, automatically added by dietpi-update
#------------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------

210
dietpi/dietpi.display.sh

@ -0,0 +1,210 @@
# To run this script on your RaspiBlitz, copy the following line to the ssh terminal (after the #):
# wget https://raw.githubusercontent.com/openoms/raspiblitz/DietPi/dietpi/dietpi.display.sh && sudo chmod +x dietpi.display.sh && ./dietpi.display.sh
# keep in mind that DietPi for Raspberry is also a stripped down Raspbian
echo "Detect Base Image ..."
baseImage="?"
isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
if [ ${isRaspbian} -gt 0 ]; then
baseImage="raspbian"
fi
if [ ${isDietPi} -gt 0 ]; then
baseImage="dietpi"
fi
if [ "${baseImage}" = "?" ]; then
cat /etc/os-release 2>/dev/null
echo "!!! FAIL !!!"
echo "Base Image cannot be detected or is not supported."
exit 1
else
echo "OK running ${baseImage}"
fi
if [ "${baseImage}" = "raspbian" ]; then
echo "Press ENTER to install LCD and reboot ..."
read key
# give Raspi a default hostname (optional)
sudo raspi-config nonint do_hostname "RaspiBlitz"
# *** Display selection ***
dialog --title "Display" --yesno "Are you using the default display available from Amazon?\nSelect 'No' if you are using the Swiss version from play-zone.ch!" 6 80
defaultDisplay=$?
if [ "${defaultDisplay}" = "0" ]; then
# *** RASPIBLITZ / LCD (at last - because makes a reboot) ***
# based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip
echo "--> LCD DEFAULT"
cd /home/admin/
sudo apt-mark hold raspberrypi-bootloader
git clone https://github.com/goodtft/LCD-show.git
sudo chmod -R 755 LCD-show
sudo chown -R admin:admin LCD-show
cd LCD-show/
sudo ./LCD35-show
else
# Download and install the driver
# based on http://www.raspberrypiwiki.com/index.php/3.5_inch_TFT_800x480@60fps
echo "--> LCD ALTERNATIVE"
cd /boot
sudo wget http://www.raspberrypiwiki.com/download/RPI-HD-35-INCH-TFT/dt-blob-For-3B-plus.bin
sudo mv dt-blob-For-3B-plus.bin dt-blob.bin
cat <<EOF >> config.txt
dtparam=spi=off
dtparam=i2c_arm=off
# Set screen size and any overscan required
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
framebuffer_width=800
framebuffer_height=480
enable_dpi_lcd=1
display_default_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x6f015
# set up the size to 800x480
hdmi_timings=480 0 16 16 24 800 0 4 2 2 0 0 0 60 0 32000000 6
#rotate screen
display_rotate=3
dtoverlay=i2c-gpio,i2c_gpio_scl=24,i2c_gpio_sda=23
fi
EOF
init 6
fi
fi
if [ "${baseImage}" = "dietpi" ]; then
OPTIONS=(GPIO "Install the default display available from Amazon" \
HDMI "Install the 3.5\" HDMI display from Aliexpress" \
SWISS "Install the Swiss version from play-zone.ch"
)
CHOICE=$(dialog --backtitle "RaspiBlitz - Display Install" --clear --title "Display Install" --menu "Choose a your diplay:" 10 70 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICE}" = "GPIO" ]; then
echo "Installing the default display available from Amazon"
# based on https://www.elegoo.com/tutorial/Elegoo%203.5%20inch%20Touch%20Screen%20User%20Manual%20V1.00.2017.10.09.zip
cd /home/admin/
#sudo apt-mark hold raspberrypi-bootloader
git clone https://github.com/goodtft/LCD-show.git
sudo chmod -R 755 LCD-show
sudo chown -R admin:admin LCD-show
cd LCD-show/
# sudo ./LCD35-show
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
sudo mkdir /etc/X11/xorg.conf.d
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/tft35a.dtbo
sudo cp -rf ./usr/99-calibration.conf-35 /etc/X11/xorg.conf.d/99-calibration.conf
sudo cp -rf ./usr/99-fbturbo.conf /usr/share/X11/xorg.conf.d/
sudo cp ./usr/cmdline.txt /DietPi/
sudo cp ./usr/inittab /etc/
sudo cp ./boot/config-35.txt /DietPi/config.txt
# revert font change
# based on https://www.raspberrypi-spy.co.uk/2014/04/how-to-change-the-command-line-font-size/
sudo sed -i 's/FONTFACE="TerminusBold"/FONTFACE="Fixed"/' /etc/default/console-setup
sudo sed -i 's/FONTSIZE="12x24"/FONTSIZE="8x16"/' /etc/default/console-setup
echo "***"
echo "reboot with \`sudo reboot\` to make the LCD work"
echo "***"
exit
elif [ "${CHOICE}" = "HDMI" ]; then
echo "Installing the 3.5\" HDMI display from Aliexpress"
# based on http://www.lcdwiki.com/3.5inch_HDMI_Display-B
git clone https://github.com/goodtft/LCD-show.git
sudo chmod -R 755 LCD-show
cd LCD-show/
#sudo ./MPI3508-show
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
sudo cp -rf ./boot/config-35-480X320.txt /DietPi/config.txt
sudo cp ./usr/cmdline.txt /DietPi/
sudo cp ./usr/inittab /etc/
sudo cp -rf ./usr/99-fbturbo.conf-HDMI /usr/share/X11/xorg.conf.d/99-fbturbo.conf
sudo mkdir -p /etc/X11/xorg.conf.d
sudo cp -rf ./usr/99-calibration.conf-3508 /etc/X11/xorg.conf.d/99-calibration.conf
# based on https://www.raspberrypi-spy.co.uk/2014/04/how-to-change-the-command-line-font-size/
sudo sed -i 's/FONTFACE="Fixed"/FONTFACE="TerminusBold"/' /etc/default/console-setup
sudo sed -i 's/FONTSIZE="8x16"/FONTSIZE="12x24"/' /etc/default/console-setup
echo "***"
echo "reboot with \`sudo reboot\` to make the LCD work"
echo "***"
exit
elif [ "${CHOICE}" = "SWISS" ]; then
# Download and install the driver
# based on http://www.raspberrypiwiki.com/index.php/3.5_inch_TFT_800x480@60fps
echo "--> LCD ALTERNATIVE"
# revert font change
# based on https://www.raspberrypi-spy.co.uk/2014/04/how-to-change-the-command-line-font-size/
sudo sed -i 's/FONTFACE="TerminusBold"/FONTFACE="Fixed"/' /etc/default/console-setup
sudo sed -i 's/FONTSIZE="12x24"/FONTSIZE="8x16"/' /etc/default/console-setup
cd /DietPi
sudo wget http://www.raspberrypiwiki.com/download/RPI-HD-35-INCH-TFT/dt-blob-For-3B-plus.bin
sudo mv dt-blob-For-3B-plus.bin dt-blob.bin
cat <<EOF >> config.txt
dtparam=spi=off
dtparam=i2c_arm=off
# Set screen size and any overscan required
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
framebuffer_width=800
framebuffer_height=480
enable_dpi_lcd=1
display_default_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x6f015
# set up the size to 800x480
hdmi_timings=480 0 16 16 24 800 0 4 2 2 0 0 0 60 0 32000000 6
#rotate screen
display_rotate=3
dtoverlay=i2c-gpio,i2c_gpio_scl=24,i2c_gpio_sda=23
fi
EOF
init 6
fi
else
echo "CANCEL"
exit
fi

77
home.admin/00infoBlitz.sh

@ -6,7 +6,8 @@ source /home/admin/_version.info
# set colors # set colors
color_red='\033[0;31m' color_red='\033[0;31m'
color_green='\033[0;32m' color_green='\033[0;32m'
color_yellow='\033[0;33m' color_amber='\033[0;33m'
color_yellow='\033[1;93m'
color_gray='\033[0;37m' color_gray='\033[0;37m'
color_purple='\033[0;35m' color_purple='\033[0;35m'
@ -50,13 +51,14 @@ load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
# get CPU temp # get CPU temp
cpu=$(cat /sys/class/thermal/thermal_zone0/temp) cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
temp=$((cpu/1000)) tempC=$((cpu/1000))
tempF=$(((cpu/1000) * (9/5) + 32))
# 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 }')")
if [ ${ram_avail} -lt 100 ]; then if [ ${ram_avail} -lt 50 ]; then
color_ram="${color_red}\e[7m" color_ram="${color_red}\e[7m"
else else
color_ram=${color_green} color_ram=${color_green}
@ -73,8 +75,15 @@ else
fi fi
# get network traffic # get network traffic
network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[()]//g') # ifconfig does not show eth0 on Armbian - get first traffic info
network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g') isArmbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Debian')
if [ ${isArmbian} -gt 0 ]; then
network_rx=$(ifconfig | grep -m1 'RX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
network_tx=$(ifconfig | grep -m1 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
else
network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
fi
# Bitcoin blockchain # Bitcoin blockchain
btc_path=$(command -v ${network}-cli) btc_path=$(command -v ${network}-cli)
@ -90,7 +99,7 @@ if [ -n ${btc_path} ]; then
block_diff=$(expr ${block_chain} - ${block_verified}) block_diff=$(expr ${block_chain} - ${block_verified})
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')") sync_percentage=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}')
if [ ${block_diff} -eq 0 ]; then # fully synced if [ ${block_diff} -eq 0 ]; then # fully synced
sync="OK" sync="OK"
@ -174,19 +183,11 @@ else
if [ $public_check = "0" ]; then if [ $public_check = "0" ]; then
public="" public=""
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure # only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
public_color="${color_yellow}" public_color="${color_amber}"
else else
public="" public=""
public_color="${color_red}" public_color="${color_red}"
fi fi
if [ ${#public_addr} -gt 25 ]; then
# if a IPv6 address dont show peers to save space
networkConnectionsInfo=""
fi
if [ ${#public_addr} -gt 35 ]; then
# if a LONG IPv6 address dont show "Public" in front to save space
public_addr_pre=""
fi
# DynDNS # DynDNS
if [ ${#dynDomain} -gt 0 ]; then if [ ${#dynDomain} -gt 0 ]; then
@ -196,14 +197,22 @@ else
if [ "${ipOfDynDNS}:${public_port}" != "${public_addr}" ]; then if [ "${ipOfDynDNS}:${public_port}" != "${public_addr}" ]; then
public_color="${color_red}" public_color="${color_red}"
else else
public_color="${color_yellow}" public_color="${color_amber}"
fi fi
# replace IP display with dynDNS # replace IP display with dynDNS
public_addr_pre="DynDNS " public_addr_pre="DynDNS "
networkConnectionsInfo=""
public_addr="${dynDomain}" public_addr="${dynDomain}"
fi
if [ ${#public_addr} -gt 25 ]; then
# if a IPv6 address dont show peers to save space
networkConnectionsInfo=""
fi
if [ ${#public_addr} -gt 35 ]; then
# if a LONG IPv6 address dont show "Public" in front to save space
public_addr_pre=""
fi fi
fi fi
@ -234,7 +243,7 @@ else
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?) public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ]; then if [ $public_check = "0" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure # 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_yellow}" ln_publicColor="${color_amber}"
else else
ln_publicColor="${color_red}" ln_publicColor="${color_red}"
fi fi
@ -268,19 +277,38 @@ else
fi fi
fi fi
# STATUS SINALING: Backup Torrent Seeding
torrentBaseStatus=""
torrentUpdateStatus=""
if [ "${backupTorrentSeeding}" == "on" ]; then
torrentBaseStatus="•"
torrentUpdateStatus="•"
source <(sudo -u admin /home/admin/50torrentHDD.sh status)
if [ "${baseComplete}" == "1" ]; then
torrentBaseStatus="↑"
elif [ "${baseSeeding}" == "1" ]; then
torrentBaseStatus="↓"
fi
if [ "${updateComplete}" == "1" ]; then
torrentUpdateStatus="↑"
elif [ "${updateSeeding}" == "1" ]; then
torrentUpdateStatus="↓"
fi
fi
sleep 5 sleep 5
printf " printf "
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}
${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias} ${color_yellow} ${color_amber}%s ${color_green} ${ln_alias}
${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, CPU %s°C ${color_yellow} ,'/ ${color_gray}%s, temp %s°C %s°F
${color_yellow} ,' / ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} Free HDD ${color_hdd}%s ${color_yellow} ,' / ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} Free HDD ${color_hdd}%s
${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray}${network_rx}${network_tx} ${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} .'____ ,' ${color_gray}${webinterfaceInfo} ${color_yellow} .'____ ,' ${color_gray}${webinterfaceInfo}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s) ${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} %s${torrentBaseStatus}${torrentUpdateStatus}
${color_yellow} / ,' ${color_gray}${public_addr_pre}${public_color}${public_addr} ${public}${networkConnectionsInfo} ${color_yellow} / ,' ${color_gray}${public_addr_pre}${public_color}${public_addr} ${public}${networkConnectionsInfo}
${color_yellow} /,' ${color_gray} ${color_yellow} /,' ${color_gray}
${color_yellow} /' ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo} ${color_yellow} /' ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo}
@ -291,9 +319,12 @@ ${color_yellow}${ln_publicColor}${ln_external}${color_red}
" \ " \
"RaspiBlitz v${codeVersion}" \ "RaspiBlitz v${codeVersion}" \
"-------------------------------------------" \ "-------------------------------------------" \
"load average:${load##up*, }" "${temp}" \ "CPU load${load##up*, }" "${tempC}" "${tempF}" \
"${hdd}" "${sync_percentage}" "${hdd}" "${sync_percentage}"
source /home/admin/stresstest.report 2>/dev/null
if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; then if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; then
echo "${undervoltageReports} undervoltage reports found - maybe upgrade power supply" echo "${undervoltageReports} undervoltage reports - run 'Hardware Test' in menu"
elif [ ${#powerFAIL} -gt 0 ] && [ ${powerFAIL} -gt 0 ]; then
echo "Weak power supply detected - run 'Hardware Test' in menu"
fi fi

2
home.admin/00infoBlitz2.sh

@ -1,2 +0,0 @@
#!/bin/bash
/usr/bin/env python3 infoblitzd.py $@

64
home.admin/00infoLCD.sh

@ -72,20 +72,27 @@ while :
if [ ${setupStep} -eq 0 ]; then if [ ${setupStep} -eq 0 ]; then
# check for internet connection # check for internet connection
# https://en.wikipedia.org/wiki/1.1.1.1 online=$(ping 1.0.0.1 -c 1 -W 2 | grep -c '1 received')
online=$(ping 1.1.1.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 if [ ${online} -eq 0 ]; then
message="no internet connection" message="no internet connection"
# when in presync - get more info on progress # when in presync - get more info on progress
elif [ "${state}" = "presync" ]; then elif [ "${state}" = "presync" ]; then
# get blockchain sync progress # get blockchain sync progress
blockchaininfo="$(sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf getblockchaininfo 2>/dev/null)" blockchaininfo="$(sudo -u root ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null)"
message="starting" message="starting"
if [ ${#blockchaininfo} -gt 0 ]; then if [ ${#blockchaininfo} -gt 0 ]; then
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
message=$(echo "${message}*100" | bc) message=$(echo $message | awk '{printf( "%.2f%%", 100 * $1)}')
message="${message}%"
fi fi
# when old data - improve message # when old data - improve message
@ -123,7 +130,8 @@ while :
fi fi
# if freshly recovered # if freshly recovered
if [ "${state}" = "recovered" ]; then recoveredInfoExists=$(sudo ls /home/admin/raspiblitz.recover.info 2>/dev/null | grep -c '.info')
if [ ${recoveredInfoExists} -gt 0 ]; then
l1="FINAL RECOVER LOGIN NEEDED:\n" l1="FINAL RECOVER LOGIN NEEDED:\n"
l2="ssh admin@${localip}\n" l2="ssh admin@${localip}\n"
l3="Use password: raspiblitz\n" l3="Use password: raspiblitz\n"
@ -190,50 +198,6 @@ while :
continue continue
fi fi
# check if bitcoin is ready
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
clienterror=`cat error.tmp`
rm error.tmp
if [ ${#clienterror} -gt 0 ]; then
boxwidth=40
l1="Waiting for ${network}d to get ready.\n"
l2="---> ${clienterror/error*:/}\n"
l3="Can take longer if device was off."
uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')"
if [ ${uptimeSeconds} -gt 600 ]; then
l3="!!Please login for more details!!"
fi
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - Welcome Back" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
continue
fi
# check if locked
locked=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ "${locked}" -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
h=5
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
l4=""
if [ "${rtlWebinterface}" = "on" ]; then
l2="Browser: http://${localip}:3000\n"
l3="PasswordB=login / PasswordC=unlock\n"
l4="PasswordA: ssh admin@${localip}"
h=6
fi
if [ "${autoUnlock}" = "on" ]; then
l2="ssh admin@${localip}\n"
l3="Waiting for AUTO-UNLOCK"
fi
boxwidth=$((${#localip} + 26))
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - ${hostname}" --infobox "$l1$l2$l3$l4" ${h} ${boxwidth}
sleep 5
continue
fi
# if LND is syncing or scanning # 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) 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 if [ ${lndSynced} -eq 0 ]; then

496
home.admin/00mainMenu.sh

@ -7,121 +7,14 @@ configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap # INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info" infoFile="/home/admin/raspiblitz.info"
# check if HDD is connected # MAIN MENU AFTER SETUP
hddExists=$(lsblk | grep -c sda1)
if [ ${hddExists} -eq 0 ]; then
# check if there is maybe a HDD but woth no partitions
noPartition=$(lsblk | grep -c sda)
if [ ${noPartition} -eq 1 ]; then
echo "***********************************************************"
echo "WARNING: HDD HAS NO PARTITIONS"
echo "***********************************************************"
echo "Press ENTER to create a Partition - or CTRL+C to abort"
read key
echo "Creating Partition ..."
sudo parted -s /dev/sda unit s mkpart primary `sudo parted /dev/sda unit s print free | grep 'Free Space' | tail -n 1`
echo "DONE."
sleep 3
else
echo "***********************************************************"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart."
echo "***********************************************************"
exit
fi
fi
# check data from _bootstrap.sh that was running on device setup
bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
echo "***********************************************************"
exit
fi
# load the data from the info file (will get produced on every startup)
source ${infoFile} source ${infoFile}
source ${configFile}
if [ "${state}" = "recovering" ]; then # get the local network IP to be displayed on the lCD
echo "***********************************************************" localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "WARNING: bootstrap still updating - close SSH, login later"
echo "To monitor progress --> tail -n1000 -f raspiblitz.log"
echo "***********************************************************"
exit
fi
# signal that after bootstrap recover user dialog is needed
if [ "${state}" = "recovered" ]; then
echo "System recovered - needs final user settings"
./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 torrent is in re-download
if [ "${state}" = "retorrent" ]; then
echo "Re-Index in progress ... start monitoring:"
/home/admin/50torrentHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00mainMenu.sh
exit
fi
# if pre-sync is running - stop it - before continue
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
# analyse if blockchain was detected broken by pre-sync
blockchainBroken=$(sudo tail /mnt/hdd/bitcoin/debug.log | grep -c "Please restart with -reindex or -reindex-chainstate to recover.")
if [ ${blockchainBroken} -eq 1 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Detected corrupted blockchain on pre-sync !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Deleting blockchain data ..."
echo "(needs to get downloaded fresh during setup)"
sudo rm -f -r /mnt/hdd/bitcoin
else
echo "********************************************"
echo "Stopping pre-sync ... pls wait (up to 1min)"
echo "********************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop
echo "bitcoind called to stop .."
sleep 50
fi
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "loading config data"
source ${configFile}
else
echo "setup still in progress - setupStep(${setupStep})"
fi
fi
## default menu settings # BASIC MENU INFO
# to fit the main menu without scrolling:
# HEIGHT=23
# CHOICE_HEIGHT=20
HEIGHT=13 HEIGHT=13
WIDTH=64 WIDTH=64
CHOICE_HEIGHT=6 CHOICE_HEIGHT=6
@ -129,257 +22,56 @@ BACKTITLE="RaspiBlitz"
TITLE="" TITLE=""
MENU="Choose one of the following options:" MENU="Choose one of the following options:"
OPTIONS=() OPTIONS=()
plus=""
# check if RTL web interface is installed if [ "${runBehindTor}" = "on" ]; then
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') plus=" / TOR"
# get the local network IP to be displayed on the lCD
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# function to use later
waitUntilChainNetworkIsReady()
{
echo "checking ${network}d - please wait .."
echo "can take longer if device was off or first time"
while :
do
# check for error on network
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
clienterror=`cat error.tmp`
rm error.tmp
# check for missing blockchain data
minSize=250000000000
if [ "${network}" = "litecoin" ]; then
minSize=20000000000
fi
blockchainsize=$(sudo du -shbc /mnt/hdd/${network} | head -n1 | awk '{print $1;}')
if [ ${#blockchainsize} -gt 0 ]; then
if [ ${blockchainsize} -lt ${minSize} ]; then
echo "blockchainsize(${blockchainsize})"
echo "Missing Blockchain Data (<${minSize}) ..."
clienterror="missing blockchain"
sleep 3
fi
fi
if [ ${#clienterror} -gt 0 ]; then
# analyse LOGS for possible reindex
reindex=$(sudo cat /mnt/hdd/${network}/debug.log | grep -c 'Please restart with -reindex or -reindex-chainstate to recover')
if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then
echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options."
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
sleep 3
dialog --backtitle "RaspiBlitz - Repair Script" --msgbox "Your blockchain data needs to be repaired.
This can be due to power problems or a failing HDD.
Please check the FAQ on RaspiBlitz Github
'My blockchain data is corrupted - what can I do?'
https://github.com/rootzoll/raspiblitz/blob/master/FAQ.md
The RaspiBlitz will now try to help you on with the repair.
To run a BACKUP of funds & channels first is recommended.
" 13 65
clear
# Basic Options
OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \
COPY "Copy from another Computer (SKILLED)" \
REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \
BACKUP "Run Backup LND data first (optional)"
)
CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
if [ "${CHOICE}" = "TORRENT" ]; then
echo "Starting TORRENT ..."
sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info
/home/admin/50torrentHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00mainMenu.sh
exit
elif [ "${CHOICE}" = "COPY" ]; then
echo "Starting COPY ..."
sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info
/home/admin/50copyHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00mainMenu.sh
exit
elif [ "${CHOICE}" = "REINDEX" ]; then
echo "Starting REINDEX ..."
sudo /home/admin/config.scripts/network.reindex.sh
exit
elif [ "${CHOICE}" = "BACKUP" ]; then
sudo /home/admin/config.scripts/lnd.rescue.sh backup
echo "PRESS ENTER to return to menu."
read key
/home/admin/00mainMenu.sh
exit
else
echo "CANCEL"
exit
fi
else
echo "${network} error: ${clienterror}"
fi
# normal info
boxwidth=40
l1="Waiting for ${network}d to get ready.\n"
l2="---> ${clienterror/error*:/}\n"
l3="Can take longer if device was off."
uptimeSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')"
# after 2 min show complete long string (full detail)
if [ ${uptimeSeconds} -gt 120 ]; then
boxwidth=80
l2="${clienterror}\n"
l3="CTRL+C => terminal"
fi
dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
else
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ ${locked} -gt 0 ]; then
./AAunlockLND.sh
echo "please wait ... update to next screen can be slow"
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
./80scanLND.sh
else
# everything is ready - return from loop
return
fi
fi
sleep 5
done
}
if [ ${#setupStep} -eq 0 ]; then
echo "WARN: no setup step found in raspiblitz.info"
setupStep=0
fi fi
if [ ${setupStep} -eq 0 ]; then if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
# check data from boostrap fi
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
if [ "${state}" = "olddata" ]; then
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD CONTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds" \
DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11
else
# 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)" )
HEIGHT=11
fi
elif [ ${setupStep} -lt 100 ]; then
# see function above
if [ ${setupStep} -gt 59 ]; then
waitUntilChainNetworkIsReady
fi
# 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
# see function above
waitUntilChainNetworkIsReady
# MAIN MENU AFTER SETUP
plus=""
if [ "${runBehindTor}" = "on" ]; then
plus=" / TOR"
fi
if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
fi
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
if [ "${rtlWebinterface}" = "on" ]; then
# WEBINTERFACE INFO LOCK SCREEN
TITLE="SSH UNLOCK"
MENU="IMPORTANT: Please unlock thru the RTL Webinterface.\nWebinterface --> http://${localip}:3000\nThen TRY AGAIN to get to main menu."
OPTIONS+=(R "TRY AGAIN - check again if unlocked" \
U "FALLBACK -> Unlock with 'lncli unlock'")
else
# NORMAL LOCK SCREEN
MENU="!!! YOUR WALLET IS LOCKED !!!"
OPTIONS+=(U "Unlock your Lightning Wallet with 'lncli unlock'")
fi
else
if [ ${runningRTL} -eq 1 ]; then
TITLE="Webinterface: http://${localip}:3000"
fi
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your on-chain Wallet" \
CONNECT "Connect to a Peer" \
CHANNEL "Open a Channel with Peer" \
SEND "Pay an Invoice/PaymentRequest" \
RECEIVE "Create Invoice/PaymentRequest" \
SERVICES "Activate/Deactivate Services" \
MOBILE "Connect Mobile Wallet" \
EXPORT "Macaroons and TLS.cert" \
NAME "Change Name/Alias of Node" \
PASSWORD "Change Passwords" \
CASHOUT "Remove Funds from on-chain Wallet")
# dont offer lnbalance/lnchannels on testnet
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List")
fi
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
if [ "${runBehindTor}" = "on" ]; then
OPTIONS+=(NYX "Monitor TOR")
fi
# final Options if [ "${rtlWebinterface}" == "on" ]; then
OPTIONS+=(OFF "PowerOff RaspiBlitz") TITLE="Webinterface: http://${localip}:3000"
OPTIONS+=(X "Console / Terminal") fi
fi # Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your on-chain Wallet" \
CONNECT "Connect to a Peer" \
CHANNEL "Open a Channel with Peer" \
SEND "Pay an Invoice/PaymentRequest" \
RECEIVE "Create Invoice/PaymentRequest" \
SERVICES "Activate/Deactivate Services" \
MOBILE "Connect Mobile Wallet" \
EXPORT "Macaroons and TLS.cert" \
NAME "Change Name/Alias of Node" \
PASSWORD "Change Passwords" \
CASHOUT "Remove Funds from on-chain Wallet"
)
# dont offer lnbalance/lnchannels on testnet
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List")
fi
# Depending Options
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")
fi
if [ "${runBehindTor}" == "on" ]; then
OPTIONS+=(NYX "Monitor TOR")
fi fi
# final Options
OPTIONS+=(HARDWARE "Run Hardwaretest")
OPTIONS+=(SOFTWARE "Run Softwaretest (DebugReport)")
OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update")
OPTIONS+=(OFF "PowerOff RaspiBlitz")
OPTIONS+=(X "Console / Terminal")
CHOICE=$(dialog --clear \ CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--title "$TITLE" \ --title "$TITLE" \
@ -388,32 +80,30 @@ CHOICE=$(dialog --clear \
"${OPTIONS[@]}" \ "${OPTIONS[@]}" \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear #clear
case $CHOICE in case $CHOICE in
CLOSE) CLOSE)
exit 1; exit 1;
;; ;;
BITCOIN) X)
sed -i "s/^network=.*/network=bitcoin/g" ${infoFile} clear
sed -i "s/^chain=.*/chain=main/g" ${infoFile} echo "***********************************"
./10setupBlitz.sh echo "* RaspiBlitz Commandline"
exit 1; echo "* Here be dragons .. have fun :)"
;; echo "***********************************"
LITECOIN) echo "LND commandline options: lncli -h"
sed -i "s/^network=.*/network=litecoin/g" ${infoFile} echo "Back to main menu use command: raspiblitz"
sed -i "s/^chain=.*/chain=main/g" ${infoFile} echo
./10setupBlitz.sh
exit 1;
;;
CONTINUE)
./10setupBlitz.sh
exit 1; exit 1;
;; ;;
INFO) INFO)
./00infoBlitz.sh walletLocked=$(lncli getinfo 2>&1 | grep -c "Wallet is encrypted")
echo "Screen is not updating ... press ENTER to continue." if [ ${walletLocked} -eq 0 ]; then
read key ./00infoBlitz.sh
./00mainMenu.sh echo "Screen is not refreshing itself ... press ENTER to continue."
read key
fi
./00raspiblitz.sh
;; ;;
lnbalance) lnbalance)
lnbalance ${network} lnbalance ${network}
@ -439,14 +129,10 @@ case $CHOICE in
;; ;;
FUNDING) FUNDING)
./BBfundWallet.sh ./BBfundWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh ./00mainMenu.sh
;; ;;
CASHOUT) CASHOUT)
./BBcashoutWallet.sh ./BBcashoutWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh ./00mainMenu.sh
;; ;;
CHANNEL) CHANNEL)
@ -489,18 +175,6 @@ case $CHOICE in
read key read key
./00mainMenu.sh ./00mainMenu.sh
;; ;;
TOR)
sudo ./96addTorService.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
RTL)
sudo ./98installRTL.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
EXPORT) EXPORT)
sudo /home/admin/config.scripts/lnd.export.sh sudo /home/admin/config.scripts/lnd.export.sh
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."
@ -519,6 +193,16 @@ case $CHOICE in
./00mainMenu.sh ./00mainMenu.sh
fi fi
;; ;;
HARDWARE)
sudo ./05hardwareTest.sh
./00mainMenu.sh
;;
SOFTWARE)
sudo ./XXdebugLogs.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
PASSWORD) PASSWORD)
sudo /home/admin/config.scripts/blitz.setpassword.sh sudo /home/admin/config.scripts/blitz.setpassword.sh
noreboot=$? noreboot=$?
@ -545,34 +229,20 @@ case $CHOICE in
sleep 10 sleep 10
echo "stop ${network}d (2) - please wait .." echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d sudo systemctl stop ${network}d
echo "starting shutdown" sleep 3
sync
echo "starting shutdown ..."
sudo shutdown now sudo shutdown now
exit 0 exit 0
;; ;;
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
;;
DELETE) DELETE)
sudo ./XXcleanHDD.sh sudo ./XXcleanHDD.sh
sudo shutdown -r now sudo shutdown -r now
exit 0 exit 0
;; ;;
X) UPDATE)
lncli -h /home/admin/99checkUpdate.sh
echo "OK you now on the command line."
echo "You can return to the main menu with the command:"
echo "raspiblitz"
;;
R)
./00mainMenu.sh
;;
U) # unlock
./AAunlockLND.sh
./00mainMenu.sh ./00mainMenu.sh
;; exit 0
;;
esac esac

469
home.admin/00raspiblitz.sh

@ -0,0 +1,469 @@
#!/bin/bash
echo "Starting the main menu ..."
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# check if HDD is connected
hddExists=$(lsblk | grep -c sda1)
if [ ${hddExists} -eq 0 ]; then
# check if there is maybe a HDD but woth no partitions
noPartition=$(lsblk | grep -c sda)
if [ ${noPartition} -eq 1 ]; then
echo "***********************************************************"
echo "WARNING: HDD HAS NO PARTITIONS"
echo "***********************************************************"
echo "Press ENTER to create a Partition - or CTRL+C to abort"
read key
echo "Creating Partition ..."
sudo parted -s /dev/sda unit s mkpart primary `sudo parted /dev/sda unit s print free | grep 'Free Space' | tail -n 1`
echo "DONE."
sleep 3
else
echo "***********************************************************"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart."
echo "***********************************************************"
exit
fi
fi
# check data from _bootstrap.sh that was running on device setup
bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
echo "***********************************************************"
exit
fi
# load the data from the info file (will get produced on every startup)
source ${infoFile}
if [ "${state}" = "recovering" ]; then
echo "***********************************************************"
echo "WARNING: bootstrap still updating - close SSH, login later"
echo "To monitor progress --> tail -n1000 -f raspiblitz.log"
echo "***********************************************************"
exit
fi
# signal that after bootstrap recover user dialog is needed
recoveredInfoExists=$(sudo ls /home/admin/raspiblitz.recover.info 2>/dev/null | grep -c '.info')
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 torrent is in re-download
if [ "${state}" = "retorrent" ]; then
echo "Re-Index in progress ... start monitoring:"
/home/admin/50torrentHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00raspiblitz.sh
exit
fi
# if pre-sync is running - stop it - before continue
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
# analyse if blockchain was detected broken by pre-sync
blockchainBroken=$(sudo tail /mnt/hdd/bitcoin/debug.log 2>/dev/null | grep -c "Please restart with -reindex or -reindex-chainstate to recover.")
if [ ${blockchainBroken} -eq 1 ]; then
# dismiss if its just a date thing
futureBlock=$(sudo tail /mnt/hdd/bitcoin/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
fi
if [ ${blockchainBroken} -eq 1 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Detected corrupted blockchain on pre-sync !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Deleting blockchain data ..."
echo "(needs to get downloaded fresh during setup)"
sudo rm -f -r /mnt/hdd/bitcoin
else
echo "************************************"
echo "Preparing ... pls wait (up to 1min) "
echo "************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop 2>/dev/null
echo "Calling presync to finish up .."
sleep 50
fi
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "loading config data"
source ${configFile}
else
echo "setup still in progress - setupStep(${setupStep})"
fi
fi
## default menu settings
# to fit the main menu without scrolling:
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=6
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
# check if RTL web interface is installed
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
# function to use later
waitUntilChainNetworkIsReady()
{
source ${configFile}
echo "checking ${network}d - please wait .."
echo "can take longer if device was off or first time"
while :
do
# check for error on network
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
clienterror=`cat error.tmp`
rm error.tmp
# check for missing blockchain data
minSize=250000000000
if [ "${network}" = "litecoin" ]; then
minSize=20000000000
fi
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
echo "blockchainsize(${blockchainsize})"
echo "Missing Blockchain Data (<${minSize}) ..."
clienterror="missing blockchain"
sleep 3
fi
fi
if [ ${#clienterror} -gt 0 ]; then
# 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
fi
if [ ${reindex} -gt 0 ] || [ "${clienterror}" = "missing blockchain" ]; then
echo "!! DETECTED NEED FOR RE-INDEX in debug.log ... starting repair options."
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
sleep 3
dialog --backtitle "RaspiBlitz - Repair Script" --msgbox "Your blockchain data needs to be repaired.
This can be due to power problems or a failing HDD.
Please check the FAQ on RaspiBlitz Github
'My blockchain data is corrupted - what can I do?'
https://github.com/rootzoll/raspiblitz/blob/master/FAQ.md
The RaspiBlitz will now try to help you on with the repair.
To run a BACKUP of funds & channels first is recommended.
" 13 65
clear
# Basic Options
OPTIONS=(TORRENT "Redownload Prepared Torrent (DEFAULT)" \
COPY "Copy from another Computer (SKILLED)" \
REINDEX "Resync thru ${network}d (TAKES VERY VERY LONG)" \
BACKUP "Run Backup LND data first (optional)"
)
CHOICE=$(dialog --backtitle "RaspiBlitz - Repair Script" --clear --title "Repair Blockchain Data" --menu "Choose a repair/recovery option:" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
if [ "${CHOICE}" = "TORRENT" ]; then
echo "Starting TORRENT ..."
sudo sed -i "s/^state=.*/state=retorrent/g" /home/admin/raspiblitz.info
/home/admin/50torrentHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00raspiblitz.sh
exit
elif [ "${CHOICE}" = "COPY" ]; then
echo "Starting COPY ..."
sudo sed -i "s/^state=.*/state=recopy/g" /home/admin/raspiblitz.info
/home/admin/50copyHDD.sh
sudo sed -i "s/^state=.*/state=repair/g" /home/admin/raspiblitz.info
/home/admin/00raspiblitz.sh
exit
elif [ "${CHOICE}" = "REINDEX" ]; then
echo "Starting REINDEX ..."
sudo /home/admin/config.scripts/network.reindex.sh
exit
elif [ "${CHOICE}" = "BACKUP" ]; then
sudo /home/admin/config.scripts/lnd.rescue.sh backup
echo "PRESS ENTER to return to menu."
read key
/home/admin/00raspiblitz.sh
exit
else
echo "CANCEL"
exit
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
else
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ ${locked} -gt 0 ]; then
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/AAunlockLND.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
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
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
# check data from boostrap
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
if [ "${state}" = "olddata" ]; then
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD CONTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds" \
DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11
else
# show hardware test
/home/admin/05hardwareTest.sh
# 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)" )
HEIGHT=11
fi
elif [ ${setupStep} -lt 100 ]; then
# continue setup
BACKTITLE="${hostname} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
else
# check if LND needs re-setup
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
if [ ${wallet} -eq 0 ] || [ ${macaroon} -eq 0 ] || [ ${config} -eq 0 ] || [ ${tls} -eq 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 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 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
#forward to main menu
/home/admin/00mainMenu.sh
exit 0
fi
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
CLOSE)
exit 1;
;;
BITCOIN)
sed -i "s/^network=.*/network=bitcoin/g" ${infoFile}
sed -i "s/^chain=.*/chain=main/g" ${infoFile}
/home/admin/10setupBlitz.sh
exit 1;
;;
LITECOIN)
sed -i "s/^network=.*/network=litecoin/g" ${infoFile}
sed -i "s/^chain=.*/chain=main/g" ${infoFile}
/home/admin/10setupBlitz.sh
exit 1;
;;
CONTINUE)
/home/admin/10setupBlitz.sh
exit 1;
;;
OFF)
echo ""
echo "LCD turns white when shutdown complete."
echo "Then wait 5 seconds and disconnect power."
echo "-----------------------------------------------"
echo "stop lnd - please wait .."
sudo systemctl stop lnd
echo "stop ${network}d (1) - please wait .."
sudo -u bitcoin ${network}-cli stop
sleep 10
echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d
sleep 3
sync
echo "starting shutdown ..."
sudo shutdown now
exit 0
;;
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
;;
DELETE)
sudo /home/admin/XXcleanHDD.sh
sudo shutdown -r now
exit 0
;;
X)
lncli -h
echo "OK you now on the command line."
echo "You can return to the main menu with the command:"
echo "raspiblitz"
;;
R)
/home/admin/00raspiblitz.sh
;;
U) # unlock
/home/admin/AAunlockLND.sh
/home/admin/00raspiblitz.sh
;;
esac

45
home.admin/00settingsMenuServices.sh

@ -11,6 +11,7 @@ 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 [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
if [ ${#chain} -eq 0 ]; then chain="main"; fi if [ ${#chain} -eq 0 ]; then chain="main"; fi
if [ ${#backupTorrentSeeding} -eq 0 ]; then backupTorrentSeeding="off"; fi
echo "map chain to on/off" echo "map chain to on/off"
chainValue="off" chainValue="off"
@ -41,6 +42,7 @@ CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to a
4 'Run behind TOR' ${runBehindTor} \ 4 'Run behind TOR' ${runBehindTor} \
5 'RTL Webinterface' ${rtlWebinterface} \ 5 'RTL Webinterface' ${rtlWebinterface} \
6 'LND Auto-Unlock' ${autoUnlock} \ 6 'LND Auto-Unlock' ${autoUnlock} \
7 'Backup Torrent Seeding' ${backupTorrentSeeding} \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
dialogcancel=$? dialogcancel=$?
echo "done dialog" echo "done dialog"
@ -213,6 +215,49 @@ else
echo "LND Autounlock Setting unchanged." echo "LND Autounlock Setting unchanged."
fi fi
# Backup Torrent Seeding
choice="off"; check=$(echo "${CHOICES}" | grep -c "7")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${backupTorrentSeeding}" != "${choice}" ]; then
echo "BACKUP TORRENT SEEDING Setting changed .."
anychange=1
if [ "${choice}" = "on" ]; then
whiptail --title "Experimental Feature" --yes-button "Activate" --no-button "Dont Activate" --yesno "The Backup Torrent Seeding is still a very early
experimental feature and could compromise your
Lightning Node stability.
Are you sure that you want to activate it?
" 11 54
if [ $? -eq 0 ]; then
/home/admin/50torrentHDD.sh backup-torrent-hosting
dialog --backtitle "RaspiBlitz Settings" --title " OK " --msgbox "
BACKUP TORRENT SEEDING IS NOW ACTIVE
-------------------------------------
If possible forward ports 49200-49250
from your router to this RaspiBlitz.
During initial torrent download your
RaspiBlitz can be slow.
" 13 42
else
echo
echo "Skipping Backup Torrent Seeding ..."
echo
sleep 3
fi
else
echo "Stopping Torrents and Cleaning Up ..."
/home/admin/50torrentHDD.sh cleanup
echo "BACKUP TORRENT SEEDING IS NOW OFF"
needsReboot=1
fi
else
echo "LND Autounlock Setting unchanged."
fi
if [ ${anychange} -eq 0 ]; then if [ ${anychange} -eq 0 ]; then
dialog --pause "Hint: Use Spacebar to check/uncheck services." 8 58 5 dialog --pause "Hint: Use Spacebar to check/uncheck services." 8 58 5
exit 0 exit 0

177
home.admin/05hardwareTest.sh

@ -0,0 +1,177 @@
#!/bin/bash
# A solid hardware setup is important to garantuee stability of data
# This script checks the hardware and gives user feedback.
# Start with parameter "no-new-stresstest" to just use the already
# made stresstest report during boostrap script.
# INFOFILE - state data from bootstrap
source /home/admin/raspiblitz.info
source /home/admin/_version.info
clear
echo "*** Hardware Test Report ***"
echo ""
# check for parameter
parameter="$1"
if [ "${parameter}" != "no-new-stresstest" ]; then
sudo /home/admin/config.scripts/blitz.stresstest.sh /home/admin/stresstest.report
echo ""
fi
# load the stresstest values
source /home/admin/stresstest.report
#########################
# Explain Report to User
#########################
# check for power issues
showPowerImproveInfo=0
if [ ${powerWARN} -gt 0 ]; then
showPowerImproveInfo=1
if [ ${powerFAIL} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${powerMIN}" --title " POWER SUPPLY CRITICAL " --msgbox "
Your power supply was FAILING the stress test (${powerMIN}).
Most reports of data loss are caused by weak power supplies.
Also a lot of RaspiBlitz setups fail because of weak power supplies.
To SHUTDOWN and upgrade the Power Supply is HIGHLY RECOMMENDED.
See upcomming screen on detailed info how to improve on power supply.
" 14 78
else
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${powerMIN}" --title " Power Supply Warning " --msgbox "
Your power supply seems OK - but could be better for stable operations.
A replacement/upgrade of the Power Supply is recommended if possible.
Because most reports of data loss are caused by weak power supplies.
See upcomming screen on detailed info how to improve on power supply.
" 12 78
fi
fi
if [ ${#undervoltageReports} -gt 0 ]; then
if [ ${undervoltageReports} -gt 0 ]; then
showPowerImproveInfo=1
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Runtime Undervoltages Detected " --msgbox "
Already during runtime of RaspiBlitz Undervoltage Reports were detected.
A upgrade of the Power Supply is strongly recommended (see next screen).
You should see the number of outages on your LCD as an ongoing counting.
Note that after replacement of power supply this number is not set to 0.
As long that counting is not going further up you are good.
" 13 78
fi
fi
if [ ${showPowerImproveInfo} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " What todo on Power Issues " --msgbox "
To improve on power issues an upgrade of the power supply is recommended.
Check if you have the latest power supply listed in your shopping list.
If you have that one, please report on GitHub that alternative is needed.
In general a good power supply needs to fullfill this three points:
- needs to deliver at least 3 Ampere
- needs to deliver a stable >=5V output (big & clunky is good)
- needs a thick cable (low AWG score) & best is no switch
If you think all is good with your power supply please also re-run test
up to 3 times. Sometimes a good power supply has 1 or 2 bad measurements.
" 18 78
choice=$(whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --menu "What todo about Power Issues?" 12 60 6 \
TESTAGAIN "Run Test again to be sure." \
CONTINUE "I take the risk - continue." \
SHUTDOWN "Shutdown to change hardware." 3>&1 1>&2 2>&3)
if [ ${#choice} -eq 0 ]; then
choice="CONTINUE"
fi
if [ "${choice}" == "TESTAGAIN" ]; then
echo "Shutting down ..."
sudo /home/admin/05hardwareTest.sh
exit 0
elif [ "${choice}" == "SHUTDOWN" ]; then
echo "Shutting down ..."
sudo shutdown now
exit 1
else
echo "OK continue .."
fi
fi
# check for heat issues
showHeatImproveInfo=0
if [ ${tempWARN} -gt 0 ]; then
showHeatImproveInfo=1
if [ ${tempFAIL} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${tempMAX}" --title " HEAT MANAGEMENT CRITICAL " --msgbox "
Your RaspiBlitz is getting MUCH TOO HOT (${tempMAX}).
The system is getting very slow when hot - thats not a NO GO but bad.
An upgrade of the Heat Management is HIGHLY RECOMMENDED.
See upcomming screen on detailed info how to improve heat management.
" 12 78
else
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${tempMAX}" --title " Heat Management Warning " --msgbox "
Your RaspiBlitz is getting a bit too hot (${tempMAX}).
The system is getting slow when hot - thats not a NO GO but bad.
An upgrade of the Heat Management is recommended if possible.
See upcomming screen on detailed info how to improve heat management.
" 12 78
fi
fi
if [ ${showHeatImproveInfo} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " What todo on Heat Issues " --msgbox "
To improve on heat issues an upgrade of the casing is recommended.
Check if you have the latest casing listed in your shopping list.
The lastest casing is a big heat sink to prevent overheating.
If you have that one, check if its applied correctly to CPU.
Alternative casings should add some passive/active heat sinks.
In extreme cases consider some external fan helping out.
Again a RaspiBlitz getting hot can be tolerated. But it is
slowing down your CPU and may reduce the lifetime of hardware.
" 16 72
choice=$(whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --menu "What todo about Heat Issues?" 12 60 6 \
TESTAGAIN "Run Test again to be sure." \
CONTINUE "I take the risk - continue." \
SHUTDOWN "Shutdown to change hardware." 3>&1 1>&2 2>&3)
if [ ${#choice} -eq 0 ]; then
choice="CONTINUE"
fi
if [ "${choice}" == "TESTAGAIN" ]; then
echo "Shutting down ..."
sudo /home/admin/05hardwareTest.sh
exit 0
elif [ "${choice}" == "SHUTDOWN" ]; then
echo "Shutting down ..."
sudo shutdown now
exit 1
else
echo "OK continue .."
fi
fi
if [ ${showPowerImproveInfo} -eq 0 ] && [ ${showHeatImproveInfo} -eq 0 ]; then
dialog --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --msgbox "
RaspiBlitz hardware setup looks good :)
Your are ready to continue - have fun.
" 8 43
fi

44
home.admin/10setupBlitz.sh

@ -27,12 +27,22 @@ if [ ${#setupStep} -eq 0 ];then
setupStep=0 setupStep=0
fi 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 setup if ready --> REBOOT
if [ ${setupStep} -gt 89 ];then if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})" echo "FINISH by setupstep(${setupStep})"
sleep 3 sleep 3
sudo ./90finishSetup.sh sudo /home/admin/90finishSetup.sh
sudo ./95finalSetup.sh sudo /home/admin/95finalSetup.sh
exit 0 exit 0
fi fi
@ -54,8 +64,8 @@ if [ ${lndRunning} -eq 1 ]; then
fi fi
if [ ${locked} -gt 0 ]; then if [ ${locked} -gt 0 ]; then
# LND wallet is locked # LND wallet is locked
./AAunlockLND.sh /home/admin/AAunlockLND.sh
./10setupBlitz.sh /home/admin/10setupBlitz.sh
exit 0 exit 0
fi fi
@ -71,12 +81,12 @@ if [ ${lndRunning} -eq 1 ]; then
if [ ${chainSyncing} -eq 1 ]; then if [ ${chainSyncing} -eq 1 ]; then
echo "Sync Chain ..." echo "Sync Chain ..."
sleep 3 sleep 3
./70initLND.sh /home/admin/70initLND.sh
exit 0 exit 0
fi fi
# check if lnd is scanning blockchain # check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo | grep "synced_to_chain") lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | grep "synced_to_chain")
lndSyncing=1 lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c) lndSyncing=$(echo "${chainInfo}" | grep "false" -c)
@ -84,15 +94,15 @@ if [ ${lndRunning} -eq 1 ]; then
if [ ${lndSyncing} -eq 1 ]; then if [ ${lndSyncing} -eq 1 ]; then
echo "Sync LND ..." echo "Sync LND ..."
sleep 3 sleep 3
./70initLND.sh /home/admin/70initLND.sh
exit 0 exit 0
fi fi
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup # if unlocked, blockchain synced and LND synced to chain .. finisch Setup
echo "FINSIH ... " echo "FINSIH ... "
sleep 3 sleep 3
sudo ./90finishSetup.sh sudo /home/admin/90finishSetup.sh
sudo ./95finalSetup.sh sudo /home/admin/95finalSetup.sh
exit 0 exit 0
fi #end - when lighting is running fi #end - when lighting is running
@ -113,7 +123,7 @@ fi
if [ ${bitcoinRunning} -eq 1 ]; then if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - ${network}d is running" echo "OK - ${network}d is running"
echo "Next step run Lightning" echo "Next step run Lightning"
./70initLND.sh /home/admin/70initLND.sh
exit 1 exit 1
else else
echo "${network} still not running" echo "${network} still not running"
@ -143,7 +153,7 @@ if [ ${mountOK} -eq 1 ]; then
if [ ${blockchainDataExists} -eq 1 ]; then if [ ${blockchainDataExists} -eq 1 ]; then
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
./XXdebugLogs.sh /home/admin/XXdebugLogs.sh
echo "UNKOWN STATE - there is blockain data config, but blockchain service is not running" 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 "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Or something with the config is not correct." echo "Or something with the config is not correct."
@ -151,7 +161,7 @@ if [ ${mountOK} -eq 1 ]; then
exit 1 exit 1
else else
echo "Got mounted blockchain, but no config and running service yet --> finish HDD" echo "Got mounted blockchain, but no config and running service yet --> finish HDD"
./60finishHDD.sh /home/admin/60finishHDD.sh
exit 1 exit 1
fi fi
fi fi
@ -163,7 +173,7 @@ if [ ${mountOK} -eq 1 ]; then
noScreenSession=$(screen -ls | grep -c "No Sockets found") noScreenSession=$(screen -ls | grep -c "No Sockets found")
if [ ${noScreenSession} -eq 0 ]; then if [ ${noScreenSession} -eq 0 ]; then
echo "found torrent data .. resuming" echo "found torrent data .. resuming"
./50torrentHDD.sh /home/admin/50torrentHDD.sh
exit 1 exit 1
fi fi
fi fi
@ -175,7 +185,7 @@ if [ ${mountOK} -eq 1 ]; then
noScreenSession=$(screen -ls | grep -c "No Sockets found") noScreenSession=$(screen -ls | grep -c "No Sockets found")
if [ ${noScreenSession} -eq 0 ]; then if [ ${noScreenSession} -eq 0 ]; then
echo "found download in data .. resuming" echo "found download in data .. resuming"
./50downloadHDD.sh /home/admin/50downloadHDD.sh
exit 1 exit 1
fi fi
fi fi
@ -235,7 +245,7 @@ fi # end HDD is already auto-mountes
if [ ${setupStep} -eq 0 ]; then if [ ${setupStep} -eq 0 ]; then
# run initial user dialog # run initial user dialog
./20setupDialog.sh /home/admin/20setupDialog.sh
# set SetupState # set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile} sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile}
@ -247,11 +257,11 @@ formatExt4OK=$(lsblk -o UUID,NAME,FSTYPE,SIZE,LABEL,MODEL | grep BLOCKCHAIN | gr
if [ ${formatExt4OK} -eq 1 ]; then if [ ${formatExt4OK} -eq 1 ]; then
echo "HDD was already initialized/prepared" echo "HDD was already initialized/prepared"
echo "Now needs to be mounted" echo "Now needs to be mounted"
./40addHDD.sh /home/admin/40addHDD.sh
exit 1 exit 1
fi fi
# the HDD had no init yet # the HDD had no init yet
echo "init HDD ..." echo "init HDD ..."
./30initHDD.sh /home/admin/30initHDD.sh
exit 1 exit 1

1
home.admin/20recoverDialog.sh

@ -46,6 +46,7 @@ ACTUAL/OLD Password C to re-activate the
Auto-Unlock feature. Enter a empty password Auto-Unlock feature. Enter a empty password
to deactivate the Auto-Unlock feature. to deactivate the Auto-Unlock feature.
" 10 52 " 10 52
echo "Activating Auto-Unlock (please wait) .."
sudo /home/admin/config.scripts/lnd.autounlock.sh on sudo /home/admin/config.scripts/lnd.autounlock.sh on
dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52 dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52

16
home.admin/30initHDD.sh

@ -70,6 +70,22 @@ if [ ${existsHDD} -eq 1 ]; then
echo "FAIL - HDD is mounted" echo "FAIL - HDD is mounted"
echo "If you really want to reinit the HDD, then unmount the HDD first and try again" echo "If you really want to reinit the HDD, then unmount the HDD first and try again"
else else
echo ""
dialog --title "Format HDD" --yes-button "Yes" --no-button "Cancel" --yesno "RaspiBlitz detected a Hard Disk Drive (HDD).
It will get formatted to EXT4 to be usefull.
This will DELETE ALL FORMER DATA on the HDD.
Is it OK to delete HDD for fresh RaspiBlitz?
" 10 48
if [ $? -eq 1 ]; then
dialog --title "Replace HDD" --msgbox "OK. RaspiBlitz will shutdown now.
Please disconnect Power then.
Backup HDD data or connect another one.
Then Power up again." 8 39
sudo shutdown now
exit 1
fi
clear
echo "" echo ""
echo "*** Formatting the HDD ***" echo "*** Formatting the HDD ***"
echo "WARNING ALL DATA ON HDD WILL GET DELETED - CAN TAKE SOME TIME" echo "WARNING ALL DATA ON HDD WILL GET DELETED - CAN TAKE SOME TIME"

6
home.admin/40addHDD.sh

@ -53,7 +53,7 @@ if [ ${existsHDD} -gt 0 ]; then
# init the RASPIBLITZ Config # init the RASPIBLITZ Config
configFile="/mnt/hdd/raspiblitz.conf" configFile="/mnt/hdd/raspiblitz.conf"
configExists=$(sudo ls ${configFile} | grep -c 'raspiblitz.conf') configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf')
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 0 ]; then
# create file and use init values from raspiblitz.info # create file and use init values from raspiblitz.info
@ -72,7 +72,7 @@ if [ ${existsHDD} -gt 0 ]; then
# sanity check on IP data # sanity check on IP data
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349 # see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "-> sanity check of IP data: ${freshPublicIP}" echo "-> sanity check of IP data:"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6" echo "OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
@ -87,7 +87,7 @@ if [ ${existsHDD} -gt 0 ]; then
echo "WARNING: No publicIP information at all yet - working with placeholder : ${localIP}" echo "WARNING: No publicIP information at all yet - working with placeholder : ${localIP}"
freshPublicIP="${localIP}" freshPublicIP="${localIP}"
fi fi
echo "publicIP=${freshPublicIP}" >> $configFile echo "publicIP='${freshPublicIP}'" >> $configFile
fi fi

2
home.admin/50downloadHDD.sh

@ -143,7 +143,7 @@ if [ ${finalSize} -lt ${targetSize} ]; then
case $response in case $response in
1) sudo rm -rf /mnt/hdd/download ;; 1) sudo rm -rf /mnt/hdd/download ;;
esac esac
./00mainMenu.sh ./00raspiblitz.sh
exit 1; exit 1;
else else

165
home.admin/50torrentHDD.sh

@ -1,33 +1,29 @@
#!/bin/bash #!/bin/bash
echo ""
# see background_downloadBlockchain.md for info # POSSOBLE PARAMETERS:
# why there are two torrent files
## get basic info # backup-torrent-hosting
source /home/admin/raspiblitz.info # to just kick of the torrent downloads in the background during
# regular RaspiBlitz running. So you support torrent hosting and have a blockchain backup ready just in case.
# cleanup
# to stop background torrents and clean up
# if setup was done - remove old data # status
if [ "${setupStep}" = "100" ]; then # to get info backround torrent hosting
echo "stopping services ..."
sudo systemctl stop lnd
sudo systemctl stop ${network}d
fi
# make sure rtorrent is available
sudo apt-get install rtorrent -y
echo ""
echo "" # stop
echo "*** Torrent Files ***" # just stopping the download - not switching off
## get basic info
source /home/admin/raspiblitz.info
# torrent files that are available # torrent files that are available
# in directory /home.admin/assets/ # in directory /home.admin/assets/
# WITHOUT THE '.torrent' ENDING # WITHOUT THE '.torrent' ENDING
bitcoinBase="raspiblitz-bitcoin1-2018-10-13-base" bitcoinBase="raspiblitz-bitcoin1-2018-10-13-base"
bitcoinUpdate="raspiblitz-bitcoin1-2019-01-16-update" bitcoinUpdate="raspiblitz-bitcoin1-2019-04-09-update"
litecoinBase="raspiblitz-litecoin1-2018-11-18-base" litecoinBase="raspiblitz-litecoin1-2018-11-18-base"
litecoinUpdate="raspiblitz-litecoin1-2018-11-18-update" litecoinUpdate="raspiblitz-litecoin1-2018-11-18-update"
@ -39,13 +35,85 @@ if [ "$network" = "litecoin" ]; then
baseTorrentFile=${litecoinBase} baseTorrentFile=${litecoinBase}
updateTorrentFile=${litecoinUpdate} updateTorrentFile=${litecoinUpdate}
fi fi
echo "base : ${baseTorrentFile}" echo "# TORRENT-FILES"
echo "update : ${updateTorrentFile}" echo "baseTorrent='${baseTorrentFile}'"
sleep 1 echo "updateTorrent='${updateTorrentFile}'"
targetDir="/mnt/hdd/torrent" targetDir="/mnt/hdd/torrent"
sessionDir="/home/admin/.rtorrent.session" sessionDir="/home/admin/.rtorrent.session"
# BACKUP TORRENT SEEDING
if [ "$1" == "stop" ] || [ "$1" == "cleanup" ]; then
echo "Stopping Torrents ..."
sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
sudo pkill -P ${sessionPID}
fi
sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
sudo pkill -P ${sessionPID}
fi
fi
if [ "$1" == "stop" ] || [ "$1" == "cleanup" ]; then
echo "Stopping Torrents ..."
sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
sudo pkill -P ${sessionPID}
fi
sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
sudo pkill -P ${sessionPID}
fi
if [ "$1" == "stop" ]; then
exit 0
fi
echo "Deleting all possible old (version) torrent data ..."
sudo rm -r /home/admin/.rtorrent.session 2>/dev/null
sudo rm -r /mnt/hdd/torrent 2>/dev/null
echo "Changing config ..."
sudo sed -i "s/^backupTorrentSeeding=.*/backupTorrentSeeding=off/g" /mnt/hdd/raspiblitz.conf
echo "DONE"
exit
fi
if [ "$1" == "status" ]; then
echo "# BASE TORRENT - for details call:"
echo "# screen -S blockchain -X hardcopy .temp.out && cat ./.temp.out && rm ./.temp.out"
sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
echo "baseSeeding=1"
else
echo "baseSeeding=0"
fi
torrentComplete=$(cat ${sessionDir}/blockchain/*.torrent.rtorrent 2>/dev/null | grep ':completei1' -c)
echo "baseComplete=${torrentComplete}"
echo "# UPDATE TORRENT - for details call:"
echo "# screen -S update -X hardcopy .temp.out && cat ./.temp.out && rm ./.temp.out"
sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs)
if [ ${#sessionPID} -gt 0 ]; then
echo "updateSeeding=1"
else
echo "updateSeeding=0"
fi
torrentComplete=$(cat ${sessionDir}/update/*.torrent.rtorrent 2>/dev/null | grep ':completei1' -c)
echo "updateComplete=${torrentComplete}"
exit
fi
# make sure folders exist
sudo mkdir ${sessionDir} 2>/dev/null sudo mkdir ${sessionDir} 2>/dev/null
sudo mkdir ${targetDir} 2>/dev/null
sudo mkdir ${sessionDir}/blockchain/ 2>/dev/null
sudo mkdir ${sessionDir}/update/ 2>/dev/null
# make sure rtorrent is available
sudo apt-get install rtorrent -y 1>/dev/null 2>/dev/null
# if setup was done - remove old data
if [ "${setupStep}" = "100" ] && [ ${#1} -eq 0 ]; then
echo "stopping servcies ..."
sudo systemctl stop lnd
sudo systemctl stop ${network}d
fi
############################## ##############################
# CHECK TORRENT 1 "BLOCKCHAIN" # CHECK TORRENT 1 "BLOCKCHAIN"
@ -63,9 +131,7 @@ if [ ${torrentComplete1} -eq 0 ]; then
# start torrent download in screen session # start torrent download in screen session
echo "starting torrent: blockchain" echo "starting torrent: blockchain"
command1="sudo rtorrent -n -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent" command1="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/blockchain/ /home/admin/assets/${baseTorrentFile}.torrent"
sudo mkdir ${targetDir} 2>/dev/null
sudo mkdir ${sessionDir}/blockchain/ 2>/dev/null
screenCommand="screen -S blockchain -L screen.log -dm ${command1}" screenCommand="screen -S blockchain -L screen.log -dm ${command1}"
echo "${screenCommand}" echo "${screenCommand}"
bash -c "${screenCommand}" bash -c "${screenCommand}"
@ -89,9 +155,7 @@ if [ ${torrentComplete2} -eq 0 ]; then
# start torrent download in screen session # start torrent download in screen session
echo "starting torrent: update" echo "starting torrent: update"
command2="sudo rtorrent -n -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent" command2="sudo nice -n 10 chrt -r 1 rtorrent -n -p 49200-49250 -d ${targetDir} -s ${sessionDir}/update/ /home/admin/assets/${updateTorrentFile}.torrent"
sudo mkdir ${targetDir} 2>/dev/null
sudo mkdir ${sessionDir}/update/ 2>/dev/null
screenCommand="screen -S update -L screen.log -dm ${command2}" screenCommand="screen -S update -L screen.log -dm ${command2}"
echo "${screenCommand}" echo "${screenCommand}"
bash -c "${screenCommand}" bash -c "${screenCommand}"
@ -100,6 +164,45 @@ if [ ${torrentComplete2} -eq 0 ]; then
fi fi
sleep 2 sleep 2
##############################
# BACKUP TORRENT SEEDING
##############################
# just let torrent start and run in the background
if [ "$1" == "backup-torrent-hosting" ]; then
# changing config - so it can be startup again after a reboot by bootstrap
source /mnt/hdd/raspiblitz.conf
if [ ${#backupTorrentSeeding} -eq 0 ]; then
echo "backupTorrentSeeding=on" >> /mnt/hdd/raspiblitz.conf
else
sudo sed -i "s/^backupTorrentSeeding=.*/backupTorrentSeeding=on/g" /mnt/hdd/raspiblitz.conf
fi
# set the torrents processes to cpulimit 25%
sleep 6
echo ""
rtorrentPIDs=$(ps axf | grep "rtorrent" | awk '{$1=$1;print}' | cut -d' ' -f1)
while read -r pid ; do
ps ${pid} | grep "rtorrent"
echo "---> reducing this rTorrent process to 25% CPU"
sudo cpulimit -p ${pid} -l 25 &
echo ""
done < <(echo "${rtorrentPIDs}")
sleep 6
# set the torrents processes to cpulimit 20%
#sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs)
#echo "Putting rTorrent blockchain 'BASE' (PID=${sessionPID}) to background ... (please wait)"
#sudo cpulimit -p ${sessionPID} -l 25 &
#sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs)
#echo "Putting rTorrent blockchain 'UPDATE' (PID=${sessionPID}) to background ... (please wait)"
#sudo cpulimit -p ${sessionPID} -l 25 &
echo "Done BACKUP TORRENT HOSTING"
exit
fi
############################## ##############################
# MONITOR PROGRESS # MONITOR PROGRESS
############################## ##############################
@ -121,7 +224,7 @@ while :
echo "NOTICE: This can take multiple hours or days !!" echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later." echo "Its OK to close terminal now and SSH back in later."
echo "If u see the torrents 100% downloaded and verified," echo "If u see the torrents 100% downloaded and verified,"
echo "press X to continue. Also press x to abort download" echo "press x to continue. Also press x to abort download"
echo "before 100% if you want to switch to another option." echo "before 100% if you want to switch to another option."
echo "****************************************************" echo "****************************************************"
echo "" echo ""
@ -258,7 +361,7 @@ if [ ${torrentError} -gt 0 ]; then
case $response in case $response in
1) sudo rm -rf ${targetDir}; sudo rm -rf ${sessionDir} ;; 1) sudo rm -rf ${targetDir}; sudo rm -rf ${sessionDir} ;;
esac esac
./00mainMenu.sh ./00raspiblitz.sh
exit 1; exit 1;
fi fi
@ -281,8 +384,8 @@ date +%s
echo "can take 10-60 minutes... please wait" echo "can take 10-60 minutes... please wait"
sudo mkdir /mnt/hdd/${network} 2>/dev/null sudo mkdir /mnt/hdd/${network} 2>/dev/null
sudo mv ${targetPath1}/* /mnt/hdd/${network}/ sudo mv ${targetPath1}/* /mnt/hdd/${network}/
sudo cp -r ${targetPath2}/* /mnt/hdd/${network}/ sudo rm -r ${sessionDir}/blockchain
sudo rm -r ${targetDir} sudo cp --verbose -r ${targetPath2}/* /mnt/hdd/${network}/
echo "OK" echo "OK"
date +%s date +%s

384
home.admin/70initLND.sh

@ -1,30 +1,43 @@
#!/bin/bash #!/bin/bash
echo ""
## get basic info ## get basic info
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# verify that bitcoin is running # CHECK #########
echo "*** Checking ${network} ***"
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) bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then if [ ${bitcoinRunning} -eq 0 ]; then
#doublecheck
bitcoinRunning=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | grep -c verificationprogress) bitcoinRunning=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | grep -c verificationprogress)
fi fi
if [ ${bitcoinRunning} -eq 0 ]; then if [ ${bitcoinRunning} -eq 0 ]; then
# HDD is not available yet whiptail --title "70initLND - WARNING" --yes-button "Retry" --no-button "EXIT+Logs" --yesno "Service ${network}d is not running." 8 50
echo "FAIL - ${network}d is not running" if [ $? -eq 0 ]; then
echo "recheck with orignal tutorial -->" /home/admin/70initLND.sh
echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md" else
/home/admin/XXdebugLogs.sh
fi
exit 1
fi fi
echo "OK - ${network}d is running"
echo ""
# verify that chainnetwork is ready # CHECK #########
echo "*** Check ${network} Responding *** (can take a while)"
chainIsReady=0 chainIsReady=0
loopCount=0 loopCount=0
echo "*** Wait until ${network}d is ready ..."
while [ ${chainIsReady} -eq 0 ] while [ ${chainIsReady} -eq 0 ]
do do
loopCount=$(($loopCount +1)) loopCount=$(($loopCount +1))
@ -57,11 +70,14 @@ while [ ${chainIsReady} -eq 0 ]
fi fi
done done
###### LND Config # CHECK #########
echo "*** LND Config ***"
configExists=$( sudo ls /mnt/hdd/lnd/ | grep -c lnd.conf ) echo "*** Check LND Config ***"
configExists=$( sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c lnd.conf )
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 0 ]; then
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
source <(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "rpcpassword" | sed 's/^[a-z]*\./lnd/g')
sudo sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${rpcpassword}/g" /mnt/hdd/lnd/lnd.conf
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
if [ -d /home/bitcoin/.lnd ]; then if [ -d /home/bitcoin/.lnd ]; then
echo "OK - LND config written" echo "OK - LND config written"
@ -75,11 +91,14 @@ fi
echo "" echo ""
###### Start LND ###### Start LND
echo "*** Starting LND ***" echo "*** Starting LND ***"
lndRunning=$(sudo systemctl status lnd.service 2>/dev/null | grep -c running) lndRunning=$(sudo systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 0 ]; then if [ ${lndRunning} -eq 0 ]; then
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service sudo systemctl stop lnd 2>/dev/null
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service 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 cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service sudo chmod +x /etc/systemd/system/lnd.service
sudo systemctl enable lnd sudo systemctl enable lnd
@ -88,8 +107,8 @@ if [ ${lndRunning} -eq 0 ]; then
dialog --pause " Starting LND - please wait .." 8 58 120 dialog --pause " Starting LND - please wait .." 8 58 120
fi fi
###### Check LND is running ###### Check LND starting
lndRunning=0
while [ ${lndRunning} -eq 0 ] while [ ${lndRunning} -eq 0 ]
do do
lndRunning=$(sudo systemctl status lnd.service | grep -c running) lndRunning=$(sudo systemctl status lnd.service | grep -c running)
@ -103,69 +122,289 @@ done
echo "OK - LND is running" echo "OK - LND is running"
echo "" echo ""
###### Instructions on Creating LND Wallet ###### 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) walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
echo "walletExists(${walletExists})" echo "walletExists(${walletExists})"
sleep 2 sleep 2
if [ ${walletExists} -eq 0 ]; then if [ ${walletExists} -eq 0 ]; then
# setup state signals, that no wallet has been created yet # UI: Ask if user wants NEW wallet or RECOVER a wallet
dialog --backtitle "RaspiBlitz - LND Lightning Wallet (${network}/${chain})" --msgbox " OPTIONS=(NEW "Setup a brand new Lightning Node (DEFAULT)" \
${network} and Lighthing Services are installed. OLD "I had a old Node I want to recover/restore")
You now need to setup your Lightning Wallet: CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
echo "choice($CHOICE)"
We will now call the command: lncli create
lncli = Lightning Network Command Line Interface
Learn more: https://api.lightning.community
Press OK and follow the 'Helping Instructions'.
" 14 52
clear
echo "****************************************************************************"
echo "Helping Instructions --> for creating a new LND Wallet"
echo "****************************************************************************"
echo "A) For 'Wallet Password' use your PASSWORD C --> !! minimum 8 characters !!"
echo "B) Answere 'n' because you dont have a 'cipher seed mnemonic' (24 words) yet"
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************"
echo ""
echo "lncli --chain=${network} create"
# execute command and monitor error
_error="./.error.out"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create 2>$_error
error=`cat ${_error}`
if [ ${#error} -gt 0 ]; then
echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo "${error}"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "Press ENTER to retry ... or CTRL-c to EXIT"
read key
echo "Starting RETRY ..."
./70initLND.sh
exit 1
fi
echo "" if [ "${CHOICE}" == "NEW" ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!! Make sure to write down the 24 words (cipher seed mnemonic) !!!" ############################
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" # NEW WALLET
echo "If you are ready. Press ENTER." ############################
read key
# let user enter password c
sudo shred /home/admin/.pass.tmp 2>/dev/null
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp
passwordC=`sudo cat /home/admin/.pass.tmp`
sudo shred /home/admin/.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
echo "Generating new Wallet ...."
source /home/admin/python-env-lnd/bin/activate
python /home/admin/config.scripts/lnd.initwallet.py new ${passwordC} > /home/admin/.seed.tmp
source /home/admin/.seed.tmp
sudo shred /home/admin/.pass.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
sudo sed -i "s/^setupStep=.*/setupStep=65/g" /home/admin/raspiblitz.info
else
############################
# RECOVER OLD WALLET
############################
sudo sed -i "s/^setupStep=.*/setupStep=65/g" /home/admin/raspiblitz.info 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
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 "FILE UPLOADED --> will get checked/activated after blockchain/lightning is synced"
fi
fi
clear
# let user enter password c
sudo shred /home/admin/.pass.tmp 2>/dev/null
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Set your Password C for the LND Wallet Unlock" /home/admin/.pass.tmp
passwordC=`sudo cat /home/admin/.pass.tmp`
sudo shred /home/admin/.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
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>/home/admin/.seed.tmp
wordstring=$( cat /home/admin/.seed.tmp | sed 's/[^a-zA-Z0-9 ]//g' )
shred /home/admin/.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 /home/admin/.pass.tmp 2>/dev/null
sudo /home/admin/config.scripts/blitz.setpassword.sh x "Enter extra Password D" /home/admin/.pass.tmp
passwordD=`sudo cat /home/admin/.pass.tmp`
sudo shred /home/admin/.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 /home/admin/python-env-lnd/bin/activate
source <(python /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${wordstring}" ${passwordD})
# 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
# user feedback
if [ ${#err} -eq 0 ]; then
dialog --title " SUCCESS " --msgbox "
Looks good :) LND was able to recover the wallet.
" 7 53
else
whiptail --title " FAIL " --msgbox "
Something went wrong - see info below:
${err}
${errMore}
" 13 72
sleep 3
/home/admin/70initLND.sh
exit 1
fi
fi
##### FALLBACK UNTIL config.scripts/lnd.initwallet.py WORKS
# echo "****************************************************************************"
# echo "* RECOVER LND WALLET BY SEED WORDS"
# echo "****************************************************************************"
# echo "A) For 'Wallet Password' use your old PASSWORD C"
# echo "B) For 'cipher seed mnemonic' answere 'y' and then enter your seed words"
# echo "C) On 'cipher seed passphrase' ONLY enter PASSWORD D if u used it on create"
# echo "D) On 'address look-ahead' only enter more than 2500 had lots of channels"
# echo "****************************************************************************"
# echo ""
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>/home/admin/.error.tmp
# error=`cat /home/admin/.error.tmp`
# rm /home/admin/.error.tmp 2>/dev/null
#
# if [ ${#error} -gt 0 ]; then
# echo ""
# echo "!!! FAIL !!! SOMETHING WENT WRONG:"
# echo "${error}"
# echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
# echo ""
# echo "Press ENTER to retry ..."
# read key
# echo "Starting RETRY ..."
# /home/admin/70initLND.sh
# exit 1
# fi
/home/admin/70initLND.sh
fi # END OLD WALLET
else
echo "OK - LND wallet already exists."
fi fi
dialog --pause " Waiting for LND - please wait .." 8 58 60 dialog --pause " Waiting for LND - please wait .." 8 58 60
###### Copy LND macaroons to admin ############################
# Copy LND macaroons to admin
############################
echo "" echo ""
echo "*** Copy LND Macaroons to user admin ***" echo "*** Copy LND Macaroons to user admin ***"
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon) 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 if [ ${macaroonExists} -eq 0 ]; then
./AAunlockLND.sh /home/admin/AAunlockLND.sh
sleep 3 sleep 3
fi fi
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon) macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
@ -198,17 +437,18 @@ fi
###### Unlock Wallet (if needed) ###### Unlock Wallet (if needed)
echo "*** Check Wallet Lock ***" echo "*** Check Wallet Lock ***"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) 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 if [ ${locked} -gt 0 ]; then
echo "OK - Wallet is locked ... starting unlocking dialog" echo "OK - Wallet is locked ... starting unlocking dialog"
./AAunlockLND.sh /home/admin/AAunlockLND.sh
else else
echo "OK - Wallet is already unlocked" echo "OK - Wallet is already unlocked"
fi fi
echo ""
# set SetupState (scan is done - so its 80%) # set SetupState (scan is done - so its 80%)
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
###### finishSetup ###### finishSetup
sudo ./90finishSetup.sh sudo /home/admin/90finishSetup.sh
sudo ./95finalSetup.sh sudo /home/admin/95finalSetup.sh

269
home.admin/80scanLND.sh

@ -1,91 +1,218 @@
#!/bin/bash #!/bin/bash
source /home/admin/_version.info
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
### USER PI AUTOSTART (LCD Display) # all system/service info gets detected by blitz.statusscan.sh
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
# parse the actual scanned height progress from LND logs # when admin and no other error found run LND setup check
item=0 if [ "$USER" == "admin" ] && [ ${#lndErrorFull} -eq 0 ]; then
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) lndErrorFull=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err=" | tail -1)
chain="$(echo "${blockchaininfo}" | jq -r '.chain')" fi
## TRY to get the actual progress height of scanning # 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
# 1) First try the "Rescanned through block" - it seems to happen if it restarts # bitcoin errors always first
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Rescanned through block" | tail -n1 | cut -d ']' -f2 | cut -d '(' -f2 | tr -dc '0-9') if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ] || [ "${1}" == "blockchain-error" ]; then
action="Rescanning"
# 2) Second try the "Caught up to height" - thats the usual on first scan start ####################
if [ ${#item} -eq 0 ]; then # On Bitcoin Error
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -n1 | cut -d ']' -f2 | tr -dc '0-9') ####################
action="Catching-Up"
fi
# 3) Third try the "LNWL: Filtering block" - thats the usual on later starts height=5
if [ ${#item} -eq 0 ]; then width=43
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "LNWL: Filtering block" | tail -n1 | cut -d ' ' -f7 | tr -dc '0-9') title="Blockchain Info"
action="Filtering" if [ ${uptime} -gt 600 ] || [ "${1}" == "blockchain-error" ]; then
fi infoStr=" The ${network}d service is not running.\n Login for more details:"
if [ "$USER" == "admin" ]; 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 "-> Use following command to debug: /home/admin/XXdebugLogs.sh"
echo "-> To force Main Menu run: /home/admin/00mainMenu.sh"
echo "-> To try restart: sudo shutdown -r now"
echo ""
fi
else
height=6
if [ ${#bitcoinErrorShort} -eq 0 ]; then
bitcoinErrorShort="Initial Startup - Please Wait"
fi
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Login with SSH for more details:"
if [ "$USER" == "admin" ]; then
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Please wait up to 5min ..."
fi
fi
# if no progress info # LND errors second
online=1 elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ] || [ "${1}" == "lightning-error" ]; then
if [ ${#item} -eq 0 ]; then
item="?"
# check if offline ####################
# https://en.wikipedia.org/wiki/1.1.1.1 # On LND Error
online=$(ping 1.1.1.1 -c 1 -W 2 | grep -c '1 received') ####################
fi
# get total number of blocks height=5
total=$(echo "${blockchaininfo}" | jq -r '.blocks') width=43
# put scanstate title="Lightning Info"
scanstate="${item}/${total}" if [ ${uptime} -gt 600 ] || [ "${1}" == "lightning-error" ]; then
if [ ${#lndErrorShort} -gt 0 ]; then
# get blockchain sync progress height=6
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" lndErrorShort=" ${lndErrorShort}\n"
progress=$(echo "${progress}*100" | bc) fi
if [ ${lndActive} -eq 0 ]; then
# check if blockchain is still syncing infoStr=" The LND service is not running.\n${lndErrorShort} Login for more details:"
heigh=6 else
width=44 infoStr=" The LND service is running with error.\n${lndErrorShort} Login for more details:"
isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c) fi
isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c ) if [ "$USER" == "admin" ]; then
if [ ${isWaitingBlockchain} -gt 0 ]; then clear
isInitialChainSync=1 echo ""
fi echo "****************************************"
if [ ${online} -eq 0 ]; then if [ ${lndActive} -eq 0 ]; then
heigh=7 echo "* The LND service is not running."
width=44 else
infoStr=$(echo " Waiting INTERNET CONNECTION\n RaspiBlitz cannot ping 1.1.1.1\n Local IP is ${localip}\n Please check cables and router.") echo "* The LND service is running with error."
elif [ ${isInitialChainSync} -gt 0 ]; then fi
heigh=7 echo "****************************************"
infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress} %\n Please wait - this can take some time.\n ssh admin@${localip}\n Password A" echo "If you just started some config/setup, this might be OK."
if [ "$USER" = "admin" ]; then echo
heigh=6 if [ ${startcountLightning} -gt 1 ]; then
width=53 echo "${startcountLightning} RESTARTS DETECTED - LND might be in a error loop"
infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress} %\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") 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 following command to debug: /home/admin/XXdebugLogs.sh"
echo "-> To force Main Menu run: /home/admin/00mainMenu.sh"
echo "-> To try restart: sudo shutdown -r now"
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
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 else
heigh=7
# check if wallet has any UTXO ####################
# reason see: https://github.com/lightningnetwork/lnd/issues/2326 # Sync Progress
txlines=$(sudo -u bitcoin lncli listchaintxns 2>/dev/null | wc -l) ####################
# has just 4 lines if empty
if [ ${txlines} -eq 4 ]; then # basic dialog info
infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n re-rescan every start until funding\n ssh admin@${localip}\n Password A") height=6
width=43
title="Node is Syncing (${scriptRuntime})"
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} %"
else else
infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A") syncProgress="${syncProgress} %"
if [ "$USER" = "admin" ]; then fi
heigh=6
width=53
infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") # 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 fi
elif [ ${#scanProgress} -lt 6 ]; then
scanProgress=" ${scanProgress} %"
else
scanProgress="${scanProgress} %"
fi fi
# setting info string
infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n ${actionString}"
fi fi
# display progress to user # display info to user
sleep 3 dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width}
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname})" --infobox "${infoStr}" ${heigh} ${width}

10
home.admin/90finishSetup.sh

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
echo "" echo ""
# add bonus scripts # add bonus scripts (auto install deactivated to reduce third party repos)
/home/admin/91addBonus.sh # /home/admin/91addBonus.sh
###### SWAP & FS ###### SWAP & FS
echo "" echo ""
@ -63,8 +63,8 @@ echo "allow: lightning gRPC"
sudo ufw allow 10009 comment 'lightning gRPC' sudo ufw allow 10009 comment 'lightning gRPC'
echo "allow: lightning REST API" echo "allow: lightning REST API"
sudo ufw allow 8080 comment 'lightning REST API' sudo ufw allow 8080 comment 'lightning REST API'
echo "allow: trasmission" echo "allow: transmission"
sudo ufw allow 51413 comment 'transmission' sudo ufw allow 49200:49250/tcp comment 'rtorrent'
echo "allow: local web admin" echo "allow: local web admin"
sudo ufw allow from 192.168.0.0/16 to any port 80 comment 'allow local LAN web' sudo ufw allow from 192.168.0.0/16 to any port 80 comment 'allow local LAN web'
echo "open firewall for auto nat discover (see issue #129)" echo "open firewall for auto nat discover (see issue #129)"
@ -81,4 +81,4 @@ sudo apt-get update
echo "OK - System is now up to date" echo "OK - System is now up to date"
# mark setup is done # mark setup is done
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info

4
home.admin/91addBonus.sh

@ -6,8 +6,8 @@ echo "Creating the command lnbalance as well as lnchannels which will give you a
cd cd
mkdir /home/admin/tmpScriptDL mkdir /home/admin/tmpScriptDL
cd /home/admin/tmpScriptDL cd /home/admin/tmpScriptDL
wget https://raw.githubusercontent.com/Stadicus/guides/master/raspibolt/resources/lnbalance wget https://stadicus.github.io/RaspiBolt/resources/lnbalance
wget https://raw.githubusercontent.com/Stadicus/guides/master/raspibolt/resources/lnchannels wget https://stadicus.github.io/RaspiBolt/resources/lnchannels
chmod +x lnbalance chmod +x lnbalance
chmod +x lnchannels chmod +x lnchannels
sudo cp lnchannels /usr/local/bin sudo cp lnchannels /usr/local/bin

6
home.admin/95finalSetup.sh

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
echo "" echo ""
# set raspiblitz config file
configFile="/mnt/hdd/raspiblitz.conf"
# load setup config # load setup config
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
# in case the config already exists
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# load version # load version
source /home/admin/_version.info source /home/admin/_version.info

146
home.admin/97addMobileWallet.sh

@ -4,19 +4,37 @@
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
justLocal=1
# if dynDomain is set connect from outside is possible (no notice)
if [ ${#dynDomain} -gt 0 ]; then
justLocal=0
fi
# if sshtunnel to 10009/8080 then outside reach is possible (no notice)
isForwarded=$(echo ${sshtunnel} | grep -c "10009<")
if [ ${isForwarded} -gt 0 ]; then
justLocal=0
fi
isForwarded=$(echo ${sshtunnel} | grep -c "8080<")
if [ ${isForwarded} -gt 0 ]; then
justLocal=0
fi
# check if dynamic domain is set # check if dynamic domain is set
if [ ${#dynDomain} -eq 0 ]; then if [ ${justLocal} -eq 1 ]; then
dialog --title " Just Local Network? " --yesno "If you want to connect with your RaspiBlitz whiptail --title " Just Local Network? " --yesno "If you want to connect with your RaspiBlitz
also from outside your local network you need to also from outside your local network you need to
activate 'Services' -> 'DynamicDNS' FIRST. activate 'Services' -> 'DynamicDNS' FIRST.
Or use SSH tunnel forwarding for port 10009.
For more details see chapter in GitHub README For more details see chapter in GitHub README
'Public Domain with DynamicDNS' on the service 'DynamicDNS'
https://github.com/rootzoll/raspiblitz https://github.com/rootzoll/raspiblitz
Do you JUST want to connect with your mobile Do you JUST want to connect with your mobile
when your are on the same LOCAL NETWORK? when your are on the same LOCAL NETWORK?
" 14 54 " 15 54
response=$? response=$?
case $response in case $response in
1) exit ;; 1) exit ;;
@ -25,21 +43,111 @@ fi
# Basic Options # Basic Options
OPTIONS=(ZAP "Zap Wallet (iOS)" \ OPTIONS=(ZAP "Zap Wallet (iOS)" \
SHANGO "Shango Wallet (iOS/Android)") SHANGO_IOS "Shango Wallet (iOS)" \
SHANGO_ANDROID "Shango Wallet (Android)" \
ZEUS_IOS "Zeus Wallet (iOS)" \
ZEUS_ANDROID "Zeus Wallet (Android)"
)
CHOICE=$(dialog --clear --title "Choose Mobile Wallet" --menu "" 10 40 6 "${OPTIONS[@]}" 2>&1 >/dev/tty) CHOICE=$(whiptail --clear --title "Choose Mobile Wallet" --menu "" 15 50 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
./XXdisplayQRlcd_hide.sh
clear clear
case $CHOICE in case $CHOICE in
CLOSE) CLOSE)
exit 1; exit 1;
;; ;;
SHANGO) SHANGO_IOS)
./97addMobileWalletShango.sh echo "https://testflight.apple.com/join/WwCjFnS8" > qr.txt
exit 1; ./XXdisplayLCD.sh /home/admin/assets/install_shango.jpg
;;
ZAP) whiptail --title "Install Testflight and Shango on your iOS device" \
./97addMobileWalletZap.sh --yes-button "continue" \
exit 1; --no-button "link as QR code" \
;; --yesno "At the moment this app is in public beta testing:\n\nhttps://testflight.apple.com/join/WwCjFnS8\n\nJoin testing and follow ALL instructions.\n\nWhen installed and started -> continue" 10 60
esac
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
./97addMobileWalletShango.sh
exit 1;
;;
SHANGO_ANDROID)
echo "market://details?id=com.shango" > qr.txt
./XXdisplayQRlcd.sh
whiptail --title "Install Shango on your Android Phone" \
--yes-button "continue" \
--no-button "link as QR code" \
--yesno "At the moment this app is in public beta testing:\n\nhttps://play.google.com/apps/testing/com.shango\n\nEasiest way to install scan QR code on LCD with phone.\n\nWhen installed and started -> continue" 10 60
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
./97addMobileWalletShango.sh
exit 1;
;;
ZAP)
echo "https://testflight.apple.com/join/P32C380R" > qr.txt
./XXdisplayQRlcd.sh
whiptail --title "Install Testflight and Zap on your iOS device" \
--yes-button "continue" \
--no-button "link as QR code" \
--yesno "At the moment this app is in public beta testing:\n\nhttps://testflight.apple.com/join/P32C380R\n\nJoin testing and follow ALL instructions.\n\nWhen installed and started -> continue" 10 60
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
./97addMobileWalletLNDconnect.sh RPC
exit 1;
;;
ZEUS_IOS)
echo "https://testflight.apple.com/join/gpVFzEHN" > qr.txt
./XXdisplayQRlcd.sh
whiptail --title "Install Testflight and Zeus on your iOS device" \
--yes-button "continue" \
--no-button "link as QR code" \
--yesno "At the moment this app is in public beta testing:\n\nhttps://testflight.apple.com/join/gpVFzEHN\n\nJoin testing and follow ALL instructions.\n\nWhen installed and started -> continue" 10 60
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
./97addMobileWalletLNDconnect.sh REST
exit 1;
;;
ZEUS_ANDROID)
echo "market://details?id=com.zeusln.zeus" > qr.txt
./XXdisplayQRlcd.sh
whiptail --title "Install Shango on your Android Phone" \
--yes-button "continue" \
--no-button "link as QR code" \
--yesno "Find the Zeus Wallet on the Android Play Store:\n\nhttps://play.google.com/store/apps/details?id=com.zeusln.zeus\n\nEasiest way to install scan QR code on LCD with phone.\n\nWhen installed and started -> continue." 10 60
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
./97addMobileWalletLNDconnect.sh REST
exit 1;
;;
esac

141
home.admin/97addMobileWalletLNDconnect.sh

@ -0,0 +1,141 @@
#!/bin/bash
# get service port from argument
servicePort="10009"
if [ $# -gt 0 ]; then
if [ "$1" == "RPC" ]; then
echo "running RPC mode"
servicePort="10009"
fi
if [ "$1" == "REST" ]; then
echo "running REST mode"
servicePort="8080"
fi
fi
# load raspiblitz config data
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# export go vars (if needed)
if [ ${#GOROOT} -eq 0 ]; then
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
fi
if [ ${#GOPATH} -eq 0 ]; then
export GOPATH=/usr/local/gocode
export PATH=$PATH:$GOPATH/bin
fi
# make sure go is installed
goVersion="1.11"
echo "### Check Framework: GO ###"
goInstalled=$(go version 2>/dev/null | grep -c 'go')
if [ ${goInstalled} -eq 0 ];then
echo "---> Installing GO"
wget https://storage.googleapis.com/golang/go${goVersion}.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go${goVersion}.linux-armv6l.tar.gz
sudo rm *.gz
sudo mkdir /usr/local/gocode
sudo chmod 777 /usr/local/gocode
goInstalled=$(go version 2>/dev/null | grep -c 'go')
fi
if [ ${goInstalled} -eq 0 ];then
echo "FAIL: Was not able to install GO (needed to run LndConnect)"
sleep 4
exit 1
fi
correctGoVersion=$(go version | grep -c "go${goVersion}")
if [ ${correctGoVersion} -eq 0 ]; then
echo "WARNING: You work with a untested version of GO - should be ${goVersion} .. trying to continue"
go version
sleep 6
echo ""
fi
# make sure qrcode-encoder in installed
echo "*** Setup ***"
echo ""
echo "Installing lndconnect. Please wait..."
echo ""
echo "Getting github.com/LN-Zap/lndconnect (please wait - can take several minutes) ..."
go get -d github.com/LN-Zap/lndconnect
cd $GOPATH/src/github.com/LN-Zap/lndconnect
echo ""
echo "Building github.com/LN-Zap/lndconnect ..."
make
cd
sleep 3
# default host to local IP and port
local=1
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
host="${localIP}"
port="${servicePort}"
# change host to dynDNS if set
if [ ${#dynDomain} -gt 0 ]; then
local=0
host="${dynDomain}"
echo "port ${servicePort} forwarding from dynDomain ${host}"
fi
# check if local service port is forwarded
if [ ${#sshtunnel} -gt 0 ]; then
isForwarded=$(echo ${sshtunnel} | grep -c "${servicePort}<")
if [ ${isForwarded} -gt 0 ]; then
local=0
host=$(echo $sshtunnel | cut -d '@' -f2 | cut -d ' ' -f1)
if [ "${servicePort}" == "10009" ]; then
port=$(echo $sshtunnel | awk '{split($0,a,"10009<"); print a[2]}' | cut -d ' ' -f1 | sed 's/[^0-9]//g')
elif [ "${servicePort}" == "8080" ]; then
port=$(echo $sshtunnel | awk '{split($0,a,"8080<"); print a[2]}' | cut -d ' ' -f1 | sed 's/[^0-9]//g')
fi
echo "port ${servicePort} forwarding from port ${port} from server ${host}"
else
echo "port ${servicePort} is not part of the ssh forwarding - keep default port ${servicePort}"
fi
fi
# write qr code data to an image
lndconnect --host=${host} --port=${port} --image
# display qr code image on LCD
./XXdisplayLCD.sh lndconnect-qr.png
# show pairing info dialog
msg=""
if [ ${local} -eq 1 ]; then
msg="Make sure you are on the same local network.\n(WLAN same as LAN - use WIFI not cell network on phone).\n\n"
fi
msg="You should now see the pairing QR code on the RaspiBlitz LCD.\n\n${msg}When you start the App choose to connect to your own node.\n(DIY / Remote-Node / lndconnect)\n\nClick on the 'Scan QR' button. Scan the QR on the LCD and <continue> or <show QR code> to see it in this window."
whiptail --backtitle "Connecting Mobile Wallet" \
--title "Pairing by QR code" \
--yes-button "continue" \
--no-button "show QR code" \
--yesno "${msg}" 20 65
if [ $? -eq 1 ]; then
lndconnect --host=${host} --port=${port}
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key
fi
# clean up
./XXdisplayQRlcd_hide.sh
shred lndconnect-qr.png 2> /dev/null
rm -f lndconnect-qr.png 2> /dev/null
shred qr.txt 2> /dev/null
rm -f qr.txt 2> /dev/null
echo "------------------------------"
echo "If the connection was not working:"
if [ ${#dynDomain} -gt 0 ]; then
echo "- Make sure that your router is forwarding port ${port} to the Raspiblitz with IP ${localIP}"
fi
if [ ${local} -eq 1 ]; then
echo "- Check that your WIFI devices can talk to the LAN devices on your router (deactivate IP isolation or guest mode)."
fi
echo "- check issues: https://github.com/LN-Zap/lndconnect/issues"
echo "- check issues: https://github.com/rootzoll/raspiblitz/issues"
echo ""

94
home.admin/97addMobileWalletShango.sh

@ -1,55 +1,65 @@
#!/bin/bash #!/bin/bash
clear
# load raspiblitz config data # load raspiblitz config data
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# make sure qrcode-encoder in installed # default host to local IP & port 10009
clear local=1
echo "*** Setup ***" host=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
sudo apt-get install qrencode -y port="10009"
# get local IP # change host to dynDNS if set
myip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') if [ ${#dynDomain} -gt 0 ]; then
local=0
host="${dynDomain}"
echo "port 10009 forwarding from dynDomain ${host}"
fi
# replace dyndomain if available # check if port 10009 is forwarded
if [ ${#dynDomain} -gt 0 ]; then if [ ${#sshtunnel} -gt 0 ]; then
myip="${dynDomain}" isForwarded=$(echo ${sshtunnel} | grep -c "10009<")
if [ ${isForwarded} -gt 0 ]; then
local=0
host=$(echo $sshtunnel | cut -d '@' -f2 | cut -d ' ' -f1)
port=$(echo $sshtunnel | awk '{split($0,a,"10009<"); print a[2]}' | cut -d ' ' -f1 | sed 's/[^0-9]//g')
echo "port 10009 forwarding from port ${port} from server ${host}"
else
echo "port 10009 is not part of the ssh forwarding - keep default port 10009"
fi
fi fi
clear # write qr code data to text file
echo "******************************" echo -e "${host}:${port},\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt
echo "Connect Shango Mobile Wallet"
echo "******************************"
echo ""
echo "GETTING THE APP"
echo "At the moment this app is in public beta testing:"
echo "iOS: Read https://testflight.apple.com/join/WwCjFnS8 (open on device)"
echo "Android: https://play.google.com/apps/testing/com.shango (open on device)"
echo ""
echo "*** STEP 1 ***"
if [ ${#dynDomain} -eq 0 ]; then
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
fi
echo "On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED'"
echo "(Or in the App go to --> 'Settings' > 'Connect to your LND Server')"
echo "There you see three 3 form fields to fill out. Skip those and go right to the buttons below."
echo ""
echo "Click on the 'Scan QR' button"
echo "Make the this terminal as big as possible - fullscreen would be best."
echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app."
read key
clear # display qr code on LCD
echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***" ./XXdisplayQRlcd.sh
#echo -e "${myip}:10009,\n$(xxd -p -c2000 ~/.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSIUTF8 < qr.txt
echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSI256 < qr.txt
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key
shred qr.txt
# show pairing info
clear clear
echo "Now press 'Connect' within the Shango Wallet." msg=""
echo "If its not working - check issues on GitHub:" if [ ${local} -eq 1 ]; then
echo "https://github.com/neogeno/shango-lightning-wallet/issues" msg="Once you have the app running make sure you are on the same local network (WLAN same as LAN).\n\n"
echo "" fi
msg="You should now see the pairing QR code on the RaspiBlitz LCD.\n\n${msg}On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED'\n\n(Or in the App go to --> 'Settings' > 'Connect to your LND Server') \n\nThere you see three 3 form fields to fill out. Skip those and go right to the buttons below.\n\nClick on the 'Scan QR' button. Scan the QR on the LCD and <continue> or <show QR code> to see it in this window."
whiptail --backtitle "Connecting Shango Mobile Wallet" \
--title "Setup Shango Step 1" \
--yes-button "continue" \
--no-button "show QR code" \
--yesno "${msg}" 20 70
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
# clean up
./XXdisplayQRlcd_hide.sh
shred qr.png 2> /dev/null
rm -f qr.png 2> /dev/null
shred qr.txt 2> /dev/null
rm -f qr.txt 2> /dev/null
# follow up dialog
whiptail --backtitle "Connecting Shango Mobile Wallet" \
--title "Press Connect on Shango" \
--msgbox "Now press 'Connect' within the Shango Wallet.\n\nIf its not working - check issues on GitHub:\n\nhttps://github.com/neogeno/shango-lightning-wallet/issues" 15 65

54
home.admin/97addMobileWalletZap.sh → home.admin/97addMobileWalletZeus.sh

@ -2,7 +2,7 @@
# load raspiblitz config data # load raspiblitz config data
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# export go vars (if needed) # export go vars (if needed)
if [ ${#GOROOT} -eq 0 ]; then if [ ${#GOROOT} -eq 0 ]; then
@ -15,13 +15,11 @@ if [ ${#GOPATH} -eq 0 ]; then
fi fi
# make sure go is installed # make sure go is installed
goVersion="1.11"
echo "### Check Framework: GO ###"
goInstalled=$(go version 2>/dev/null | grep -c 'go') goInstalled=$(go version 2>/dev/null | grep -c 'go')
if [ ${goInstalled} -eq 0 ];then if [ ${goInstalled} -eq 0 ];then
echo "---> Installing GO" echo "### Installing GO ###"
wget https://storage.googleapis.com/golang/go${goVersion}.linux-armv6l.tar.gz wget https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go${goVersion}.linux-armv6l.tar.gz sudo tar -C /usr/local -xzf go1.11.linux-armv6l.tar.gz
sudo rm *.gz sudo rm *.gz
sudo mkdir /usr/local/gocode sudo mkdir /usr/local/gocode
sudo chmod 777 /usr/local/gocode sudo chmod 777 /usr/local/gocode
@ -29,24 +27,16 @@ if [ ${goInstalled} -eq 0 ];then
fi fi
if [ ${goInstalled} -eq 0 ];then if [ ${goInstalled} -eq 0 ];then
echo "FAIL: Was not able to install GO (needed to run LndConnect)" echo "FAIL: Was not able to install GO (needed to run LndConnect)"
sleep 4
exit 1 exit 1
fi fi
clear
correctGoVersion=$(go version | grep -c "go${goVersion}")
if [ ${correctGoVersion} -eq 0 ]; then
echo "WARNING: You work with a untested version of GO - should be ${goVersion} .. trying to continue"
go version
sleep 6
echo ""
fi
# make sure qrcode-encoder in installed # make sure qrcode-encoder in installed
clear
echo "*** Setup ***" echo "*** Setup ***"
echo "" echo ""
echo "Installing zapconnect." echo "Installing lndconnect. Please wait..."
echo "" echo ""
echo "Getting github.com/LN-Zap/lndconnect (please wait - can take several minutes) ..." echo "Getting github.com/LN-Zap/lndconnect (please wait) ..."
go get -d github.com/LN-Zap/lndconnect go get -d github.com/LN-Zap/lndconnect
cd $GOPATH/src/github.com/LN-Zap/lndconnect cd $GOPATH/src/github.com/LN-Zap/lndconnect
echo "" echo ""
@ -57,41 +47,41 @@ sleep 3
clear clear
echo "******************************" echo "******************************"
echo "Connect Zap Mobile Wallet" echo "Connect Zeus Mobile Wallet"
echo "******************************" echo "******************************"
echo "" echo ""
echo "GETTING THE APP" echo "GETTING THE APP"
echo "At the moment this app is in closed beta testing and the source code has not been published yet." echo "At the moment this app is in alpha stages."
echo "1. Install the app 'TestFlight' from Apple Appstore. Open it and agree to all terms of services." echo "You can compile the code for iOS or Android but only an Android APK is currently available for downloads."
echo "2. Open on your iOS device https://github.com/LN-Zap/zap-iOS and follow 'Download the Alpha'" echo "Go to https://github.com/ZeusLN/zeus/releases to find the latest release."
echo "" echo ""
echo "*** PAIRING STEP 1 ***" echo "*** STEP 1 ***"
if [ ${#dynDomain} -eq 0 ]; then if [ ${#dynDomain} -eq 0 ]; then
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
fi fi
echo "During Setup of the Zap app you should get to the 'Connect Remote-Node' screen." echo "During setup of the Zeus app you should get to the 'Settings' screen."
echo "" echo ""
echo "---> Click on Scan" echo "---> Click on the Scan lndconnect config button"
echo "Make the this terminal as big as possible - fullscreen would be best." echo "Make the this terminal as big as possible - fullscreen would be best."
echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app." echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app."
read key read key
clear clear
echo "*** PAIRING STEP 2 : Click on Scan (make whole QR code fill camera) ***" echo "*** STEP 2 : Click on Scan (make whole QR code fill camera) ***"
if [ ${#dynDomain} -eq 0 ]; then if [ ${#dynDomain} -eq 0 ]; then
# If you drop the -i parameter, lndconnect will use the external IP. # If you drop the -i parameter, lndconnect will use the external IP.
lndconnect -i lndconnect -i --port=8080
else else
# when dynamic domain is set # when dynamic domain is set
lndconnect --host=${dynDomain} lndconnect --host=${dynDomain} --port=8080
fi fi
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished." echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key read key
clear clear
echo "If its not working - check issues on GitHub:" echo "If it's not working - check issues on GitHub:"
echo "https://github.com/LN-Zap/zap-iOS/issues" echo "https://github.com/ZeusLN/zeus"
echo "https://github.com/LN-Zap/lndconnect/issues" echo "https://github.com/LN-Zap/lndconnect/issues"
echo "" echo ""

133
home.admin/99checkUpdate.sh

@ -0,0 +1,133 @@
#!/bin/bash
# load raspiblitz config data
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
source /home/admin/_version.info
clear
# get latest release verison from GitHub
sudo curl -s -X GET https://raw.githubusercontent.com/rootzoll/raspiblitz/master/home.admin/_version.info > /home/admin/.version.tmp
gitHubVersionMain=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]")
gitHubVersionSub=$(cut -d"=" -f2 /home/admin/.version.tmp | cut -d'"' -f2 | cut -d"." -f2 | egrep "^[0-9]")
sudo shred /home/admin/.version.tmp
sudo rm /home/admin/.version.tmp 2>/dev/null
# check valid version info
if [ ${#gitHubVersionMain} -eq 0 ] || [ ${#gitHubVersionSub} -eq 0 ]; then
echo "FAIL: Was not able to get latest release Version from GitHub."
echo "PRESS ENTER to continue."
read key
exit 1
fi
# get local version
localVersionMain=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f1 | egrep "^[0-9]")
localVersionSub=$(cut -d"=" -f2 /home/admin/_version.info | cut -d'"' -f2 | cut -d"." -f2 | egrep "^[0-9]")
echo "github version: ${gitHubVersionMain}.${gitHubVersionSub}"
echo "local version: ${localVersionMain}.${localVersionSub}"
# compare versions
newerVersionAvailable=0
if [ ${gitHubVersionMain} -gt ${localVersionMain} ]; then
echo "Main version is higher ..."
newerVersionAvailable=1
else
if [ ${gitHubVersionMain} -lt ${localVersionMain} ]; then
echo "Strange that GutHub main version is lower then local - you maybe using a early release."
elif [ ${gitHubVersionSub} -gt ${localVersionSub} ]; then
echo "Sub version is higher ..."
newerVersionAvailable=1
fi
fi
# give feedback on version number
if [ ${newerVersionAvailable} -eq 0 ]; then
dialog --title " Update Check " --yes-button "OK" --no-button "Update Anyway" --yesno "
OK. You are running the newest version of RaspiBlitz.
" 7 57
if [ $? -eq 0 ]; then
exit 1
fi
clear
else
whiptail --title "Update Check" --yes-button "Yes" --no-button "Not Now" --yesno "
There is a new Version of RaspiBlitz available.
You are running: ${localVersionMain}.${localVersionSub}
New Version: ${gitHubVersionMain}.${gitHubVersionSub}
Do you want more Information on how to update?
" 12 52
if [ $? -eq 1 ]; then
exit 1
fi
fi
whiptail --title "Update Instructions" --yes-button "Not Now" --no-button "Start Update" --yesno "To update your RaspiBlitz to a new version:
- Download the new SD card image to your laptop:
https://github.com/rootzoll/raspiblitz
- Flash that SD card image to a new SD card
- Choose 'Start Update' below.
No need to close channels or download blockchain again.
Do you want to start the Update now?
" 16 62
if [ $? -eq 0 ]; then
exit 1
fi
whiptail --title "LND 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 LND Data
and download that file to your laptop.
Do you want to download LND Data Backup now?
" 12 58
if [ $? -eq 0 ]; then
clear
echo "*************************************"
echo "* PREPARING LND BACKUP DOWNLOAD"
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup
echo
echo "PRESS ENTER to continue once your done downloading."
read key
else
clear
echo "*************************************"
echo "* JUST MAKING BACKUP TO OLD SD CARD"
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup no-download
fi
whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno "If you start the update: The RaspiBlitz will power down.
Once the LCD is white and no LEDs are blicking anymore:
- Remove the Power from RaspiBlitz
- Exchange the old with the new SD card
- Connect Power back to the RaspiBlitz
- Follow the instructions on the LCD
Do you have the SD card with the new version image ready
and do you WANT TO START UPDATE NOW?
" 16 62
if [ $? -eq 1 ]; then
dialog --title " Update Canceled " --msgbox "
OK. RaspiBlitz will NOT update now.
" 7 39
sudo systemctl start lnd
exit 1
fi
clear
sudo shutdown now

2
home.admin/AAunlockLND.sh

@ -22,7 +22,7 @@ while :
do do
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
sleep 4 sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) 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 if [ ${locked} -eq 0 ]; then
break break
fi fi

103
home.admin/BBcashoutWallet.sh

@ -22,33 +22,32 @@ if [ ${#openChannels} -eq 0 ]; then
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 check ./XXdebugLogs.sh"
echo "************************************************" echo "************************************************"
echo "Press ENTER to return to main menu."
read key
exit 1 exit 1
fi fi
if [ ${openChannels} -gt 0 ]; then if [ ${openChannels} -gt 0 ]; then
dialog --title 'Info' --msgbox '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.' 7 58 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
echo "please wait ..." if [ $? -eq 1 ]; then
exit 1
fi
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) unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
if [ ${unconfirmed} -gt 0 ]; then if [ ${unconfirmed} -gt 0 ]; then
dialog --title 'Info' --msgbox "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 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
echo "please wait ..." if [ $? -eq 1 ]; then
fi exit 1
fi
# get available amount in on-chain wallet echo "..."
maxAmount=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${maxAmount} -eq 0 ]; then
dialog --title 'Info' --msgbox "You have 0 moveable funds available.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58
exit 1
fi fi
# let user enter the address # let user enter the address
l1="Enter on-chain address to send confirmed funds to:" l1="Enter on-chain address to send confirmed funds to:"
l2="You will send: ${maxAmount} sat" dialog --title "Where to send funds?" --inputbox "\n$l1\n" 9 75 2>$_temp
l3="Maximal fee: 20000 sat (wil be subtracted)"
dialog --title "Where to send funds?" \
--inputbox "$l1\n$l2\n$l3" 9 75 2>$_temp
if test $? -eq 0 if test $? -eq 0
then then
echo "ok pressed" echo "ok pressed"
@ -60,63 +59,33 @@ address=$(cat $_temp | xargs)
shred $_temp shred $_temp
if [ ${#address} -eq 0 ]; then 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."
read key
exit 1 exit 1
fi fi
# TODO: check address is valid for network and chain
clear clear
echo "******************************" echo "******************************"
echo "Send on-chain Funds" echo "Sweep all possible Funds"
echo "******************************" echo "******************************"
tryAgain=1
count=1
while [ ${tryAgain} -eq 1 ]
do
sleep 1
fee=$(($count * 1000))
amount=$(($maxAmount - $fee))
echo ""
echo "TRY #${count} ---> with max fee ${fee} sat:"
# execute command # execute command
command="lncli --chain=${network} --network=${chain}net sendcoins --addr ${address} --amt ${amount} --conf_target 3" command="lncli --chain=${network} --network=${chain}net sendcoins --sweepall --addr=${address} --conf_target=6"
echo "$command" echo "$command"
result=$($command 2>$_error) result=$($command 2>$_error)
error=`cat ${_error}` error=`cat ${_error}`
#error="sim error: insufficient funds available to construct transaction" echo ""
#result="" if [ ${#error} -gt 0 ]; then
echo "FAIL: $error"
if [ ${#result} -eq 0 ]; then echo ""
# fail - retry on 'insufficient funds available to construct transaction' echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL: $error" echo "FAIL --> Was not able to send transaction (see error above)"
tryAgain=$(echo "${error}" | grep -c 'insufficient funds available to construct transaction') echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
if [ ${tryAgain} -eq 0 ]; then else
echo "" echo "Result: $result"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo ""
echo "FINAL FAIL --> Was not able to send transaction (see error above)" echo "********************************************************************"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" fi
fi
else
# success
echo "$result"
echo ""
echo "********************************************************************"
echo "OK --> send ${amount} sat to address + ${fee} sat fees max"
echo "********************************************************************"
tryAgain=0
fi
# abort aftzer 20 tries
count=$(($count + 1))
if [ ${count} -gt 20 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FINAL FAIL --> Was not able to send transaction with max 20000 sat"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
tryAgain=0
fi
done
exit 1
echo "" echo ""
echo "Press ENTER to return to main menu."
read key

96
home.admin/BBcreateInvoice.sh

@ -13,29 +13,9 @@ if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
echo "" # Check if ready (chain in sync and channels open)
echo "*** Precheck ***" ./XXchainInSync.sh $network $chain
if [ $? != 0 ]; then
# check if chain is in sync
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
echo "Wait until chain is sync with LND and try again."
echo "!!!!!!!!!!!!!!!!!!!"
echo ""
exit 1
fi
# 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 exit 1
fi fi
@ -51,6 +31,8 @@ if [ ${#amount} -eq 0 ]; then
exit 1 exit 1
fi fi
# TODO let user enter a description
# build command # build command
command="lncli --chain=${network} --network=${chain}net addinvoice ${amount}" command="lncli --chain=${network} --network=${chain}net addinvoice ${amount}"
@ -79,20 +61,64 @@ if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}" echo "${error}"
else else
echo "******************************" # echo "******************************"
echo "WIN" # echo "WIN"
echo "******************************" # echo "******************************"
echo "${result}" # echo "${result}"
echo ""
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4) rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4) payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4)
echo -e "${payReq}" > qr.txt
./XXdisplayQRlcd.sh
echo
echo "********************"
echo "Here is your invoice"
echo "********************"
echo
./XXaptInstall.sh qrencode
qrencode -t ANSI256 < /home/admin/qr.txt
echo
echo "Give this Invoice/PaymentRequest to someone to pay it:" echo "Give this Invoice/PaymentRequest to someone to pay it:"
echo "" echo
echo ${payReq} echo "${payReq}"
echo "" echo
echo "You can use 'lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}' to check the payment. " echo "Monitoring Incomming Payment with:"
echo "lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash}"
echo "Press x and hold to skip to menu."
# TODO: Offer to go into monitor for incommin payment loop. while :
do
fi result=$(lncli --chain=${network} --network=${chain}net lookupinvoice ${rhash})
echo "" wasPayed=$(echo $result | grep -c '"settled": true')
if [ ${wasPayed} -gt 0 ]; then
echo
echo $result
echo
echo "Returning to menu - OK Invoice payed."
/home/admin/XXdisplayQRlcd_hide.sh
/home/admin/XXdisplayLCD.sh /home/admin/raspiblitz/pictures/ok.png
sleep 2
break
fi
# wait 2 seconds for key input
read -n 1 -t 2 keyPressed
# check if user wants to abort session
if [ "${keyPressed}" = "x" ]; then
echo
echo $result
echo
echo "Returning to menu - invoice was not payed yet."
break
fi
done
/home/admin/XXdisplayQRlcd_hide.sh
shred qr.txt
rm -f qr.txt
fi

83
home.admin/BBfundWallet.sh

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
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
@ -10,61 +11,71 @@ if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
command="lncli --chain=${network} --network=${chain}net newaddress np2wkh"
clear
echo "******************************"
echo "Fund your Blockchain Wallet"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync # PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c) chainOutSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": false' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainOutSync} -eq 1 ]; then
command="" echo "FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " echo ""
echo "PRESS ENTER to return to menu"
read key
exit 1
fi fi
# execute command # execute command
if [ ${#command} -gt 0 ]; then echo "calling lncli ... please wait"
result=$($command) command="lncli --chain=${network} --network=${chain}net newaddress np2wkh"
fi echo "${command}"
result=$($command)
echo "$result"
# on no result # on no result
if [ ${#result} -eq 0 ]; then if [ ${#result} -eq 0 ]; then
echo "Sorry something went wrong - thats unusual." echo "Empty result - sorry something went wrong - thats unusual."
echo "" echo ""
echo "PRESS ENTER to return to menu"
read key
exit 1 exit 1
fi fi
# when result is available # parse address from result
echo "$result"
# get address from result
address=$( echo "$result" | grep "address" | cut -d '"' -f4) address=$( echo "$result" | grep "address" | cut -d '"' -f4)
# prepare coin info # prepare coin info
coininfo="REAL Bitcoin" coininfo="Bitcoin"
if [ "$network" = "litecoin" ]; then if [ "$network" = "litecoin" ]; then
coininfo="REAL Litecoin" coininfo="Litecoin"
fi fi
if [ "$chain" = "test" ]; then if [ "$chain" = "test" ]; then
coininfo="TESTNET Bitcoin" coininfo="TESTNET Bitcoin"
fi fi
# output info msg="Send ${coininfo} to address --> ${address}\n\nScan the QR code on the LCD with your mobile wallet or copy paste the address.\nThe wallet you sending from needs to support Segwit addresses."
echo ""
echo "******************************"
echo "TODO"
echo "******************************"
echo "Send ${coininfo} to address --> ${address}"
if [ "$chain" = "test" ]; then if [ "$chain" = "test" ]; then
echo "get some testnet coins from https://testnet-faucet.mempool.co" msg="${msg} \n\n Get some testnet coins from https://testnet-faucet.mempool.co"
fi fi
echo "Whats next? --> Wait for confirmations. You can use info on LCD to check if funds have arrived."
echo "If you want your lighting node to open channels automatically, activate the 'Autopilot' under 'Activate/Deactivate Services'" echo "generating QR code ... please wait"
echo "" echo -e "$network:${address}" > qr.txt
/home/admin/XXdisplayQRlcd.sh
# dialog with instructions while QR code is shown on LCD
whiptail --backtitle "Fund your on chain wallet" \
--title "Send ${coininfo}" \
--yes-button "DONE" \
--no-button "Show QR Code" \
--yesno "${msg}" 0 0
# display QR code
if [ $? -eq 1 ]; then
/home/admin/XXdisplayQR.sh
fi
# clean up
shred qr.txt
rm -f qr.txt
/home/admin/XXdisplayQRlcd_hide.sh
# follow up info
whiptail --backtitle "Fund your on chain wallet" \
--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

32
home.admin/BBpayInvoice.sh

@ -12,32 +12,10 @@ if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain') chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi fi
echo "" # Check if ready (chain in sync and channels open)
echo "*** Precheck ***" ./XXchainInSync.sh $network $chain
echo "please wait a moment ..." if [ $? != 0 ]; then
exit 1
# check if chain is in sync
chainInSync=$(lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
echo "Wait until chain is sync with LND and try again."
echo "!!!!!!!!!!!!!!!!!!!"
echo ""
exit 1
fi
# 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 fi
paymentRequestStart="???" paymentRequestStart="???"
@ -118,4 +96,4 @@ else
echo "******************************" echo "******************************"
echo "It worked :) - check out the service you were paying." echo "It worked :) - check out the service you were paying."
fi fi
echo "" echo ""

4
home.admin/XXaptInstall.sh

@ -0,0 +1,4 @@
# Installs package if not yet installed
if [ $(sudo dpkg-query -l | grep "ii $1" | wc -l) = 0 ]; then
sudo apt-get install $1 -y > /dev/null
fi

37
home.admin/XXchainInSync.sh

@ -0,0 +1,37 @@
#!/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 -eq 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

3
home.admin/XXcleanHDD.sh

@ -43,6 +43,7 @@ else
# just delete selective # just delete selective
echo "selective delete ... (please wait)" echo "selective delete ... (please wait)"
sudo rm -f -r /mnt/hdd/backup_lnd
sudo rm -f -r /mnt/hdd/lnd sudo rm -f -r /mnt/hdd/lnd
sudo rm -f -r /mnt/hdd/ssh sudo rm -f -r /mnt/hdd/ssh
sudo rm -f /mnt/hdd/swapfile sudo rm -f /mnt/hdd/swapfile
@ -62,6 +63,8 @@ else
sudo rm -f -r /mnt/hdd/lost+found sudo rm -f -r /mnt/hdd/lost+found
sudo rm -f -r /mnt/hdd/download sudo rm -f -r /mnt/hdd/download
sudo rm -f -r /mnt/hdd/tor sudo rm -f -r /mnt/hdd/tor
sudo rm -f -r /mnt/hdd/temp
sudo rm -f -r /mnt/hdd/backup_lnd
sudo rm -f /mnt/hdd/raspiblitz.conf sudo rm -f /mnt/hdd/raspiblitz.conf
sudo rm -f /home/admin/raspiblitz.info sudo rm -f /home/admin/raspiblitz.info

65
home.admin/XXdebugLogs.sh

@ -29,25 +29,31 @@ if [ ${#chain} -eq 0 ]; then
fi fi
fi fi
clear
echo "" echo ""
echo "*** RASPIBLITZ LOGS ***" echo "***************************************************************"
echo "* RASPIBLITZ DEBUG LOGS "
echo "***************************************************************"
echo "blitzversion: ${codeVersion}" echo "blitzversion: ${codeVersion}"
echo "chainnetwork: ${network} / ${chain}" echo "chainnetwork: ${network} / ${chain}"
uptime uptime
echo "" echo ""
echo "*** CHAINNETWORK SYSTEMD STATUS ***" echo "*** BCLOCKHAIN SYSTEMD STATUS ***"
sudo systemctl status ${network}d -n2 --no-pager sudo systemctl status ${network}d -n2 --no-pager
echo "" echo ""
echo "*** LAST 5 ERROR LOGS ***" echo "*** LAST BCLOCKHAIN ERROR LOGS ***"
sudo journalctl -u ${network}d -b --no-pager -n5 echo "sudo journalctl -u ${network}d -b --no-pager -n8"
sudo journalctl -u ${network}d -b --no-pager -n8
cat /home/admin/systemd.blockchain.log | grep "ERROR" | tail -n -2
echo "" echo ""
echo "*** LAST 20 INFO LOGS ***" echo "*** LAST BCLOCKHAIN 20 INFO LOGS ***"
pathAdd="" pathAdd=""
if [ "${chain}" = "test" ]; then if [ "${chain}" = "test" ]; then
pathAdd="/testnet3" pathAdd="/testnet3"
fi fi
echo "sudo tail -n 20 /mnt/hdd/${network}${pathAdd}/debug.log"
sudo tail -n 20 /mnt/hdd/${network}${pathAdd}/debug.log sudo tail -n 20 /mnt/hdd/${network}${pathAdd}/debug.log
echo "" echo ""
@ -55,17 +61,54 @@ echo "*** LND SYSTEMD STATUS ***"
sudo systemctl status lnd -n2 --no-pager sudo systemctl status lnd -n2 --no-pager
echo "" echo ""
echo "*** LAST 5 LND ERROR LOGS ***" echo "*** LAST LND ERROR LOGS ***"
sudo journalctl -u lnd -b --no-pager -n5 echo "sudo journalctl -u lnd -b --no-pager -n12"
sudo journalctl -u lnd -b --no-pager -n12
cat /home/admin/systemd.lightning.log | grep "ERROR" | tail -n -1
echo "" echo ""
echo "*** LAST 20 LND INFO LOGS ***" echo "*** LAST 30 LND INFO LOGS ***"
sudo tail -n 20 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 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
echo "" echo ""
if [ "${rtlWebinterface}" = "on" ]; then if [ "${rtlWebinterface}" = "on" ]; then
echo "*** LAST 20 RTL LOGS ***" echo "*** LAST 20 RTL LOGS ***"
sudo journalctl -u RTL -b --no-pager -n20 sudo journalctl -u RTL -b --no-pager -n20
echo ""
else else
echo "- RTL is OFF by config" echo "- RTL is OFF by config"
fi fi
echo ""
echo "*** HARDWARE TEST RESULTS ***"
showImproveInfo=0
if [ ${#undervoltageReports} -gt 0 ]; then
echo "UndervoltageReports in Logs: ${undervoltageReports}"
if [ ${undervoltageReports} -gt 0 ]; then
showImproveInfo=1
fi
fi
if [ -f /home/admin/stresstest.report ]; then
sudo cat /home/admin/stresstest.report
source /home/admin/stresstest.report
if [ ${powerWARN} -gt 0 ]; then
showImproveInfo=1
fi
if [ ${tempWARN} -gt 0 ]; then
showImproveInfo=1
fi
fi
if [ ${showImproveInfo} -gt 0 ]; then
echo "IMPORTANT: There are some hardware issues with your setup."
echo "'Run Hardwaretest' in main menu or: sudo /home/admin/05hardwareTest.sh"
fi
echo ""
echo "*** SYSTEM STATUS (can take some seconds to gather) ***"
sudo /home/admin/config.scripts/blitz.statusscan.sh
echo ""
echo "*** OPTION: SHARE THIS DEBUG OUTPUT ***"
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 "/home/admin/XXdebugLogs.sh | nc termbin.com 9999"
echo ""

8
home.admin/XXdisplayLCD.sh

@ -0,0 +1,8 @@
#!/bin/bash
# Display an image on the LCD
# make sure fbi is installed
./XXaptInstall.sh fbi
sudo fbi -a -T 1 -d /dev/fb1 --noverbose $1 2> /dev/null

24
home.admin/XXdisplayQR.sh

@ -0,0 +1,24 @@
#!/bin/bash
# Display a QR code for the string in qr.txt
# make sure qrcode-encode and fbi are installed
#clear
#echo "*** Setup ***"
echo 50 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100
./XXaptInstall.sh qrencode
echo 90 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100
./XXaptInstall.sh fbi
whiptail --title "Get ready" --backtitle "QR-Code in Terminal Window" \
--msgbox "Make this terminal window as large as possible - fullscreen would be best. \n\nThe QR-Code might be too large for your display. In that case, shrink the letters by pressing the keys Ctrl and Minus (or Cmd and Minus if you are on a Mac) \n\nPRESS ENTER when you are ready to see the QR-code." 20 60
clear
qrencode -t ANSI256 < /home/admin/qr.txt
shred /home/admin/qr.txt
rm -f /home/admin/qr.txt
echo "(To shrink QR code: macOS press CMD- / LINUX press CTRL-) Press ENTER when finished."
read key
clear

10
home.admin/XXdisplayQRlcd.sh

@ -0,0 +1,10 @@
#!/bin/bash
# Display a QR code for the string in qr.txt
# make sure qrcode-encode and fbi are installed
./XXaptInstall.sh qrencode
./XXaptInstall.sh fbi
qrencode -l L -o /home/admin/qr.png < /home/admin/qr.txt > /dev/null
sudo fbi -a -T 1 -d /dev/fb1 --noverbose /home/admin/qr.png 2> /dev/null

4
home.admin/XXdisplayQRlcd_hide.sh

@ -0,0 +1,4 @@
#!/bin/bash
sudo killall -3 fbi
shred /home/admin/qr.png 2> /dev/null
rm -f /home/admin/qr.png 2> /dev/null

9
home.admin/XXsyncScripts.sh

@ -61,11 +61,12 @@ else
echo "******************************************" echo "******************************************"
fi fi
echo "COPYING from GIT-Directory to /home/admin/ .." echo "COPYING from GIT-Directory to /home/admin/ .."
sudo -u admin cp -f /home/admin/raspiblitz/home.admin/*.* /home/admin sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin
sudo -u admin chmod +x *.sh sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/assets/*.* /home/admin/assets
sudo -u admin cp -f /home/admin/raspiblitz/home.admin/assets/*.* /home/admin/assets sudo -u admin chmod +x /home/admin/*.sh
sudo -u admin cp -f /home/admin/raspiblitz/home.admin/config.scripts/*.* /home/admin/config.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/*.sh
sudo -u admin chmod +x /home/admin/config.scripts/*.py
echo "******************************************" echo "******************************************"
echo "OK - shell scripts and assests are synced" echo "OK - shell scripts and assests are synced"
echo "Reboot recommended" echo "Reboot recommended"

166
home.admin/_background.sh

@ -22,6 +22,10 @@ fi
echo "_background.sh STARTED" echo "_background.sh STARTED"
# monitor lost LND sync
syncedSince=0
lastSyncState=0
counter=0 counter=0
while [ 1 ] while [ 1 ]
do do
@ -87,6 +91,10 @@ do
# every 15min - not too often # every 15min - not too often
# because its a ping to external service # because its a ping to external service
recheckPublicIP=$((($counter % 900)+1)) recheckPublicIP=$((($counter % 900)+1))
# prevent when lndAddress is set
if [ ${#lndAddress} -gt 3 ]; then
recheckPublicIP=0
fi
updateDynDomain=0 updateDynDomain=0
if [ ${recheckPublicIP} -eq 1 ]; then if [ ${recheckPublicIP} -eq 1 ]; then
echo "*** RECHECK PUBLIC IP ***" echo "*** RECHECK PUBLIC IP ***"
@ -96,12 +104,10 @@ do
# get actual public IP # get actual public IP
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php 2>/dev/null) freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php 2>/dev/null)
echo "freshPublicIP(${freshPublicIP})"
echo "publicIP(${publicIP})"
# sanity check on IP data # sanity check on IP data
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349 # see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "-> sanity check of IP data: ${freshPublicIP}" echo "-> sanity check of new IP data"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6" echo "OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
@ -120,8 +126,8 @@ do
# 1) update config file # 1) update config file
echo "update config value" echo "update config value"
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile} sed -i "s/^publicIP=.*/publicIP='${freshPublicIP}'/g" ${configFile}
publicIP=${freshPublicIP} publicIP='${freshPublicIP}'
# 2) only restart LND if dynDNS is activated # 2) only restart LND if dynDNS is activated
# because this signals that user wants "public node" # because this signals that user wants "public node"
@ -144,6 +150,151 @@ do
fi fi
###############################
# SCB Monitoring
###############################
# check every 1min
recheckSCB=$(($counter % 60))
if [ ${recheckSCB} -eq 1 ]; then
#echo "SCB Monitoring ..."
source ${configFile}
# check if channel.backup exists
scbExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | grep -c 'channel.backup')
if [ ${scbExists} -eq 1 ]; then
#echo "Found Channel Backup File .. check if changed .."
md5checksumORG=$(sudo md5sum /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1)
md5checksumCPY=$(sudo md5sum /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup 2>/dev/null | head -n1 | cut -d " " -f1)
if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then
echo "--> Channel Backup File changed"
# make copy to sd card (as local basic backup)
sudo mkdir -p /home/admin/.lnd/data/chain/${network}/${chain}net/ 2>/dev/null
sudo cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup
echo "OK channel.backup copied to '/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup'"
# check if a SCP backup target is set
# paramter in raspiblitz.conf:
# scpBackupTarget='[USER]@[SERVER]:[DIRPATH-WITHOUT-ENDING-/]'
# On target server add the public key of your RaspiBlitz to the authorized_keys for the user
# https://www.linode.com/docs/security/authentication/use-public-key-authentication-with-ssh/
if [ ${#scpBackupTarget} -gt 0 ]; then
echo "--> Offsite-Backup SCP Server"
# its ok to ignore known host, because data is encrypted (worst case of MiM would be: no offsite channel backup)
# but its more likely that whithout ignoriing known host, script might not run thru and that way: no offsite channel backup
sudo scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ${scpBackupTarget}/channel.backup
result=$?
if [ ${result} -eq 0 ]; then
echo "OK - SCP Backup exited with 0"
else
echo "FAIL - SCP Backup exited with ${result}"
fi
fi
# check if a DropBox backup target is set
# paramter in raspiblitz.conf:
# dropboxBackupTarget='[DROPBOX-APP-OAUTH2-TOKEN]'
# see dropbox setup: https://gist.github.com/vindard/e0cd3d41bb403a823f3b5002488e3f90
if [ ${#dropboxBackupTarget} -gt 0 ]; then
echo "--> Offsite-Backup Dropbox"
source <(sudo /home/admin/config.scripts/dropbox.upload.sh upload ${dropboxBackupTarget} /home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup)
if [ ${#err} -gt 0 ]; then
echo "FAIL - ${err}"
echo "${errMore}"
else
echo "OK - ${upload}"
fi
fi
#else
# echo "Channel Backup File not changed."
fi
#else
# echo "No Channel Backup File .."
fi
fi
###############################
# LND MONITOR LOST SYNC
###############################
# check every 5min
recheckSync=$(($counter % 300))
if [ ${recheckSync} -eq 1 ]; then
source ${configFile}
#echo "LND MONITOR LOST SYNC ..."
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)
#echo "lndSynced(${lndSynced})"
#echo "syncedSince(${syncedSince})"
#echo "lastSyncState(${lastSyncState})"
if [ ${lndSynced} -eq ${lastSyncState} ]; then
echo "no sync change"
if [ ${lndSynced} -eq 1 ]; then
#echo "all is good - LND still in sync now for:"
actualSecondsTimestamp=$(date +%s)
secondsInSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc)
#echo "${secondsInSync} seconds"
# when >10min in sync
if [ ${secondsInSync} -gt 3600 ]; then
#echo "LND in sync for longer then 1 hour"
if [ "${backupTorrentSeeding}" == "on" ]; then
#echo "Backup Torrent Seeding is ON - check if already running"
source <(sudo -u admin /home/admin/50torrentHDD.sh status)
if [ "${baseSeeding}" == "0" ] || [ "${updateSeeding}" == "0" ]; then
echo "---> STARTING Backup Torrent Seeding"
sudo -u admin /home/admin/50torrentHDD.sh backup-torrent-hosting
fi
fi
fi
else
#echo "still not in sync"
if [ ${syncedSince} -gt 0 ]; then
echo "was in sync at least once since rinning but lost now for:"
actualSecondsTimestamp=$(date +%s)
secondsOutOfSync=$(echo "${actualSecondsTimestamp}-"${syncedSince} | bc)
echo "${secondsOutOfSync} seconds"
# when >1h out of sync
#if [ ${secondsOutOfSync} -gt 3600 ]; then
# echo "!!!! LND fell out of sync for longer then 1 hour !!!"
# TODO: When auto-unlock is ON --> consider implementing restart (this sometimes help)
#fi
fi
fi
else
echo "sync change detected"
if [ ${lastSyncState} -eq 1 ] && [ ${lndSynced} -eq 0 ]; then
echo "--> LND SYNC LOST"
if [ "${backupTorrentSeeding}" == "on" ]; then
#echo "Backup Torrent Seeding is ON - check if still running"
source <(sudo -u admin /home/admin/50torrentHDD.sh status)
if [ "${baseSeeding}" == "1" ] || [ "${updateSeeding}" == "1" ]; then
echo "---> STOPPING Backup Torrent Seeding"
sudo -u admin /home/admin/50torrentHDD.sh stop
fi
fi
else
if [ ${syncedSince} -eq 0 ]; then
echo "--> LND SYNC GAINED"
else
echo "--> LND SYNC RECOVERED"
fi
syncedSince=$(date +%s)
fi
fi
lastSyncState=${lndSynced}
fi
############################### ###############################
# LND AUTO-UNLOCK # LND AUTO-UNLOCK
############################### ###############################
@ -165,11 +316,8 @@ do
passwordC=$(sudo cat /root/lnd.autounlock.pwd) passwordC=$(sudo cat /root/lnd.autounlock.pwd)
command="sudo python /home/admin/config.scripts/lnd.unlock.py '${passwordC}'" command="sudo python /home/admin/config.scripts/lnd.unlock.py '${passwordC}'"
bash -c "${command}" bash -c "${command}"
else
echo "lncli says not locked"
fi fi
else
echo "auto-unlock is OFF"
fi fi
fi fi

96
home.admin/_bootstrap.provision.sh

@ -82,18 +82,25 @@ sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${lo
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1 sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
sudo chmod +x /etc/systemd/system/lnd.service >> ${logFile} 2>&1 sudo chmod +x /etc/systemd/system/lnd.service >> ${logFile} 2>&1
# backup LND dir (especially for macaroons and tlscerts)
# https://github.com/rootzoll/raspiblitz/issues/324
echo "*** Make backup of LND directory" >> ${logFile}
sudo rm -r /mnt/hdd/backup_lnd
sudo cp -r /mnt/hdd/lnd /mnt/hdd/backup_lnd >> ${logFile} 2>&1
numOfDiffers=$(sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd | grep -c "differ")
if [ ${numOfDiffers} -gt 0 ]; then
echo "FAIL: Backup was not successfull" >> ${logFile}
sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd >> ${logFile} 2>&1
echo "removing backup dir to prevent false override" >> ${logFile}
else
echo "OK Backup is valid." >> ${logFile}
fi
echo "" >> ${logFile}
# 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 /home/admin/90finishSetup.sh >> ${logFile} 2>&1
# set the local network hostname
if [ ${#hostname} -gt 0 ]; then
echo "Setting new network hostname '$hostname'" >> ${logFile}
sudo raspi-config nonint do_hostname ${hostname} >> ${logFile} 2>&1
else
echo "No hostname set." >> ${logFile}
fi
########################## ##########################
# PROVISIONING SERVICES # PROVISIONING SERVICES
########################## ##########################
@ -158,7 +165,9 @@ fi
# CUSTOM PORT # CUSTOM PORT
echo "Provisioning LND Port" >> ${logFile} echo "Provisioning LND Port" >> ${logFile}
lndPort=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':') if [ ${#lndPort} -eq 0 ]; then
lndPort=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':')
fi
if [ ${#lndPort} -gt 0 ]; then if [ ${#lndPort} -gt 0 ]; then
if [ "${lndPort}" != "9735" ]; then if [ "${lndPort}" != "9735" ]; then
echo "User is running custom LND port: ${lndPort}" >> ${logFile} echo "User is running custom LND port: ${lndPort}" >> ${logFile}
@ -170,8 +179,77 @@ else
echo "Was not able to get LND port from config." >> ${logFile} echo "Was not able to get LND port from config." >> ${logFile}
fi fi
# DNS Server
if [ ${#dnsServer} -gt 0 ]; then
echo "Provisioning DNS Server - Setting DNS Server" >> ${logFile}
sudo /home/admin/config.scripts/internet.dns.sh ${dnsServer} >> ${logFile} 2>&1
else
echo "Provisioning DNS Server - keep default" >> ${logFile}
fi
# ROOT SSH KEYS
# check if a backup on HDD exists and when retsore back
backupRootSSH=$(sudo ls /mnt/hdd/ssh/root_backup 2>/dev/null | grep -c "id_rsa")
if [ ${backupRootSSH} -gt 0 ]; then
echo "Provisioning Root SSH Keys - RESTORING from HDD" >> ${logFile}
sudo cp -r /mnt/hdd/ssh/root_backup /root/.ssh
sudo chown -R root:root /root/.ssh
else
echo "Provisioning Root SSH Keys - keep default" >> ${logFile}
fi
# SSH TUNNEL
if [ "${#sshtunnel}" -gt 0 ]; then
echo "Provisioning SSH Tunnel - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup SSH Tunnel'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.sshtunnel.py restore ${sshtunnel} >> ${logFile} 2>&1
else
echo "Provisioning SSH Tunnel - not active" >> ${logFile}
fi
# BACKUP TORRENT HOSTING
if [ "${backupTorrentHosting}" == "on" ]; then
echo "Backup Torrent Hosting - clean up possible old torrent data" >> ${logFile}
sudo /home/admin/50torrentHDD.sh backup-torrent-hosting-cleanup
else
echo "Backup Torrent Hosting - not active" >> ${logFile}
fi
# replay backup LND conf & tlscerts
# https://github.com/rootzoll/raspiblitz/issues/324
echo "" >> ${logFile}
echo "*** Replay backup of LND conf/tls" >> ${logFile}
if [ -d "/mnt/hdd/backup_lnd" ]; then
echo "Copying TLS ..." >> ${logFile}
sudo cp /mnt/hdd/backup_lnd/lnd.conf /mnt/hdd/lnd/lnd.conf >> ${logFile} 2>&1
sudo cp /mnt/hdd/backup_lnd/tls.cert /mnt/hdd/lnd/tls.cert >> ${logFile} 2>&1
sudo cp /mnt/hdd/backup_lnd/tls.key /mnt/hdd/lnd/tls.key >> ${logFile} 2>&1
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd >> ${logFile} 2>&1
echo "On next final restart admin creds will be updated by _boostrap.sh" >> ${logFile}
echo "DONE" >> ${logFile}
else
echo "No BackupDir so skipping that step." >> ${logFile}
fi
echo "" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile}
# set the local network hostname
# have at the end - see https://github.com/rootzoll/raspiblitz/issues/462
if [ ${#hostname} -gt 0 ]; then
hostnameSanatized=$(echo "${hostname}"| tr -dc '[:alnum:]\n\r')
if [ ${#hostnameSanatized} -gt 0 ]; then
echo "Setting new network hostname '$hostnameSanatized'" >> ${logFile}
sudo raspi-config nonint do_hostname ${hostnameSanatized} >> ${logFile} 2>&1
else
echo "WARNING: hostname in raspiblitz.conf contains just special chars" >> ${logFile}
fi
else
echo "No hostname set." >> ${logFile}
fi
echo "DONE - Give raspi some cool off time after hard building .... 20 secs sleep" >> ${logFile} echo "DONE - Give raspi some cool off time after hard building .... 20 secs sleep" >> ${logFile}
sleep 20 sleep 20

130
home.admin/_bootstrap.sh

@ -64,6 +64,12 @@ if [ "${setupStep}" != "100" ]; then
fi fi
sudo chmod 777 ${infoFile} sudo chmod 777 ${infoFile}
# resetting start count files
echo "SYSTEMD RESTART LOG: blockchain (bitcoind/litecoind)" > /home/admin/systemd.blockchain.log
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
sudo chmod 777 /home/admin/systemd.blockchain.log
sudo chmod 777 /home/admin/systemd.lightning.log
# Emergency cleaning logs when over 1GB (to prevent SD card filling up) # Emergency cleaning logs when over 1GB (to prevent SD card filling up)
# see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944 # see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944
echo "*** Checking Log Size ***" echo "*** Checking Log Size ***"
@ -268,7 +274,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
#presyncActive=$(systemctl status bitcoind | grep -c 'could not be found') #presyncActive=$(systemctl status bitcoind | grep -c 'could not be found')
echo "starting pre-sync in background" >> $logFile echo "starting pre-sync in background" >> $logFile
# make sure that debug file is clean, so just pre-sync gets analysed on stop # make sure that debug file is clean, so just pre-sync gets analysed on stop
sudo rm /mnt/hdd/bitcoin/debug.log sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
# starting in background, because this scripts is part of systemd # starting in background, because this scripts is part of systemd
# so to change systemd needs to happen after delay in seperate process # so to change systemd needs to happen after delay in seperate process
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>> $logFile sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>> $logFile
@ -302,38 +308,65 @@ echo "Check if HDD contains configuration .." >> $logFile
configExists=$(ls ${configFile} | grep -c '.conf') configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
# make sure lndAddress & lndPort exist
valueExists=$(cat ${configFile} | grep -c 'lndPort=')
if [ ${valueExists} -eq 0 ]; then
lndPort=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':')
if [ ${#lndPort} -eq 0 ]; then
lndPort="9735"
fi
echo "lndPort='${lndPort}'" >> ${configFile}
fi
valueExists=$(cat ${configFile} | grep -c 'lndAddress=')
if [ ${valueExists} -eq 0 ]; then
echo "lndAddress=''" >> ${configFile}
fi
# load values # load values
echo "load and update publicIP" >> $logFile echo "load and update publicIP" >> $logFile
source ${configFile} source ${configFile}
freshPublicIP=""
# determine the publicIP/domain that LND should announce
if [ ${#lndAddress} -gt 3 ]; then
# use domain as PUBLICIP
freshPublicIP="${lndAddress}"
# update public IP on boot
# wait otherwise looking for publicIP fails
sleep 5
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
# sanity check on IP data
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "-> sanity check of IP data: ${freshPublicIP}"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
echo "OK IPv4"
else else
echo "FAIL - not an IPv4 or IPv6 address"
freshPublicIP=""
fi
if [ ${#freshPublicIP} -eq 0 ]; then # update public IP on boot
# prevent having no publicIP set at all and LND getting stuck # wait otherwise looking for publicIP fails
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101 sleep 5
if [ ${#publicIP} -eq 0 ]; then freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "WARNING: No publicIP information at all - working with placeholder: ${localIP}" >> $logFile # sanity check on IP data
freshPublicIP="${localIP}" # see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "-> sanity check of IP data:"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
echo "OK IPv4"
else
echo "FAIL - not an IPv4 or IPv6 address"
freshPublicIP=""
fi
if [ ${#freshPublicIP} -eq 0 ]; then
# prevent having no publicIP set at all and LND getting stuck
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
if [ ${#publicIP} -eq 0 ]; then
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "WARNING: No publicIP information at all - working with placeholder: ${localIP}" >> $logFile
freshPublicIP="${localIP}"
fi
fi fi
fi fi
# set publicip value in raspiblitz.conf
if [ ${#freshPublicIP} -eq 0 ]; then if [ ${#freshPublicIP} -eq 0 ]; then
echo "WARNING: Was not able to determine external IP on startup." >> $logFile echo "WARNING: Was not able to determine external IP/domain on startup." >> $logFile
else else
publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' ) publicIPValueExists=$( sudo cat ${configFile} | grep -c 'publicIP=' )
if [ ${publicIPValueExists} -gt 1 ]; then if [ ${publicIPValueExists} -gt 1 ]; then
@ -344,10 +377,10 @@ if [ ${configExists} -eq 1 ]; then
fi fi
if [ ${publicIPValueExists} -eq 0 ]; then if [ ${publicIPValueExists} -eq 0 ]; then
echo "create value (${freshPublicIP})" >> $logFile echo "create value (${freshPublicIP})" >> $logFile
echo "publicIP=${freshPublicIP}" >> $configFile echo "publicIP='${freshPublicIP}'" >> $configFile
else else
echo "update value (${freshPublicIP})" >> $logFile echo "update value (${freshPublicIP})" >> $logFile
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile} sed -i "s/^publicIP=.*/publicIP='${freshPublicIP}'/g" ${configFile}
fi fi
fi fi
@ -359,6 +392,32 @@ fi
################################# #################################
sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null
#################################
# MAKE SURE ADMIN USER HAS LATEST LND DATA
#################################
source ${configFile}
if [ ${#network} -gt 0 ] && [ ${#chain} -gt 0 ]; then
echo "making sure LND blockchain RPC password is set correct in lnd.conf" >> $logFile
source <(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "rpcpass" | sed 's/^[a-z]*\./lnd/g')
if [ ${#rpcpassword} -gt 0 ]; then
sudo sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${rpcpassword}/g" /mnt/hdd/lnd/lnd.conf 2>/dev/null
else
echo "WARN: could not get value 'rpcuser' from blockchain conf" >> $logFile
fi
echo "updating admin user LND data" >> $logFile
sudo cp /mnt/hdd/lnd/lnd.conf /home/admin/.lnd/lnd.conf 2>> $logFile
sudo chown admin:admin /home/admin/.lnd/lnd.conf 2>> $logFile
sudo cp /mnt/hdd/lnd/tls.cert /home/admin/.lnd/tls.cert 2>> $logFile
sudo chown admin:admin /home/admin/.lnd/tls.cert 2>> $logFile
sudo cp /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null
sudo chown admin:admin /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>> $logFile
else
echo "skipping admin user LND data update" >> $logFile
fi
################################ ################################
# DETECT FRESHLY RECOVERED SD # DETECT FRESHLY RECOVERED SD
################################ ################################
@ -399,5 +458,24 @@ if [ ${loaded} -gt 0 ]; then
sed -i "s/^chain=.*/chain=main/g" ${infoFile} sed -i "s/^chain=.*/chain=main/g" ${infoFile}
fi fi
################################
# DELETE LOG FILES
################################
# LND and Blockchain Errors will be still in systemd journals
# /mnt/hdd/bitcoin/debug.log
sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null
# /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log
sudo rm /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null
################################
# STRESSTEST HARDWARE
################################
# generate stresstest report on every startup (in case hardware has changed)
sed -i "s/^state=.*/state=stresstest/g" ${infoFile}
sed -i "s/^message=.*/message='Testing Hardware 60s'/g" ${infoFile}
sudo /home/admin/config.scripts/blitz.stresstest.sh /home/admin/stresstest.report
echo "DONE BOOTSTRAP" >> $logFile echo "DONE BOOTSTRAP" >> $logFile
exit 0 exit 0

2
home.admin/_commands.sh

@ -6,5 +6,5 @@
# calls the the raspiblitz mainmenu # calls the the raspiblitz mainmenu
function raspiblitz() { function raspiblitz() {
cd /home/admin cd /home/admin
./00mainMenu.sh ./00raspiblitz.sh
} }

2
home.admin/_version.info

@ -1,2 +1,2 @@
# RaspiBlitz Version - always [main].[sub] # RaspiBlitz Version - always [main].[sub]
codeVersion="1.1" codeVersion="1.2"

1
home.admin/assets/bitcoind.service

@ -13,6 +13,7 @@ User=bitcoin
Group=bitcoin Group=bitcoin
Type=forking Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid
KillMode=process KillMode=process
Restart=always Restart=always

BIN
home.admin/assets/install_shango.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

1
home.admin/assets/litecoind.service

@ -10,6 +10,7 @@ After=bootstrap.service
User=bitcoin User=bitcoin
Group=bitcoin Group=bitcoin
Type=simple Type=simple
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf
KillMode=process KillMode=process
Restart=always Restart=always

2
home.admin/assets/lnd.bitcoin.conf

@ -1,7 +1,7 @@
# lnd configuration # lnd configuration
[Application Options] [Application Options]
debuglevel=info debuglevel=debug
maxpendingchannels=5 maxpendingchannels=5
alias=raspiblitz alias=raspiblitz
color=#68F442 color=#68F442

2
home.admin/assets/lnd.litecoin.conf

@ -1,7 +1,7 @@
# lnd configuration # lnd configuration
[Application Options] [Application Options]
debuglevel=info debuglevel=debug
maxpendingchannels=5 maxpendingchannels=5
alias=raspiblitz alias=raspiblitz
color=#68F442 color=#68F442

3
home.admin/assets/lnd.service

@ -10,7 +10,8 @@ After=bitcoind.service
[Service] [Service]
EnvironmentFile=/mnt/hdd/raspiblitz.conf EnvironmentFile=/mnt/hdd/raspiblitz.conf
ExecStart=/usr/local/bin/lnd --externalip=${publicIP} ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log lightning STARTED
ExecStart=/usr/local/bin/lnd --externalip=${publicIP}:${lndPort}
PIDFile=/home/bitcoin/.lnd/lnd.pid PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin User=bitcoin
Group=bitcoin Group=bitcoin

2136
home.admin/assets/raspiblitz-bitcoin1-2019-04-09-update.torrent

File diff suppressed because one or more lines are too long

139
home.admin/config.scripts/blitz.datadrive.sh

@ -0,0 +1,139 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "STILL EXPERIMENTAL - NOT FINISHED"
echo "managing additional data storage"
echo "blitz.datadrive.sh [on|off]"
echo "exits on 0 = needs reboot"
exit 1
fi
# check if sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root (with sudo)"
exit 1
fi
# update install sources
echo "make sure BTRFS is installed ..."
sudo apt-get install -y btrfs-tools
echo ""
# check on/off state
dataStorageNotAvailableYet=$(sudo btrfs filesystem df /mnt/data 2>&1 | grep -c "ERROR: not a btrfs filesystem")
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "Trying to switch additional data storage on ..."
if [ ${dataStorageNotAvailableYet} -eq 0 ]; then
echo "FAIL -> data storage is already on"
exit 1
fi
elif [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "Trying to switch additional data storage off ..."
if [ ${dataStorageNotAvailableYet} -eq 1 ]; then
echo "FAIL -> data storage is already off"
exit 1
fi
else
echo "FAIL -> Parameter '${$1}' not known."
exit 1
fi
###################
# SWITCH ON
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# detect the two usb drives
echo "Detecting two USB sticks/drives with same size ..."
lsblk -o NAME | grep "^sd" | while read -r test1 ; do
size1=$(lsblk -o NAME,SIZE -b | grep "^${test1}" | awk '$1=$1' | cut -d " " -f 2)
echo "Checking : ${test1} size(${size1})"
lsblk -o NAME | grep "^sd" | grep -v "${test1}" | while read -r test2 ; do
size2=$(lsblk -o NAME,SIZE -b | grep "^${test2}" | awk '$1=$1' | cut -d " " -f 2)
if [ "${size1}" = "${size2}" ]; then
echo " MATCHING ${test2} size(${size2})"
echo "${test1}" > .dev1.tmp
echo "${test2}" > .dev2.tmp
else
echo " different ${test2} size(${size2})"
fi
done
done
dev1=$(cat .dev1.tmp)
dev2=$(cat .dev2.tmp)
rm -f .dev1.tmp
rm -f .dev2.tmp
echo "RESULTS:"
echo "dev1(${dev1})"
echo "dev2(${dev2})"
echo ""
# check that results are available
if [ ${#dev1} -eq 0 ] || [ ${#dev2} -eq 0 ]; then
echo "!! FAIL -> was not able to detect two devices with the same size"
exit 1
fi
# check size (at least 4GB minus some tolerance)
size=$(lsblk -o NAME,SIZE -b | grep "^${dev1}" | awk '$1=$1' | cut -d " " -f 2)
if [ ${size} -lt 3500000000 ]; then
echo "!! FAIL -> too small - additional storage needs to be bigger than 4GB"
exit 1
fi
# check if devices are containing old data
echo "Analysing Drives ..."
nameDev1=$(lsblk -o NAME,LABEL | grep "^${dev1}" | awk '$1=$1' | cut -d " " -f 2)
nameDev2=$(lsblk -o NAME,LABEL | grep "^${dev2}" | awk '$1=$1' | cut -d " " -f 2)
if [ "${nameDev1}" = "DATASTORE" ] || [ "${nameDev2}" = "DATASTORE" ]; then
# TODO: once implemented -> also make sure that dev1 is named "DATASTORE" and if 2nd is other -> format and add as raid
echo "!! NOT IMPLEMENTED YET -> devices seem contain old data, because name is 'DATASTORE'"
echo "if you dont care about that data: format devices devices on other computer with FAT(32) named TEST"
exit 1
fi
echo "OK drives dont contain old data."
echo ""
# format first drive
echo "Formatting /dev/${dev1} with BTRFS ..."
sudo mkfs.btrfs -L DATASTORE -f /dev/${dev1}
echo "OK"
echo ""
# mount the BTRFS drive
echo "Mounting under /mnt/data ..."
sudo mkdir -p /mnt/data
sudo mount /dev/${dev1} /mnt/data
echo "OK"
echo ""
# adding the second device
echo "Adding the second device as RAID1 .."
sudo btrfs device add -f /dev/${dev2} /mnt/data
sudo btrfs filesystem balance start -dconvert=raid1 -mconvert=raid1 /mnt/data
echo ""
exit 0
# adding the second device
uuid=$(sudo btrfs filesystem show /mnt/data | grep "uuid:" | awk '$1=$1' | cut -d " " -f 4)
fi
###################
# SWITCH OFF
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "TODO -> Turn off"
sudo btrfs filesystem show /mnt/data
sudo btrfs filesystem df /mnt/data
sudo umount /mnt/data
exit 0
fi

59
home.admin/config.scripts/blitz.setpassword.sh

@ -4,6 +4,8 @@
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|b|c|d] [?newpassword] " echo "blitz.setpassword.sh [?a|b|c|d] [?newpassword] "
echo "or just as a password enter dialog (result as file)"
echo "blitz.setpassword.sh [x] [text] [result-file]"
echo "exits on 0 = needs reboot" echo "exits on 0 = needs reboot"
exit 1 exit 1
fi fi
@ -248,6 +250,63 @@ elif [ "${abcd}" = "d" ]; then
echo "Sorry - the password D cannot be changed. Its the password you set on creating your wallet to protect your seed (the list of words)." echo "Sorry - the password D cannot be changed. Its the password you set on creating your wallet to protect your seed (the list of words)."
exit 1 exit 1
############################
# PASSWORD X
elif [ "${abcd}" = "x" ]; then
# second parameter is the flexible text
text=$2
resultFile=$3
shred $3 2>/dev/null
# ask user for new password (first time)
dialog --backtitle "RaspiBlitz"\
--insecure --passwordbox "${text}:\n(min 8chars, 1word, chars+number, no specials)" 10 52 2>$_temp
# get user input
password1=$( cat $_temp )
shred $_temp
# ask user for new password A (second time)
dialog --backtitle "RaspiBlitz - Setup"\
--insecure --passwordbox "Re-Enter the Password:\n(to test if typed in correctly)" 10 52 2>$_temp
# get user input
password2=$( cat $_temp )
shred $_temp
# check if passwords match
if [ "${password1}" != "${password2}" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3"
exit 1
fi
# password zero
if [ ${#password1} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password cannot be empty\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3"
exit 1
fi
# check that password does not contain bad characters
clearedResult=$(echo "${password1}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#password1} ] || [ ${#clearedResult} -eq 0 ]; then
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 x "$2" "$3"
exit 1
fi
# password longer than 8
if [ ${#password1} -lt 8 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8\nPlease try again ..." 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh x "$2" "$3"
exit 1
fi
# store result is file
echo "${password1}" > ${resultFile}
# 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)"

246
home.admin/config.scripts/blitz.statusscan.sh

@ -0,0 +1,246 @@
#!/bin/bash
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# script to scan the state of the system after setup"
exit 1
fi
# measure time of scan
startTime=$(date +%s)
# macke sure temp folder on HDD is available and fro all usable
sudo mkdir /mnt/hdd/temp 2>/dev/null
sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null
# localIP
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "localIP='${localip}'"
# temp
tempC=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc)
echo "tempCelsius='${tempC}'"
# uptime in seconds
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
echo "uptime=${uptime}"
# count restarts of bitcoind/litecoind
startcountBlockchain=$(cat /home/admin/systemd.blockchain.log 2>/dev/null | grep -c "STARTED")
echo "startcountBlockchain=${startcountBlockchain}"
# is bitcoind running
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
echo "bitcoinActive=${bitcoinRunning}"
if [ ${bitcoinRunning} -eq 1 ]; then
# 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
# check if error on request
blockchaininfo=$(cat /mnt/hdd/temp/.bitcoind.out 2>/dev/null)
bitcoinError=$(cat /mnt/hdd/temp/.bitcoind.error 2>/dev/null)
#rm /mnt/hdd/temp/.bitcoind.error 2>/dev/null
if [ ${#bitcoinError} -gt 0 ]; then
bitcoinErrorShort=$(echo ${bitcoinError/error*:/} | sed 's/[^a-zA-Z0-9 ]//g')
echo "bitcoinErrorShort='${bitcoinErrorShort}'"
bitcoinErrorFull=$(echo ${bitcoinError} | tr -d "'")
echo "bitcoinErrorFull='${bitcoinErrorFull}'"
else
##############################
# Get data from blockchaininfo
##############################
# get total number of blocks
total=$(echo ${blockchaininfo} | jq -r '.blocks')
echo "blockchainHeight=${total}"
# is initial sync of blockchain
initialSync=$(echo ${blockchaininfo} | jq -r '.initialblockdownload' | grep -c 'true')
echo "initialSync=${initialSync}"
# get blockchain sync progress
syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')"
syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}' | tr '%' ' ' | tr -s " ")
echo "syncProgress=${syncProgress}"
fi
else
# find out why Bitcoin not running
pathAdd=""
if [ "${chain}" = "test" ]; then
pathAdd="/testnet3"
fi
#### POSSIBLE/SOFT PROBLEMS
# place here in future analysis
#### HARD PROBLEMS
# LOW DISK SPACE
lowDiskSpace=$(sudo tail -n 100 /mnt/hdd/${network}${pathAdd}/debug.log 2>/dev/null | grep -c "Error: Disk space is low!")
if [ ${lowDiskSpace} -gt 0 ]; then
bitcoinErrorShort="HDD DISK SPACE LOW"
bitcoinErrorFull="HDD DISK SPACE LOW - check what data you can delete on HDD and restart"
fi
#### GENERIC ERROR FIND
# if still no error identified - search logs for generic error (after 4min uptime)
if [ ${#bitcoinErrorShort} -eq 0 ] && [ ${uptime} -gt 240 ]; then
bitcoinErrorFull=$(sudo tail -n 100 /mnt/hdd/${network}${pathAdd}/debug.log 2>/dev/null | grep -c "Error:" | tail -1 | tr -d "'")
if [ ${#bitcoinErrorFull} -gt 0 ]; then
bitcoinErrorShort="Error found in Logs"
fi
fi
# output error if found
if [ ${#bitcoinErrorShort} -gt 0 ]; then
echo "bitcoinErrorShort='${bitcoinErrorShort}'"
echo "bitcoinErrorFull='${bitcoinErrorFull}'"
/home/admin/config.scripts/blitz.systemd.sh log blockchain "ERROR: ${bitcoinErrorShort}"
fi
fi
# count restarts of bitcoind/litecoind
startcountLightning=$(cat /home/admin/systemd.lightning.log 2>/dev/null | grep -c "STARTED")
echo "startcountLightning=${startcountLightning}"
# is LND running
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
echo "lndActive=${lndRunning}"
if [ ${lndRunning} -eq 1 ]; then
# get LND info
lndRPCReady=1
lndinfo=$(sudo -u bitcoin lncli getinfo 2>/mnt/hdd/temp/.lnd.error)
# check if error on request
lndErrorFull=$(cat /mnt/hdd/temp/.lnd.error 2>/dev/null)
lndErrorShort=''
#rm /mnt/hdd/temp/.lnd.error 2>/dev/null
if [ ${#lndErrorFull} -gt 0 ]; then
# flag if error could be resoled by analysis
errorResolved=0
### analyse LND logs since start
# find a the line number in logs of start of LND
# just do this on error case to save on processing memory
lndStartLineNumber=$(sudo cat /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -in "LTND: Active chain:" | tail -1 | cut -d ":" -f1)
# get logs of last LND start
lndLogsAfterStart=$(sudo tail --lines=+${lndStartLineNumber} /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null)
# check RPC server ready (can take some time after wallet was unlocked)
lndRPCReady=$(echo "${lndLogsAfterStart}" | grep -c "RPCS: RPC server listening on")
echo "lndRPCReady=${lndRPCReady}"
# check wallet if wallet was opened (after correct password)
lndWalletOpened=$(echo "${lndLogsAfterStart}" | grep -c "LNWL: Opened wallet")
echo "walletOpened=${lndWalletOpened}"
# check wallet if wallet is ready (can take some time after wallet was opened)
lndWalletReady=$(echo "${lndLogsAfterStart}" | grep -c "LTND: LightningWallet opened")
echo "walletReady=${lndWalletReady}"
### check errors
# scan error for walletLocked as common error
locked=$(echo ${lndErrorFull} | grep -c 'Wallet is encrypted')
if [ ${locked} -gt 0 ]; then
echo "walletLocked=1"
else
echo "walletLocked=0"
rpcNotWorking=$(echo ${lndErrorFull} | grep -c 'connection refused')
if [ ${rpcNotWorking} -gt 0 ]; then
# this can happen for a long time when LND is starting fresh sync
# on first startup - check if logs since start signaled RPC ready before
if [ ${lndRPCReady} -eq 0 ]; then
# nullify error - this is normal
lndErrorFull=""
errorResolved=1
# oputput basic data because no error
echo "# LND RPC is still warming up - no scan progress: prepare scan"
echo "scanTimestamp=-2"
echo "syncedToChain=0"
else
echo "# LND RPC was started - some other problem going on"
lndErrorShort='LND RPC not responding'
lndErrorFull=$(echo "LND RPC is not responding. LND may have problems starting up. Check logs, config files and systemd service. Org-Error: ${lndErrorFull}" | tr -d "'")
fi
fi
# if not known error and not resolved before - keep generic
if [ ${#lndErrorShort} -eq 0 ] && [ ${errorResolved} -eq 0 ]; then
lndErrorShort='Unkown Error - see logs'
lndErrorFull=$(echo ${lndErrorFull} | tr -d "'")
fi
# write to results
if [ ${#lndErrorFull} -gt 0 ]; then
echo "lndErrorShort='${lndErrorShort}'"
echo "lndErrorFull='${lndErrorFull}'"
/home/admin/config.scripts/blitz.systemd.sh log lightning "ERROR: ${lndErrorFull}"
fi
fi
else
# check if wallet is locked
locked=$(echo ${lndinfo} | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "walletLocked=1"
else
echo "walletLocked=0"
fi
# synced to chain
syncedToChain=$(echo ${lndinfo} | jq -r '.synced_to_chain' | grep -c 'true')
echo "syncedToChain=${syncedToChain}"
# lnd scan progress
scanTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp')
if [ ${#scanTimestamp} -gt 0 ]; then
echo "scanTimestamp=${scanTimestamp}"
scanDate=$(date -d @${scanTimestamp})
echo "scanDate='${scanDate}'"
# calculate LND scan progress by seconds since Genesisblock
genesisTimestamp=1230940800
nowTimestamp=$(date +%s)
totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc)
scannedSeconds=$(echo "${scanTimestamp}-${genesisTimestamp}" | bc)
scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc)
echo "scanProgress=${scanProgress}"
else
echo "# was not able to parse 'best_header_timestamp' from: lncli getinfo"
echo "scanTimestamp=-1"
fi
fi
# output if lnd-RPC is ready
echo "lndRPCReady=${lndRPCReady}"
fi
# check if online if problem with other stuff
# info on scan run time
endTime=$(date +%s)
runTime=$(echo "${endTime}-${startTime}" | bc)
echo "scriptRuntime=${runTime}"

104
home.admin/config.scripts/blitz.stresstest.sh

@ -0,0 +1,104 @@
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "run stress test to measure heat and voltage"
echo "blitz.stresstest.sh [?filenameForReport]"
exit 1
fi
# Based on https://github.com/bamarni/pi64/issues/4#issuecomment-292707581
# sysbench manual: http://imysql.com/wp-content/uploads/2014/10/sysbench-manual.pdf
# get parameter
filenameForReport=$1
# check if bechmarking tool is installed
sysbenchInstalled=$(sysbench --version 2>/dev/null | grep -c 'sysbench 0.')
if [ ${sysbenchInstalled} -eq 0 ];then
sudo apt install -y sysbench
fi
# do debug outputs to the STDERR - so that the STDOUT is just the results in the end
echo "RaspiBlitz Hardwaretest v0.1" >&2
echo "Starting sysbench to run for 60 seconds (--max-time=60 --cpu-max-prime=10000)" >&2
# result values
powerWARN=0
powerFAIL=0
powerMIN=9999999
tempWARN=0
tempFAIL=0
tempMAX=0
# starting bench mark
sysbench --max-time=60 --test=cpu --cpu-max-prime=10000 --num-threads=4 run 1>/dev/null 2>&1 &
# keep monitoring in the background
Maxfreq=$(( $(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) -15 ))
for (( n=0; n<15; ++n )); do
# make measurements
Temp=$(sudo vcgencmd measure_temp | cut -f2 -d=)
RealClockspeed=$(sudo vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
SysFSClockspeed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
CoreVoltage=$(sudo vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
# debug output
if [ ${RealClockspeed} -ge ${Maxfreq} ]; then
echo "${Temp}$(printf "%5s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
else
echo "${Temp}$(printf "%5s" ${RealClockspeed})/$(printf "%4s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
fi
# analyse Voltage
voltFloat=$(echo "${CoreVoltage/V/}*1000000" | bc)
voltInt=${voltFloat/.*}
#echo "V -> ${voltFloat}/${voltInt}"
if [ ${voltInt} -lt 1200100 ] && [ ${powerWARN} -gt 1 ]; then
((powerFAIL=powerFAIL+1))
echo "--> Power CRITICAL detected" >&2
fi
if [ ${voltInt} -lt 1250000 ]; then
((powerWARN=powerWARN+1))
echo "--> Power WARN detected" >&2
fi
if [ ${voltInt} -lt ${powerMIN} ]; then
powerMIN=${voltInt}
fi
# analyse Temp
tempFloat=$(echo "${Temp/\'C/}*100" | bc)
tempInt=${tempFloat/.*}
#echo "T -> ${tempFloat}/${tempInt}"
if [ ${tempInt} -gt 6999 ]; then
((tempFAIL=tempFAIL+1))
echo "--> Temp CRITICAL detected" >&2
fi
if [ ${tempInt} -gt 6500 ]; then
((tempWARN=tempWARN+1))
echo "--> Temp WARN detected" >&2
fi
if [ ${tempInt} -gt ${tempMAX} ]; then
tempMAX=${tempInt}
fi
sleep 5
done
if [ ${#filenameForReport} -eq 0 ]; then
echo "powerFAIL=${powerFAIL}"
echo "powerWARN=${powerWARN}"
echo "powerMIN='${powerMIN} microVolt'"
echo "tempFAIL=${tempFAIL}"
echo "tempWARN=${tempWARN}"
echo "tempMAX='${tempMAX} centiGrad'"
else
echo "powerFAIL=${powerFAIL}" >${filenameForReport}
echo "powerWARN=${powerWARN}" >>${filenameForReport}
echo "powerMIN='${powerMIN} microVolt'" >>${filenameForReport}
echo "tempFAIL=${tempFAIL}" >>${filenameForReport}
echo "tempWARN=${tempWARN}" >>${filenameForReport}
echo "tempMAX='${tempMAX} centiGrad'" >>${filenameForReport}
sudo chmod 744 ${filenameForReport}
fi

19
home.admin/config.scripts/blitz.systemd.sh

@ -0,0 +1,19 @@
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "additional systemd services"
echo "blitz.systemd.sh log blockchain STARTED"
echo "blitz.systemd.sh log loghtning STARTED"
exit 1
fi
# check parameter
if [ "${1}" != "log" ]; then
echo "# FAIL: unkown parameter"
fi
# writing log file entry
logFile="/home/admin/systemd.${2}.log"
echo "$(date +%s) ${3}" >> ${logFile}
echo "# OK: log '${3}' written to ${logFile}"

4
home.admin/config.scripts/bonus.rtl.sh

@ -41,7 +41,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check if nodeJS was installed # check if nodeJS was installed
nodeJSInstalled=$(node -v | grep -c "v11.") nodeJSInstalled=$(node -v | grep -c "v11.")
if [ nodeJSInstalled -eq 0 ]; then if [ ${nodeJSInstalled} -eq 0 ]; then
echo "FAIL - Was not able to install nodeJS 11" echo "FAIL - Was not able to install nodeJS 11"
echo "ABORT - RTL install" echo "ABORT - RTL install"
exit 1 exit 1
@ -51,7 +51,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "*** Get the RTL Source Code ***" echo "*** Get the RTL Source Code ***"
git clone https://github.com/ShahanaFarooqui/RTL.git git clone https://github.com/ShahanaFarooqui/RTL.git
cd RTL cd RTL
git reset --hard v0.2.15 git reset --hard v0.2.16
# check if node_modles exists now # check if node_modles exists now
if [ -d "/home/admin/RTL" ]; then if [ -d "/home/admin/RTL" ]; then
echo "OK - RTL code copy looks good" echo "OK - RTL code copy looks good"

99
home.admin/config.scripts/dropbox.upload.sh

@ -0,0 +1,99 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# script to upload a file to DropBox (without third party libs)"
echo "# dropbox.upload.sh upload [AUTHTOKEN] [FILEPATH]"
echo "# dropbox.upload.sh check [AUTHTOKEN]"
echo "# for Dropbox Setup with Authtoken, see:"
echo "# https://gist.github.com/vindard/e0cd3d41bb403a823f3b5002488e3f90"
echo "err='just informational output'"
exit 1
fi
# get first parameter
MODE="$1"
if [ "${MODE}" == "check" ]; then
# get needed second parameter
DROPBOX_APITOKEN="$2"
if [ ${#DROPBOX_APITOKEN} -eq 0 ]; then
echo "err='missing Parameter AUTHTOKEN'"
exit 1
fi
# run API check
curl -s -X POST https://api.dropboxapi.com/2/users/get_current_account \
--header "Authorization: Bearer "$DROPBOX_APITOKEN | grep rror
if [[ ! $? -eq 0 ]] ; then
echo "# Dropbox API Token worked"
echo "check=1"
else
echo "# Invalid Dropbox API Token!"
echo "check=0"
fi
elif [ "${MODE}" == "upload" ]; then
# get needed second parameter
DROPBOX_APITOKEN="$2"
if [ ${#DROPBOX_APITOKEN} -eq 0 ]; then
echo "err='missing Parameter AUTHTOKEN'"
exit 1
fi
# get needed third parameter
SOURCEFILE="$3"
if [ ${#SOURCEFILE} -eq 0 ]; then
echo "err='missing Parameter SOURCEFILE'"
exit 1
fi
source /mnt/hdd/raspiblitz.conf
if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz"
fi
DEVICE=$(echo "${hostname}" | awk '{print tolower($0)}' | sed -e 's/ /-/g')
BACKUPFOLDER=lndbackup-$DEVICE
FILENAME=$(basename "${SOURCEFILE}")
sudo curl -s -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer "${DROPBOX_APITOKEN}"" \
--header "Dropbox-API-Arg: {\"path\": \"/"$BACKUPFOLDER"/"$FILENAME"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @$SOURCEFILE > /home/admin/.dropbox.tmp
safeResponse=$(sed 's/[^a-zA-Z0-9 ]//g' /home/admin/.dropbox.tmp)
sudo shred /home/admin/.dropbox.tmp
sudo rm /home/admin/.dropbox.tmp 2>/dev/null
success=$(echo "${safeResponse}" | grep -c 'servermodified')
sizeZero=$(echo "${safeResponse}" | grep -c 'size 0')
if [ ${sizeZero} -gt 0 ]; then
echo "# Upload happened but is size zero"
echo "upload=0"
echo "err='size zero'"
echo "errMore='${safeResponse}'"
elif [ ${success} -gt 0 ] ; then
echo "# Successfully uploaded!"
echo "upload=1"
else
echo "# Unknown Error"
echo "upload=0"
echo "err='unknown'"
echo "errMore='${safeResponse}'"
fi
else
echo "err='unkown mode'"
exit 1
fi

43
home.admin/config.scripts/internet.dns.sh

@ -0,0 +1,43 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to set a the DNS server that should be used"
echo "internet.dns.sh [DNS-SERVER]"
exit 1
fi
# 1. parameter
DNSSERVER="$1"
echo "The DNS server you want to set is: ${DNSSERVER}"
# checking for IP address
if [[ $DNSSERVER =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6"
elif [[ $DNSSERVER =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
echo "OK IPv4"
else
echo "FAIL - not an IPv4 or IPv6 address"
exit 1
fi
echo ""
# setting DNS address
echo "Setting DNS server in /etc/dhcpcd.conf ..."
sudo sed -i "s/^static domain_name_servers=.*/static domain_name_servers=${DNSSERVER}/g" /etc/dhcpcd.conf
echo "OK"
echo ""
# make sure entry in raspiblitz.conf exists
source /mnt/hdd/raspiblitz.conf
if [ ${#dnsServer} -eq 0 ]; then
echo "Adding value to /mnt/hdd/raspiblitz.conf"
echo "dnsServer=${DNSSERVER}" >> /mnt/hdd/raspiblitz.conf
else
echo "Updating value in /mnt/hdd/raspiblitz.conf"
sudo sed -i "s/^dnsServer=.*/dnsServer=${DNSSERVER}/g" /mnt/hdd/raspiblitz.conf
fi
echo "OK"
echo ""
echo "DNS Server is set - reboot needed before active"

2
home.admin/config.scripts/internet.dyndomain.sh

@ -92,7 +92,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^dynDomain=.*/dynDomain='${dynDomain}'/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^dynDomain=.*/dynDomain='${dynDomain}'/g" /mnt/hdd/raspiblitz.conf
# setting dynUpdateUrl is a bit cpmplicated because value can contain chars that break sed replacement # setting dynUpdateUrl is a bit complicated because value can contain chars that break sed replacement
# so first remove dynUpdateUrl from config and then add fresh as new line at the end # so first remove dynUpdateUrl from config and then add fresh as new line at the end
grep -v "dynUpdateUrl" /mnt/hdd/raspiblitz.conf > ./raspiblitz.conf.new grep -v "dynUpdateUrl" /mnt/hdd/raspiblitz.conf > ./raspiblitz.conf.new
echo "dynUpdateUrl='${dynUpdateUrl}'" >> ./raspiblitz.conf.new echo "dynUpdateUrl='${dynUpdateUrl}'" >> ./raspiblitz.conf.new

43
home.admin/config.scripts/internet.sshpubkey.sh

@ -0,0 +1,43 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# config script to init/show/transfer ssh pub keys."
echo "# -> return pubkey (and will init if needed):"
echo "# internet.sshpubkey.sh get"
echo "# -> transfer ssh-pub to a authorizedkey of remote server:"
echo "# internet.sshpubkey.sh transfer [REMOTEUSER]@[REMOTESERVER]"
echo "err='just informational output'"
exit 1
fi
# 1. parameter MODE
MODE="$1"
# root as default user
# its used for all ssh tunnel/back action
# make sure the ssh keys for that user are initialized
sshKeysExist=$(sudo ls /root/.ssh/id_rsa.pub | grep -c 'id_rsa.pub')
if [ ${sshKeysExist} -eq 0 ]; then
echo "# generation SSH keys for user root"
sudo mkdir /root/.ssh 2>/dev/null
sudo sh -c 'yes y | sudo ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""'
fi
if [ "${MODE}" == "get" ]; then
# get ssh pub key and print
sshPubKey=$(sudo cat /root/.ssh/id_rsa.pub)
echo "user='root'"
echo "sshPubKey='${sshPubKey}'"
elif [ "${MODE}" == "transfer" ]; then
sudo ssh-copy-id $2
else
echo "err='paremeter not known - run with -help'"
fi

245
home.admin/config.scripts/internet.sshtunnel.py

@ -0,0 +1,245 @@
#!/usr/bin/python3
import sys, subprocess, re
from pathlib import Path
# IDEA: At the momemt its just Reverse-SSh Tunnels thats why [INTERNAL-PORT]<[EXTERNAL-PORT]
# For the future also just local ssh tunnels could be added with [INTERNAL-PORT]-[EXTERNAL-PORT]
# for the use case when a server wants to use a RaspiBlitz behind a NAT as Lightning backend
# display config script info
if len(sys.argv) <= 1 or sys.argv[1] == "-h" or sys.argv[1] == "help":
print("forward ports from another server to raspiblitz with reverse SSH tunnel")
print("internet.sshtunnel.py [on|off|restore] [USER]@[SERVER] \"[INTERNAL-PORT]<[EXTERNAL-PORT]\"")
print("note that [INTERNAL-PORT]<[EXTERNAL-PORT] can one or multiple forwardings")
sys.exit(1)
#
# CONSTANTS
# sudo journalctl -f -u autossh-tunnel
#
SERVICENAME="autossh-tunnel.service"
SERVICEFILE="/etc/systemd/system/"+SERVICENAME
SERVICETEMPLATE="""# see config script internet.sshtunnel.py
[Unit]
Description=AutoSSH tunnel service
After=network.target
[Service]
User=root
Group=root
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -N -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" [PLACEHOLDER]
StandardOutput=journal
[Install]
WantedBy=multi-user.target
"""
# get LND port form lnd.conf
LNDPORT = subprocess.getoutput("sudo cat /mnt/hdd/lnd/lnd.conf | grep '^listen=*' | cut -f2 -d':'")
if len(LNDPORT) == 0:
LNDPORT="9735"
#
# RESTORE = SWITCHING ON with restore flag on
# on restore other external scripts dont need calling
#
forwardingLND = False
restoringOnUpdate = False
if sys.argv[1] == "restore":
print("internet.sshtunnel.py -> running with restore flag")
sys.argv[1] = "on"
restoringOnUpdate = True
#
# SWITCHING ON
#
if sys.argv[1] == "on":
# check if already running
isRunning = subprocess.getoutput("sudo systemctl --no-pager | grep -c '%s'" % (SERVICENAME))
if int(isRunning) > 0:
print("SSH TUNNEL SERVICE IS RUNNING - run 'internet.sshtunnel.py off' first to set new tunnel")
sys.exit(1)
# check server address
if len(sys.argv) < 3:
print("[USER]@[SERVER] missing - use 'internet.sshtunnel.py -h' for help")
sys.exit(1)
if sys.argv[2].count("@") != 1:
print("[USER]@[SERVER] wrong - use 'internet.sshtunnel.py -h' for help")
sys.exit(1)
ssh_server = sys.argv[2]
# genenate additional parameter for autossh (forwarding ports)
if len(sys.argv) < 4:
print("[INTERNAL-PORT]<[EXTERNAL-PORT] missing")
sys.exit(1)
ssh_ports=""
additional_parameters=""
i = 3
while i < len(sys.argv):
# check forwarding format
if sys.argv[i].count("<") != 1:
print("[INTERNAL-PORT]<[EXTERNAL-PORT] wrong format '%s'" % (sys.argv[i]))
sys.exit(1)
# get ports
sys.argv[i] = re.sub('"','', sys.argv[i] )
ports = sys.argv[i].split("<")
port_internal = ports[0]
port_external = ports[1]
if port_internal.isdigit() == False:
print("[INTERNAL-PORT]<[EXTERNAL-PORT] internal not number '%s'" % (sys.argv[i]))
sys.exit(1)
if port_external.isdigit() == False:
print("[INTERNAL-PORT]<[EXTERNAL-PORT] external not number '%s'" % (sys.argv[i]))
sys.exit(1)
if port_internal == LNDPORT:
print("Detected LND Port Forwarding")
forwardingLND = True
if port_internal != port_external:
print("FAIL: When tunneling your local LND port '%s' it needs to be the same on the external server, but is '%s'" % (LNDPORT,port_external))
print("Try again by using the same port. If you cant change the external port, change local LND port with: /home/admin/config.scripts/lnd.setport.sh")
sys.exit(1)
ssh_ports = ssh_ports + "\"%s\" " % (sys.argv[i])
additional_parameters= additional_parameters + "-R %s:localhost:%s " % (port_external,port_internal)
i=i+1
# genenate additional parameter for autossh (server)
ssh_ports = ssh_ports.strip()
additional_parameters= additional_parameters + ssh_server
# generate custom service config
service_data = SERVICETEMPLATE.replace("[PLACEHOLDER]", additional_parameters)
# debug print out service
print()
print("*** New systemd service: %s" % (SERVICENAME))
print(service_data)
# write service file
service_file = open("/home/admin/temp.service", "w")
service_file.write(service_data)
service_file.close()
subprocess.call("sudo mv /home/admin/temp.service %s" % (SERVICEFILE), shell=True)
# check if SSH keys for root user need to be created
print()
print("*** Checking root SSH pub keys")
ssh_pubkey=""
try:
ssh_pubkey = subprocess.check_output("sudo cat /root/.ssh/id_rsa.pub", shell=True, universal_newlines=True)
print("OK - root id_rsa.pub file exists")
except subprocess.CalledProcessError as e:
print("Generating root SSH keys ...")
subprocess.call("sudo sh -c 'yes y | sudo -u root ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N \"\"'", shell=True)
ssh_pubkey = subprocess.check_output("sudo cat /root/.ssh/id_rsa.pub", shell=True, universal_newlines=True)
# copy SSH keys for backup (for update with new sd card)
print("making backup copy of SSH keys")
subprocess.call("sudo cp -r /root/.ssh /mnt/hdd/ssh/root_backup", shell=True)
print("DONE")
# write ssh tunnel data to raspiblitz config (for update with new sd card)
print("*** Updating RaspiBlitz Config")
with open('/mnt/hdd/raspiblitz.conf') as f:
file_content = f.read()
if file_content.count("sshtunnel=") == 0:
file_content = file_content+"\nsshtunnel=''"
file_content = re.sub("sshtunnel=.*", "sshtunnel='%s %s'" % (ssh_server, ssh_ports), file_content)
if restoringOnUpdate == False:
serverdomain=ssh_server.split("@")[1]
# make sure serverdomain is set as tls alias
print("Setting server as tls alias")
oldConfigHash=subprocess.getoutput("sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf")
subprocess.call("sudo sed -i \"s/^#tlsextradomain=.*/tlsextradomain=/g\" /mnt/hdd/lnd/lnd.conf", shell=True)
subprocess.call("sudo sed -i \"s/^tlsextradomain=.*/tlsextradomain=%s/g\" /mnt/hdd/lnd/lnd.conf" % (serverdomain), shell=True)
newConfigHash=subprocess.getoutput("sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf")
if oldConfigHash != newConfigHash:
print("lnd.conf changed ... generating new TLS cert")
subprocess.call("sudo /home/admin/config.scripts/lnd.newtlscert.sh", shell=True)
else:
print("lnd.conf unchanged... keep TLS cert")
if forwardingLND:
# setting server explicitly on LND if LND port is forwarded
print("Setting fixed address for LND with raspiblitz lndAddress")
file_content = re.sub("lndAddress=.*", "lndAddress='%s'" % (serverdomain), file_content)
else:
print("No need to set fixed address for LND with raspiblitz lndAddress")
file_content = "".join([s for s in file_content.splitlines(True) if s.strip("\r\n")]) + "\n"
print(file_content)
with open("/mnt/hdd/raspiblitz.conf", "w") as text_file:
text_file.write(file_content)
print("DONE")
# make sure autossh is installed
# https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/
print()
print("*** Install autossh")
subprocess.call("sudo apt-get install -y autossh", shell=True)
# enable service
print()
print("*** Enabling systemd service: %s" % (SERVICENAME))
subprocess.call("sudo systemctl daemon-reload", shell=True)
subprocess.call("sudo systemctl enable %s" % (SERVICENAME), shell=True)
# final info (can be ignored if run by other script)
print()
print("**************************************")
print("*** WIN - SSH TUNNEL SERVICE SETUP ***")
print("**************************************")
print("See chapter 'How to setup port-forwarding with a SSH tunnel?' in:")
print("https://github.com/rootzoll/raspiblitz/blob/master/FAQ.md")
print("- Tunnel service needs final reboot to start.")
print("- After reboot check logs: sudo journalctl -f -u %s" % (SERVICENAME))
print("- Make sure the SSH pub key of this RaspiBlitz is in 'authorized_keys' of %s :" % (ssh_server))
print(ssh_pubkey)
print()
#
# SWITCHING OFF
#
elif sys.argv[1] == "off":
print("*** Disabling systemd service: %s" % (SERVICENAME))
subprocess.call("sudo systemctl stop %s" % (SERVICENAME), shell=True)
subprocess.call("sudo systemctl disable %s" % (SERVICENAME), shell=True)
subprocess.call("sudo systemctl reset-failed", shell=True)
subprocess.call("sudo rm %s" % (SERVICEFILE), shell=True)
subprocess.call("sudo systemctl daemon-reload", shell=True)
print("OK Done")
print()
print("*** Removing LND Address")
subprocess.call("sudo /home/admin/config.scripts/lnd.setaddress.sh off", shell=True)
print()
print("*** Removing SSH Tunnel data from RaspiBlitz config")
with open('/mnt/hdd/raspiblitz.conf') as f:
file_content = f.read()
file_content = re.sub("sshtunnel=.*", "", file_content)
file_content = re.sub("\n\n", "\n", file_content)
print(file_content)
with open("/mnt/hdd/raspiblitz.conf", "w") as text_file:
text_file.write(file_content)
print("OK Done")
#
# UNKOWN PARAMETER
#
else:
print ("unkown parameter - use 'internet.sshtunnel.py -h' for help")

2
home.admin/config.scripts/internet.tor.sh

@ -245,7 +245,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo systemctl disable lnd sudo systemctl disable lnd
echo "editing /etc/systemd/system/lnd.service" echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}/g" /etc/systemd/system/lnd.service sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:\${lndPort}/g" /etc/systemd/system/lnd.service
sudo systemctl enable lnd sudo systemctl enable lnd
echo "OK" echo "OK"

2
home.admin/config.scripts/lnd.autonat.sh

@ -67,7 +67,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo sed -i "s/^nat=.*/nat=false/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^nat=.*/nat=false/g" /mnt/hdd/lnd/lnd.conf
# editing lnd service (adding the static publicip) # editing lnd service (adding the static publicip)
echo "editing /etc/systemd/system/lnd.service" echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}/g" /etc/systemd/system/lnd.service sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:\${lndPort}\/g" /etc/systemd/system/lnd.service
# edit raspi blitz config # edit raspi blitz config
echo "editing /mnt/hdd/raspiblitz.conf" echo "editing /mnt/hdd/raspiblitz.conf"
sudo sed -i "s/^autoNatDiscovery=.*/autoNatDiscovery=off/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^autoNatDiscovery=.*/autoNatDiscovery=off/g" /mnt/hdd/raspiblitz.conf

42
home.admin/config.scripts/lnd.autounlock.sh

@ -5,8 +5,8 @@ sudo pip install requests
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to autounlock lnd after restart" echo "# small config script to autounlock lnd after restart"
echo "lnd.autounlock.sh [on|off] [?passwordC]" echo "# lnd.autounlock.sh [on|off] [?passwordC]"
exit 1 exit 1
fi fi
@ -32,19 +32,20 @@ Password C will be stored on the device.
# test if empty # test if empty
if [ ${#passwordC} -eq 0 ]; then if [ ${#passwordC} -eq 0 ]; then
echo "CANCEL input cannot be empty" echo "# CANCEL input cannot be empty"
sleep 3 sleep 3
exit 1 exit 1
fi fi
# test if correct # test if correct
echo "testing password .. please wait" echo "# testing password .. please wait"
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
sudo systemctl restart lnd sudo systemctl restart lnd
sleep 4 sleep 4
result=$(sudo python /home/admin/config.scripts/lnd.unlock.py ${passwordC}) result=$(sudo python /home/admin/config.scripts/lnd.unlock.py ${passwordC})
invalid=$(echo "${result}" | grep -c 'invalid') invalid=$(echo "${result}" | grep -c 'invalid')
if [ ${invalid} -gt 0 ];then if [ ${invalid} -gt 0 ];then
echo "PASSWORD C is wrong - try again or cancel" echo "# PASSWORD C is wrong - try again or cancel"
sleep 3 sleep 3
sudo /home/admin/config.scripts/lnd.autounlock.sh on sudo /home/admin/config.scripts/lnd.autounlock.sh on
exit 1 exit 1
@ -61,7 +62,7 @@ lndConfig="/mnt/hdd/lnd/lnd.conf"
# check if config file exists # check if config file exists
configExists=$(ls ${configFile} | grep -c '.conf') configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 0 ]; then
echo "FAIL - missing ${configFile}" echo "err='missing ${configFile}''"
exit 1 exit 1
fi fi
@ -74,6 +75,9 @@ fi
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# get hash of lnd.conf before edit (to detect if changed later)
md5HashBefore=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf)
# make sure config values are uncommented # make sure config values are uncommented
sudo sed -i "s/^#restlisten=.*/restlisten=/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^#restlisten=.*/restlisten=/g" /mnt/hdd/lnd/lnd.conf
sudo sed -i "s/^#tlsextraip=.*/tlsextraip=/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^#tlsextraip=.*/tlsextraip=/g" /mnt/hdd/lnd/lnd.conf
@ -92,32 +96,38 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo sed -i "s/^restlisten=.*/restlisten=0.0.0.0:8080/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^restlisten=.*/restlisten=0.0.0.0:8080/g" /mnt/hdd/lnd/lnd.conf
sudo sed -i "s/^tlsextraip=.*/tlsextraip=0.0.0.0/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^tlsextraip=.*/tlsextraip=0.0.0.0/g" /mnt/hdd/lnd/lnd.conf
# refresh TLS cert # refresh TLS cert (if lnd.conf was changed)
sudo /home/admin/config.scripts/lnd.newtlscert.sh md5HashAfter=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf)
if [ "${md5HashAfter}" != "${md5HashBefore}" ]; then
echo "# lnd.conf changed - TLS certs need refreshing"
sudo /home/admin/config.scripts/lnd.newtlscert.sh
else
echo "# lnd.conf NOT changed - keep TLS certs"
fi
echo "switching the Auto-Unlock ON" echo "# switching the Auto-Unlock ON"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^autoUnlock=.*/autoUnlock=on/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^autoUnlock=.*/autoUnlock=on/g" /mnt/hdd/raspiblitz.conf
# password C needs to be stored on RaspiBlitz # password C needs to be stored on RaspiBlitz
echo "storing password for root in /root/lnd.autounlock.pwd" echo "# storing password for root in /root/lnd.autounlock.pwd"
sudo sh -c "echo \"${passwordC}\" > /root/lnd.autounlock.pwd" sudo sh -c "echo \"${passwordC}\" > /root/lnd.autounlock.pwd"
echo "Auto-Unlock is now ON" echo "# Auto-Unlock is now ON"
echo "NOTE: you may need to reconnect mobile/external wallets (macaroon/tls)" echo "# NOTE: you may need to reconnect mobile/external wallets (macaroon/tls)"
fi fi
# switch off # switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "switching the Auto-Unlock OFF" echo "# switching the Auto-Unlock OFF"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^autoUnlock=.*/autoUnlock=off/g" /mnt/hdd/raspiblitz.conf sudo sed -i "s/^autoUnlock=.*/autoUnlock=off/g" /mnt/hdd/raspiblitz.conf
# delete password C securly # delete password C securly
echo "shredding password on for RaspiBlitz Auto-Unlock" echo "# shredding password on for RaspiBlitz Auto-Unlock"
sudo shred -u /root/lnd.autounlock.pwd 2>/dev/null sudo shred -u /root/lnd.autounlock.pwd 2>/dev/null
echo "Auto-Unlock is now OFF" echo "# Auto-Unlock is now OFF"
fi fi

178
home.admin/config.scripts/lnd.check.sh

@ -0,0 +1,178 @@
#!/bin/bash
if [ $# -eq 0 ]; then
echo "# script to check LND states"
echo "# lnd.check.sh basic-setup"
exit 1
fi
# load raspiblitz conf
source /mnt/hdd/raspiblitz.conf
# check basic LND setup
if [ "$1" == "basic-setup" ]; then
# check TLS exits
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c 'tls.cert')
if [ ${tlsExists} -gt 0 ]; then
echo "tls=1"
else
echo "tls=0"
echo "err='tls.cert is missing in /mnt/hdd/lnd'"
fi
# check TLS exits (on SD card for admin)
tlsExists=$(sudo ls /home/admin/.lnd/tls.cert 2>/dev/null | grep -c 'tls.cert')
if [ ${tlsExists} -gt 0 ]; then
echo "tlsCopy=1"
# check if the same
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/tls.cert 2>/dev/null | cut -d " " -f1)
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/tls.cert 2>/dev/null | cut -d " " -f1)
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then
echo "tlsMismatch=0"
else
echo "tlsMismatch=1"
echo "err='tls.cert for user admin is old'"
fi
else
echo "tlsCopy=0"
echo "tlsMismatch=0"
echo "err='tls.cert is missing for user admin'"
fi
# check lnd.conf exits
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c 'lnd.conf')
if [ ${lndConfExists} -gt 0 ]; then
echo "config=1"
else
echo "config=0"
echo "err='lnd.conf is missing in /mnt/hdd/lnd'"
fi
# check lnd.conf exits (on SD card for admin)
lndConfExists=$(sudo ls /home/admin/.lnd/lnd.conf 2>/dev/null | grep -c 'lnd.conf')
if [ ${lndConfExists} -gt 0 ]; then
echo "configCopy=1"
# check if the same
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf 2>/dev/null | cut -d " " -f1)
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/lnd.conf 2>/dev/null | cut -d " " -f1)
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then
echo "configMismatch=0"
else
echo "configMismatch=1"
echo "err='lnd.conf for user admin is old'"
fi
else
echo "configCopy=0"
echo "configMismatch=0"
echo "err='lnd.conf is missing for user admin'"
fi
# get network from config (BLOCKCHAIN)
lndNetwork=""
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep 'bitcoin.active' | sed 's/^[a-z]*\./bitcoin_/g')
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep 'litecoin.active' | sed 's/^[a-z]*\./litecoin_/g')
if [ "${bitcoin_active}" == "1" ] && [ "${litecoin_active}" == "1" ]; then
echo "err='lnd.conf: bitcoin and litecoin are set active at the same time'"
elif [ "${bitcoin_active}" == "1" ]; then
lndNetwork="bitcoin"
elif [ "${litecoin_active}" == "1" ]; then
lndNetwork="litecoin"
else
echo "err='lnd.conf: no blockchain network is set'"
fi
echo "network='${lndNetwork}'"
# check if network is same the raspiblitz config
if [ "${network}" != "${lndNetwork}" ]; then
echo "err='lnd.conf: blockchain network in lnd.conf (${lndNetwork}) is different from raspiblitz.conf (${network})'"
fi
# get chain from config (TESTNET / MAINNET)
lndChain=""
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g')
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g')
if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then
echo "err='lnd.conf: mainnet and testnet are set active at the same time'"
elif [ "${mainnet}" == "1" ]; then
lndChain="main"
elif [ "${testnet}" == "1" ]; then
lndChain="test"
else
echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'"
fi
echo "chain='${lndChain}'"
# check if chain is same the raspiblitz config
if [ "${chain}" != "${lndChain}" ]; then
echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'"
fi
# check for admin macaroon exist (on HDD)
adminMacaroonExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon')
if [ ${adminMacaroonExists} -gt 0 ]; then
echo "macaroon=1"
else
echo "macaroon=0"
echo "err='admin.macaroon is missing in /mnt/hdd/lnd/data/chain/${network}/${chain}net'"
fi
# check for admin macaroon exist (on SD card for admin)
adminMacaroonExists=$(sudo ls /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon')
if [ ${adminMacaroonExists} -gt 0 ]; then
echo "macaroonCopy=1"
# check if the same
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | cut -d " " -f1)
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | cut -d " " -f1)
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then
echo "macaroonMismatch=0"
else
echo "macaroonMismatch=1"
echo "err='admin.macaroon for user admin is old'"
fi
else
echo "macaroonCopy=0"
echo "macaroonMismatch=0"
echo "err='admin.macaroon is missing for user admin"
fi
# check for walletDB exist
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep -c 'wallet.db')
if [ ${walletExists} -gt 0 ]; then
echo "wallet=1"
else
echo "wallet=0"
fi
# check that RPC USER between Bitcoin and LND is correct
rpcusercorrect=0
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}d.rpcuser" | sed 's/^[a-z]*\./lnd/g')
source <(sudo cat /mnt/hdd/${lndNetwork}/${lndNetwork}.conf 2>/dev/null | grep "rpcuser" | sed 's/^[a-z]*\./lnd/g')
if [ ${#lndrpcuser} -eq 0 ]; then
echo "err='lnd.conf: missing ${lndNetwork}d.rpcuser (needs to be same as set in ${lndNetwork}.conf)'"
elif [ ${#rpcuser} -eq 0 ]; then
echo "err='${lndNetwork}.conf: missing rpcuser (needs to be same as set in lnd.conf)'"
elif [ "${rpcuser}" != "${lndrpcuser}" ]; then
echo "err='${lndNetwork}.conf (${rpcuser}) & lnd.conf (${lndrpcuser}): RPC user missmatch! - LND cannot connect to blockchain RPC'"
else
# OK looks good
rpcusercorrect=1
fi
echo "rpcusercorrect=${rpcusercorrect}"
# check that RPC PASSWORD between Bitcoin and LND is correct
rpcpasscorrect=0
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}d.rpcpass" | sed 's/^[a-z]*\./lnd/g')
source <(sudo cat /mnt/hdd/${lndNetwork}/${lndNetwork}.conf 2>/dev/null | grep "rpcpassword" | sed 's/^[a-z]*\./lnd/g')
if [ ${#lndrpcpass} -eq 0 ]; then
echo "err='lnd.conf: missing ${lndNetwork}d.rpcpass (needs to be same as set in ${lndNetwork}.conf)'"
elif [ ${#rpcpassword} -eq 0 ]; then
echo "err='${lndNetwork}.conf: missing rpcpassword (needs to be same as set in lnd.conf)'"
elif [ "${rpcpassword}" != "${lndrpcpass}" ]; then
echo "err='${lndNetwork}.conf (${rpcpassword}) & lnd.conf (${lndrpcpass}): RPC password missmatch! - should autofix on reboot'"
else
# OK looks good
rpcpasscorrect=1
fi
echo "rpcpasscorrect=${rpcpasscorrect}"
else
echo "# FAIL: parameter not known"
fi

204
home.admin/config.scripts/lnd.initwallet.py

@ -0,0 +1,204 @@
#!/usr/bin/python
import codecs, os, sys, base64
# display config script info
if len(sys.argv) <= 1 or sys.argv[1] == "-h" or sys.argv[1] == "help":
print("# ! always activate virtual env first: source /home/admin/python-env-lnd/bin/activate")
print("# ! and run with with: python /home/admin/config.scripts/lnd.initwallet.py")
print("# creating or recovering the LND wallet")
print("# lnd.winitwallet.py new [walletpassword] [?seedpassword]")
print("# lnd.winitwallet.py seed [walletpassword] [\"seeds-words-seperated-spaces\"] [?seedpassword]")
print("# lnd.winitwallet.py scb [walletpassword] [\"seeds-words-seperated-spaces\"] [filepathSCB] [?seedpassword]")
print("err='missing parameters'")
sys.exit(1)
import grpc
from lndlibs import rpc_pb2 as ln
from lndlibs import rpc_pb2_grpc as lnrpc
from pathlib2 import Path
walletpassword=""
seedwords=""
seedpassword=""
filepathSCB=""
mode=sys.argv[1]
if mode=="new":
print("# *** CREATING NEW LND WALLET ***")
if len(sys.argv)>2:
walletpassword=sys.argv[2]
if len(walletpassword)<8:
print("err='wallet password is too short'")
sys.exit(1)
else:
print("err='wallet password is too short'")
sys.exit(1)
if len(sys.argv)>3:
seedpassword=sys.argv[3]
elif mode=="seed" or mode=="scb":
if len(sys.argv)>2:
walletpassword=sys.argv[2]
if len(walletpassword)<8:
print("err='wallet password is too short'")
sys.exit(1)
else:
print("err='not correct amount of parameter - missing wallet password'")
sys.exit(1)
if len(sys.argv)>3:
seedwordString=sys.argv[3]
seedwords=seedwordString.split(" ")
if len(seedwords)<24:
print("err='not 24 seed words seperated by just spaces (surrounded with \")'")
sys.exit(1)
else:
print("err='not correct amount of parameter - missing seed string'")
sys.exit(1)
if mode=="seed":
if len(sys.argv)>4:
seedpassword=sys.argv[4]
elif mode=="scb":
if len(sys.argv)>4:
filepathSCB=sys.argv[4]
scbFile = Path(filepathSCB)
if scbFile.is_file():
print("# OK SCB file exists")
else:
print("err='the given filepathSCB - file does not exists or no permission'")
sys.exit(1)
else:
print("err='not correct amount of parameter - missing seed filepathSCB'")
sys.exit(1)
if len(sys.argv)>5:
seedpassword=sys.argv[4]
else:
print("err='unkown mode parameter - run without any parameters to see options'")
sys.exit(1)
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open('/mnt/hdd/lnd/tls.cert', 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
channel = grpc.secure_channel('localhost:10009', ssl_creds)
stub = lnrpc.WalletUnlockerStub(channel)
if mode=="new":
request = ln.GenSeedRequest()
try:
response = stub.GenSeed(request)
seedwords = response.cipher_seed_mnemonic
seedwordsString=', '.join(seedwords)
print("seedwords='"+seedwordsString+"'")
# add a 6x4 formatted version to the output
seedwords6x4=""
for i in range(0,len(seedwords)):
if i % 6 == 0 and i != 0:
seedwords6x4=seedwords6x4+"\n"
singleWord=str(i+1)+":"+seedwords[i]
while len(singleWord)<12:
singleWord=singleWord+" "
seedwords6x4=seedwords6x4+singleWord
print("seedwords6x4='"+seedwords6x4+"'")
except grpc.RpcError as rpc_error_call:
code = rpc_error_call.code()
print >> sys.stderr, code
details = rpc_error_call.details()
print("err='RPCError GenSeedRequest'")
print("errMore='"+details+"'")
sys.exit(1)
except:
e = sys.exc_info()[0]
print >> sys.stderr, e
print("err='GenSeedRequest'")
sys.exit(1)
request = ln.InitWalletRequest(
wallet_password=walletpassword,
cipher_seed_mnemonic=seedwords
)
try:
response = stub.InitWallet(request)
except grpc.RpcError as rpc_error_call:
code = rpc_error_call.code()
print >> sys.stderr, code
details = rpc_error_call.details()
print("err='RPCError InitWallet'")
print("errMore='"+details+"'")
sys.exit(1)
except:
e = sys.exc_info()[0]
print >> sys.stderr, e
print("err='InitWallet'")
sys.exit(1)
elif mode=="seed":
request = ln.InitWalletRequest(
wallet_password=walletpassword,
cipher_seed_mnemonic=seedwords,
recovery_window=250,
aezeed_passphrase=seedpassword
)
try:
response = stub.InitWallet(request)
except grpc.RpcError as rpc_error_call:
code = rpc_error_call.code()
print >> sys.stderr, code
details = rpc_error_call.details()
print("err='RPCError InitWallet'")
print("errMore='"+details+"'")
sys.exit(1)
except:
e = sys.exc_info()[0]
print >> sys.stderr, e
print("err='InitWallet'")
sys.exit(1)
elif mode=="scb":
import binascii
with open(filepathSCB, 'rb') as f:
content = f.read()
scbHexString=binascii.hexlify(content)
print(scbHexString)
request = ln.InitWalletRequest(
wallet_password=walletpassword,
cipher_seed_mnemonic=seedwords,
recovery_window=250,
aezeed_passphrase=seedpassword,
channel_backups=scbHexString
)
try:
response = stub.InitWallet(request)
except grpc.RpcError as rpc_error_call:
code = rpc_error_call.code()
print >> sys.stderr, code
details = rpc_error_call.details()
print("err='RPCError InitWallet'")
print("errMore='"+details+"'")
sys.exit(1)
except:
e = sys.exc_info()[0]
print >> sys.stderr, e
print("err='InitWallet'")
sys.exit(1)
print("err='TODO: implement creating from seed/scb'")
sys.exit(1)

119
home.admin/config.scripts/lnd.rescue.sh

@ -1,9 +1,18 @@
#!/bin/bash #!/bin/bash
source /mnt/hdd/raspiblitz.conf
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small rescue script to to backup or restore" echo "# small rescue script to to backup or restore LND data"
echo "lnd.rescue.sh [backup|restore]" echo "# -> backup all LND data in a tar.gz file for download:"
echo "# lnd.rescue.sh backup [?no-download]"
echo "# -> upload a LND data tar.gz file to replace LND data:"
echo "# lnd.rescue.sh restore"
echo "# -> download the LND channel.backup file from SD card:"
echo "# lnd.rescue.sh scb-down"
echo "# -> upload the LND channel.backup to recover wallet:"
echo "# lnd.rescue.sh scb-up"
exit 1 exit 1
fi fi
@ -29,11 +38,21 @@ if [ ${mode} = "backup" ]; then
sudo tar -zcvf /home/admin/lnd-rescue.tar.gz /mnt/hdd/lnd sudo tar -zcvf /home/admin/lnd-rescue.tar.gz /mnt/hdd/lnd
sudo chown admin:admin /home/admin/lnd-rescue.tar.gz sudo chown admin:admin /home/admin/lnd-rescue.tar.gz
# delete old backups
rm /home/admin/lnd-rescue-*.tar.gz 2>/dev/null
# name with md5 checksum # name with md5 checksum
md5checksum=$(md5sum /home/admin/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1) md5checksum=$(md5sum /home/admin/lnd-rescue.tar.gz | head -n1 | cut -d " " -f1)
mv /home/admin/lnd-rescue.tar.gz /home/admin/lnd-rescue-${md5checksum}.tar.gz mv /home/admin/lnd-rescue.tar.gz /home/admin/lnd-rescue-${md5checksum}.tar.gz
# stop here in case of 'no-download' option
if [ "${2}" == "no-download" ]; then
echo "No download of LND data requested."
exit 0
fi
# offer SCP for download # offer SCP for download
clear
echo echo
echo "****************************" echo "****************************"
echo "* DOWNLOAD THE BACKUP FILE *" echo "* DOWNLOAD THE BACKUP FILE *"
@ -47,7 +66,7 @@ if [ ${mode} = "backup" ]; then
echo "BEWARE: Your Lightning node is now stopped. So its safe to backup the data and restore it" echo "BEWARE: Your Lightning node is now stopped. So its safe to backup the data and restore it"
echo "later on - for example on a fresh RaspiBlitz. But once this Lightning node gets started" echo "later on - for example on a fresh RaspiBlitz. But once this Lightning node gets started"
echo "again by 'sudo systemctl start lnd' or a reboot its not adviced to restore the backup file" echo "again by 'sudo systemctl start lnd' or a reboot its not adviced to restore the backup file"
echo "anymore bacause it cointains outdated channel data and can lead to loss of channel funds." echo "anymore because it cointains outdated channel data and can lead to loss of channel funds."
elif [ ${mode} = "restore" ]; then elif [ ${mode} = "restore" ]; then
@ -55,9 +74,12 @@ elif [ ${mode} = "restore" ]; then
# RESTORE # RESTORE
################################ ################################
echo "*** LND.RESCUE --> RESTORE" echo "# LND.RESCUE --> RESTORE"
echo "" echo ""
# delete old backups
rm /home/admin/lnd-rescue-*.tar.gz
filename="" filename=""
while [ ${#filename} -eq 0 ] while [ ${#filename} -eq 0 ]
do do
@ -66,9 +88,10 @@ elif [ ${mode} = "restore" ]; then
echo "**************************" echo "**************************"
echo "* UPLOAD THE BACKUP FILE *" echo "* UPLOAD THE BACKUP FILE *"
echo "**************************" echo "**************************"
echo
echo "If you have a lnd-rescue backup file on your laptop you can now" echo "If you have a lnd-rescue backup file on your laptop you can now"
echo "upload it and restore the your old LND state." echo "upload it and restore the your latest LND state."
echo
echo "CAUTION: Dont restore old LND states - risk of loosing funds!"
echo echo
echo "To make upload open a new terminal on your laptop," echo "To make upload open a new terminal on your laptop,"
echo "change into the directory where your lnd-rescue file is and" echo "change into the directory where your lnd-rescue file is and"
@ -76,14 +99,15 @@ elif [ ${mode} = "restore" ]; then
echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/" echo "scp -r ./lnd-rescue-*.tar.gz admin@${localip}:/home/admin/"
echo "" echo ""
echo "Use password A to authenticate file transfere." echo "Use password A to authenticate file transfere."
echo echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel."
echo "PRESS ENTER when upload is done. Use CTRL-C to abort."
fi fi
if [ ${countZips} -gt 1 ]; then if [ ${countZips} -gt 1 ]; then
echo "!! WARNING !!" echo "!! WARNING !!"
echo "There are multiple lnd-rescue files in directory /home/admin." echo "There are multiple lnd-rescue files in directory /home/admin."
echo "Make sure there is only one file to work with and start again." echo "Make sure you upload only one tar.gz-file and start again."
echo echo
echo "PRESS ENTER to continue."
read key
exit 1 exit 1
fi fi
if [ ${countZips} -eq 1 ]; then if [ ${countZips} -eq 1 ]; then
@ -108,12 +132,18 @@ elif [ ${mode} = "restore" ]; then
echo "Recommend to abort and upload again!" echo "Recommend to abort and upload again!"
fi fi
oldWalletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep -c "wallet.db")
if [ ${oldWalletExists} -gt 0 ]; then
echo
echo "WARNING: This will delete/overwrite the LND state/funds of this RaspiBlitz."
fi
echo echo
echo "WARNING: This will delete the actual LND state/funds of this RaspiBlitz." echo "PRESS ENTER to start restore. Enter x & ENTER to cancel."
echo
echo "PRESS ENTER to start restore. Use CTRL-C to abort."
fi fi
read key read key
if [ "${key}" == "x" ]; then
exit 1
fi
done done
# stop LND # stop LND
@ -143,9 +173,72 @@ elif [ ${mode} = "restore" ]; then
echo echo
echo "DONE - please check if LND starts up correctly with restored state and funds." echo "DONE - please check if LND starts up correctly with restored state and funds."
echo "Keep in mind that some channels got forced closed by channel partners in the meanwhile." echo "Keep in mind that some channels maybe forced closed in the meanwhile."
echo echo
elif [ ${mode} = "scb-down" ]; then
echo
echo "****************************"
echo "* DOWNLOAD THE BACKUP FILE *"
echo "****************************"
echo
echo "RUN THE FOLLOWING COMMAND ON YOUR LAPTOP IN NEW TERMINAL:"
echo "scp -r admin@${localip}:/home/admin/.lnd/data/chain/${network}/${chain}net/channel.backup ./"
echo ""
echo "Use password A to authenticate file transfere."
echo
echo "NOTE: Use this file when setting up a fresh RaspiBlitz by choosing"
echo "option OLD WALLET and then SCB+SEED -> Seed & channel.backup file"
echo "Will just recover on-chain & channel-funds, but closing all channels"
elif [ ${mode} = "scb-up" ]; then
gotFile=-1
while [ ${gotFile} -lt 1 ]
do
# show info
clear
sleep 1
echo "**********************************"
echo "* UPLOAD THE channel.backup FILE *"
echo "**********************************"
echo
if [ ${gotFile} -eq -1 ]; then
echo "If you have the channel.backup file on your laptop or on"
echo "another server you can now upload it to the RaspiBlitz."
elif [ ${gotFile} -eq 0 ]; then
echo "NO channel.backup FOUND IN /home/admin"
echo "Please try upload again."
fi
echo
echo "To make upload open a new terminal and change,"
echo "into the directory where your lnd-rescue file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:"
echo "scp ./channel.backup admin@${localip}:/home/admin/"
echo ""
echo "Use password A to authenticate file transfere."
echo "PRESS ENTER when upload is done. Enter x & ENTER to cancel."
# wait user interaction
echo "Please upload file. Press ENTER to try again or (x & ENTER) to cancel."
read key
if [ "${key}" == "x" ]; then
# EXIT with CODE 1 --> USER CANCEL
echo "# CANCEL upload"
exit 1
fi
# test upload
gotFile=$(ls /home/admin/channel.backup | grep -c 'channel.backup')
done
# EXIT with CODE 1 --> FILE UPLOADED
echo "# OK channel.backup uploaded"
exit 0
else else
echo "unknown parameter '${mode}' - exit" echo "unknown parameter '${mode}' - exit"
fi fi

98
home.admin/config.scripts/lnd.setaddress.sh

@ -0,0 +1,98 @@
#!/bin/bash
# INFO : Does not need to be part of update/provision, because
# all data is already on HDD ready
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a fixed domain or IP for LND"
echo "internet.setaddress.sh [on|off] [?address]"
exit 1
fi
# 1. parameter [on|off]
mode="$1"
echo "number of args($#)"
# config file
configFile="/mnt/hdd/raspiblitz.conf"
# lnd conf file
lndConfig="/mnt/hdd/lnd/lnd.conf"
# check if config file exists
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
echo "FAIL - missing ${configFile}"
exit 1
fi
# get hash of lnd.conf before edit (to detect if changed later)
md5HashBefore=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf)
# FIXED DOMAIN/IP
if [ "${mode}" = "on" ]; then
address=$2
if [ ${#address} -eq 0 ]; then
echo "missing parameter"
exit 1
fi
echo "switching fixed LND Domain ON"
echo "address(${address})"
# setting value in raspi blitz config
sudo sed -i "s/^lndAddress=.*/lndAddress='${address}'/g" /mnt/hdd/raspiblitz.conf
echo "changing lnd.conf"
# lnd.conf: uncomment tlsextradomain (just if it is still uncommented)
sudo sed -i "s/^#tlsextradomain=.*/tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf
# lnd.conf: domain value
sudo sed -i "s/^tlsextradomain=.*/tlsextradomain=${address}/g" /mnt/hdd/lnd/lnd.conf
# refresh TLS cert
md5HashAfter=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf)
if [ "${md5HashAfter}" != "${md5HashBefore}" ]; then
echo "# lnd.conf changed - TLS certs need refreshing"
sudo /home/admin/config.scripts/lnd.newtlscert.sh
else
echo "# lnd.conf NOT changed - keep TLS certs"
fi
echo "fixedAddress is now ON"
fi
# switch off
if [ "${mode}" = "off" ]; then
echo "switching fixedAddress OFF"
# stop services
echo "making sure services are not running"
sudo systemctl stop lnd 2>/dev/null
# setting value in raspi blitz config
sudo sed -i "s/^lndAddress=.*/lndAddress=''/g" /mnt/hdd/raspiblitz.conf
echo "changing lnd.conf"
# lnd.conf: comment tlsextradomain out
sudo sed -i "s/^tlsextradomain=.*/#tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf
# refresh TLS cert
md5HashAfter=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf)
if [ "${md5HashAfter}" != "${md5HashBefore}" ]; then
echo "# lnd.conf changed - TLS certs need refreshing"
sudo /home/admin/config.scripts/lnd.newtlscert.sh
else
echo "# lnd.conf NOT changed - keep TLS certs"
fi
echo "fixedAddress is now OFF"
fi
echo "may needs reboot to run normal again"
exit 0

2
home.admin/config.scripts/lnd.setname.sh

@ -17,7 +17,7 @@ if [ ${#newName} -eq 0 ]; then
dialog --backtitle "Set LND Name/Alias" --inputbox "ENTER the new Name/Alias for LND node: dialog --backtitle "Set LND Name/Alias" --inputbox "ENTER the new Name/Alias for LND node:
(free to choose, one word, use basic characters) (free to choose, one word, use basic characters)
" 8 52 2>./.tmp " 8 52 2>./.tmp
newName=$( cat ./.tmp ) newName=$( cat ./.tmp | tr -dc '[:alnum:]\n\r' )
if [ ${#newName} -eq 0 ]; then if [ ${#newName} -eq 0 ]; then
echo "FAIL input cannot be empty" echo "FAIL input cannot be empty"
exit 1 exit 1

13
home.admin/config.scripts/lnd.setport.sh

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# based on: https://github.com/rootzoll/raspiblitz/issues/100#issuecomment-465997126 # based on: https://github.com/rootzoll/raspiblitz/issues/100#issuecomment-465997126
# based on: https://github.com/rootzoll/raspiblitz/issues/386
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "small config script set the port LND is running on" echo "small config script set the port LND is running on"
@ -62,9 +63,19 @@ sudo systemctl disable lnd
echo "change port in lnd config" echo "change port in lnd config"
sudo sed -i "s/^listen=.*/listen=0.0.0.0:${portnumber}/g" /mnt/hdd/lnd/lnd.conf sudo sed -i "s/^listen=.*/listen=0.0.0.0:${portnumber}/g" /mnt/hdd/lnd/lnd.conf
# add to raspiblitz.config (so it can survive update)
valueExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c 'lndPort=')
if [ ${valueExists} -eq 0 ]; then
# add as new value
echo "lndPort=${portnumber}" >> /mnt/hdd/raspiblitz.conf
else
# update existing value
sudo sed -i "s/^lndPort=.*/lndPort=${portnumber}/g" /mnt/hdd/raspiblitz.conf
fi
# editing service file # editing service file
echo "editing /etc/systemd/system/lnd.service" echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:${portnumber}/g" /etc/systemd/system/lnd.service sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}:\${lndPort}/g" /etc/systemd/system/lnd.service
# enable service again # enable service again
echo "enable service again" echo "enable service again"

28
home.admin/config.scripts/lndlibs/README.md

@ -0,0 +1,28 @@
For every new LND version the LND RPC libs need to be compiled from the matching protobuff files.
Do this on a raspberrypi with the exact same python version the scripts will be are running on.
See https://dev.lightning.community/guides/python-grpc/
Make sure Virtual Environment is setup:
```
sudo apt-get -f -y install virtualenv
virtualenv lnd
source lnd/bin/activate
pip install grpcio grpcio-tools googleapis-common-protos
```
Normally that is already done by build_sdcard.sh for user admin user. So just run:
```
source lnd/bin/activate
````
Now to generate the lnd RPC libs:
```
git clone https://github.com/googleapis/googleapis.git
curl -o rpc.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/rpc.proto
python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. rpc.proto
````
*NOTE: If LND master branch is already a version ahead .. use the rpc.proto from the version tagged branch.*
Now copy the generated RPC libs per SCP over to your Laptop and add them to the `/home/admin/config.scripts/lndlibs`.

0
home.admin/config.scripts/lndlibs/__init__.py

2367
home.admin/config.scripts/lndlibs/rpc.proto

File diff suppressed because it is too large

8039
home.admin/config.scripts/lndlibs/rpc_pb2.py

File diff suppressed because one or more lines are too long

BIN
home.admin/config.scripts/lndlibs/rpc_pb2.pyc

Binary file not shown.

1226
home.admin/config.scripts/lndlibs/rpc_pb2_grpc.py

File diff suppressed because it is too large

BIN
home.admin/config.scripts/lndlibs/rpc_pb2_grpc.pyc

Binary file not shown.

3
home.admin/config.scripts/network.reindex.sh

@ -59,6 +59,7 @@ while [ ${finished} -eq 0 ]
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo)
progress=$(echo "${blockchaininfo}" | jq -r '.verificationprogress') progress=$(echo "${blockchaininfo}" | jq -r '.verificationprogress')
#progress=$(echo "${progress}*100" | bc) #progress=$(echo "${progress}*100" | bc)
progress=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}')
inprogress="$(echo "${blockchaininfo}" | jq -r '.initialblockdownload')" inprogress="$(echo "${blockchaininfo}" | jq -r '.initialblockdownload')"
if [ "${inprogress}" = "false" ]; then if [ "${inprogress}" = "false" ]; then
finished=1 finished=1
@ -97,6 +98,6 @@ echo "*************************"
sudo -u bitcoin ${network}-cli stop sudo -u bitcoin ${network}-cli stop
sleep 4 sleep 4
# clean logs (to prevent a false reindex detection) # clean logs (to prevent a false reindex detection)
sudo rm /mnt/hdd/${network}/debug.log sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null
# reboot # reboot
sudo shutdown -r now sudo shutdown -r now

1584
home.admin/infoblitzd.py

File diff suppressed because it is too large

BIN
pictures/bitcoin512.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
pictures/hardwaresetup.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
pictures/mainmenu-services.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 24 KiB

BIN
pictures/mainmenu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 59 KiB

BIN
pictures/mainmenu1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

BIN
pictures/mainmenu2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
pictures/mainmenu3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
pictures/mobile.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 56 KiB

BIN
pictures/ok.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

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

Loading…
Cancel
Save