Merge pull request #1 from rootzoll/master

rebase
This commit is contained in:
geco91 2018-10-21 22:53:31 +02:00 committed by GitHub
commit 6adac4825f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 22430 additions and 9159 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 The RaspiBlitz developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

124
README.md
View File

@ -1,9 +1,11 @@
[ [Hardware](#hardware-needed-amazon-shopping-list) ] -- [ [Setup](#boot-your-raspiblitz) ] -- [ [Documentation](#documentation) ] -- [ [Education](#educational-tutorials) ] -- [ [Development](#further-development-of-raspiblitz) ]
[ [Hardware](#hardware-needed-amazon-shopping-list) ] -- [ [Setup](#boot-your-raspiblitz) ] -- [ [Documentation](#documentation) ] -- [ [Development](#further-development-of-raspiblitz) ]
-----
# RaspiBlitz
Fastest and cheapest way to get your own Lightning Node running - on a RaspberryPi with a nice LCD.
`Latest Version with lnd 0.5 and bitcoin 0.17.0rc4 & litecoin 0.16.3 (both with dos bugfix).`
![RaspiBlitz](pictures/raspiblitz.jpg)
*This tutorial is based on the RaspiBolt project - you can find in detail here: https://github.com/Stadicus/guides/blob/master/raspibolt The RaspiBlitz serves as a shortcut through this setup process with some changes and an additional LCD display so that you can quickly experiment with a Lightning node and start working on your LApps on a hacking event (or at home). This shortcut is fine for testnet usage and maybe trying some small things on mainnet. But if you choose to go full reckless afterwards … please consider taking the time and work thru the original RaspiBolt project. Dont trust us, verify.*
@ -13,28 +15,37 @@ Fastest and cheapest way to get your own Lightning Node running - on a Raspberry
* [ [Hardware](#hardware-needed-amazon-shopping-list) ] Shopping Lists and Putting all together
* [ [Setup](#boot-your-raspiblitz) ] Init and Setup your RaspiBlitz Lightning Node
* [ [Documentation](#documentation) ] Features and Usecases
* [ [Education](#educational-tutorials) ] Tutorials with the RaspiBlitz to learn about Lightning
* [ [Development](#further-development-of-raspiblitz) ] Lets work together on the RaspiBlitz
## Hardware Needed (Amazon Shopping List)
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.de:*
* RaspBerry Pi 3 (31,99 EUR) https://www.amazon.de/dp/B01CD5VC92
* Micro SD-Card 16GB (7,11 EUR) https://www.amazon.de/dp/B0162YQEIE
* Power >=3A (9,29 EUR) https://www.amazon.de/dp/B01E75SB2C
* 1TB Hard Drive (49,99 EUR) https://www.amazon.de/dp/B00KWHJY7Q
* RaspBerry Pi 3 (34,99 EUR) https://www.amazon.de/dp/B07BDR5PDW
* Micro SD-Card 16GB (7,99 EUR) https://www.amazon.de/gp/product/B073K14CVB/
* Power >=3A (9,99 EUR) https://www.amazon.de/gp/product/B078567K85
* 1TB Hard Drive (44,98 EUR) https://www.amazon.de/dp/B07997KKSK?th=1
* Case (9,36 EUR) https://www.amazon.de/dp/B0173GQF8Y
* LCD-Display (19,58 EUR) https://www.amazon.de/dp/B01JRUH0CY
* LCD-Display (16,88 EUR) https://www.amazon.de/gp/product/B06X191RX7
**Total Price: 127,31 EUR** (thats under 150 USD)
**Total Price: 124,19 EUR** (thats under 150 USD)
Amazon shopping lists for different countries:
[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ] [ [FR](shoppinglist_fr.md) ]
[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ] [ [FR](shoppinglist_fr.md) ] [ [China](shoppinglist_cn.md) ]
You can even pay your RaspiBlitz Amazon Shopping with Bitcoin & Lightning thru [Bitrefill](https://blog.bitrefill.com/its-here-buy-amazon-vouchers-with-bitcoin-on-bitrefill-bb2a4449724a).
### Optional Hardware
The shopping list for China refers to Taobao/T-Mall.
### 3D Printed Case (optional)
You can replace the generic case in the shopping lists above with a customized 3D printed for the RaspiBlitz called "Lightning Shell" - great work by @CryptoCloaks
https://thecryptocloak.com/product/lightningshell/
![LightningShell](pictures/lightningshell.png)
### More optional Hardware
*Some optional goodies to consider to add to your shopping list for your RaspiBlitz (Amazon DE/US):*
@ -46,8 +57,6 @@ You can even pay your RaspiBlitz Amazon Shopping with Bitcoin & Lightning thru [
If you organizing an educational event where you want to support people learning on and with multiple RaspiBlitz, here is a package list of useful hardware to have at that event: [ [Event Package List](shoppinglist_event.md) ]
## Prepare your Hardware
*There are two ways to start:*
@ -59,7 +68,7 @@ If you are at an event, ask for a ready-2-go set or if you have your own hardwar
You got all the hardware of the shopping list above and you have no further assistance. Then you need to prepare your SD-Card yourself .. this scenario is still experimental, feedback needed and can take some time.
1. Download SD-Card image:
http://wiki.fulmo.org/downloads/raspiblitz-2018-08-02.img.gz
https://wiki.fulmo.org/downloads/raspiblitz-2018-09-22.img.gz (or [build your own](#build-the-sd-card-image))
2. Write the SD-Card image to your SD Card - if you need details, see here:
https://www.raspberrypi.org/documentation/installation/installing-images/README.md
@ -147,7 +156,9 @@ The option "SYNC" should just be use as a fallback. So normally you have the fol
#### Download the Blockchain
This is the recommended way for users that are making the setup at home without any further assistance but can take quite some time. You can choose to download over TORRENT or FTP-DOWNLOAD. Choose the FTP is the torrent if not working for you. To stop torrent and choose another option use CTRL+z and then start './10setupBlitz.sh' from terminal.
This is the recommended way for users that are making the setup at home without any further assistance but can take quite some time. You can choose to download over TORRENT or FTP-DOWNLOAD. Choose the FTP if the torrent is not working for you.
For more details: [Background on Download Blockchain](background_downloadBlockchain.md)
#### Copy the Blockchain
@ -167,7 +178,7 @@ To connect the 2nd HDD to the RaspiBlitz, the use of a Y cable to provide extra
![ExtraPower](pictures/extrapower.png)
**Background: If the blockchain was already on the HDD or was acquired successfully, the script `60finsihHDD.sh` will be called. It will further prepare the HDD and start the bitcoin service.*
**Background: If the blockchain was already on the HDD or was acquired successfully, the script `60finishHDD.sh` will be called. It will further prepare the HDD and start the bitcoin service.*
#### Lightning
@ -201,15 +212,19 @@ After SSH back in as admin the main menu shows the unlock option:
Once the wallet is unlocked the setup is finally over and the main menu shows the option and features of the RaspiBlitz:
![SSH9e](pictures/ssh9e-mainmenu.png)
![SSH9e1](pictures/ssh9e-mainmenu1.png)
And if you scroll down .. you see even more feature options:
![SSH9e2](pictures/ssh9e-mainmenu2.png)
*Background: The script `00mainMenu.sh` is now the place to offer further features und extend the possibilities of the RaspiBlitz. Feel free to come up with ideas. Check out the developer section at the end of this page.*
### Features
But you manually extened your RaspiBlitz with features listed in the RaspiBlot Guide: https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_60_bonus.md
But you manually extened your RaspiBlitz with features listed in the RaspiBolt Guide: https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_60_bonus.md
Already integrated features of the RaspiBlitz are/willbe listed as part of the main menu after connecting per ssh with the admin user.
Already integrated features of the RaspiBlitz are/will be listed as part of the main menu after connecting via ssh as admin user.
*Background: The script `91addBonus.sh` is the place to put your setup of features you want to add to RaspiBlitz. Its run at the end of the automated setup process before final reboot. To make the feature executable for the user, add a new option to the `00mainMenu.sh`*
@ -223,11 +238,76 @@ Already integrated features of the RaspiBlitz are/willbe listed as part of the m
<img src="pictures/bonus-lnchannels.png" alt="bonus-lnchannels" width="600">
## Educational Tutorials
#### TOR Integration (experimental)
*Once the Setup Process is done, the learning and building should begin ... more detailed educational content should be added in this section in the future.*
You can use the Switch to TOR option from the main menu to make the node reachable thru TOR. This way you can get thru a NAT without needed to open/forward ports on your router. Bitcoin and LND will have a seperate onion-address displayed on LCD and the Status Info Screen option in menu.
A good way to start for now is to get some Testnet coins, connect to other peers and make your first transactions. You find tutorials for this at the original RaspiBolt guide: https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#get-some-testnet-bitcoin
![tor1](pictures/tor1.png)
The TOR integration is experimental and at the moment there is no way to switch off TOR again.
#### Connect to Mobile Wallet
There is now the option to connect and control your LND node with the mobile app called "Shango" - choose option in the main menu.
![shango1](pictures/shango1.png)
#### RaspiBlitz as Backend for BTCPayServer (experimental)
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 here: https://goo.gl/KnTzLu
Thanks to @RobEdb (ask on twitter for more details) running his demo store with RaspiBlitz: https://store.edberg.eu - buy a picture of [him and Andreas](https://store.edberg.eu/produkt/jag-andreas/) :)
## Build the SD Card Image
A ready to use SD card image of the RaspiBlitz for your RaspberryPi is provided as download by us to get everbody started quickly. 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/)
* 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
* Start card in Raspi and login per SSH with `ssh pi@[IP-OF-YOUR-RASPI]` password is `raspberry`
Now you are ready to start the SD card build script - copy the following command into your terminal and execute:
`wget https://raw.githubusercontent.com/rootzoll/raspiblitz/master/build.sdcard/raspbianStretchDesktop.sh && sudo bash raspbianStretchDesktop.sh`
As you can see from the URL you find the build script in this Git repo under `build.sdcard/raspbianStretchDesktop.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. And the end the LCD drives get installed and a reboot is needed. Remember the default password is now `raspiblitz`. You can login per SSH again - this time use root: `ssh root@[IP-OF-YOUR-RASPI]` and simply shutdown with `sudo shutdown now`. Once you see the LCD going white and the actovity LED of the pi starts going dark. You can unplug power and remove the SD card. You have now build 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.*
## Update to a new SD Card Release
At the beginning of this README you can find the newest SD card we provide. Or you can build the newest SD card image yourself like in the chapter above. The SD card image is used to setup a fresh install of the RaspiBlitz. So what to do if you already have an older version running and you want to upgrade?
Until we reach version 1.0 the update process will be a bit rough .. so what you do is:
* close all open lightning channels you have (`lncli closeallchannels --force`)
* wait until all closing transactions are done
* move all on-chain funds to a wallet outside raspiblitz (`lncli --conf_target 3 sendcoins [ADDRESS]`)
* run the script `./XXcleanHDD.sh` in admin home directory (Blockchain will stay on HDD)
* shutdown RaspiBlitz (`sudo shutdown now`)
* flash SD card with new image
* Redo a fresh setup of RaspiBlitz
* Move your funds back in
* Re-Open your channels
We know that this is not optimal yet. But until version 1.0 we will change too much stuff to garantue any other save update mechanism. Also by redoing all the setup you help out on testing the lastest setup process.
From the upcomming version 1.0 onwards the goal is to make it easier to keep up with the lastest RaspiBlitz updates.
## Mobile Development: Connect RaspiBlitz without a Router/Switch
To connect a 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:
* connect with LAN directly
* Settings > Sharing/Freigaben > activate "internet sharing" from WLAN to Ethernet
* Settings > Network > Ethernet-Adapter > set to DHCP
* in terminal > `ifconfig` there you should the the IP of the bridge100
* in terminal > `arp -a` and check for an IP of a client to the bridge
* in terminal > ssh admin@[clientIP]
## Further Development of RaspiBlitz
@ -239,4 +319,4 @@ Everybody is welcome to join, improve and extend the RaspiBlitz - its a work in
Join me on twitter [@rootzoll](https://twitter.com/rootzoll), visit us at a [#lightninghackday](https://twitter.com/hashtag/LightningHackday?src=hash) in Berlin or drop by the Bitcoin Assembly at the [#35C3](https://twitter.com/hashtag/35C3).
IRC channel on Freenode `irc://irc.freenode.net/raspiblitz`
IRC channel on Freenode `irc://irc.freenode.net/raspiblitz` (unmoderated)

View File

@ -0,0 +1,150 @@
# Background: Blockchain Download
## Why do we need to download the blockchain and not syncing it?
The RaspiBlitz is powered by the RaspberryPi. The processing power of this SingleBoardComputer is too low to make a fast sync of the blockchain from the bitcoin peer to peer network during setup process (validation). To sync and index the complete blockchain could take weeks or even longer. Thats why the RaspiBlitz needs to download a prepared blockchain from another source.
## Is downloading the blockchain secure?
The downloaded Blockchain is pre-indexed and pre-validated. That is 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 would simply just dont work in practice.
There might be theoretical scenarios why it would be bad for the whole network if anybody is downloading a prepared blockchain and not syncing and self-validating every block, but with a lot of self-validating full nodes already out there, just putting some RaspiBlitz with a downloaded blockchain into the mix and runnig as a self-valifating full node from that point on, is practically just strengthening the the overall network. And dont forget, the most important part of running a full node is to validate the new blocks summited by the miners - to balance out there power and to keep the Bitcoin network running by our rules.
If you have any link to a more detailed discussion of this topic, please add it here for people to do their own research.
## Blockchain Data
The RaspiBlitz needs the following files from a bitcoind (>=0.17.0) that is fully sync and has indexing switched on (txindex=1) - all files from the directories:
```
/blocks
/chainstate
/indexes
```
Make sure not to add other files like wallet data or lock files to a prepared download.
You might want to include the testnet data also - then add the testnet3 folder that just contains the same three folders from the testnet blockchain.
On download all those files need to be placed finally in the /mnt/hdd/bitcoin folder of the RaspiBlitz.
## Download Process
At the moment the RaspiBlitz offers two technical ways to download the blockchain:
### FTP Download (fallback)
The easiest way is to put the blockchain data on a FTP server and let people download it. FTP is able to download complete directories - HTTP can just handle single file. FTP clients and server hosting is widly available.
The downside that this is a central point solution and is hard to scale up (without spending a lot of money). But it is available as a backup, if other solutions do not work.
### Torrent Download (default)
The preferred way is to to download the blockchain data thru the peer2peer torrent network. This way the community can help to seed the torrents (at least while downloading). Supporters of the project can setup constant seeding. There is no single point of failure within the download structure.
In the beginning we used just on torrent file - containing all the directories and data like mentioned above. But this had the downside, that everytime when we update the torrent the seeding is bad in the beginning and downloads are slow. Good seeding needs time to build up.
Thats why there are two torrent files now:
#### Base Torrent File
Inspired by the website getbitcoinblockchain.com we use one of their base torrent files to have a basic set of blocks - that will not change for the future. This torrent contains most of the data (the big file) and we dont need to change the torrent for a long time. This way the torrent can get establish a wide spread seeding and the torrent network can take the heavy load.
At the moment this is just the blk and rev files up to the number:
- /blocks : 01385
- /testnet3/blocks: 00152
#### Update Torrent File (Description)
All the rest of the files get packaged into a second torrent file. This file will be updated much more often. The seeding is expected to be not that good and download may be slower, but thats OK because its a much smaller file.
This way a good balance between good seeding and up-to-date blockchain can be reached.
#### Update Torrent File (Creation)
To create the Update Torrent file, follow the following step ...
Have a almost 100% synced bitcoind MAINNET with txindex=1 on a RaspiBlitz
Stop bitcoind with:
```
sudo systemctl stop bitcoind
```
Delete base torrent blk-files with:
```
sudo rm /mnt/hdd/bitcoin/blocks/blk00*.dat
sudo rm /mnt/hdd/bitcoin/blocks/blk0{1000..1390}.dat
```
Delete base torrent rev-files with:
```
sudo rm /mnt/hdd/bitcoin/blocks/rev00*.dat
sudo rm /mnt/hdd/bitcoin/blocks/rev0{1000..1390}.dat
```
Now change to your computer where you package the torrent files and transfere the three directories into your torrent base directory (should be your current working directory):
```
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/blocks ./blocks
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/chainstate ./chainstate
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/indexes ./indexes
```
Also have a almost 100% synced bitcoind TESTNET with txindex=1 on a RaspiBlitz
Stop bitcoind with:
```
sudo systemctl stop bitcoind
```
Delete base torrent blk-files with:
```
sudo rm /mnt/hdd/bitcoin/testnet3/blocks/blk000*.dat
sudo rm /mnt/hdd/bitcoin/testnet3/blocks/blk00{100..152}.dat
```
Delete base torrent rev-files with:
```
sudo rm /mnt/hdd/bitcoin/testnet3/blocks/rev000*.dat
sudo rm /mnt/hdd/bitcoin/testnet3/blocks/rev00{100..152}.dat
```
Now change again to your computer where you package the torrent files and transfere the three directories into your torrent base directory (should be your current working directory):
```
mkdir testnet3
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/testnet3/blocks ./testnet3/blocks
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/testnet3/chainstate ./testnet3/chainstate
scp -r bitcoin@[RaspiBlitzIP]:/mnt/hdd/bitcoin/testnet3/indexes ./testnet3/indexes
```
(Re-)name the "torrent base directory" to the same name as the torrent UPDATE file itself later (without the .torrent ending). For the correct naming see the chapter "Torrent Files Naming Schema" below.
Now open your torrent client (e.g. qTorrent for OSX) and create a new torrent-file with the freshly renamed "torrent base directory" as source directory.
Add this list of trackers to your torrent and start seeding (keep a free/empty line between the three single trackers):
```
udp://tracker.justseed.it:1337
udp://tracker.coppersurfer.tk:6969/announce
udp://open.demonii.si:1337/announce
udp://denis.stalker.upeer.me:6969/announce
```
Name the new torrent file
To create the torrent file can take some time. Finally add the generated torrent file to the /home.admin/assets/ of the github and change the name of the updateTorrent varibale file in the script 50torrentHDD.bitcoin.sh
#### Torrent Files Naming Schema
The base torrent file should always have the following naming scheme:
`raspiblitz-[CHAINNETWORK][BASEITERATIONNUMBER]-[YEAR]-[MONTH]-[DAY]-base.torrent`
So for example the second version of the base torrent for litecoin created on 2018-10-31 would have this name: raspiblitz-litecoin2-2018-10-31-base.torrent
The update torrentfile should always have the following naming schema:
`raspiblitz-[CHAINNETWORK][BASEITERATIONNUMBER]-[YEAR]-[MONTH]-[DAY]-update.torrent`
So for exmaple an update torrent created on 2018-12-24 for litecoin that is an update to the second base torrent version would have this name: raspiblitz-litecoin2-2018-12-24-update.torrent

View File

@ -0,0 +1,43 @@
# Background: RaspiBlitz Settings
## Before Version 1.0
The RaspiBlitz started as small collection of shell scripts to setup a bitcoin+lightning node. At this time it was not needed to have settings file. The idea was that the scripts analyse the system state and make the changes required - automatically trying to catch up. That was OK as long RaspiBlitz was just a helper to setup your Lightning node and the rest was up to you.
Over time users that are running a RaspiBlitz expected that it can handle more complex setup and customization. Also it should be easy to update the system (exchange sd card with a newer image) and should be able to have the same configuration afterwards - keeping its state. Thats why starting from version 1.0 there will be a raspiblitz config file stored on the HDD that stores stores the config state.
## The Config File
The RaspiBlitz config file is stored on the HDD root:
`/mnt/hdd/raspiblitz.conf`
Its simple structure is: one key-value pair per line. In the end its bash-script syntax to define varibales. The RaspiBlitz shell scripts can import this file with:
`source /mnt/hdd/raspiblitz.conf`
After this line all the config values are available and can be worked with. I prefer to call this line in scripts explicitly and not setting this values as environment variables, because when you read as a newbie such a script, you get an idea where the config file is stored.
## The Config Values
So see what config parameters are available check the comments in the following script:
`/home/admin/_bootstrap.sh`
## Adding new Config Values
If you extend the RaspiBlitz scripts and you have the need to add a new config key-value add it to the `/home/admin/00enforceConfig.sh` script. There is a section for default values and setting them in the config file, if they dont exist there yet. Because this script runs on every startup, you can be sure that the default value is then available to your extended script - especially if people update their system.
## Bootstrap Service: Enforcing the Config
On every start of the RaspiBlitz take the config file and check if the system is running as stated in the config file and when needed make changes to the system. This is done by calling this script on startup with systemd:
`/home/admin/_bootstrap.sh`
So if you change the config by hand or you write a script that changes the config, then simply trigger a restart the RaspiBliz.
Having this script checking the system on every startup, the user can easily update the SD card with a fresh image and the system will automatically establish the old state.
## What to put into the config file and what not
All values users put into setup or setting dialogs and that is not stored on the HDD (for example in the config files of lnd or bitcoin) is a hot cadidate to put into the raspi config file. Some values make sense to get stored as a duplicate (for performance or easy of access) - but dont get to wild.

View File

@ -0,0 +1,422 @@
#!/bin/bash
#########################################################################
# Build your SD card image based on:
# RASPBIAN STRETCH WITH DESKTOP (2018-06-27)
# https://www.raspberrypi.org/downloads/raspbian/
# SHA256: 8636ab9fdd8f58a8ec7dde33b83747696d31711d17ef68267dbbcd6cfb968c24
##########################################################################
# setup fresh SD card with image above - login per SSH and run this script:
##########################################################################
echo ""
echo "****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v0.95 *"
echo "****************************************"
echo ""
echo ""
echo "*** CHECK BASE IMAGE ***"
# armv7=32Bit , armv8=64Bit
echo "Check if Linux ARM based ..."
isARM=$(uname -m | grep -c 'arm')
if [ ${isARM} -eq 0 ]; then
echo "!!! FAIL !!!"
echo "Can just build on ARM Linux, not on:"
uname -m
exit 1
fi
echo "OK running on Linux ARM architecture."
# keep in mind thet 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
# update debian
echo ""
echo "*** UPDATE DEBIAN ***"
sudo apt-get update
sudo apt-get upgrade -f -y --allow-change-held-packages
# special prepare when DietPi
if [ "${baseImage}" = "dietpi" ]; then
echo ""
echo "*** PREPARE DietPi ***"
echo "renaming dietpi user ti pi"
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
sudp apt-get install -y python-pip
fi
# special prepare when Raspbian
if [ "${baseImage}" = "raspbian" ]; then
echo ""
echo "*** PREPARE Raspbian ***"
# do memory split (16MB)
sudo raspi-config nonint do_memory_split 16
# set to wait until network is available on boot (0 seems to yes)
sudo raspi-config nonint do_boot_wait 0
# set WIFI country so boot does not block
sudo raspi-config nonint do_wifi_country US
# extra: remove some big packages not needed
sudo apt-get remove -y --purge libreoffice*
sudo apt-get clean
sudo apt-get -y autoremove
fi
echo ""
echo "*** CONFIG ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config
# set new default passwort for root user
echo "root:raspiblitz" | sudo chpasswd
echo "pi:raspiblitz" | sudo chpasswd
# set Raspi to boot up automatically with user pi (for the LCD)
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632
sudo raspi-config nonint do_boot_behaviour B2
sudo bash -c "echo '[Service]' >> /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"
echo ""
echo "*** SOFTWARE UPDATE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#software-update
# installs like on RaspiBolt
sudo apt-get install -y htop git curl bash-completion jq dphys-swapfile
echo ""
echo "*** ADDING MAIN USER admin ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin
# using the default password 'raspiblitz'
sudo adduser --disabled-password --gecos "" admin
echo "admin:raspiblitz" | sudo chpasswd
sudo adduser admin sudo
sudo chsh admin -s /bin/bash
# configure sudo for usage without password entry
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
echo "*** ADDING SERVICE USER bitcoin"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
# create user and set default password for user
sudo adduser --disabled-password --gecos "" bitcoin
echo "bitcoin:raspiblitz" | sudo chpasswd
echo ""
echo "*** SWAP FILE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#moving-the-swap-file
# but just deactivating and deleting old (will be created alter when user adds HDD)
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
echo ""
echo "*** INCREASE OPEN FILE LIMIT ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#increase-your-open-files-limit
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf"
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
echo ""
echo "*** BITCOIN ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_30_bitcoin.md#installation
# set version (change if update is available)
bitcoinVersion="0.17.0"
laanwjPGP="01EA5486DE18A882D4C2684590C8019E36C2E964"
# prepare directories
sudo -u admin mkdir /home/admin/download
cd /home/admin/download
# download resources
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz
if [ ! -f "./bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz" ]
then
echo "!!! FAIL !!! Download BITCOIN BINARY not success."
exit 1
fi
sudo -u admin wget https://bitcoin.org/bin/bitcoin-core-${bitcoinVersion}/SHA256SUMS.asc
if [ ! -f "./SHA256SUMS.asc" ]
then
echo "!!! FAIL !!! Download SHA256SUMS.asc not success."
exit 1
fi
sudo -u admin wget https://bitcoin.org/laanwj-releases.asc
if [ ! -f "./laanwj-releases.asc" ]
then
echo "!!! FAIL !!! Download laanwj-releases.asc not success."
exit 1
fi
# test checksum
checksum=$(sha256sum --check SHA256SUMS.asc --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c)
if [ ${checksum} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Bitcoin download checksum not OK"
exit 1
fi
# check gpg finger print
fingerprint=$(gpg ./laanwj-releases.asc 2>/dev/null | grep "${laanwjPGP}" -c)
if [ ${fingerprint} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Bitcoin download PGP author not OK"
exit 1
fi
gpg --import ./laanwj-releases.asc
verifyResult=$(gpg --verify SHA256SUMS.asc 2>&1)
goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
echo "goodSignature(${goodSignature})"
correctKey=$(echo ${verifyResult} | grep "using RSA key ${laanwjPGP: -16}" -c)
echo "correctKey(${correctKey})"
if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})"
exit 1
fi
# install
sudo -u admin tar -xvf bitcoin-${bitcoinVersion}-arm-linux-gnueabihf.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-${bitcoinVersion}/bin/*
sleep 3
installed=$(sudo -u admin bitcoind --version | grep "${bitcoinVersion}" -c)
if [ ${installed} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})"
exit 1
fi
echo ""
echo "*** LITECOIN ***"
# based on https://medium.com/@jason.hcwong/litecoin-lightning-with-raspberry-pi-3-c3b931a82347
# set version (change if update is available)
litecoinVersion="0.16.3"
cd /home/admin/download
sudo -u admin wget https://download.litecoin.org/litecoin-${litecoinVersion}/linux/litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz
sudo -u admin tar -xvf litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin litecoin-${litecoinVersion}/bin/*
installed=$(sudo -u admin litecoind --version | grep "${litecoinVersion}" -c)
if [ ${installed} -lt 1 ]; then
echo ""
echo "!!! BUILD FAILED --> Was not able to install litecoind version(${litecoinVersion})"
exit 1
fi
echo ""
echo "*** LND ***"
## based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md#lightning-lnd
#lndVersion="0.5-beta-rc1"
#olaoluwaPGP="65317176B6857F98834EDBE8964EA263DD637C21"
#
# get LND resources
#cd /home/admin/download
#sudo -u admin wget https://github.com/lightningnetwork/lnd/releases/download/v${lndVersion}/lnd-linux-arm-v${lndVersion}.tar.gz
#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://keybase.io/roasbeef/pgp_keys.asc
## test checksum
#checksum=$(sha256sum --check manifest-v${lndVersion}.txt --ignore-missing 2>/dev/null | grep '.tar.gz: OK' -c)
#if [ ${checksum} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND download checksum not OK"
# exit 1
#fi
## check gpg finger print
#fingerprint=$(gpg ./pgp_keys.asc 2>/dev/null | grep "${olaoluwaPGP}" -c)
#if [ ${fingerprint} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND download author PGP not OK"
# exit 1
#fi
#gpg --import ./pgp_keys.asc
#sleep 2
#verifyResult=$(gpg --verify manifest-v${lndVersion}.txt.sig manifest-v${lndVersion}.txt 2>&1)
#goodSignature=$(echo ${verifyResult} | grep 'Good signature' -c)
#echo "goodSignature(${goodSignature})"
#correctKey=$(echo ${verifyResult} | grep "using RSA key ${olaoluwaPGP: -16}" -c)
#echo "correctKey(${correctKey})"
#if [ ${correctKey} -lt 1 ] || [ ${goodSignature} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> LND PGP Verify not OK / signatute(${goodSignature}) verify(${correctKey})"
# exit 1
#fi
## install
#sudo -u admin tar -xzf lnd-linux-arm-v${lndVersion}.tar.gz
#sudo install -m 0755 -o root -g root -t /usr/local/bin lnd-linux-arm-v${lndVersion}/*
#sleep 3
#installed=$(sudo -u admin lnd --version | grep "${lndVersion}" -c)
#if [ ${installed} -lt 1 ]; then
# echo ""
# echo "!!! BUILD FAILED --> Was not able to install LND version(${lndVersion})"
# exit 1
#fi
##### Build from Source
# To quickly catch up get latest patches if needed
repo="github.com/lightningnetwork/lnd"
commit="61e867741926bcb318432a6344b80161fabd1455"
# BUILDING LND FROM SOURCE
echo "*** Installing Go ***"
wget https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz
if [ ! -f "./go1.11.linux-armv6l.tar.gz" ]
then
echo "!!! FAIL !!! Download not success."
exit 1
fi
sudo tar -C /usr/local -xzf go1.11.linux-armv6l.tar.gz
sudo rm *.gz
sudo mkdir /usr/local/gocode
sudo chmod 777 /usr/local/gocode
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/usr/local/gocode
export PATH=$PATH:$GOPATH/bin
echo "*** Build LND from Source ***"
go get -d $repo
# make sure to always have the same code (commit) to build
# TODO: To update lnd -> change to latest commit
cd $GOPATH/src/$repo
sudo git checkout $commit
make && make install
sudo chmod 555 /usr/local/gocode/bin/lncli
sudo chmod 555 /usr/local/gocode/bin/lnd
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/admin/.bashrc"
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/pi/.bashrc"
sudo bash -c "echo 'export PATH=$PATH:/usr/local/gocode/bin/' >> /home/bitcoin/.bashrc"
lndVersionCheck=$(lncli --version)
echo "LND VERSION: ${lndVersionCheck}"
if [ ${#lndVersionCheck} -eq 0 ]; then
echo "FAIL - Something went wrong with building LND from source."
echo "Sometimes it may just be a connection issue. Reset to fresh Rasbian and try again?"
exit 1
fi
echo ""
echo "** Link to /usr/local/bin ***"
sudo ln -s /usr/local/gocode/bin/lncli /usr/local/bin/lncli
sudo ln -s /usr/local/gocode/bin/lnd /usr/local/bin/lnd
echo ""
echo "*** RASPIBLITZ EXTRAS ***"
# for setup schell scripts
sudo apt-get -y install dialog bc
# enable copy of blockchain from 2nd HDD formatted with exFAT
sudo apt-get -y install exfat-fuse
# for blockchain torrent download
sudo apt-get -y install transmission-cli
# for background downloading
sudo apt-get -y install screen
# optimization for torrent download
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf"
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
# *** SHELL SCRIPTS AND ASSETS
# move files from gitclone
cd /home/admin/
sudo -u admin git clone https://github.com/rootzoll/raspiblitz.git
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.* /home/admin
sudo -u admin chmod +x *.sh
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
# bash aoutstart for admin
sudo bash -c "echo '# automatically start main menu for admin' >> /home/admin/.bashrc"
sudo bash -c "echo './00mainMenu.sh' >> /home/admin/.bashrc"
# bash aoutstart for pi
# run as exec to dont allow easy physical access by keyboard
# see https://github.com/rootzoll/raspiblitz/issues/54
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /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
cat > /home/admin/setup.sh <<EOF
# make LCD screen rotation correct
sudo sed --in-place -i "57s/.*/dtoverlay=tft35a:rotate=270/" /boot/config.txt
EOF
sudo chmod +x /home/admin/setup.sh
echo ""
echo "*** HARDENING ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#hardening-your-pi
# fail2ban (no config required)
sudo apt-get install -y fail2ban
# *** BOOTSTRAP ***
# see background README for details
echo ""
echo "*** RASPI BOOSTRAP SERVICE ***"
sudo chmod +x /home/admin/_bootstrap.sh
sudo cp ./assets/bootstrap.service /etc/systemd/system/bootstrap.service
sudo systemctl enable bootstrap
# *** RASPIBLITZ IMAGE READY ***
echo ""
echo "**********************************************"
echo "ALMOST READY"
echo "**********************************************"
echo ""
echo "Your SD Card Image for RaspiBlitz is almost ready."
echo "Last step is to install LCD drivers. This will reboot your Pi when done."
echo ""
echo "Maybe take the chance and look thru the output above if you can spot any errror."
echo ""
echo "After final reboot - your SD Card Image is ready."
echo "Press ENTER to install LCD and reboot ..."
read key
# give Raspi a default hostname (optional)
sudo raspi-config nonint do_hostname "RaspiBlitz"
# *** 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
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

View File

@ -1,9 +1,7 @@
#!/bin/sh
# RaspiBolt LND Mainnet: systemd unit for getpublicip.sh script
# /etc/systemd/system/20-raspibolt-welcome.sh
#!/bin/bash
# make executable and copy script to /etc/update-motd.d/
# root must be able to execute network cli and lncli
# load code software version
source /home/admin/_version.info
# set colors
color_red='\033[0;31m'
@ -14,12 +12,20 @@ color_gray='\033[0;37m'
# load network
network=`sudo cat /home/admin/.network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# set datadir
bitcoin_dir="/home/bitcoin/.${network}"
lnd_dir="/home/bitcoin/.lnd"
lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net"
# get uptime & load
load=$(w | grep "load average:" | cut -c11-)
load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
# get CPU temp
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
@ -35,16 +41,8 @@ else
color_ram=${color_green}
fi
# get storage
sd_free_ratio=$(printf "%d" "$(df -h | grep "/$" | awk '{ print $4/$2*100 }')") 2>/dev/null
sd=$(printf "%s (%s%%)" "$(df -h | grep '/$' | awk '{ print $4 }')" "${sd_free_ratio}")
if [ ${sd_free_ratio} -lt 10 ]; then
color_sd="${color_red}"
else
color_sd=${color_green}
fi
hdd_free_ratio=$(printf "%d" "$(df -h | grep '/mnt/hdd$' | awk '{ print $4/$2*100 }')") 2>/dev/null
# get free HDD ratio
hdd_free_ratio=$(printf "%d" "$(df -h | grep '/mnt/hdd$' | awk '{ print $4/$2*100 }')" 2>/dev/null)
hdd=$(printf "%s (%s%%)" "$(df -h | grep '/mnt/hdd$' | awk '{ print $4 }')" "${hdd_free_ratio}")
if [ ${hdd_free_ratio} -lt 10 ]; then
@ -61,16 +59,16 @@ network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[
btc_path=$(command -v ${network}-cli)
if [ -n ${btc_path} ]; then
btc_title=$network
chain="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.chain')"
if [ -n $chain ]; then
blockchaininfo="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo 2>/dev/null)"
if [ ${#blockchaininfo} -gt 0 ]; then
btc_title="${btc_title} (${chain}net)"
# get sync status
block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
block_verified="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.blocks')"
block_chain="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)"
block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')"
block_diff=$(expr ${block_chain} - ${block_verified})
progress="$(${network}-cli -datadir=${bitcoin_dir} getblockchaininfo | jq -r '.verificationprogress')"
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
if [ ${block_diff} -eq 0 ]; then # fully synced
@ -92,13 +90,13 @@ if [ -n ${btc_path} ]; then
fi
# get last known block
last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount)"
last_block="$(${network}-cli -datadir=${bitcoin_dir} getblockcount 2>/dev/null)"
if [ ! -z "${last_block}" ]; then
btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
fi
# get mem pool transactions
mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo | jq -r '.size')"
mempool="$(${network}-cli -datadir=${bitcoin_dir} getmempoolinfo 2>/dev/null | jq -r '.size')"
else
btc_line2="${color_red}NOT RUNNING\t\t"
@ -106,77 +104,105 @@ if [ -n ${btc_path} ]; then
fi
# get IP address & port
networkInfo=$(${network}-cli -datadir=${bitcoin_dir} getnetworkinfo 2>/dev/null)
local_ip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
public_ip=$(curl -s http://v4v6.ipv6-test.com/api/myip.php)
public_port=$(cat ${bitcoin_dir}/${network}.conf 2>/dev/null | grep port= | awk -F"=" '{print $2}')
if [ "${public_port}" = "" ]; then
if [ $chain = "test" ]; then
public_port=18333
public_ip=$(curl -s http://v4.ipv6-test.com/api/myip.php)
public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')"
if [ "${public_port}" = "null" ]; then
public_port="8333"
fi
# CHAIN NETWORK
public_addr="??"
torInfo=""
# Version
networkVersion=$(${network}-cli -datadir=${bitcoin_dir} -version 2>/dev/null | cut -d ' ' -f6)
# TOR or IP
onionAddress=$(echo ${networkInfo} | jq -r '.localaddresses [0] .address')
if [ "${onionAddress}" != "null" ]; then
# TOR address
public_addr="${onionAddress}:${public_port}"
public=""
public_color="${color_green}"
torInfo="+ TOR"
else
# IP address
public_addr="${public_ip}:${public_port}"
public_check=$(timeout 2s nc -z ${public_ip} ${public_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ]; then
public="Yes"
public_color="${color_green}"
else
public_port=8333
public="Not reachable"
public_color="${color_red}"
fi
fi
public_check=$(curl -s https://bitnodes.earn.com/api/v1/nodes/me-${public_port}/ | jq .success)
#IP
if [ $public_check = "true" ]; then
public="Yes"
public_color="${color_green}"
else
public="Not reachable"
public_color="${color_red}"
fi
public_addr="${public_ip}:${public_port}"
# get LND info
/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>&1 | grep "Please unlock" >/dev/null
wallet_unlocked=$?
if [ "$wallet_unlocked" -eq 0 ] ; then
# LIGHTNING NETWORK
ln_baseInfo="-"
ln_channelInfo="\n"
ln_external="\n"
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock)
if [ "$wallet_unlocked" -gt 0 ] ; then
alias_color="${color_red}"
ln_alias="Wallet Locked"
else
ln_getInfo=$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
alias_color="${color_grey}"
ln_alias="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.alias')" 2>/dev/null
ln_walletbalance="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
ln_channelbalance="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
fi
ln_channels_online="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_external="$(/usr/local/bin/lncli --macaroonpath=${lnd_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo | jq -r '.uris[0]' | tr "@" " " | awk '{ print $2 }')" 2>/dev/null
ln_external_ip="$(echo $ln_external | tr ":" " " | awk '{ print $1 }' )" 2>/dev/null
if [ "$ln_external_ip" = "$public_ip" ]; then
external_color="${color_grey}"
else
external_color="${color_red}"
ln_alias=$(echo "${ln_getInfo}" | grep "alias" | cut -d '"' -f4)
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
if [ ${ln_sync} -eq 0 ]; then
if [ ${#ln_getInfo} -eq 0 ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
else
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep "(height" | tail -n1 | awk '{print $10} {print $11} {print $12}' | tr -dc '0-9')
total=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.blocks')
ln_baseInfo="${color_red} waiting for chain sync"
if [ ${#item} -gt 0 ]; then
ln_channelInfo="scanning ${item}/${total}"
fi
fi
else
ln_walletbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance | jq -r '.confirmed_balance')" 2>/dev/null
ln_channelbalance="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance | jq -r '.balance')" 2>/dev/null
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
ln_channels_total="$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} sat"
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat"
fi
fi
networkVersion=$(${network}-cli -datadir=${bitcoin_dir} -version | cut -d ' ' -f6)
ln_alias=`sudo -u admin cat /home/admin/.hostname`
printf "
sleep 5
printf "
${color_yellow}
${color_yellow}
${color_yellow}
${color_yellow} ${color_yellow}%s ${color_green} ${ln_alias}
${color_yellow} ${color_gray}${network} Fullnode + Lightning Network
${color_yellow} ${color_yellow}%s
${color_yellow} ,/ ${color_yellow}
${color_yellow} ${color_gray}${network} Fullnode + Lightning Network ${torInfo}
${color_yellow} ,/ ${color_yellow}%s
${color_yellow} ,'/ ${color_gray}%s, CPU %s°C
${color_yellow} ,' / ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} Free HDD ${color_hdd}%s
${color_yellow} ,' /_____, ${color_gray}
${color_yellow} .'____ ,' ${color_gray}Local ${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}
${color_yellow} / ,' ${color_gray}
${color_yellow} /,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} /' ${color_gray}LND ${color_green}v0.4.2 ${color_gray}wallet ${ln_walletbalance} sat
${color_yellow} ${color_gray}${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} sat
${color_yellow} ${ln_external}
${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} .'____ ,' ${color_gray}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}
${color_yellow} /,' ${color_gray}
${color_yellow} /' ${color_gray}LND ${color_green}v0.5-beta ${ln_baseInfo}
${color_yellow} ${color_gray}${ln_channelInfo}
${color_yellow}
${color_yellow}${ln_external}
" \
"RaspiBlitz v0.4" \
"RaspiBlitz v${codeVersion}" \
"-------------------------------------------" \
"${load##up*, }" "${temp}" \
"load average:${load##up*, }" "${temp}" \
"${hdd}" "${sync_percentage}"
echo "$(tput -T xterm sgr0)"
if [ ${#onionAddress} -eq 0 ]; then
# one extra space line at the end if nodeaddress is not TOR
echo ""
fi

View File

@ -1,115 +1,147 @@
#!/bin/sh
if [ "$USER" = "pi" ]; then
# load network
network=`sudo cat /home/admin/.network`
### USER PI AUTOSTART (LCD Display)
# this script gets started by the autologin of the pi user and
# and its output is gets displayed on the LCD or the RaspiBlitz
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# check that user is pi
if [ "$USER" != "pi" ]; then
echo "plz run as user pi --> su pi"
exit 1
fi
# check if bitcoin service is configured
bitcoinInstalled=$(sudo -u bitcoin ls /mnt/hdd/${network}/ 2>/dev/null | grep -c ${network}.conf)
if [ ${bitcoinInstalled} -eq 1 ]; then
# wait enough secs to let bitcoind init
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 130
fi
# 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'/')
# show updating status in loop
while :
do
# DISPLAY LOOP
chain=""
freshstart=1
while :
do
# refresh network
network=`sudo cat /home/admin/.network`
# refresh network (if information is already available)
network=`sudo cat /home/admin/.network 2>/dev/null`
# get the setup state
setupStepExists=$(sudo -u admin ls -la /home/admin/.setup | grep -c .setup)
if [ ${setupStepExists} -eq 1 ]; then
setupStep=$(sudo -u admin cat /home/admin/.setup)
else
setupStep=0
# get the actual step number of setup process
setupStep=$(sudo -u admin cat /home/admin/.setup 2>/dev/null)
if [ ${#setupStep} -eq 0 ]; then
setupStep=0
fi
# before initial setup
if [ ${setupStep} -eq 0 ]; then
# setup process has not started yet
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use password: raspiblitz\n"
boxwidth=$((${#localip} + 24))
sleep 3
dialog --backtitle "RaspiBlitz ${localip} - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
# during basic setup
elif [ ${setupStep} -lt 65 ]; then
# setup process has not started yet
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use your password A\n"
boxwidth=$((${#localip} + 24))
sleep 3
dialog --backtitle "RaspiBlitz ${localip} - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
# when blockchain and lightning are running
elif [ ${setupStep} -lt 100 ]; then
# when entering first time after boot - display a delay
if [ ${freshstart} -eq 1 ]; then
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 130
freshstart=0
fi
if [ ${setupStep} -eq 0 ]; then
# get state of system
if [ ${#chain} -eq 0 ];then
# get chain if not available before
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
fi
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
# setup process has not started yet
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use password: raspiblitz\n"
boxwidth=$((${#localip} + 20))
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
if [ ${locked} -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 24))
dialog --backtitle "RaspiBlitz ${localip} - Action Required" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${setupStep} -lt 100 ]; then
elif [ ${lndSynced} -eq 0 ]; then
# setup process init is done and not finished
lndSyncing=$(sudo -u bitcoin lncli getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c false)
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
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
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 20))
dialog --backtitle "RaspiBlitz - Action Required" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${lndSyncing} -gt 0 ]; then
# special case: LND is syncing
/home/admin/80scanLND.sh
sleep 5
else
# setup in progress without special case - password has been changed
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 20))
if [ ${setupStep} -eq 50 ]; then
l1="Blockhain Setup - monitor progress:\n"
boxwidth=45
fi
sleep 3
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 10
fi
# special case: LND is syncing
/home/admin/80scanLND.sh
sleep 20
else
# RaspiBlitz is full Setup
# setup in progress without special case - password has been changed
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 24))
sleep 3
dialog --backtitle "RaspiBlitz ${localip} - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 10
fi
else
# RASPIBLITZ iS FULL SETUP
# 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
l1="Waiting for ${network}d to get ready.\n"
l2="---> Starting Up\n"
l3="Can take longer if devcie was off."
isVerifying=$(echo "${clienterror}" | grep -c 'Verifying blocks')
if [ ${isVerifying} -gt 0 ]; then
l2="---> Verifying Blocks\n"
fi
boxwidth=40
dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
else
# check if locked
locked=$(sudo -u admin lncli --chain=${network} getinfo 2>&1 | grep -c unlock)
if [ "${locked}" -gt 0 ]; then
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 22))
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
boxwidth=$((${#localip} + 24))
dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
else
# no special case - show status display
/home/admin/00infoBlitz.sh
sleep 5
fi
fi
done
else
echo "plz run as user pi --> su pi"
fi
done
fi

View File

@ -9,11 +9,20 @@ TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
# default config values (my get changed later)
if [ ! -f ./.network ]; then
echo "bitcoin" > /home/admin/.network
## get basic info (its OK if not set yet)
# get name
name=`sudo cat /home/admin/.hostname`
# get network
network=`sudo cat /home/admin/.network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
network=`cat .network`
## get actual setup state
setupState=0;
@ -32,10 +41,17 @@ if [ ${setupState} -eq 0 ]; then
elif [ ${setupState} -lt 100 ]; then
# make sure to have a init pause aufter fresh boot
uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}')
waittimesecs=$(expr 150 - $uptimesecs)
if [ ${waittimesecs} -gt 0 ]; then
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 ${waittimesecs}
fi
# continue setup
BACKTITLE="RaspiBlitz - Setup"
BACKTITLE="${name} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nThe setup process in snot finished yet: \n "
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
@ -50,23 +66,53 @@ else
# MAIN MENU AFTER SETUP
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
BACKTITLE="${name} / ${network} / ${chain}"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
# LOCK SCREEN
MENU="!!! YOUR WALLET IS LOCKED !!!"
OPTIONS+=(X "Unlock your Lightning Wallet with 'lncli unlock'")
OPTIONS+=(U "Unlock your Lightning Wallet with 'lncli unlock'")
else
# REGULAR MENU
switchOption="to MAINNET"
if [ "${chain}" = "main" ]; then
switchOption="back to TESTNET"
fi
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your Wallet" \
FUNDING "Fund your on-chain Wallet" \
CASHOUT "Remove Funds from 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" \
lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List" \
RECKLES "Console / Terminal")
MOBILE "Connect Mobile Wallet")
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
if [ "${network}" = "bitcoin" ]; then
OPTIONS+=(SWITCH "Switch ${switchOption}")
fi
torInstalled=$(sudo ls /mnt/hdd/tor/lnd9735/hostname 2>/dev/null | grep 'hostname' -c)
if [ ${torInstalled} -eq 0 ]; then
OPTIONS+=(TOR "Make reachable thru TOR")
else
OPTIONS+=(NYX "Monitor TOR")
fi
# final Options
OPTIONS+=(OFF "PowerOff RaspiBlitz")
OPTIONS+=(X "Console / Terminal")
fi
@ -106,13 +152,17 @@ case $CHOICE in
./00mainMenu.sh
;;
lnbalance)
lnbalance
lnbalance ${network}
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
NYX)
sudo nyx
./00mainMenu.sh
;;
lnchannels)
lnchannels
lnchannels ${network}
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
@ -129,12 +179,71 @@ case $CHOICE in
read key
./00mainMenu.sh
;;
RECKLES)
CASHOUT)
./BBcashoutWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
CHANNEL)
./BBopenChannel.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
SEND)
./BBpayInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
RECEIVE)
./BBcreateInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
SERVICES)
./00settingsMenuServices.sh
./00mainMenu.sh
;;
CLOSEALL)
./BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
SWITCH)
sudo ./95switchMainTest.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
MOBILE)
./97addMobileWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
TOR)
sudo ./96addTorService.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
OFF)
echo "After Shutdown remove power from RaspiBlitz."
echo "Press ENTER to start shutdown - then wait some seconds."
read key
sudo shutdown now
exit 0
;;
X)
lncli -h
echo "SUCH WOW come back with ./00mainMenu.sh"
;;
X) # unlock
;;
U) # unlock
./AAunlockLND.sh
./00mainMenu.sh
;;
esac
esac

View File

@ -0,0 +1,39 @@
#!/bin/bash
# get raspiblitz config
source /mnt/hdd/raspiblitz.conf
# show select dialog
CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 5 \
1 "Channel Autopilot" ${autoPilot} \
2>&1 >/dev/tty)
#CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 5 \
#1 "Channel Autopilot" ${autoPilot} \
#2 "UPnP Router-Portforwarding" ${natUPnP} \
#3 "Auto Unlock on Start" ${autoUnlock} \
#4 "Seed Torrent Blockchain" ${torrentSeed} \
#4 "RTL Webinterface" ${rtlWebinterface} \
#2>&1 >/dev/tty)
dialogcancel=$?
clear
# check if user canceled dialog
if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled"
exit 1
fi
# AUTOPILOT process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "1")
if [ ${check} -eq 1 ]; then choice="on"; fi
sudo sed -i "s/^autoPilot=.*/autoPilot=${choice}/g" /mnt/hdd/raspiblitz.conf
# confirm reboot to activate new settings with bootstrap.service
dialog --backtitle "Rebooting" --yesno "To activate the settings a reboot is needed." 6 52
if [ $? -eq 0 ];then
echo "Starting Reboot .."
sudo shutdown -r now
else
echo "No Reboot - changes stored, but maybe not active."
sleep 3
fi

View File

@ -4,32 +4,95 @@ echo ""
# load network
network=`cat .network`
# check chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# get setup progress
setupStep=$(sudo -u admin cat /home/admin/.setup)
if [ ${#setupStep} -eq 0 ];then
setupStep=0
fi
# if setup if ready --> REBOOT
if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})"
sleep 3
./90finishSetup.sh
exit 0
fi
# CHECK WHAT IS ALREADY WORKING
# check list from top down - so ./10setupBlitz.sh
# and re-enters the setup process at the correct spot
# in case it got interrupted
# check if lightning is running
lndRunning=$(systemctl status lnd.service | grep -c running)
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 1 ]; then
echo "LND is running ..."
sleep 1
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' 2>/dev/null | grep -c false)
# check if LND is locked
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
locked=0
# only when a wallet exists - it can be locked
if [ ${walletExists} -eq 1 ];then
echo "lnd wallet exists ... checking if locked"
sleep 2
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
fi
if [ ${locked} -gt 0 ]; then
# LND wallet is locked
./AAunlockLND.sh
./10setupBlitz.sh
elif [ ${lndSyncing} -gt 0 ]; then
./70initLND.sh
else
./90finishSetup.sh
exit 0
fi
exit 1
# check if blockchain still syncing (during sync sometimes CLI returns with error at this point)
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainSyncing=1
if [ ${#chainInfo} -gt 0 ];then
chainSyncing=$(echo "${chainInfo}" | grep "true" -c)
fi
if [ ${chainSyncing} -eq 1 ]; then
echo "Sync Chain ..."
sleep 3
./70initLND.sh
exit 0
fi
# check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo | grep "synced_to_chain")
lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c)
fi
if [ ${lndSyncing} -eq 1 ]; then
echo "Sync LND ..."
sleep 3
./70initLND.sh
exit 0
fi
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup
echo "FINSIH ... "
sleep 3
./90finishSetup.sh
exit 0
fi
# check if bitcoin is running
bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep -c blocks)
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
# double check
bitcoinRunning=$(${network}-cli getblockchaininfo | grep "initialblockdownload" -c)
fi
if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - ${network}d is running"
echo "Next step run Lightning"
@ -43,10 +106,15 @@ if [ ${mountOK} -eq 1 ]; then
# are there any signs of blockchain data
if [ -d "/mnt/hdd/${network}" ]; then
echo "TAIL Chain Network Log"
sudo tail /mnt/hdd/${network}/debug.log
echo ""
echo "UNKOWN STATE - there is blockain data folder, but blockchaind is not running"
echo "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Maybe try --> ./60finishHDD.sh"
echo "If this sill is not working reboot after running --> sudo rm -r /mnt/hdd/${network}"
echo "If you want start fresh --> sudo rm -r /mnt/hdd/${network}"
echo "Or something with the config is not correct."
exit 1
fi
@ -125,7 +193,7 @@ if [ ! -f "home/admin/.setup" ]; then
echo "*** Update System ***"
sudo apt-mark hold raspberrypi-bootloader
sudo apt-get update
sudo apt-get upgrade -f -y --force-yes
sudo apt-get upgrade -f -y --allow-change-held-packages
echo "OK - System is now up to date"
fi

View File

@ -11,12 +11,12 @@ while [ ${#result} -eq 0 ]
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup" --inputbox "$l1$l2" 11 52 2>$_temp
result=`cat $_temp`
result=$( cat $_temp | tr -d [:space:] )
shred $_temp
done
# set lightning alias
sed -i "7s/.*/alias=${result}/" /home/admin/assets/lnd.${network}.conf
sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
# store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system
@ -40,7 +40,7 @@ dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# get user input
result=`cat $_temp`
result=$( cat $_temp )
shred $_temp
# check input (check for more later)
@ -67,13 +67,13 @@ while [ ${#result} -lt 8 ]
do
dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Enter your RPC Password B (min 8 chars):" 9 52 2>$_temp
result=`cat $_temp`
result=$( cat $_temp )
shred $_temp
done
# set Blockchain RPC Password (for admin cli & template for user bitcoin)
sed -i "14s/.*/rpcpassword=$result/" /home/admin/assets/${network}.conf
sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf
sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf
# success info dialog
dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52

View File

@ -49,6 +49,8 @@ if [ ${existsHDD} -gt 0 ]; then
echo "*** Analysing HDD Content ***"
if [ -d "/mnt/hdd/${network}" ]; then
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null
sudo chown -R bitcoin:bitcoin /mnt/hdd/litecoin 2>/dev/null
echo "Looks like the HDD is prepared with the Blockchain."
echo "Continuing with finishing the system setup ..."
./60finishHDD.sh

View File

@ -1,10 +1,11 @@
#!/bin/bash
echo ""
# *** BITCOIN ***
# *** BITCOIN (just mainnet) ***
bitcoinList="" # url to list with other sources
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16"
bitcoinSize=231000000 # 231235816-tolerance
#bitcoinUrl="ftp://anonymous:anonymous@91.83.237.185:21/raspiblitz-bitcoin-2018-07-16"
bitcoinUrl="ftp://f00f39c4:download@w0189aba.kasserver.com/"
bitcoinSize=253000000 # 253827180-tolerance
# *** LITECOIN ***
litecoinList="" # url to list with other sources
@ -28,7 +29,6 @@ fi
name="Download"
targetDir="/mnt/hdd/download/"
targetSize=$size
maxTimeoutLoops=500
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}"
# starting session if needed
@ -48,8 +48,6 @@ sleep 3
# monitor session
screenDump="... started ..."
actualSize=0
timeout=1
timeoutInfo="-"
while :
do
@ -57,7 +55,6 @@ while :
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
if [ ${isRunning} -eq 0 ]; then
timeout=0
echo "OK - session finished"
break
fi
@ -68,35 +65,21 @@ while :
freshSize=0
fi
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
echo $progress > '.${name}.progress'
echo $progress > ".${name}.progress"
# detect if since last loop any progress occured
if [ ${actualSize} -eq ${freshSize} ]; then
timeoutInfo="${timeout}/${maxTimeoutLoops}"
timeout=$(( $timeout + 1 ))
else
timeout=1
timeoutInfo="no timeout detected"
fi
actualSize=$freshSize
# detect if mx timeout loop limit is reached
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then
echo "FAIL - download hit timeout"
break
fi
# display info screen
clear
echo "****************************************************"
echo "Monitoring Screen Session: ${name}"
echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
echo "Timeout: ${timeoutInfo}"
echo "If needed press key x to stop ${name}"
echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later."
echo "****************************************************"
screen -S ${name} -X hardcopy .${name}.out
newScreenDump=$(cat .Download.out | grep . | tail -10)
newScreenDump=$(cat .${name}.out | grep . | tail -8)
if [ ${#newScreenDump} -gt 0 ]; then
screenDump=$newScreenDump
fi
@ -152,10 +135,10 @@ if [ ${finalSize} -lt ${targetSize} ]; then
# Download failed
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 6 57
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 8 57
response=$?
case $response in
1) sudo rm -rf ${targetDir}${targetPath} ;;
1) sudo rm -rf ${targetDir} ;;
esac
./00mainMenu.sh
exit 1;

View File

@ -0,0 +1,234 @@
#!/bin/bash
echo ""
# see background_downloadBlockchain.md for info
# why there are two torrent files
# torrent files that are available
# in directory /home.admin/assets/
# WITHOUT THE '.torrent' ENDING
baseTorrentFile="raspiblitz-bitcoin1-2018-10-13-base"
updateTorrentFile="raspiblitz-bitcoin1-2018-10-13-update"
# make sure rtorrent is available
sudo apt-get install rtorrent -y
echo ""
targetDir="/mnt/hdd/torrent"
sessionDir="/home/admin/.rtorrent.session"
sudo mkdir ${sessionDir} 2>/dev/null
##############################
# CHECK TORRENT 1 "BLOCKCHAIN"
##############################
echo "*** checking torrent 1: base blockchain"
torrentComplete1=$(cat ${sessionDir}/blockchain/*.torrent.rtorrent | grep ':completei1' -c)
echo "torrentComplete1(${torrentComplete1})"
if [ ${torrentComplete1} -eq 0 ]; then
# check if screen session for this torrent
isRunning1=$( screen -S blockchain -ls | grep "blockchain" -c )
echo "isRunning1(${isRunning1})"
if [ ${isRunning1} -eq 0 ]; then
# start torrent download in screen session
echo "starting torrent: blockchain"
command1="sudo rtorrent -n -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}"
echo "${screenCommand}"
bash -c "${screenCommand}"
fi
fi
sleep 2
##############################
# CHECK TORRENT 2 "UPDATE"
##############################
echo "*** checking torrent 2: update blockchain"
torrentComplete2=$(cat ${sessionDir}/update/*.torrent.rtorrent | grep ':completei1' -c)
echo "torrentComplete2(${torrentComplete2})"
if [ ${torrentComplete2} -eq 0 ]; then
# check if screen session for this torrent
isRunning2=$( screen -S update -ls | grep "update" -c )
echo "isRunning2(${isRunning2})"
if [ ${isRunning2} -eq 0 ]; then
# start torrent download in screen session
echo "starting torrent: update"
command2="sudo rtorrent -n -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}"
echo "${screenCommand}"
bash -c "${screenCommand}"
fi
fi
sleep 2
##############################
# MONITOR PROGRESS
##############################
sleep 3
# monitor screen session
screenDump1="... started ..."
screenDump2="... started ..."
torrentComplete1=0
torrentComplete2=0
while :
do
# display info screen
clear
echo "****************************************************"
echo "Monitoring Screen Session: Torrent base+update"
echo "If needed press key x to stop TORRENT download"
echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later."
echo "****************************************************"
echo ""
# display torrent 1 info
echo "*** 1) Status Torrent 'blockchain':"
torrentComplete1=$(cat ${sessionDir}/blockchain/*.torrent.rtorrent | grep ':completei1' -c)
if [ ${torrentComplete1} -eq 0 ]; then
screen -S blockchain -X hardcopy .blockchain.out
newScreenDump=$(cat .blockchain.out | head -6 | tail -3 )
if [ ${#newScreenDump} -gt 0 ]; then
screenDump1=$newScreenDump
fi
echo "$screenDump1"
else
echo "Completed"
fi
echo ""
# display torrent 2 info
echo "*** 2) Status Torrent 'update':"
torrentComplete2=$(cat ${sessionDir}/update/*.torrent.rtorrent | grep ':completei1' -c)
if [ ${torrentComplete2} -eq 0 ]; then
screen -S update -X hardcopy .update.out
newScreenDump=$(cat .update.out| head -6 | tail -3 )
if [ ${#newScreenDump} -gt 0 ]; then
screenDump2=$newScreenDump
fi
echo "$screenDump2"
else
echo "Completed"
fi
echo ""
# check if both torrents completed
if [ ${torrentComplete1} -eq 1 ]; then
if [ ${torrentComplete2} -eq 1 ]; then
echo "OK - all torrents finished"
break
fi
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 "Aborting getbitcoinblockchain.com"
break
fi
done
# clean up
rm -f .blockchain.out
rm -f .update.out
##############################
# AFTER PARTY & CLEAN UP
##############################
# quit session1
isRunning=$( screen -S blockchain -ls | grep "blockchain" -c )
if [ ${isRunning} -eq 1 ]; then
# get the PID of screen session
sessionPID=$(screen -ls | grep "blockchain" | cut -d "." -f1 | xargs)
echo "killing screen session PID(${sessionPID})"
# kill all child processes of screen sceesion
sudo pkill -P ${sessionPID}
echo "proccesses killed"
sleep 3
# tell the screen session to quit and wait a bit
screen -S blockchain -X quit 1>/dev/null
sleep 3
echo "cleaning screen"
screen -wipe 1>/dev/null
sleep 3
fi
# quit session2
isRunning=$( screen -S update -ls | grep "update" -c )
if [ ${isRunning} -eq 1 ]; then
# get the PID of screen session
sessionPID=$(screen -ls | grep "update" | cut -d "." -f1 | xargs)
echo "killing screen session PID(${sessionPID})"
# kill all child processes of screen sceesion
sudo pkill -P ${sessionPID}
echo "proccesses killed"
sleep 3
# tell the screen session to quit and wait a bit
screen -S update -X quit 1>/dev/null
sleep 3
echo "cleaning screen"
screen -wipe 1>/dev/null
sleep 3
fi
# check result
torrentComplete=0
torrentComplete1=$(cat ${sessionDir}/blockchain/*.torrent.rtorrent | grep ':completei1' -c)
torrentComplete2=$(cat ${sessionDir}/update/*.torrent.rtorrent | grep ':completei1' -c)
if [ ${torrentComplete1} -eq 1 ]; then
if [ ${torrentComplete2} -eq 1 ]; then
torrentComplete=1
fi
fi
if [ ${torrentComplete} -eq 0 ]; then
# User Cancel --> Torrent incomplete
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 8 57
response=$?
case $response in
1) sudo rm -rf ${targetDir} ;;
esac
./00mainMenu.sh
exit 1;
fi
# the path torrent will download to
targetPath1="${targetDir}/${baseTorrentFile}"
targetPath2="${targetDir}/${updateTorrentFile}"
# Download worked / just move, copy on USB2 >4h
echo ""
echo "*** Moving Files ***"
date +%s
echo "can take some minutes ... öease wait"
sudo mkdir /mnt/hdd/bitcoin 2>/dev/null
sudo mv ${targetPath1}/* /mnt/hdd/bitcoin/
sudo cp -r ${targetPath2}/* /mnt/hdd/bitcoin/
sudo rm -r ${targetDir}
echo "OK"
date +%s
# continue setup
./60finishHDD.sh

View File

@ -1,9 +1,12 @@
#!/bin/sh
#!/bin/bash
echo ""
# --> TODO: Check https://getbitcoinblockchain.com/
# *** BITCOIN Torrent ***
bitcoinTorrent="raspiblitz-bitcoin-2018-07-16"
bitcoinTorrentsize=231230512
bitcoinTorrent="raspiblitz-bitcoin-2018-10-06"
bitcoinTorrentsize=259000000
# *** LITECOIN Torrent ***
litecoinTorrent="raspiblitz-litecoin-2018-07-29"
litecoinTorrentsize=10240000
@ -11,58 +14,161 @@ litecoinTorrentsize=10240000
# load network
network=`cat .network`
## experimental redirect if bitcoin
if [ "$network" = "bitcoin" ]; then
./50torrentHDD.bitcoin.sh
exit 1
fi
# make sure rtorrent is available
sudo apt-get install rtorrent -y
echo ""
# settings based on network
torrent=$bitcoinTorrent
torrentsize=$bitcoinTorrentsize
size=$bitcoinTorrentsize
if [ "$network" = "litecoin" ]; then
torrent=$litecoinTorrent
torrentsize=$litecoinTorrentsize
size=$litecoinTorrentsize
fi
echo ""
echo "torrentFile: ${torrent}"
echo ""
echo "*** Downloading TORRENT ***"
echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:"
echo "CTRL+z start ./10setupBlitz.sh choose other option"
echo "***************************"
echo ""
tmpfile=$(mktemp)
chmod a+x $tmpfile
echo "killall transmission-cli" > $tmpfile
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile
echo "OK - Download closed"
echo ""
# screen background monitoring settings
name="Torrent"
targetDir="/mnt/hdd/torrent"
targetSize=$size
sessionDir="/home/admin/.rtorrent.session/"
command="sudo rtorrent -n -d ${targetDir} -s ${sessionDir} /home/admin/assets/${torrent}.torrent"
# 2 screen sessions - differnt rtorrent session dir?
#sudo rtorrent -n -d /mnt/hdd/torrent -s /home/admin/.rtorrent.session/ https://getbitcoinblockchain.com/blockchain.torrent
#sudo rtorrent -n -d /mnt/hdd/torrent -s /home/admin/.rtorrent.session/ https://getbitcoinblockchain.com/update.torrent
echo "*** Checking TORRENT ***"
echo "wait a moment"
sleep 5
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9')
if [ ${#downloadsize} -eq 0 ]; then
downloadsize=0
# starting screen session if needed
echo "checking if ${name} has a running screen session"
screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
echo "isRunning(${isRunning})"
if [ ${isRunning} -eq 0 ]; then
echo "Starting screen session"
sudo mkdir ${targetDir} 2>/dev/null
sudo mkdir ${sessionDir} 2>/dev/null
screenCommand="screen -S ${name} -L screen.log -dm ${command}"
echo "${screenCommand}"
bash -c "${screenCommand}"
else
echo "Continue screen session"
fi
# add some tolerance for checking
size="$(($size-1024000))"
echo "download size is(${downloadsize}) needs to be minimum(${size})"
if [ ${downloadsize} -lt ${size} ]; then
sleep 3
# monitor screen session
screenDump="... started ..."
actualSize=0
torrentComplete=0
while :
do
# check if completed by inspecting rtorrent session files
torrentComplete=$(cat /home/admin/.rtorrent.session/*.torrent.rtorrent | grep ':completei1' -c)
if [ ${torrentComplete} -eq 1 ]; then
echo "OK - torrent finished"
break
fi
# calculate progress and write it to file for LCD to read
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
if [ ${#actualSize} -eq 0 ]; then
freshSize=0
fi
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
echo $progress > ".${name}.progress"
actualSize=$freshSize
# display info screen
clear
echo "****************************************************"
echo "Monitoring Screen Session: ${name}"
echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
echo "If needed press key x to stop ${name}"
echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later."
echo "****************************************************"
screen -S ${name} -X hardcopy .${name}.out
newScreenDump=$(cat .${name}.out | grep . | tail -8)
if [ ${#newScreenDump} -gt 0 ]; then
screenDump=$newScreenDump
fi
echo "$screenDump"
# 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 "Aborting ${name}"
break
fi
done
# clean up
rm -f .${name}.out
rm -f .${name}.progress
# quit session if still running
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
if [ ${isRunning} -eq 1 ]; then
# get the PID of screen session
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs)
echo "killing screen session PID(${sessionPID})"
# kill all child processes of screen sceesion
sudo pkill -P ${sessionPID}
echo "proccesses killed"
sleep 3
# tell the screen session to quit and wait a bit
screen -S ${name} -X quit 1>/dev/null
sleep 3
echo "cleaning screen"
screen -wipe 1>/dev/null
sleep 3
fi
# the path torrent will download to
targetPath="${targetDir}/${torrent}"
echo "path to downloaded data is ${targetPath}"
# calculate progress and write it to file for LCD to read
finalSize=$( du -s ${targetDir} 2>/dev/null | head -n1 | awk '{print $1;}' )
if [ ${#finalSize} -eq 0 ]; then
finalSize=0
fi
echo "final size is ${finalSize} of targeted size ${targetSize}"
# check result
if [ ${finalSize} -lt ${targetSize} ]; then
# Download failed
sleep 3
echo -ne '\007'
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 8 57
response=$?
case $response in
1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;;
1) sudo rm -rf ${targetDir} ;;
esac
./00mainMenu.sh
exit 1;
fi
else
echo "*** Moving Files ***"
echo "moving files ..."
sudo mv /mnt/hdd/$torrent /mnt/hdd/${network}
echo ""
# Download worked / just move, copy on USB2 >4h
echo "*** Moving Files ***"
echo "START"
date +%s
sudo mv ${targetPath} /mnt/hdd/${network}
echo "OK"
date +%s
# set SetupState
echo "50" > /home/admin/.setup
# continue setup
./60finishHDD.sh
# continue setup
./60finishHDD.sh
fi

View File

@ -17,14 +17,14 @@ if [ ${mountOK} -eq 1 ]; then
echo "*** Prepare ${network} ***"
sudo killall -u bitcoin
sleep 5
sudo rm -r /home/bitcoin/.${network}
sudo rm -r /home/bitcoin/.${network} 2>/dev/null
sleep 2
if [ -d /home/bitcoin/.${network} ]; then
echo "FAIL - /home/bitcoin/.${network} exists and cannot be removed!"
exit 1
fi
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
sudo mkdir /home/admin/.${network}
sudo mkdir /home/admin/.${network} 2>/dev/null
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network}
sudo mkdir /mnt/hdd/lnd
@ -40,6 +40,8 @@ if [ ${mountOK} -eq 1 ]; then
echo "*** Start ${network} ***"
echo "This can take a while .."
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
sudo chmod +x /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload
sudo systemctl enable ${network}d.service
sudo systemctl start ${network}d.service
echo "Giving ${network}d service 180 seconds to init - please wait ..."

View File

@ -4,9 +4,20 @@ echo ""
# load network
network=`cat .network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# verify that bitcoin is running
echo "*** Checking ${network} ***"
bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep -c blocks)
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
#doublecheck
bitcoinRunning=$(${network}-cli getblockchaininfo | grep -c verificationprogress)
fi
if [ ${bitcoinRunning} -eq 0 ]; then
# HDD is not available yet
echo "FAIL - ${network}d is not running"
@ -16,34 +27,32 @@ fi
echo "OK - ${network}d is running"
echo ""
###### Wait for Blochain Sync
echo "*** Syncing Blockchain ***"
ready=0
while [ ${ready} -eq 0 ]
# verify that chainnetwork is ready
chainIsReady=0
while [ ${chainIsReady} -eq 0 ]
do
progress="$(sudo -u bitcoin ${network}-cli getblockchaininfo | jq -r '.verificationprogress')"
verySmallProgress=$(echo $progress | grep -c 'e-');
if [ ${verySmallProgress} -eq 1 ]; then
progress="0.00";
fi
ready=$(echo $progress'>0.99' | bc -l)
sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
#echo "progress($progress) verySmallProgress($verySmallProgress) ready($ready) sync_percentage($sync_percentage)"
if [ ${#ready} -eq 0 ]; then
echo "waiting for init ... can take a while"
ready=0
elif [ "$sync_percentage" = "0.00%" ]; then
echo "waiting for network ... can take a while"
ready=0
elif [ ${ready} -eq 0 ]; then
echo "${sync_percentage}"
echo "*** Test if chainnetwork is ready ..."
date +%s
result=$(${network}-cli getblockchaininfo 2>error.out)
error=`cat error.out`
rm error.out
echo "result(${result})"
echo "error(${error})"
if [ ${#error} -gt 0 ]; then
testnetAdd=""
if [ "${chain}" = "test" ]; then
testnetAdd="testnet3/"
fi
sudo tail -n 5 /mnt/hdd/bitcoin/${testnetAdd}debug.log
echo "Waiting 1 minute and then trying again ..."
sleep 60
echo ""
else
echo "finishing sync ... can take a while"
echo "OK - chainnetwork is working"
chainIsReady=1
break
fi
sleep 3
done
echo "OK - Blockchain is synced"
echo ""
###### LND Config
echo "*** LND Config ***"
@ -64,42 +73,47 @@ echo ""
###### Start LND
echo "*** Starting LND ***"
lndRunning=$(systemctl status lnd.service | grep -c running)
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
sudo systemctl enable lnd
sudo systemctl start lnd
echo "Started LND .. waiting 30 seconds for init ..."
sleep 30
echo "Starting LND ... give 120 seconds to init."
sleep 120
fi
###### Check LND is running
lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL - LND is not running"
echo "recheck with original tutorial -->"
echo "https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_40_lnd.md"
exit 1
fi
lndRunning=0
while [ ${lndRunning} -eq 0 ]
do
lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then
date +%s
echo "LND not ready yet ... waiting another 60 seconds."
echo "If this takes too long (more then 10min total) --> CTRL+c and report Problem"
sleep 60
fi
done
echo "OK - LND is running"
echo ""
###### Instructions on Creating LND Wallet
setupStep=0
setupStep=$(sudo cat "/home/admin/.setup")
if [ ${setupStep} -lt 65 ]; then
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
echo "walletExists(${walletExists})"
sleep 2
if [ ${walletExists} -eq 0 ]; then
# setup state signals, that no wallet has been created yet
dialog --backtitle "RaspiBlitz - LND Lightning Wallet" --msgbox "
dialog --backtitle "RaspiBlitz - LND Lightning Wallet (${network}/${chain})" --msgbox "
${network} and Lighthing Services are installed.
You now need to setup your Lightning Wallet:
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
@ -111,37 +125,67 @@ Press OK and follow the 'Helping Instructions'.
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************"
echo ""
echo "lncli create"
sudo -u bitcoin lncli create
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 ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!! Make sure to write down the 24 words (cipher seed mnemonic) !!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "If you are ready. Press ENTER."
read key
# set SetupState to 75 (mid thru this process)
echo "65" > /home/admin/.setup
fi
echo "--> lets wait 30 seconds for LND to get ready"
sleep 30
echo "--> lets wait 60 seconds for LND to get ready"
sleep 60
###### Copy LND macaroons to admin
echo ""
echo "*** Copy LND Macaroons to user admin ***"
macaroonExists=$(sudo -u bitcoin ls -la /mnt/hdd/lnd/admin.macaroon | grep -c admin.macaroon)
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
./AAunlockLND.sh
sleep 3
fi
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon
echo ""
echo "FAIL - LND Macaroons not created"
echo "Please check the following LND issue:"
echo "https://github.com/lightningnetwork/lnd/issues/890"
echo "You may want try again with starting ./70initLND.sh"
exit 1
fi
sudo mkdir /home/admin/.lnd
macaroonExists=$(sudo ls -la /home/admin/.lnd/ | grep -c admin.macaroon)
macaroonExists=$(sudo ls -la /home/admin/.lnd/data/chain/${network}/${chain}net/ | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo mkdir /home/admin/.lnd
sudo mkdir /home/admin/.lnd/data
sudo mkdir /home/admin/.lnd/data/chain
sudo mkdir /home/admin/.lnd/data/chain/${network}
sudo mkdir /home/admin/.lnd//data/chain/${network}/${chain}net
sudo cp /home/bitcoin/.lnd/tls.cert /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/admin.macaroon /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/lnd.conf /home/admin/.lnd
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon /home/admin/.lnd/data/chain/${network}/${chain}net
sudo chown -R admin:admin /home/admin/.lnd/
echo "OK - LND Macaroons created"
else
@ -150,11 +194,10 @@ fi
###### Unlock Wallet (if needed)
echo "*** Check Wallet Lock ***"
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "OK - Wallet is locked ... starting unlocking dialog"
./unlockLND.sh
./AAunlockLND.sh
else
echo "OK - Wallet is already unlocked"
fi
@ -163,8 +206,7 @@ fi
echo ""
echo "*** Check LND Sync ***"
item=0
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true)
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 0 ]; then
echo "OK - wait for LND to be synced"
while :
@ -172,10 +214,10 @@ if [ ${lndSyncing} -eq 0 ]; then
# show sync status
./80scanLND.sh
sleep 3
sleep 15
# break loop when synced
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c true)
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 1 ]; then
break
fi
@ -186,6 +228,8 @@ if [ ${lndSyncing} -eq 0 ]; then
break
fi
sleep 15
done
clear
else

View File

@ -1,34 +1,66 @@
# load network
network=`sudo cat /home/admin/.network`
# load name of Blitz
name=`sudo cat /home/admin/.hostname`
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# parse the actual scanned height progress from LND logs
item=0
chain="$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
gotData=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c height)
if [ ${gotData} -gt 0 ]; then
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep height | tail -n1 | awk '{print $9} {print $10} {print $11} {print $12}' | tr -dc '0-9')
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo)
chain="$(echo "${blockchaininfo}" | jq -r '.chain')"
## TRY to get the actual progress height of scanning
# 1) First try the "Rescanned through block" - it seems to happen if it restarts
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')
# 2) Second try the "Caught up to height" - thats the usual on first scan start
if [ ${#item} -eq 0 ]; then
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')
fi
# TODO next fallback try later here if necessary
if [ ${#item} -eq 0 ]; then
item="?"
fi
# get total number of blocks
total=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.blocks')
total=$(echo "${blockchaininfo}" | jq -r '.blocks')
# put scanstate
scanstate="${item}/${total}"
# calculate progress in percent
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }")
if [ ${percent} -eq 100 ]; then
# normally if 100% gets calculated, item parsed the wrong height
percent=0
fi
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\nplease wait - this can take some time")
# get blockchain sync progress
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
# check if blockchain is still syncing
heigh=6
width=44
isInitialChainSync=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c)
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 [ ${isWaitingBlockchain} -gt 0 ]; then
infoStr=" Waiting for final Blockchain Sync\nplease wait - this can take some time"
isInitialChainSync=1
fi
if [ ${isInitialChainSync} -gt 0 ]; then
heigh=7
infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some time.\n ssh admin@${localip}\n Password A"
if [ "$USER" = "admin" ]; then
heigh=6
width=53
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.")
fi
else
heigh=7
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A")
if [ "$USER" = "admin" ]; then
heigh=6
width=53
infoStr=$(echo " Lightning Rescanning Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi
fi
# display progress to user
dialog --backtitle "RaspiBlitz (${localip} / ${network} / ${chain})" --infobox "${infoStr}" 4 42
sleep 3
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${name})" --infobox "${infoStr}" ${heigh} ${width}

View File

@ -4,7 +4,7 @@ echo ""
# add bonus scripts
./91addBonus.sh
###### SWAP
###### SWAP & FS
echo "*** SWAP file ***"
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
if [ ${swapExists} -eq 1 ]; then
@ -20,7 +20,13 @@ else
sudo dphys-swapfile setup
sudo chmod 0600 /mnt/hdd/swapfile
sudo dphys-swapfile swapon
# expand FS of SD
echo "*** Expand RootFS ***"
sudo raspi-config --expand-rootfs
echo ""
fi
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
if [ ${swapExists} -eq 1 ]; then
echo "OK - SWAP is working"
@ -32,9 +38,36 @@ else
sleep 60
fi
# expand FS of SD
echo "*** Expand RootFS ***"
sudo raspi-config --expand-rootfs
# firewall - just install (not configure)
echo ""
echo "*** Setting and Activating Firewall ***"
sudo apt-get install -y ufw
echo "deny incoming connection on other ports"
sudo ufw default deny incoming
echo "allow outgoing connections"
sudo ufw default allow outgoing
echo "allow: ssh"
sudo ufw allow ssh
echo "allow: bitcoin testnet"
sudo ufw allow 18333 comment 'bitcoin testnet'
echo "allow: bitcoin mainnet"
sudo ufw allow 8333 comment 'bitcoin mainnet'
echo "allow: litecoin mainnet"
sudo ufw allow 9333 comment 'litecoin mainnet'
echo 'allow: lightning testnet'
sudo ufw allow 19735 comment 'lightning testnet'
echo "allow: lightning mainnet"
sudo ufw allow 9735 comment 'lightning mainnet'
echo "allow: lightning gRPC"
sudo ufw allow 10009 comment 'lightning gRPC'
echo "allow: trasmission"
sudo ufw allow 51413 comment 'transmission'
echo "allow: local web admin"
sudo ufw allow from 192.168.0.0/24 to any port 80 comment 'allow local LAN web'
echo "open firewall for auto nat discover (see issue #129)"
sudo ufw allow proto udp from 192.168.0.0/24 port 1900 to any comment 'allow local LAN SSDP for UPnP discovery'
echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# mark setup is done
@ -56,4 +89,6 @@ sudo raspi-config nonint do_hostname ${hostname}
# mark setup is done (100%)
echo "100" > /home/admin/.setup
clear
echo "Setup done. Rebooting now."
sudo shutdown -r now

View File

@ -13,5 +13,11 @@ chmod +x lnchannels
sudo cp lnchannels /usr/local/bin
sudo cp lnbalance /usr/local/bin
echo "OK"
echo "installing bash completion for bitcoin-cli and lncli"
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/bitcoin-cli.bash-completion
wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/contrib/lncli.bash-completion
sudo cp *.bash-completion /etc/bash_completion.d/
echo "OK - bash completion available after next login"
echo "type \"bitcoin-cli getblockch\", press [Tab] → bitcoin-cli getblockchaininfo"
cd
rm -r /home/admin/tmpScriptDL

125
home.admin/95switchMainTest.sh Executable file
View File

@ -0,0 +1,125 @@
#!/usr/bin/env bash
# based on pull request from vnnkl
# load network
network=`cat .network`
echo ""
echo "*** Switch between Testnet/Mainnet ***"
# allow only on bitcoin network
if [ "${network}" = "bitcoin" ]; then
echo "Bitcoin network can be switched between testnet/mainnet ..."
else
echo "FAIL - Only Bitcoin Network can be switched between man/tast at the moment."
exit 1
fi
NETWORK_CONFIG="/home/bitcoin/.${network}/${network}.conf"
NETWORK_TEMPLATE="/home/admin/assets/${network}.conf"
LND_CONFIG="/home/bitcoin/.lnd/lnd.conf"
LND_TEMPLATE="/home/admin/assets/lnd.${network}.conf"
echo "NETWORK_CONFIG(${NETWORK_CONFIG})"
echo "LND_CONFIG(${LND_CONFIG})"
echo "NETWORK_TEMPLATE(${NETWORK_TEMPLATE})"
echo "LND_TEMPLATE(${LND_TEMPLATE})"
# function to detect main/testnet
function isMainnet(){
grep "^#testnet=1$" -q $NETWORK_CONFIG && return 1
return 0
}
function switchToMainnet {
echo "switching to mainnet"
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_CONFIG
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to mainnet"
}
function switchToTestnet {
echo "switching to testnet"
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_CONFIG
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to testnet"
}
# LND Service
lndInstalled=$(systemctl status lnd.service | grep loaded -c)
if [ ${lndInstalled} -gt 0 ]; then
echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli closeallchannels' or main menu option."
echo "!!!!!!!!!!!!!!!!!!!"
exit 1
else
echo "no open channels found"
fi
echo "stopping lnd client"
systemctl stop lnd
sleep 4
else
echo "LND not running"
fi
# NETWORK Service
networkInstalled=$(systemctl status ${network}d.service | grep loaded -c)
if [ ${networkInstalled} -gt 0 ]; then
echo "stopping bitcoind client"
systemctl stop bitcoind
sleep 4
else
echo "Network ${network} not running"
fi
# TURN THE SWITCH
isMainnet
if [ $? -eq 1 ]; then
echo "switching from mainnet to testnet"
switchToTestnet
else
echo "switching from testnet to mainnet"
switchToMainnet
fi
echo "copying over config to admin user"
cp $NETWORK_CONFIG /home/admin/.${network}/
chown admin:admin /home/admin/.${network}/${network}.conf
cp $LND_CONFIG /home/admin/.lnd/
chown admin:admin /home/admin/.lnd/lnd.conf
# restarting network
if [ ${networkInstalled} -gt 0 ]; then
# start network
systemctl start bitcoind
echo "started ${network}d back up, giving it a 120 SECONDS to prepare"
sleep 120
# set setup info again
echo "60" > /home/admin/.setup
# run again the complete LND init procedure
./70initLND.sh
else
echo "No starting of network, because it was not running before"
fi

View File

@ -0,0 +1,219 @@
#!/bin/bash
# Background:
# https://medium.com/@lopp/how-to-run-bitcoin-as-a-tor-hidden-service-on-ubuntu-cff52d543756
# https://bitcoin.stackexchange.com/questions/70069/how-can-i-setup-bitcoin-to-be-anonymous-with-tor
# https://github.com/lightningnetwork/lnd/blob/master/docs/configuring_tor.md
# load network
network=`cat .network`
chain="$(${network}-cli getblockchaininfo | jq -r '.chain')"
# location of TOR config
torrc="/etc/tor/torrc"
# check if TOR was already installed and is funtional
clear
echo ""
echo "*** Check if TOR service is functional ***"
torRunning=$(curl --connect-timeout 10 --socks5-hostname 127.0.0.1:9050 https://check.torproject.org | grep "Congratulations. This browser is configured to use Tor." -c)
if [ ${torRunning} -gt 0 ]; then
clear
echo "You are all good - TOR is already running."
echo ""
exit 0
else
echo "TOR not running ... proceed with switching to TOR."
echo ""
fi
# ask user if to proceed
dialog --title " WARNING " --yesno "At the moment you just can switch TOR on - YOU CANNOT SWITCH BACK. Do you want to proceed?" 8 57
response=$?
case $response in
1) exit 1;
esac
echo "*** Adding Tor Sources to sources.list ***"
echo "deb http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://deb.torproject.org/torproject.org stretch main" | sudo tee -a /etc/apt/sources.list
echo "OK"
echo ""
echo "*** Installing dirmngr ***"
sudo apt install dirmngr
echo ""
## lopp: gpg --keyserver keys.gnupg.net --recv 886DDD89
echo "*** Fetching GPG key ***"
gpg --keyserver keys.gnupg.net --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
echo ""
echo "*** Updating System ***"
sudo apt-get update
echo ""
echo "*** Install Tor ***"
sudo apt install tor tor-arm -y
echo ""
echo "*** Tor Config ***"
sudo rm -r -f /mnt/hdd/tor 2>/dev/null
sudo mkdir /mnt/hdd/tor
sudo mkdir /mnt/hdd/tor/sys
sudo mkdir /mnt/hdd/tor/web80
sudo mkdir /mnt/hdd/tor/lnd9735
sudo mkdir /mnt/hdd/tor/lndrpc9735
sudo chmod -R 700 /mnt/hdd/tor
sudo chown -R bitcoin:bitcoin /mnt/hdd/tor
cat > ./torrc <<EOF
### See 'man tor', or https://www.torproject.org/docs/tor-manual.html
DataDirectory /mnt/hdd/tor/sys
PidFile /mnt/hdd/tor/sys/tor.pid
SafeLogging 0
Log notice stdout
Log notice file /mnt/hdd/tor/notice.log
Log info file /mnt/hdd/tor/info.log
RunAsDaemon 1
User bitcoin
PortForwarding 1
ControlPort 9051
SocksPort 9050
CookieAuthFile /mnt/hdd/tor/sys/control_auth_cookie
CookieAuthentication 1
CookieAuthFileGroupReadable 1
# Hidden Service v2 for WEB ADMIN INTERFACE
HiddenServiceDir /mnt/hdd/tor/web80/
HiddenServicePort 80 127.0.0.1:80
# Hidden Service v2 for LND RPC
HiddenServiceDir /mnt/hdd/tor/lndrpc10009/
HiddenServicePort 80 127.0.0.1:10009
# Hidden Service v3 for LND incomming connections (just in case)
# https://trac.torproject.org/projects/tor/wiki/doc/NextGenOnions#Howtosetupyourownprop224service
HiddenServiceDir /mnt/hdd/tor/lnd9735
HiddenServiceVersion 3
HiddenServicePort 9735 127.0.0.1:9735
# NOTE: bitcoind get tor service automatically - see /mnt/hdd/bitcoin for onion key
EOF
sudo rm $torrc
sudo mv ./torrc $torrc
sudo chmod 644 $torrc
sudo chown -R bitcoin:bitcoin /var/run/tor/
echo ""
# NYX - Tor monitor tool
# https://nyx.torproject.org/#home
echo "*** Installing NYX - TOR monitoring Tool ***"
nyxInstalled=$(sudo pip list 2>/dev/null | grep 'nyx' -c)
if [ ${nyxInstalled} -eq 0 ]; then
sudo pip install nyx
else
echo "NYX already installed"
fi
echo ""
echo "*** Activating TOR system service ***"
echo "ReadWriteDirectories=-/mnt/hdd/tor" | sudo tee -a /lib/systemd/system/tor@default.service
sudo systemctl daemon-reload
sudo systemctl restart tor@default
echo ""
echo "*** Waiting for TOR to boostrap ***"
torIsBootstrapped=0
while [ ${torIsBootstrapped} -eq 0 ]
do
echo "--- Checking 1 ---"
date +%s
sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped" | tail -n 10
torIsBootstrapped=$(sudo cat /mnt/hdd/tor/notice.log 2>/dev/null | grep "Bootstrapped 100" -c)
echo "torIsBootstrapped(${torIsBootstrapped})"
echo "If this takes too long --> CTRL+c, reboot and check manually"
sleep 5
done
echo "OK - Tor Bootstrap is ready"
echo ""
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
echo "Only Connect thru TOR"
echo "onlynet=onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
if [ "${network}" = "bitcoin" ]; then
echo "Adding some bitcoin onion nodes to connect to"
echo "addnode=fno4aakpl6sg6y47.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=toguvy5upyuctudx.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=ndndword5lpb7eex.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=6m2iqgnqjxh7ulyk.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=5tuxetn7tar3q5kp.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
fi
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Chain network already configured for TOR"
fi
echo "*** ${network} re-init - Waiting for Onion Address ***"
# restarting bitcoind to start with tor and generare onion.address
echo "restarting ${network}d ..."
sudo systemctl restart ${network}d
sleep 8
onionAddress=""
while [ ${#onionAddress} -eq 0 ]
do
echo "--- Checking 2 ---"
date +%s
testNetAdd=""
if [ "${chain}" = "test" ];then
testNetAdd="/testnet3"
fi
sudo cat /mnt/hdd/${network}${testNetAdd}/debug.log 2>/dev/null | grep "tor" | tail -n 10
onionAddress=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"address"' | cut -d '"' -f4)
echo "Can take up to 20min - if this takes longer --> CTRL+c, reboot and check manually"
sleep 5
done
onionPort=$(sudo -u bitcoin ${network}-cli getnetworkinfo | grep '"port"' | tr -dc '0-9')
echo "Your Chain Network Onion Address is: ${onionAddress}:${onionPort}"
echo ""
echo "*** Setting your Onion Address ***"
onionLND=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)
echo "Your Lightning Tor Onion Address is: ${onionLND}:9735"
echo ""
# ACTIVATE LND OVER TOR
echo "*** Putting LND behind TOR ***"
echo "Disable LND again"
sudo systemctl disable lnd
echo "Writing Public Onion Address to /mnt/hdd/tor/v3Address (just in case for TotHiddenServiceV3)"
echo "V3ADDRESS=${onionLND}" | sudo tee /mnt/hdd/tor/v3Address
echo "Configure and Changing to lnd.tor.service"
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.tor.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.tor.service
sudo cp /home/admin/assets/lnd.tor.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
echo "Enable LND again"
sudo systemctl enable lnd
echo "OK"
echo ""
echo "*** Finshing Setup / REBOOT ***"
echo "OK - all should be set"
echo ""
echo "PRESS ENTER ... to REBOOT"
read key
sudo shutdown -r now
exit 0

View File

@ -0,0 +1,57 @@
#!/bin/bash
# load network
network=`cat .network`
# location of TOR config
torrc="/etc/tor/torrc"
echo "*** Stopping all Services ***"
sudo systemctl stop lnd
sudo systemctl stop ${network}d
sudo systemctl stop tor@default
echo ""
echo "*** Disable TOR service ***"
sudo systemctl disable tor@default
echo ""
echo "*** Changing ${network} Config ***"
sudo cat /home/bitcoin/.${network}/${network}.conf | grep -Ev 'onlynet=onion|.onion' | sudo tee /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
echo "*** Removing TOR from LND ***"
sudo systemctl disable lnd
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
sudo systemctl enable lnd
echo "OK"
echo ""
echo "*** Remove Tor ***"
sudo apt remove tor tor-arm -y
echo ""
echo "*** Remove dirmngr ***"
sudo apt remove dirmngr -y
echo ""
echo "*** Remove NYX ***"
sudo pip uninstall nyx -y
echo ""
echo "*** Remove TOR Files/Config ***"
sudo rm -r -f /mnt/hdd/tor
echo ""
echo "*** Finshing Setup / REBOOT ***"
echo "OK - all should be set"
echo ""
echo "PRESS ENTER ... to REBOOT"
read key
sudo shutdown -r now
exit 0

View File

@ -0,0 +1,22 @@
#!/bin/bash
# Basic Options
OPTIONS=(ZAP "Zap Wallet (iOS)" \
SHANGO "Shango Wallet (iOS/Android)")
CHOICE=$(dialog --clear --title "Choose Mobile Wallet" --menu "" 10 40 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
case $CHOICE in
CLOSE)
exit 1;
;;
SHANGO)
./97addMobileWalletShango.sh
exit 1;
;;
ZAP)
./97addMobileWalletZap.sh
exit 1;
;;
esac

View File

@ -0,0 +1,51 @@
#!/bin/bash
# load network
network=`cat .network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# make sure qrcode-encoder in installed
clear
echo "*** Setup ***"
sudo apt-get install qrencode -y
# get local IP
myip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
clear
echo "******************************"
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 ***"
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
echo "Then go to --> '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 OR' 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
echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***"
echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/bitcoin/mainnet/admin.macaroon)," > qr.txt && cat ./.lnd/tls.cert >>qr.txt && qrencode -t ANSIUTF8 < qr.txt
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key
clear
echo "Now press 'Connect' within the Shango Wallet."
echo "If its not working - check issues on GitHub:"
echo "https://github.com/neogeno/shango-lightning-wallet/issues"
echo ""

View File

@ -0,0 +1,58 @@
#!/bin/bash
# load network
network=`cat .network`
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# make sure qrcode-encoder in installed
clear
echo "*** Setup ***"
echo ""
echo "Installing zapconnect. Please wait..."
echo ""
echo "Getting github.com/LN-Zap/zapconnect ..."
go get -d github.com/LN-Zap/zapconnect
echo ""
echo "Building github.com/LN-Zap/zapconnect ..."
cd /home/admin/go/src/github.com/LN-Zap/zapconnect/
go build -o /home/admin/go/src/github.com/LN-Zap/zapconnect/zapconnect
clear
echo "******************************"
echo "Connect Zap Mobile Wallet"
echo "******************************"
echo ""
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 "Go to http://www.zap-ios.jackmallers.com sign up with your email (confirmation can take time)"
echo "iOS: Read https://developer.apple.com/testflight/testers/"
echo ""
echo "*** STEP 1 ***"
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
echo ""
echo "Click on Connect remote node"
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
echo "*** STEP 2 : Click on Scan (make whole QR code fill camera) ***"
# If you drop the -i parameter, zapconnect will use the external IP.
/home/admin/go/src/github.com/LN-Zap/zapconnect/zapconnect -i
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key
clear
echo "If its not working - check issues on GitHub:"
echo "https://github.com/LN-Zap/zap-iOS/issues"
echo "https://github.com/LN-Zap/zapconnect/issues"
echo ""

163
home.admin/AAunlockLND.py Executable file
View File

@ -0,0 +1,163 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import base64
import os
import signal
import subprocess
import sys
from optparse import OptionParser
try: # make sure that (unsupported) Python2 can fail gracefully
import configparser
except ImportError:
pass
if sys.version_info < (3, 5, 0):
print("Python2 not supported! Please run with Python3.5+")
sys.exit(1)
def sigint_handler(signum, frame):
print('CTRL+C pressed - exiting!')
sys.exit(0)
def _read_pwd(password_file):
# read and convert password from file
p = subprocess.run("sudo cat {}".format(password_file),
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=False, shell=True, timeout=None)
if not p.returncode == 0:
print("unable to read password from: {}".format(password_file))
sys.exit(1)
passwd_bytes = p.stdout.split(b"\n")[0]
passwd_b64 = base64.encodebytes(passwd_bytes).decode('utf-8').split("\n")[0]
return passwd_b64
def _read_macaroon(lnd_macaroon_file):
# read and convert macaroon from file
p = subprocess.run("sudo xxd -ps -u -c 1000 {}".format(lnd_macaroon_file),
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, shell=True, timeout=None)
macaroon_hex_dump = p.stdout.split("\n")[0]
return macaroon_hex_dump
def check_locked(password_file, lnd_cert_file, lnd_macaroon_file, host="localhost", port="8080", verbose=False):
# check locked
if verbose:
print("Checking for lock")
passwd_b64 = _read_pwd(password_file)
macaroon_hex_dump = _read_macaroon(lnd_macaroon_file)
cmds = ["curl", "-s",
"-H", "'Grpc-Metadata-macaroon: {}'".format(macaroon_hex_dump),
"--cacert", "{}".format(lnd_cert_file),
"-d", "{{\"wallet_password\": \"{}\"}}".format(passwd_b64),
"https://{}:{}/v1/getinfo".format(host, port)]
p = subprocess.run(cmds,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, shell=False, timeout=None)
if not p.returncode == 0:
print("\033[91mSomething went wrong!\033[00m \033[93mIs lnd running? Wrong credentials?\033[00m")
# print("Returncode: {}".format(p.returncode))
# print("Stderr: {}".format(p.stderr))
sys.exit(1)
if p.stdout == "Not Found\n":
return True
else:
return False
def unlock(password_file, lnd_cert_file, lnd_macaroon_file, host="localhost", port="8080", verbose=False):
if verbose:
print("Trying to unlock")
passwd_b64 = _read_pwd(password_file)
macaroon_hex_dump = _read_macaroon(lnd_macaroon_file)
# unlock lnd by calling curl
cmds = ["curl", "-s",
"-H", "'Grpc-Metadata-macaroon: {}'".format(macaroon_hex_dump),
"--cacert", "{}".format(lnd_cert_file),
"-d", "{{\"wallet_password\": \"{}\"}}".format(passwd_b64),
"https://{}:{}/v1/unlockwallet".format(host, port)]
p = subprocess.run(cmds,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, shell=False, timeout=None)
if p.returncode == 0:
return True
else:
if verbose:
print("\033[91mSomething went wrong!\033[00m \033[93mIs lnd running? Wrong credentials?\033[00m")
# print("Returncode: {}".format(p.returncode))
# print("Stderr: {}".format(p.stderr))
return False
def main():
signal.signal(signal.SIGINT, sigint_handler)
usage = "usage: %prog [Options]"
parser = OptionParser(usage=usage, version="%prog {}".format("0.1"))
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
help="Print more output")
parser.add_option("-H", dest="host", type="string", default="localhost",
help="Host (default: localhost)")
parser.add_option("-P", dest="port", type="string", default="8080",
help="Port (default: 8080)")
parser.add_option("-p", dest="password_file", type="string", default="pwd",
help="File containing *cleartext* password (default: pwd)")
parser.add_option("-c", dest="cert", type="string",
help="TLS certificate file (e.g. ~/.lnd/tls.cert)"),
parser.add_option("-m", dest="macaroon", type="string",
help="Macaroon file (e.g. readonly.macaroon)")
options, args = parser.parse_args()
password_file = os.path.abspath(options.password_file)
if not os.path.exists(password_file):
print("Password file does not exist - exiting: {}".format(password_file))
sys.exit(1)
if options.cert:
lnd_cert_file = options.cert
else:
lnd_cert_file = "/home/bitcoin/.lnd/tls.cert"
if options.macaroon:
lnd_macaroon_file = options.macaroon
else:
lnd_macaroon_file = "/home/bitcoin/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon"
if options.verbose:
print("Password File: \033[93m{}\033[00m".format(password_file))
print("TLS CERT File: \033[93m{}\033[00m".format(lnd_cert_file))
print("Macaroon File: \033[93m{}\033[00m".format(lnd_macaroon_file))
print("URL: \033[93mhttps://{}:{}\033[00m".format(options.host, options.port))
if check_locked(password_file, lnd_cert_file, lnd_macaroon_file,
host=options.host, port=options.port, verbose=options.verbose):
if options.verbose:
print("\033[93m{}\033[00m".format("Locked"))
else:
print("\033[92m{}\033[00m".format("Not Locked"))
sys.exit(1)
if unlock(password_file, lnd_cert_file, lnd_macaroon_file,
host=options.host, port=options.port, verbose=options.verbose):
print("\033[92m{}\033[00m".format("Successfully unlocked."))
else:
print("\033[91m{}\033[00m".format("Failed to unlock."))
if __name__ == "__main__":
main()

View File

@ -5,14 +5,15 @@ network=`cat .network`
echo ""
echo "****************************************************************************"
echo "Unlock LND Wallet --> lncli unlock"
echo "Unlock LND Wallet --> lncli --chain=${network} unlock"
echo "****************************************************************************"
echo "HELP: Enter your PASSWORD C"
echo "You may wait some seconds until you get asked for password."
echo "****************************************************************************"
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
while :
do
lncli unlock
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 0 ]; then
@ -20,5 +21,7 @@ while :
fi
echo ""
echo "network(${network}) chain(${chain})"
sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log
echo "Wallet still locked - please try again or Cancel with CTRL+C"
done

78
home.admin/BBcashoutWallet.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
# get available amount in on-chain wallet
maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
# TODO: pre-check if channels are open or are still in closing
# and let user know not all funds are available yet (just info Dialoge)
# TODO: pre-check user hast more than 0 sat in on-chain wallet to send
# let user enter the amount
l1="Enter the amount of funds you want to send/remove:"
l2="You have max available: ${maxAmount} sat"
l3="If you enter nothing, all funds available will be send."
dialog --title "Remove Funds from RaspiBlitz" \
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
amount=$(cat $_temp | xargs)
shred $_temp
if [ ${#amount} -eq 0 ]; then
amount=${maxAmount}
fi
# TODO: check if amount is in valid range
# let user enter the address
l1="Enter the on-chain address to send funds to:"
l2="You will send: ${amount} sat to that address"
dialog --title "Where to send funds?" \
--inputbox "$l1\n$l2" 8 65 2>$_temp
address=$(cat $_temp | xargs)
shred $_temp
if [ ${#address} -eq 0 ]; then
echo "FAIL - not a valid address (${address})"
exit 1
fi
# TODO: check address is valid for network and chain
# TODO: check if fees are getting done right so that transaction will get processed
amount=$((amount - 10000))
command="lncli --chain=${network} sendcoins --addr ${address} --amt ${amount} --conf_target 3"
clear
echo "******************************"
echo "Send on-chain Funds"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# execute command
if [ ${#command} -gt 0 ]; then
result=$($command)
fi
# on no result
if [ ${#result} -eq 0 ]; then
echo "Sorry something went wrong - thats unusual."
echo ""
exit 1
fi
# when result is available
echo "$result"
# TODO: check if all cashed out (0 funds + 0 channels) -> let user knwo its safe to update/reset RaspiBlitz
echo "OK. That worked :)"
echo ""

View File

@ -0,0 +1,36 @@
#!/bin/bash
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli closeallchannels --force"
clear
echo "***********************************"
echo "Closing All Channels (EXPERIMENTAL)"
echo "***********************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
# execute command
if [ ${#command} -gt 0 ]; then
${command}
fi
echo ""
echo "OK - wait a 5 seconds"
sleep 5
echo "Your Open Channel List (to check):"
lnchannels

View File

@ -29,7 +29,7 @@ if [ ${#_input} -eq 0 ]; then
fi
# build command
command="lncli connect ${_input}"
command="lncli --chain=${network} connect ${_input}"
# info output
clear
@ -40,7 +40,7 @@ echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
echo "RESULT (might have to wait for timeout):"
win=1
info=""
@ -88,7 +88,7 @@ else
# check if the node is now in peer list
pubkey=$(echo $_input | cut -d '@' -f1)
isPeer=$(lncli listpeers 2>/dev/null| grep "${pubkey}" -c)
isPeer=$(lncli --chain=${network} listpeers 2>/dev/null| grep "${pubkey}" -c)
if [ ${isPeer} -eq 0 ]; then
# basic error message

92
home.admin/BBcreateInvoice.sh Executable file
View File

@ -0,0 +1,92 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
sudo chmod 7777 ${_error}
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} 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} 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
# let user enter the invoice
l1="Enter the AMOUNT IN SATOSHI of the invoice:"
l2="1 ${network} = 100 000 000 SAT"
dialog --title "Pay thru Lightning Network" \
--inputbox "$l1\n$l2" 9 50 2>$_temp
amount=$(cat $_temp | xargs | tr -dc '0-9')
shred $_temp
if [ ${#amount} -eq 0 ]; then
echo "FAIL - not a valid input (${amount})"
exit 1
fi
# build command
command="lncli --chain=${network} addinvoice ${amount}"
# info output
clear
echo "******************************"
echo "Create Invoice / Payment Request"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
sleep 2
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "******************************"
echo "WIN"
echo "******************************"
echo "${result}"
echo ""
rhash=$(echo "$result" | grep r_hash | cut -d '"' -f4)
payReq=$(echo "$result" | grep pay_req | cut -d '"' -f4)
echo "Give this Invoice/PaymentRequest to someone to pay it:"
echo ""
echo ${payReq}
echo ""
echo "You can use 'lncli --chain=${network} lookupinvoice ${rhash}' to check the payment. "
# TODO: Offer to go into monitor for incommin payment loop.
fi
echo ""

View File

@ -2,9 +2,9 @@
# load network and chain info
network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli newaddress np2wkh"
command="lncli --chain=${network} newaddress np2wkh"
clear
echo "******************************"
@ -16,8 +16,17 @@ echo $command
echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "
fi
# execute command
result=$($command)
if [ ${#command} -gt 0 ]; then
result=$($command)
fi
# on no result
if [ ${#result} -eq 0 ]; then
@ -48,7 +57,8 @@ echo "TODO"
echo "******************************"
echo "Send ${coininfo} to address --> ${address}"
if [ "$chain" = "test" ]; then
echo "get some testnet coins from https://testnet.manu.backend.hamburg/faucet"
echo "get some testnet coins from https://testnet-faucet.mempool.co"
fi
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or 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 ""

136
home.admin/BBopenChannel.sh Executable file
View File

@ -0,0 +1,136 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
echo "Wait until chain is sync with LND and try again."
echo ""
exit 1
fi
# check available funding
confirmedBalance=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${confirmedBalance} -eq 0 ]; then
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet."
echo "Please fund your on-chain wallet first and wait until confirmed."
echo ""
exit 1
fi
# check number of connected peers
numConnectedPeers=$(lncli --chain=${network} listpeers | grep pub_key -c)
if [ ${numConnectedPeers} -eq 0 ]; then
echo "FAIL - no peers connected on lightning network"
echo "You can only open channels to peer nodes to connected to first."
echo "Use CONNECT peer option in main menu first."
echo ""
exit 1
fi
# let user pick a peer to open a channels with
OPTIONS=()
while IFS= read -r grepLine
do
pubKey=$(echo ${grepLine} | cut -d '"' -f4)
#echo "grepLine(${pubKey})"
OPTIONS+=(${pubKey} "")
done < <(lncli --chain=${network} listpeers | grep pub_key)
TITLE="Open (Payment) Channel"
MENU="\nChoose a peer you connected to, to open the channel with: \n "
pubKey=$(dialog --clear \
--title "$TITLE" \
--menu "$MENU" \
14 73 5 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
if [ ${#pubKey} -eq 0 ]; then
echo "Selected CANCEL"
echo ""
exit 1
fi
# find out what is the minimum amount
# TODO find a better way - also consider dust and channel reserve
# details see here: https://github.com/btcontract/lnwallet/issues/52
minSat=20000
if [ "${network}" = "bitcoin" ]; then
minSat=250000
fi
_error="./.error.out"
lncli --chain=${network} openchannel ${CHOICE} 1 0 2>$_error
error=`cat ${_error}`
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
minSat=$(echo "${error}" | tr -dc '0-9')
fi
# let user enter a amount
l1="Amount in SATOSHI to fund this channel:"
l2="min required : ${minSat}"
l3="max available : ${confirmedBalance}"
dialog --title "Funding of Channel" \
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
amount=$(cat $_temp | xargs | tr -dc '0-9')
shred $_temp
if [ ${#amount} -eq 0 ]; then
echo "FAIL - not a valid input (${amount})"
exit 1
fi
# build command
command="lncli --chain=${network} openchannel ${pubKey} ${amount} 0"
# info output
clear
echo "******************************"
echo "Open Channel"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT:"
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "******************************"
echo "WIN"
echo "******************************"
echo "${result}"
echo ""
echo "Whats next? --> You need to wait 6 confirmations, for the channel to be ready."
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
echo "https://blockexplorer.com/tx/${fundingTX}"
else
echo "https://testnet.blockexplorer.com/tx/${fundingTX}"
fi
fi
if [ "${network}" = "litecoin" ]; then
echo "https://live.blockcypher.com/ltc/tx/${fundingTX}/"
fi
fi
echo ""

106
home.admin/BBpayInvoice.sh Executable file
View File

@ -0,0 +1,106 @@
#!/bin/bash
_temp="./download/dialog.$$"
_error="./.error.out"
# load network and chain info
network=`cat .network`
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
echo ""
echo "*** Precheck ***"
# check if chain is in sync
chainInSync=$(lncli --chain=${network} 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} 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
paymentRequestStart="???"
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
paymentRequestStart="lnbc"
else
paymentRequestStart="lntb"
fi
elif [ "${network}" = "litecoin" ]; then
paymentRequestStart="lnltc"
fi
testSite="???"
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
testSite="https://satoshis.place"
else
testSite="https://testnet.satoshis.place"
fi
elif [ "${network}" = "litecoin" ]; then
testSite="https://millionlitecoinhomepage.net"
fi
# let user enter the invoice
l1="Copy the LightningInvoice/PaymentRequest into here:"
l2="Its a long string starting with '${paymentRequestStart}'"
l3="To try it out go to: ${testSite}"
dialog --title "Pay thru Lightning Network" \
--inputbox "$l1\n$l2\n$l3" 10 70 2>$_temp
invoice=$(cat $_temp | xargs)
shred $_temp
if [ ${#invoice} -eq 0 ]; then
echo "FAIL - not a valid input (${invoice})"
exit 1
fi
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq
# build command
command="lncli --chain=${network} sendpayment --force --pay_req=${invoice}"
# info output
clear
echo "******************************"
echo "Pay Invoice / Payment Request"
echo "******************************"
echo ""
echo "COMMAND LINE: "
echo $command
echo ""
echo "RESULT (may wait in case of timeout):"
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
#echo "result(${result})"
#echo "error(${error})"
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
echo "${result}"
echo "******************************"
echo "WIN"
echo "******************************"
echo "It worked :) - check out the service you were paying."
fi
echo ""

View File

@ -16,10 +16,12 @@ sudo rm -f /mnt/hdd/${network}/${network}.conf
sudo rm -f /mnt/hdd/${network}/${network}.pid
sudo rm -f /mnt/hdd/${network}/*.dat
sudo rm -f /mnt/hdd/${network}/*.log
sudo rm -f /mnt/hdd/${network}/*.pid
sudo rm -f /mnt/hdd/${network}/testnet3/*.dat
sudo rm -f /mnt/hdd/${network}/testnet3/*.log
sudo rm -f /mnt/hdd/${network}/testnet3/.lock
sudo rm -f -r /mnt/hdd/${network}/database
sudo rm -f -r /mnt/hdd/tor
sudo chown admin:admin -R /mnt/hdd/${network}
echo "1" > /home/admin/.setup
echo "OK - the HDD is now clean"

17
home.admin/XXupdateScripts.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
echo ""
echo "*** UPDATING SHELL SCRIPTS FROM GITHUB ***"
echo "justincase, not the final upadte mechanism"
echo "******************************************"
cd /home/admin/raspiblitz
git pull
cd ..
rm *.sh
rm -r assets
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.* /home/admin
sudo -u admin chmod +x *.sh
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
echo "******************************************"
echo "OK - shell scripts and assests are up to date"
echo "Reboot recommended"
echo ""

140
home.admin/_bootstrap.sh Normal file
View File

@ -0,0 +1,140 @@
#!/bin/bash
# This script runs on every start calles by boostrap.service
# It makes sure that the system is configured like the
# default values or as in the config.
# For more details see background_raspiblitzSettings.md
# load codeVersion
source /home/admin/_version.info
logfile="/home/admin/raspiblitz.log"
echo "Writing logs to: ${logfile}"
echo "" > $logfile
echo "***********************************************" >> $logfile
echo "Running RaspiBlitz Bootstrap ${codeVersion}" >> $logfile
date >> $logfile
echo "***********************************************" >> $logfile
################################
# AFTER BOOT SCRIPT
# when a process needs to
# execute stuff after a reboot
# /home/admin/setup.sh
################################
# check for after boot script
afterSetupScriptExists=$(ls /home/admin/setup.sh 2>/dev/null | grep -c setup.sh)
if [ ${afterSetupScriptExists} -eq 1 ]; then
echo "*** SETUP SCRIPT DETECTED ***"
# echo out script to journal logs
sudo cat /home/admin/setup.sh
# execute the after boot script
sudo /home/admin/setup.sh
# delete the after boot script
sudo rm /home/admin/setup.sh
# reboot again
echo "DONE wait 6 secs ... one more reboot needed ... "
sudo shutdown -r now
sleep 100
fi
################################
# PUBLIC IP
# for LND on startup
################################
printf "PUBLICIP=$(curl -vv ipinfo.io/ip 2> /run/publicip.log)\n" > /run/publicip;
chmod 774 /run/publicip
################################
# HDD CHECK / INIT
# for the very first setup
################################
# check if the HDD is mounted
hddAvailable=$(ls -la /mnt/hdd 2>/dev/null)
if [ ${#hddAvailable} -eq 0 ]; then
echo "HDD is NOT available" >> $logfile
echo "TODO: Try to mount."
exit 1
fi
################################
# CONFIGFILE BASICS
################################
# check if there is a config file
configFile="/mnt/hdd/raspiblitz.conf"
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
# create new config
echo "creating config file: ${configFile}" >> $logfile
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${version}'" >> $configFile
sudo chmod 777 ${configFile}
else
# load & check config version
source $configFile
if [ "${raspiBlitzVersion}" != "${raspiBlitzVersion}" ]; then
echo "detected version change ... starting migration script" >> $logfile
/home/admin/_migrateVersion.sh
fi
fi
################################
# DEFAULT VALUES
################################
# AUTOPILOT
# autoPilot=off|on
if [ ${#autoPilot} -eq 0 ]; then
echo "autoPilot=off" >> $configFile
fi
# after all default values written to config - reload config
source $configFile
################################
# AUTOPILOT
################################
echo "" >> $logfile
echo "** AUTOPILOT" >> $logfile
# check if LND is installed
lndExists=$(ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c '.conf')
if [ ${lndExists} -eq 1 ]; then
# check if autopilot is active in LND config
lndAutopilot=$( grep -c "autopilot.active=1" /mnt/hdd/lnd/lnd.conf )
echo "confAutopilot(${autoPilot})" >> $logfile
echo "lndAutopilot(${lndAutopilot})" >> $logfile
# switch on
if [ ${lndAutopilot} -eq 0 ] && [ "${autoPilot}" = "on" ]; then
echo "switching the LND autopilot ON" >> $logfile
sudo sed -i "s/^autopilot.active=.*/autopilot.active=1/g" /mnt/hdd/lnd/lnd.conf
fi
# switch off
if [ ${lndAutopilot} -eq 1 ] && [ "${autoPilot}" = "off" ]; then
echo "switching the LND autopilot OFF" >> $logfile
sudo sed -i "s/^autopilot.active=.*/autopilot.active=0/g" /mnt/hdd/lnd/lnd.conf
fi
else
echo "WARNING: /mnt/hdd/lnd/lnd.conf does not exists. Setup needs to run properly first!" >> $logfile
fi
echo "" >> $logfile
echo "DONE BOOTSTRAP" >> $logfile

17
home.admin/_migration.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# load codeVersion
source ./_version.info
# load raspiblitz config
source /mnt/hdd/raspiblitz.conf
echo ""
echo "*****************************"
echo "Version Migration RaspiBlitz"
echo "*****************************"
echo "Version Code: ${codeVersion}"
echo "Version Data: ${raspiBlitzVersion}"
echo "TODO: Update Migration check ..."
echo ""

2
home.admin/_version.info Normal file
View File

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

View File

@ -1,7 +1,7 @@
# bitcoind configuration
# remove the following line to enable Bitcoin mainnet
testnet=1
# mainnet/testnet - to switch just comment/uncomment
#testnet=1
# Bitcoind options
server=1
@ -11,9 +11,9 @@ disablewallet=1
# Connection settings
rpcuser=raspibolt
# LINE15 -insert-> rpcpassword=[PASSWORDB]
zmqpubrawblock=tcp://127.0.0.1:29000
zmqpubrawtx=tcp://127.0.0.1:29000
rpcpassword=passwordB
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# Raspberry Pi optimizations
dbcache=100

View File

@ -2,8 +2,8 @@
[Unit]
Description=Bitcoin daemon
Wants=getpublicip.service
After=getpublicip.service
Wants=bootstrap.service
After=bootstrap.service
# for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n

View File

@ -0,0 +1,16 @@
# Boostrap the RaspiBlitz
# /etc/systemd/system/bootstrap.service
[Unit]
Description=setting up RaspiBlitz and enforcing the config on every startup
After=network.target
[Service]
User=root
Group=root
Type=oneshot
ExecStart=/home/admin/_bootstrap.sh
StandardOutput=journal
[Install]
WantedBy=multi-user.target

View File

@ -1,9 +1,9 @@
# litecoind configuration
# lightning on litecoin just has mainnet
# mainnet/testnet - to switch just comment/uncomment
#testnet=1
# Bitcoind options
# litcoind options
server=1
daemon=1
txindex=1
@ -11,9 +11,9 @@ disablewallet=1
# Connection settings
rpcuser=raspibolt
# LINE15 -insert-> rpcpassword=[PASSWORDB]
rpcpassword=passwordB
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# Raspberry Pi optimizations
dbcache=100

View File

@ -1,7 +1,7 @@
[Unit]
Description=Bitcoin daemon
Wants=getpublicip.service
After=getpublicip.service
Wants=bootstrap.service
After=bootstrap.service
# for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n

View File

@ -1,22 +1,32 @@
# lnd configuration
[Application Options]
debuglevel=info
debughtlc=true
debuglevel=debug
maxpendingchannels=5
# LINE7 -insert-> alias=[ALIAS]
alias=raspiblitz
color=#68F442
nat=false
# RPC open to all connections on Port 10009
rpclisten=0.0.0.0:10009
# Domain, could use https://freedns.afraid.org
#tlsextradomain=lightning.yourhost.com
[Bitcoin]
bitcoin.active=1
# enable either testnet or mainnet
bitcoin.testnet=1
#bitcoin.mainnet=1
bitcoin.node=bitcoind
# enable either testnet or mainnet
#bitcoin.testnet=1
bitcoin.mainnet=1
[Bitcoind]
bitcoind.rpcuser=raspibolt
bitcoind.rpcpass=passwordB
bitcoind.rpchost=127.0.0.1
bitcoind.zmqpubrawblock=tcp://*:28332
bitcoind.zmqpubrawtx=tcp://*:28333
[autopilot]
autopilot.active=1
autopilot.active=0
autopilot.maxchannels=5
autopilot.allocation=0.6

View File

@ -1,21 +1,30 @@
# lnd configuration
[Application Options]
debuglevel=info
debughtlc=true
debuglevel=debug
maxpendingchannels=5
# LINE7 -insert-> alias=[ALIAS]
alias=raspiblitz
color=#68F442
nat=false
# RPC open to all connections on Port 10009
rpclisten=0.0.0.0:10009
# Domain, could use https://freedns.afraid.org
#tlsextradomain=lightning.yourhost.com
[Litecoin]
litecoin.active=1
litecoin.mainnet=1
litecoin.node=litecoind
litecoind.rpcuser=jason
litecoind.rpcpass=litecoin
litecoind.zmqpath=tcp://127.0.0.1:28332
litecoin.node=litecoind
[Litecoind]
litecoind.rpchost=127.0.0.1
litecoind.rpcuser=raspibolt
litecoind.rpcpass=passwordB
litecoind.zmqpubrawblock=tcp://*:28332
litecoind.zmqpubrawtx=tcp://*:28333
[autopilot]
autopilot.active=1
autopilot.active=0
autopilot.maxchannels=5
autopilot.allocation=0.6

View File

@ -9,9 +9,7 @@ After=bitcoind.service
#OnFailure=systemd-sendmail@%n
[Service]
# get var PUBIP from file
EnvironmentFile=/run/publicip
ExecStart=/usr/local/bin/lnd --externalip=${PUBLICIP}
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin

View File

@ -0,0 +1,32 @@
# RaspiBlitz: systemd unit for lnd
[Unit]
Description=LND Lightning Daemon
Wants=bitcoind.service
After=bitcoind.service
# for use with sendmail alert
#OnFailure=systemd-sendmail@%n
[Service]
# get var PUBIP from file
EnvironmentFile=/mnt/hdd/tor/v3Address
# TOR Hidden Service v2
ExecStart=/usr/local/bin/lnd --tor.active --tor.v2 --listen=127.0.0.1:9735
# TOR Hidden Service v3
# ExecStart=/usr/local/bin/lnd --tor.active --tor.v3 --externalip=${V3ADDRESS} --listen=127.0.0.1:9735
PIDFile=/home/bitcoin/.lnd/lnd.pid
User=bitcoin
Group=bitcoin
LimitNOFILE=128000
Type=simple
KillMode=process
TimeoutSec=180
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
pictures/lightningshell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
pictures/shango1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
pictures/tor1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -1,70 +0,0 @@
#########################################################################
# Build your SD card image based on:
# RASPBIAN STRETCH WITH DESKTOP (2018-06-27)
# https://www.raspberrypi.org/downloads/raspbian/
# SHA256: 8636ab9fdd8f58a8ec7dde33b83747696d31711d17ef68267dbbcd6cfb968c24
##########################################################################
# setup fresh SD card with image above - login per SSH and run this script
##########################################################################
# *** RASPI CONFIG ***
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config
# A) Set Raspi to boot up automatically with user pi (for the LCD)
# https://www.raspberrypi.org/forums/viewtopic.php?t=21632
sudo raspi-config nonint do_boot_behaviour B2
# B) Give Raspi a default hostname (optional)
sudo raspi-config nonint do_hostname "RaspiBlitz"
# do memory split (16MB)
# TODO: sudo raspi-config nonint do_memory_split %d
# *** SOFTWARE UPDATE ***
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#software-update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install htop git curl bash-completion jq dphys-swapfile
# *** ADDING MAIN USER "admin" ***
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin
# using the default password 'raspiblitz'
# TODO: set password automatically
sudo adduser admin
sudo adduser admin sudo
sudo chsh admin -s /bin/bash
sudo passwd root
# TODO
# $ sudo visudo
# %sudo ALL=(ALL:ALL) ALL
# %sudo ALL=(ALL) NOPASSWD:ALL
# *** ADDING SERVICE USER “bitcoin”
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
sudo adduser bitcoin
# *** SWAP FILE ***
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#moving-the-swap-file
# but just deactivating and deleting old (will be created alter when user adds HDD)
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
# --> CONTINUE: https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#hardening-your-pi
# *** TODOS / DECIDE / GIVE MANUAL INTRUCTIONS ******
# ???
# sudo raspi-config nonint do_ssh %d
# Wait for network at boot?
# sudo raspi-config nonint get_boot_wait
# sudo raspi-config nonint do_boot_wait %d
# automaticall detect and set time zone?
# maybe do on in setup scripts

21
shoppinglist_cn.md Normal file
View File

@ -0,0 +1,21 @@
## Hardware Needed (Taobao.com/T-Mall Shopping List)
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on taobao.com:*
Set (¥378.00 CNY)
* RaspBerry Pi 3 B+
* Micro SD-Card 16GB
* Power Unit 2.5A
* several items (e.g. cooling fins)
https://item.taobao.com/item.htm?spm=a1z09.2.0.0.46982e8dibAzMc&id=550270480898&_u=b110k44d3302
Single HDD (Bulk)
* 1TB Hard Drive (¥379.00 CNY)
https://detail.tmall.com/item.htm?id=38476523976&spm=a1z09.2.0.0.46982e8dibAzMc&_u=b110k44d53f4&sku_properties=5919063:6536025
Set (¥119.00 CNY)
* LCD-Display
* Case (acrylic)
https://item.taobao.com/item.htm?spm=a1z09.2.0.0.46982e8dibAzMc&id=576167736126&_u=b110k44df816
**Total Price: ¥876.00 CNY** approx. 111 EUR or 128 USD

View File

@ -1,3 +1,8 @@
Your are from the UK? Your help is needed!
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.co.uk:*
It would be great if you can create a shopping list for amazon UK for the RaspiBlitz and test if everything is running with the hardware setup. Thx.
* RaspBerry Pi 3 https://www.amazon.co.uk/Raspberry-Pi-Model-64-Bit-Processor/dp/B07BDR5PDW
* Micro SD-Card 16GB https://www.amazon.co.uk/Kingston-SDC10G2-16GB-microSDHC-Included/dp/B0162YQEIE
* Power https://www.amazon.co.uk/iTrunk-Raspberry-Model-Supply-Charger/dp/B01MFFSPHE
* 1TB Hard Drive https://www.amazon.co.uk/Toshiba-Canvio-Basics-Portable-External/dp/B00KWHJY7Q
* Case https://www.amazon.co.uk/SB-Components-Transparent-Case-Raspberry/dp/B0173GQF8Y
* LCD-Display https://www.amazon.co.uk/ELEGOO-480x320-Raspberry-Monitor-Interface/dp/B01MRQTMTD

View File

@ -2,11 +2,11 @@
*The RaspiBlitz software is build and tested for the following Hardware set that you can buy cheap on Amazon.com:*
* RaspBerry Pi 3 ($41.00 USD) http://a.co/ahl7RIp
* Micro SD-Card 16GB ($6.75 USD) http://a.co/6R49HZz
* Power ($7.99 USD) https://www.amazon.com/Yuconn-Switch-Charger-Adapter-Raspberry/dp/B071YC2T9S
* RaspBerry Pi 3 ($39.70 USD) http://a.co/ahl7RIp
* Micro SD-Card 16GB ($5.99 USD) http://a.co/d/710f4oJ
* Power ($8.88 USD) http://a.co/d/fVVOYZZ
* 1TB Hard Drive ($49.99 USD) http://a.co/eUgVfLd
* Case ($7.99 USD) http://a.co/1774Hwl
* LCD-Display ($19.99 USD) http://a.co/65p2wu6
**Total Price: $145.95 USD**
**Total Price: $132.54 USD**