merge from dev - prepare for 1.0

This commit is contained in:
rootzoll
2018-12-21 03:13:11 +01:00
36 changed files with 1113 additions and 700 deletions

View File

@@ -259,6 +259,14 @@ 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/) :)
#### Public Domain with DynamicDNS
This is a way to make your RaspiBlitz publicly reachable from the internet so that other nodes can open channels with you and you can connect with the
To do so you can register at an DynamicDomain service like freedns.afraid.org, forward the TCP ports 8333 (Bitcoin/mainnet),9735 (LND Node) & 10009 (LND RPC) from your internet router to the local IP of your RaspiBlitz and then activate unter "Services" the "DynamicDNS" option.
You will be asked for your dynamic domain name such like "mynode.crabdance.org" and you can also optionally set an URL that will be called regularly to update your routers IP with the dynnamic domain service. At freedns.afraid.org this URL is called "Direct URL" under the menu "Dynamic DNS" once you added one.
## Get a Debug Report
If your RaspiBlitz is not working right and you like to get help from the community, its good to provide more debug information, so other can better diagnose your problem - please follow the following steps to generate a debug report:
@@ -292,6 +300,10 @@ The whole build process takes a while. At the end the LCD drivers get installed
*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.*
And if you are a developer - to build a sd card from the dev-branch use this command to execute:
`wget https://raw.githubusercontent.com/rootzoll/raspiblitz/dev/build.sdcard/raspbianStretchDesktop.sh && sudo bash raspbianStretchDesktop.sh 'dev'`
## 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?

View File

@@ -9,11 +9,21 @@
##########################################################################
echo ""
echo "****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v0.97 *"
echo "****************************************"
echo "*****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v0.97d *"
echo "*****************************************"
echo ""
# 1st optional parameter is the branch to get code from when
# provisioning sd card with raspiblitz assets/scripts later on
echo "*** CHECK INPUT PARAMETERS ***"
wantedBranch="$1"
if [ ${#wantedBranch} -eq 0 ]; then
wantedBranch="master"
fi
echo "will use code from branch --> '${wantedBranch}'"
sleep 3
echo ""
echo "*** CHECK BASE IMAGE ***"
@@ -322,6 +332,24 @@ if [ ${#installed} -eq 0 ]; then
exit 1
fi
# Go is needed for ZAP connect later
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 from Source
## To quickly catch up get latest patches if needed
#repo="github.com/lightningnetwork/lnd"
@@ -391,7 +419,7 @@ sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
# move files from gitclone
cd /home/admin/
sudo -u admin git clone https://github.com/rootzoll/raspiblitz.git
sudo -u admin git clone -b ${wantedBranch} 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/
@@ -434,6 +462,28 @@ sudo chmod +x /home/admin/_bootstrap.sh
sudo cp ./assets/bootstrap.service /etc/systemd/system/bootstrap.service
sudo systemctl enable bootstrap
# *** BOOTSTRAP ***
# see background README for details
echo ""
echo "*** RASPI BACKGROUND SERVICE ***"
sudo chmod +x /home/admin/_background.sh
sudo cp ./assets/background.service /etc/systemd/system/background.service
sudo systemctl enable background
# Prepare for TOR service
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 ""
echo "*** Fetching GPG key ***"
sudo gpg --keyserver keys.gnupg.net --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89
sudo gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
echo "!!!!!! Please check if the above really worked!"
# *** RASPIBLITZ IMAGE READY ***
echo ""
echo "**********************************************"

View File

@@ -127,7 +127,7 @@ 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://v4.ipv6-test.com/api/myip.php)
public_ip="${publicIP}"
public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')"
if [ "${public_port}" = "null" ]; then
if [ "${chain}" = "test" ]; then
@@ -156,17 +156,20 @@ networkConnections=$(echo ${networkInfo} | jq -r '.connections')
networkConnectionsInfo="${color_purple}${networkConnections} ${color_gray}connections"
if [ "${onionAddress}" != "null" ]; then
# TOR address
networkConnectionsInfo="${color_purple}${networkConnections} ${color_gray}peers"
public_addr="${onionAddress}:${public_port}"
public=""
public_color="${color_green}"
torInfo="+ TOR"
else
# IP address
networkConnectionsInfo="${color_purple}${networkConnections} ${color_gray}connections"
public_addr="${public_ip}:${public_port}"
public_check=$(timeout 2s nc -z ${public_ip} ${public_port} 2>/dev/null; echo $?)
public_check=$(nc -z -w6 ${public_ip} ${public_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ]; then
public=""
public_color="${color_green}"
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
public_color="${color_yellow}"
else
public=""
public_color="${color_red}"
@@ -179,6 +182,7 @@ ln_baseInfo="-"
ln_channelInfo="\n"
ln_external="\n"
ln_alias="${hostname}"
ln_publicColor=""
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
@@ -187,6 +191,18 @@ if [ "$wallet_unlocked" -gt 0 ] ; then
else
ln_getInfo=$(sudo -u bitcoin /usr/local/bin/lncli --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null)
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4)
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
if [ ${ln_tor} -eq 1 ]; then
ln_publicColor="${color_green}"
else
public_check=$(nc -z -w6 ${public_ip} 9735 2>/dev/null; echo $?)
if [ $public_check = "0" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
ln_publicColor="${color_yellow}"
else
ln_publicColor="${color_red}"
fi
fi
alias_color="${color_grey}"
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1)
@@ -229,12 +245,13 @@ ${color_yellow} ,' / ${color_gray}Free Mem ${color_ram}${ram} ${color_g
${color_yellow} ,' /_____, ${color_gray}ssh admin@${color_green}${local_ip}${color_gray}${network_rx}${network_tx}
${color_yellow} .'____ ,' ${color_gray}${webinterfaceInfo}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${chain}net ${color_gray}Sync ${sync_color}${sync} (%s)
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public} ${networkConnectionsInfo}
${color_yellow} / ,' ${color_gray}Public ${public_color}${public_addr} ${public}${networkConnectionsInfo}
${color_yellow} /,' ${color_gray}
${color_yellow} /' ${color_gray}LND ${color_green}${ln_version} ${ln_baseInfo}
${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo}
${color_yellow}
${color_yellow}${ln_external}
${color_yellow}${ln_publicColor}${ln_external}
" \
"RaspiBlitz v${codeVersion}" \
"-------------------------------------------" \

View File

@@ -4,223 +4,198 @@
# this script gets started by the autologin of the pi user and
# and its output is gets displayed on the LCD or the RaspiBlitz
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# check that user is pi
if [ "$USER" != "pi" ]; then
echo "plz run as user pi --> su pi"
exit 1
fi
# check if RTL web interface is installed
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
# display a 10s startup time
source /home/admin/_version.info
dialog --pause " Starting RaspiBlitz v${codeVersion} ..." 8 58 12
# DISPLAY LOOP
chain=""
freshstart=1
while :
do
###########################
# CHECK BASIC DATA
###########################
# 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'/')
# waiting for IP in general
if [ ${#localip} -eq 0 ]; then
# waiting for IP in general
l1="Waiting for Network ...\n"
l2="Not able to get local IP.\n"
l3="Is LAN cable connected?\n"
dialog --backtitle "RaspiBlitz" --infobox "$l1$l2$l3" 5 30
dialog --backtitle "RaspiBlitz ${codeVersion}" --infobox "$l1$l2$l3" 5 30
sleep 3
continue
fi
elif [ "${localip:0:4}" = "169." ]; then
# waiting for DHCP in general
# waiting for DHCP in general
if [ "${localip:0:4}" = "169." ]; then
l1="Waiting for DHCP ...\n"
l2="Not able to get local IP.\n"
l3="Is Router working?\n"
dialog --backtitle "RaspiBlitz (${localip})" --infobox "$l1$l2$l3" 5 30
l3="Will try reboot every 5min.\n"
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip})" --infobox "$l1$l2$l3" 5 30
sleep 3
else
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# check hostname and get backup if from old config
if [ ${#hostname} -eq 0 ]; then
# keep for old nodes
hostname=`sudo cat /home/admin/.hostname` 2>/dev/null
if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz"
fi
fi
# for old nodes
if [ ${#network} -eq 0 ]; then
network="bitcoin"
litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf')
if [ ${litecoinActive} -eq 1 ]; then
network="litecoin"
else
network=`sudo cat /home/admin/.network 2>/dev/null`
fi
if [ ${#network} -eq 0 ]; then
network="bitcoin"
fi
fi
# for old nodes
if [ ${#chain} -eq 0 ]; then
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
fi
# get the actual step number of setup process
source /home/admin/raspiblitz.info
if [ ${#setupStep} -eq 0 ]; then
setupStep=0
fi
# before initial setup
if [ ${setupStep} -eq 0 ]; then
state="0"
message="Welcome"
# check data from _bootstrap.sh that was running on device setup
bootstrapInfoExists=$(ls /home/admin/raspiblitz.info | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 1 ]; then
# load the data from the info file - overwrite state & message
source /home/admin/raspiblitz.info
if [ "${state}" = "presync" ]; then
# get blockchain sync progress
blockchaininfo="$(bitcoin-cli -datadir=/mnt/hdd/bitcoin getblockchaininfo 2>/dev/null)"
if [ ${#blockchaininfo} -gt 0 ]; then
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
fi
fi
fi
# 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 (${state}) - ${message}" --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
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)
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"
if [ ${runningRTL} -eq 1 ]; then
l2="Open: http://${localip}:3000\n"
l3="Use Password C to unlock\n"
fi
boxwidth=$((${#localip} + 24))
dialog --backtitle "RaspiBlitz ${localip} - Action Required" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
elif [ ${lndSynced} -eq 0 ]; then
# special case: LND is syncing
/home/admin/80scanLND.sh
sleep 20
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} + 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 device 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
# 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"
if [ ${runningRTL} -eq 1 ]; then
l2="Open: http://${localip}:3000\n"
l3="Use Password C to unlock\n"
fi
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
fi
continue
fi
## get basic info from SD
bootstrapInfoExists=$(ls ${infoFile} 2>/dev/null | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 1 ]; then
source ${infoFile}
fi
# get final config if already avaulable
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
source ${configFile}
setupStep=100
fi
# if no information available from files - set default
if [ ${#setupStep} -eq 0 ]; then
setupStep=0
fi
# before setup even started
if [ ${setupStep} -eq 0 ]; then
# when in presync - get more info on progress
if [ "${state}" = "presync" ]; then
# get blockchain sync progress
blockchaininfo="$(sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf getblockchaininfo 2>/dev/null)"
message="starting"
if [ ${#blockchaininfo} -gt 0 ]; then
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
message=$(echo "${message}*100" | bc)
message="${message}%"
fi
fi
# when old data - improve message
if [ "${state}" = "olddata" ]; then
message="login for manual migration"
fi
# when no HDD - improve message
if [ "${state}" = "nohdd" ]; then
message="Connect HHD"
fi
# 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 ${codeVersion} (${state}) - ${message}" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
continue
fi
# when setup is in progress - password has been changed
if [ ${setupStep} -lt 100 ]; then
l1="Login to your RaspiBlitz with:\n"
l2="ssh admin@${localip}\n"
l3="Use your Password A\n"
boxwidth=$((${#localip} + 24))
sleep 3
dialog --backtitle "RaspiBlitz ${codeVersion} ${localip} - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 7
continue
fi
###########################
# DISPLAY AFTER SETUP
###########################
# check if recovering/upgrade is running
if [ "${state}" = "recovering" ]; then
if [ ${#message} -eq 0 ]; then
message="Setup in Progress"
fi
l1="Upgrade/Recover/Provision\n"
l2="---> ${message}\n"
l3="Please keep running until reboot."
boxwidth=$((${#localip} + 28))
dialog --backtitle "RaspiBlitz ${codeVersion} (${state})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 3
continue
fi
# if freshly recovered
if [ "${state}" = "recovered" ]; then
l1="FINAL RECOVER LOGIN NEEDED:\n"
l2="ssh admin@${localip}\n"
l3="Use password: raspiblitz\n"
boxwidth=$((${#localip} + 28))
dialog --backtitle "RaspiBlitz ${codeVersion} (${state})" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 3
continue
fi
# 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 device was off."
isVerifying=$(echo "${clienterror}" | grep -c 'Verifying blocks')
if [ ${isVerifying} -gt 0 ]; then
l2="---> Verifying Blocks\n"
fi
boxwidth=40
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - Welcome Back" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
continue
fi
# check if locked
locked=$(sudo -u bitcoin lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ "${locked}" -gt 0 ]; then
# special case: LND wallet is locked ---> show unlock info
l1="!!! LND WALLET IS LOCKED !!!\n"
l2="Login: ssh admin@${localip}\n"
l3="Use your Password A\n"
if [ "${rtlWebinterface}" = "on" ]; then
l2="Open: http://${localip}:3000\n"
l3="Use Password C to unlock\n"
fi
boxwidth=$((${#localip} + 24))
dialog --backtitle "RaspiBlitz ${codeVersion} (${localip}) - ${hostname}" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
continue
fi
# if LND is syncing or scanning
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSynced} -eq 0 ]; then
/home/admin/80scanLND.sh
sleep 20
continue
fi
# no special case - show status display
/home/admin/00infoBlitz.sh
sleep 5
done
fi

View File

@@ -1,49 +1,80 @@
#!/bin/bash
echo "Starting the main menu - please wait ..."
echo "Starting the main menu ..."
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# check if HDD is connected
hddExists=$(lsblk | grep -c sda1)
if [ ${hddExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart."
echo "***********************************************************"
exit
fi
# check data from _bootstrap.sh that was running on device setup
infoFile='/home/admin/raspiblitz.info'
bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 1 ]; then
if [ ${bootstrapInfoExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
echo "***********************************************************"
exit
fi
# load the data from the info file
source ${infoFile}
# load the data from the info file (will get produced on every startup)
source ${infoFile}
# if pre-sync is running - stop it
if [ "${state}" = "presync" ]; then
if [ "${state}" = "recovering" ]; then
echo "***********************************************************"
echo "WARNING: bootstrap still updating - close SSH, login later"
echo "To monitor progress --> tail -n1000 -f raspiblitz.log"
echo "***********************************************************"
exit
fi
# stopping the pre-sync
echo "********************************************"
echo "Stopping pre-sync ... pls wait (up to 1min)"
echo "********************************************"
sudo systemctl stop bitcoind.service
sudo systemctl disable bitcoind.service
sudo rm /mnt/hdd/bitcoin/bitcoin.conf
sudo rm /etc/systemd/system/bitcoind.service
sudo unlink /home/bitcoin/.bitcoin
# signal that after bootstrap recover user dialog is needed
if [ "${state}" = "recovered" ]; then
echo "System recovered - needs final user settings"
./20recoverDialog.sh
exit 1
fi
# unmount the temporary mount
sudo umount -l /mnt/hdd
# if pre-sync is running - stop it - before continue
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
echo "********************************************"
echo "Stopping pre-sync ... pls wait (up to 1min)"
echo "********************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop
echo "bitcoind called to stop .."
sleep 50
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "setup is done - loading config data"
source ${configFile}
setupStep=100
else
echo "setup still in progress - setupStep(${setupStep})"
fi
# signal if bootstrap recover is not ready yet
if [ "${state}" = "recovering" ]; then
echo "WARNING: bootstrap is still updating - please close SSH and login later again"
exit 1
fi
# signal that after bootstrap recover user dialog is needed
if [ "${state}" = "recovered" ]; then
echo "System recovered - needs final user settings"
./20recoverDialog.sh
exit 1
fi
fi
## default menu settings
@@ -55,44 +86,6 @@ TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
## get basic info (its OK if not set yet)
source /mnt/hdd/raspiblitz.conf
# check hostname and get backup if from old config
if [ ${#hostname} -eq 0 ]; then
echo "backup info for old nodes: hostname"
hostname=`sudo cat /home/admin/.hostname` 2>/dev/null
if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz"
fi
fi
# check network and get backup if from old config
if [ ${#network} -eq 0 ]; then
echo "backup info for old nodes: network"
network="bitcoin"
litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf')
if [ ${litecoinActive} -eq 1 ]; then
network="litecoin"
else
# keep for old nodes
network=`sudo cat /home/admin/.network 2>/dev/null`
fi
if [ ${#network} -eq 0 ]; then
network="bitcoin"
fi
fi
# for old nodes
if [ ${#chain} -eq 0 ]; then
echo "backup info for old nodes: 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
fi
# check if RTL web interface is installed
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
@@ -102,6 +95,8 @@ localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1
# function to use later
waitUntilChainNetworkIsReady()
{
echo "checking ${network}d - please wait .."
echo "can take longer if device was off or first time"
while :
do
sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 1>/dev/null 2>error.tmp
@@ -117,43 +112,53 @@ waitUntilChainNetworkIsReady()
fi
boxwidth=40
dialog --backtitle "RaspiBlitz ${localip} - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
sleep 5
else
return
locked=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>&1 | grep -c unlock)
if [ ${locked} -gt 0 ]; then
./AAunlockLND.sh
echo "please wait ... update to next screen can be slow"
fi
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSynced} -eq 0 ]; then
./80scanLND.sh
else
# everything is ready - return from loop
return
fi
fi
sleep 5
done
}
## get actual setup info
source ${infoFile}
if [ ${#setupStep} -eq 0 ]; then
echo "WARN: no setup step found in raspiblitz.info"
setupStep=0
fi
if [ ${setupStep} -eq 0 ]; then
# check data from boostrap
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
if [ "${state}" = "olddata" ]; then
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD COINTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds" \
DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11
else
# check data from boostrap
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
if [ "${state}" = "olddata" ]; then
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD COINTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds" \
DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11
fi
else
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
fi
elif [ ${setupStep} -lt 100 ]; then
@@ -176,7 +181,14 @@ else
# MAIN MENU AFTER SETUP
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}"
plus=""
if [ "${runBehindTor}" = "on" ]; then
plus=" / TOR"
fi
if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
fi
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -gt 0 ]; then
@@ -199,11 +211,6 @@ else
TITLE="Webinterface: http://${localip}:3000"
fi
switchOption="to MAINNET"
if [ "${chain}" = "main" ]; then
switchOption="back to TESTNET"
fi
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your on-chain Wallet" \
@@ -222,7 +229,7 @@ else
fi
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | jq '.[] | length')
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
@@ -360,9 +367,18 @@ case $CHOICE in
./00mainMenu.sh
;;
OFF)
echo "After Shutdown remove power from RaspiBlitz."
echo "Press ENTER to start shutdown - then wait some seconds."
read key
echo ""
echo "LCD turns white when shutdown complete."
echo "Then wait 5 seconds and disconnect power."
echo "-----------------------------------------------"
echo "stop lnd - please wait .."
sudo systemctl stop lnd
echo "stop bitcoind (1) - please wait .."
sudo -u bitcoin bitcoin-cli stop
sleep 10
echo "stop bitcoind (2) - please wait .."
sudo systemctl stop ${network}d
echo "starting shutdown"
sudo shutdown now
exit 0
;;

View File

@@ -12,13 +12,22 @@ if [ ${#chain} -eq 0 ]; then chain="main"; fi
chainValue="off"
if [ "${chain}" = "test" ]; then chainValue="on"; fi
# map domain to on/off
domainValue="off"
dynDomainMenu='DynamicDNS'
if [ ${#dynDomain} -gt 0 ]; then
domainValue="on"
dynDomainMenu="${dynDomain}"
fi
# show select dialog
CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 6 \
1 "Channel Autopilot" ${autoPilot} \
2 "Testnet" ${chainValue} \
3 "Router AutoNAT" ${autoNatDiscovery} \
4 "Run behind TOR" ${runBehindTor} \
5 "RTL Webinterface" ${rtlWebinterface} \
CHOICES=$(dialog --checklist 'Activate/Deactivate Services:' 15 45 7 \
1 'Channel Autopilot' ${autoPilot} \
2 'Testnet' ${chainValue} \
3 'Router AutoNAT' ${autoNatDiscovery} \
4 ${dynDomainMenu} ${domainValue} \
5 'Run behind TOR' ${runBehindTor} \
6 'RTL Webinterface' ${rtlWebinterface} \
2>&1 >/dev/tty)
dialogcancel=$?
clear
@@ -66,7 +75,7 @@ if [ "${chain}" != "${choice}" ]; then
echo "B) Answere 'n' because you dont have a 'cipher seed mnemonic' (24 words) yet"
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************"
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create 2>error.out
sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net create 2>error.out
error=`sudo cat error.out`
if [ ${#error} -eq 0 ]; then
sleep 2
@@ -125,9 +134,20 @@ else
echo "AutoNAT Setting unchanged."
fi
# TOR process choice
# Dynamic Domain
choice="off"; check=$(echo "${CHOICES}" | grep -c "4")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${domainValue}" != "${choice}" ]; then
echo "Dynamic Domain changed .."
sudo /home/admin/config.scripts/internet.dyndomain.sh ${choice}
needsReboot=1
else
echo "Dynamic Domain unchanged."
fi
# TOR process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "5")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${runBehindTor}" != "${choice}" ]; then
echo "TOR Setting changed .."
sudo /home/admin/config.scripts/internet.tor.sh ${choice}
@@ -137,7 +157,7 @@ else
fi
# RTL process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "5")
choice="off"; check=$(echo "${CHOICES}" | grep -c "6")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${rtlWebinterface}" != "${choice}" ]; then
echo "RTL Webinterface Setting changed .."
@@ -147,7 +167,7 @@ if [ "${rtlWebinterface}" != "${choice}" ]; then
l2="Try to open the following URL in your local webrowser"
l3="and unlock your wallet from there with PASSWORD C."
l4="---> http://${localip}:3000"
dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 9 25
dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 9 45
fi
needsReboot=1
else

View File

@@ -31,8 +31,8 @@ fi
if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})"
sleep 3
./90finishSetup.sh
./95finalSetup.sh
sudo ./90finishSetup.sh
sudo ./95finalSetup.sh
exit 0
fi
@@ -63,7 +63,10 @@ if [ ${lndRunning} -eq 1 ]; then
chainInfo=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep 'initialblockdownload')
chainSyncing=1
if [ ${#chainInfo} -gt 0 ];then
echo "check chaininfo"
chainSyncing=$(echo "${chainInfo}" | grep "true" -c)
else
echo "chaininfo is zero"
fi
if [ ${chainSyncing} -eq 1 ]; then
echo "Sync Chain ..."
@@ -88,8 +91,8 @@ if [ ${lndRunning} -eq 1 ]; then
# if unlocked, blockchain synced and LND synced to chain .. finisch Setup
echo "FINSIH ... "
sleep 3
./90finishSetup.sh
./95finalSetup.sh
sudo ./90finishSetup.sh
sudo ./95finalSetup.sh
exit 0
fi #end - when lighting is running
@@ -98,13 +101,19 @@ fi #end - when lighting is running
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
if [ ${bitcoinRunning} -eq 0 ]; then
# double check
echo "${network} is not running - double checking - wait 120secs"
sleep 120
bitcoinRunning=$(${network}-cli getblockchaininfo | grep "initialblockdownload" -c)
else
echo "${network} is running"
fi
if [ ${bitcoinRunning} -eq 1 ]; then
echo "OK - ${network}d is running"
echo "Next step run Lightning"
./70initLND.sh
exit 1
else
echo "${network} still not running"
fi #end - when bitcoin is running
# check if HDD is auto-mounted

View File

@@ -2,25 +2,24 @@
_temp="./download/dialog.$$"
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf
passwordValid=0
result=""
while [ ${passwordValid} -eq 0 ]
do
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords.
Referenced as password A, B, C and D.
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
You need to set a new Password A:
A) Master User Password
B) Blockchain RPC Password
C) LND Wallet Password
D) LND Seed Password
Choose now 4 new passwords - all min 8 chars,
Passwords B, C & D stay as before.
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 15 52
" 14 52
# ask user for new password A
dialog --backtitle "RaspiBlitz - Setup"\
@@ -47,38 +46,27 @@ Write them down & store them in a safe place.
echo "admin:$result" | sudo chpasswd
sleep 1
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password changed to '$result'\nfor all users pi, admin, root & bitcoin" 6 52
# repeat until user input is nit length 0
result=""
dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Enter your RPC Password B:" 9 52 2>$_temp
result=$( cat $_temp )
shred $_temp
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then
clear
echo "FAIL - Password contained not allowed chars (see next screen)"
echo "Press ENTER to continue to start again"
read key
passwordValid=0
else
# set Blockchain RPC Password (for admin cli & template for user bitcoin)
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
clear
# activate lnd & bitcoin service
echo "Enabling Services"
sudo systemctl daemon-reload
sudo systemctl enable lnd.service
sudo systemctl enable ${network}d.service
if [ "${rtlWebinterface}" = "on" ]; then
sudo systemctl enable RTL
fi
# remove flag that freshly recovered
sudo rm /home/admin/raspiblitz.recover.info
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "New SSH password A is '$result'\nFINAL REBOOT IS NEEDED." 6 52
sudo shutdown -r now
fi
done

View File

@@ -10,7 +10,7 @@ while [ ${#result} -eq 0 ]
do
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup" --inputbox "$l1$l2" 11 52 2>$_temp
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2" 11 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred $_temp
done
@@ -22,11 +22,11 @@ sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
# work around - because without a reboot the hostname seems not updates in the whole system
valueExistsInInfoFile=$(sudo cat /home/admin/raspiblitz.info | grep -c "hostname=")
if [ ${valueExistsInInfoFile} -eq 0 ]; then
# update
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
else
# add
echo "hostname=${result}" >> /home/admin/raspiblitz.info
else
# update
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
fi
@@ -35,7 +35,7 @@ result=""
while [ ${passwordValid} -eq 0 ]
do
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords.
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "RaspiBlitz uses 4 different passwords.
Referenced as password A, B, C and D.
A) Master User Password
@@ -49,7 +49,7 @@ Write them down & store them in a safe place.
" 15 52
# ask user for new password A
dialog --backtitle "RaspiBlitz - Setup"\
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})"\
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# get user input
@@ -78,7 +78,7 @@ Write them down & store them in a safe place.
# repeat until user input is nit length 0
result=""
dialog --backtitle "RaspiBlitz - Setup"\
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})"\
--inputbox "Enter your RPC Password B:" 9 52 2>$_temp
result=$( cat $_temp )
shred $_temp
@@ -97,7 +97,7 @@ Write them down & store them in a safe place.
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
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52
clear
fi

View File

@@ -10,9 +10,9 @@ bitcoinSize=253000000 # 253827180-tolerance
# *** LITECOIN ***
litecoinList="" # url to list with other sources
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-11-30"
litecoinSize=35000000 # 35021940-tolerance
litecoinSize=22220000 # 22221160-tolerance
# NOTE TO GET THE SIZE RIGHT: for new download add 9999999999 as size. Runf download.
# NOTE TO GET THE SIZE RIGHT: for new download add 9999999999 as size. Run download.
# When finished the warning comes up and behind WARNING: copy that number
## get basic info

View File

@@ -44,10 +44,8 @@ if [ ${mountOK} -eq 1 ]; then
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 ..."
sleep 180
echo "OK - ${network}d started"
sleep 2
echo "Started ... wait 10 secs"
sleep 10
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info

View File

@@ -22,25 +22,32 @@ echo ""
# verify that chainnetwork is ready
chainIsReady=0
loopCount=0
echo "*** Wait until ${network}d is ready ..."
while [ ${chainIsReady} -eq 0 ]
do
echo "*** Test if chainnetwork is ready ..."
date +%s
loopCount=$(($loopCount +1))
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/"
if [ ${loopCount} -gt 33 ]; then
echo "*** TAKES LONGER THEN EXCEPTED ***"
date +%s
echo "result(${result})"
echo "error(${error})"
testnetAdd=""
if [ "${chain}" = "test" ]; then
testnetAdd="testnet3/"
fi
sudo tail -n 5 /mnt/hdd/${network}/${testnetAdd}debug.log
echo "If you see an error -28 relax, just give it some time."
echo "Waiting 1 minute and then trying again ..."
sleep 60
else
echo "(${loopCount}/33) still waiting .."
sleep 10
fi
sudo tail -n 5 /mnt/hdd/${network}/${testnetAdd}debug.log
echo "If you see an error -28 relax, just give it some time."
echo "Waiting 1 minute and then trying again ..."
sleep 60
echo ""
else
echo "OK - chainnetwork is working"
echo ""
@@ -156,12 +163,12 @@ sleep 60
###### Copy LND macaroons to admin
echo ""
echo "*** Copy LND Macaroons to user admin ***"
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon | grep -c admin.macaroon)
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
./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)
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then
sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon
echo ""
@@ -199,43 +206,43 @@ else
echo "OK - Wallet is already unlocked"
fi
### Show Lighthning Sync
echo ""
echo "*** Check LND Sync ***"
item=0
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 :
do
# show sync status
./80scanLND.sh
sleep 15
# break loop when synced
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
# break loop when wallet is locked
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 1 ]; then
break
fi
sleep 15
done
clear
else
echo "OK - LND is in sync"
fi
#### Show Lighthning Sync
#echo ""
#echo "*** Check LND Sync ***"
#item=0
#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 :
# do
#
# # show sync status
# ./80scanLND.sh
# sleep 15
#
# # break loop when synced
# 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
#
# # break loop when wallet is locked
# locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
# if [ ${locked} -eq 1 ]; then
# break
# fi
#
# sleep 15
#
# done
# clear
#else
# echo "OK - LND is in sync"
#fi
# set SetupState (scan is done - so its 80%)
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
###### finishSetup
./90finishSetup.sh
./95finalSetup.sh
sudo ./90finishSetup.sh
sudo ./95finalSetup.sh

View File

@@ -1,5 +1,4 @@
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf 2>/dev/null
source /mnt/hdd/raspiblitz.conf
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
@@ -13,13 +12,21 @@ chain="$(echo "${blockchaininfo}" | jq -r '.chain')"
# 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')
action="Rescanning"
# 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')
action="Catching-Up"
fi
# TODO next fallback try later here if necessary
# 3) Third try the "LNWL: Filtering block" - thats the usual on later starts
if [ ${#item} -eq 0 ]; then
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "LNWL: Filtering block" | tail -n1 | cut -d ' ' -f7 | tr -dc '0-9')
action="Filtering"
fi
# if no progress info
if [ ${#item} -eq 0 ]; then
item="?"
fi
@@ -31,6 +38,7 @@ scanstate="${item}/${total}"
# get blockchain sync progress
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
progress=$(echo "${progress}*100" | bc)
# check if blockchain is still syncing
heigh=6
@@ -42,22 +50,22 @@ if [ ${isWaitingBlockchain} -gt 0 ]; then
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"
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.")
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")
infoStr=$(echo " Lightning ${action} 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.")
infoStr=$(echo " Lightning ${action} Blockchain\n Progress: ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi
fi
# display progress to user
sleep 3
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${name})" --infobox "${infoStr}" ${heigh} ${width}
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${hostname})" --infobox "${infoStr}" ${heigh} ${width}

View File

@@ -2,9 +2,10 @@
echo ""
# add bonus scripts
./91addBonus.sh
/home/admin/91addBonus.sh
###### SWAP & FS
echo ""
echo "*** SWAP file ***"
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
if [ ${swapExists} -eq 1 ]; then
@@ -72,6 +73,12 @@ echo "enable lazy firewall"
sudo ufw --force enable
echo ""
# set raspi config as environment for lnd service
sudo systemctl stop lnd
sudo systemctl disable lnd
sudo sed -i "s/^EnvironmentFile=.*/EnvironmentFile=\/mnt\/hdd\/raspiblitz.conf/g" /etc/systemd/system/lnd.service
sudo systemctl enable lnd
# update system
echo ""
echo "*** Update System ***"

View File

@@ -1,6 +1,9 @@
#!/bin/bash
echo ""
# set raspiblitz config file
configFile="/mnt/hdd/raspiblitz.conf"
# load setup config
source /home/admin/raspiblitz.info
@@ -9,14 +12,14 @@ source /home/admin/_version.info
# show info to user
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
Press OK for a final reboot.
After reboot RaspiBlitz
needs to be unlocked and
sync with the network.
Remember: After every reboot
you need to unlock the LND wallet.
Press OK for a final reboot.
" 10 42
# init the RASPIBLITZ Config
configFile="/mnt/hdd/raspiblitz.conf"
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${codeVersion}'" >> $configFile
sudo chmod 777 ${configFile}
@@ -27,7 +30,10 @@ echo "network=${network}" >> $configFile
echo "chain=${chain}" >> $configFile
# let migration/init script do the rest
./_bootstrap.migration.sh
/home/admin/_bootstrap.migration.sh
# copy logfile to analyse setup
cp $logFile /home/admin/raspiblitz.setup.log
# set the hostname inputed on initDialog
if [ ${#hostname} -gt 0 ]; then
@@ -42,4 +48,6 @@ sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
clear
echo "Setup done. Rebooting now."
sudo shutdown -r now
sleep 3
sudo shutdown -r now

View File

@@ -1,5 +1,27 @@
#!/bin/bash
# get raspiblitz config
source /mnt/hdd/raspiblitz.conf
# check if dynamic domain is set
if [ ${#dynDomain} -eq 0 ]; then
dialog --title " Just Local Network? " --yesno "If you want to connect with your RaspiBlitz
also from outside your local network you need to
activate 'Services' -> 'DynamicDNS' FIRST.
For more details see chapter in GitHub README
'Public Domain with DynamicDNS'
https://github.com/rootzoll/raspiblitz
Do you JUST want to connect with your mobile
when your are on the same LOCAL NETWORK?
" 14 54
response=$?
case $response in
1) exit ;;
esac
fi
# Basic Options
OPTIONS=(ZAP "Zap Wallet (iOS)" \
SHANGO "Shango Wallet (iOS/Android)")

View File

@@ -1,11 +1,7 @@
#!/bin/bash
# load raspiblitz config data (with backup from old config)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi
source /mnt/hdd/raspiblitz.conf
# make sure qrcode-encoder in installed
clear
@@ -15,6 +11,11 @@ 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')
# replace dyndomain if available
if [ ${#dynDomain} -gt 0 ]; then
myip="${dynDomain}"
fi
clear
echo "******************************"
echo "Connect Shango Mobile Wallet"
@@ -26,11 +27,14 @@ 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'"
if [ ${#dynDomain} -eq 0 ]; then
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
fi
echo "On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED'"
echo "(Or in the App go to --> 'Settings' > 'Connect to your LND Server')"
echo "There you see three 3 form fields to fill out. Skip those and go right to the buttons below."
echo ""
echo "Click on the 'Scan OR' button"
echo "Click on the 'Scan QR' button"
echo "Make the this terminal as big as possible - fullscreen would be best."
echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app."
read key

View File

@@ -1,25 +1,26 @@
#!/bin/bash
# load raspiblitz config data (with backup from old config)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
if [ ${#chain} -eq 0 ]; then
chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
fi
# load raspiblitz config data
source /mnt/hdd/raspiblitz.conf
# make sure qrcode-encoder in installed
clear
echo "*** Setup ***"
echo ""
echo "Installing zapconnect. Please wait..."
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/usr/local/gocode
export PATH=$PATH:$GOPATH/bin
echo ""
echo "Getting github.com/LN-Zap/zapconnect ..."
echo "Getting github.com/LN-Zap/zapconnect (please wait) ..."
cd $GOPATH/src/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
make
cd
sleep 3
clear
echo "******************************"
@@ -32,9 +33,12 @@ echo "Go to http://www.zap-ios.jackmallers.com sign up with your email (confirma
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)."
if [ ${#dynDomain} -eq 0 ]; then
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)."
fi
echo "During Setup of the Zap app you should get to the 'Connect Remote-Node' screen."
echo ""
echo "Click on Connect remote node"
echo "---> Click on Scan"
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
@@ -42,8 +46,13 @@ 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
if [ ${#dynDomain} -eq 0 ]; then
# If you drop the -i parameter, zapconnect will use the external IP.
zapconnect -i
else
# when dynamic domain is set
zapconnect --host=${dynDomain}
fi
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
read key

View File

@@ -12,7 +12,7 @@ if [ ${#chain} -eq 0 ]; then
fi
# check if user has money in lightning channels - info about close all
openChannels=$(lncli --chain=${network} listchannels 2>/dev/null | jq '.[] | length')
openChannels=$(lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
if [ ${#openChannels} -eq 0 ]; then
clear
echo "*** IMPORTANT **********************************"
@@ -28,14 +28,14 @@ if [ ${openChannels} -gt 0 ]; then
fi
# check if money is waiting to get confirmed
unconfirmed=$(lncli --chain=${network} walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
unconfirmed=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"unconfirmed_balance"' | cut -d '"' -f4)
if [ ${unconfirmed} -gt 0 ]; then
dialog --title 'Info' --msgbox "Still waiting confirmation for ${unconfirmed} sat.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58
echo "please wait ..."
fi
# get available amount in on-chain wallet
maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
maxAmount=$(lncli --chain=${network} --network=${chain}net walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${maxAmount} -eq 0 ]; then
dialog --title 'Info' --msgbox "You have 0 moveable funds available.\nNOTICE: Just confirmed on-chain funds can be moved." 6 58
exit 1
@@ -78,7 +78,7 @@ while [ ${tryAgain} -eq 1 ]
echo "TRY #${count} ---> with max fee ${fee} sat:"
# execute command
command="lncli --chain=${network} sendcoins --addr ${address} --amt ${amount} --conf_target 3"
command="lncli --chain=${network} --network=${chain}net sendcoins --addr ${address} --amt ${amount} --conf_target 3"
echo "$command"
result=$($command 2>$_error)
error=`cat ${_error}`

View File

@@ -13,7 +13,7 @@ if [ "${autoPilot}" = "on" ]; then
exit 1
fi
command="lncli --chain=${network} closeallchannels --force"
command="lncli --chain=${network} --network=${chain}net closeallchannels --force"
clear
echo "***********************************"
@@ -26,7 +26,7 @@ echo ""
echo "RESULT:"
# PRECHECK) check if chain is in sync
chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
chainInSync=$(lncli --chain=${network} --network=${chain}net 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 "

View File

@@ -128,9 +128,9 @@ else
fundingTX=$(echo "${result}" | grep 'funding_txid' | cut -d '"' -f4)
if [ "${network}" = "bitcoin" ]; then
if [ "${chain}" = "main" ]; then
echo "https://blockexplorer.com/tx/${fundingTX}"
echo "https://live.blockcypher.com/btc/tx/${fundingTX}"
else
echo "https://testnet.blockexplorer.com/tx/${fundingTX}"
echo "https://live.blockcypher.com/btc-testnet/tx/${fundingTX}"
fi
fi
if [ "${network}" = "litecoin" ]; then

View File

@@ -1,30 +1,29 @@
echo ""
# load raspiblitz config data (with backup from old config)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
echo "!!!! This will DELETE your data & POSSIBLE FUNDS from the HDD !!!!"
echo "Press ENTER to really continue - CTRL+c to CANCEL (last chance)"
read key
sudo dphys-swapfile swapoff
sudo systemctl stop ${network}d.service
sudo systemctl stop lnd.service
sudo systemctl stop bitcoind.service 2>/dev/null
sudo systemctl stop litecoind.service 2>/dev/null
sudo systemctl stop lnd.service 2>/dev/null
sudo rm -f -r /mnt/hdd/lnd
sudo rm -f /mnt/hdd/swapfile
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 /mnt/hdd/bitcoin/bitcoin.conf
sudo rm -f /mnt/hdd/bitcoin/bitcoin.pid
sudo rm -f /mnt/hdd/bitcoin/*.dat
sudo rm -f /mnt/hdd/bitcoin/*.log
sudo rm -f /mnt/hdd/bitcoin/*.pid
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.dat
sudo rm -f /mnt/hdd/bitcoin/testnet3/*.log
sudo rm -f /mnt/hdd/bitcoin/testnet3/.lock
sudo rm -f /mnt/hdd/litecoin/litecoin.conf
sudo rm -f /mnt/hdd/litecoin/litecoin.pid
sudo rm -f /mnt/hdd/litecoin/*.dat
sudo rm -f /mnt/hdd/litecoin/*.log
sudo rm -f /mnt/hdd/litecoin/*.pid
sudo rm -f -r /mnt/hdd/lost+found
sudo rm -f -r /mnt/hdd/download
sudo rm -f -r /mnt/hdd/tor
sudo rm -f /mnt/hdd/raspiblitz.conf
sudo chown admin:admin -R /mnt/hdd/${network}
sudo rm -f /home/admin/raspiblitz.info
echo "OK - the HDD is now clean"

View File

@@ -6,7 +6,7 @@
source /home/admin/_version.info
## get basic info (its OK if not set yet)
source /mnt/hdd/raspiblitz.conf
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# for old nodes
if [ ${#network} -eq 0 ]; then
@@ -16,14 +16,13 @@ if [ ${#network} -eq 0 ]; then
if [ ${litecoinActive} -eq 1 ]; then
network="litecoin"
fi
network=`sudo cat /home/admin/.network`
fi
# for old nodes
# for non final config nodes
if [ ${#chain} -eq 0 ]; then
echo "backup info: chain"
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "testnet=0" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
@@ -54,4 +53,12 @@ echo ""
echo "*** LAST 20 LND LOGS ***"
sudo journalctl -u lnd -b --no-pager -n20
echo ""
echo ""
if [ "${rtlWebinterface}" = "on" ]; then
echo "*** LAST 20 RTL LOGS ***"
sudo journalctl -u RTL -b --no-pager -n20
echo ""
else
echo "- RTL is OFF by config"
fi

139
home.admin/_background.sh Normal file
View File

@@ -0,0 +1,139 @@
#!/bin/bash
# This script runs on after start in background
# as a service and gets restarted on failure
# it runs ALMOST every seconds
# DEBUG: sudo journalctl -f -u background
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# Check if HDD contains configuration
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
source ${configFile}
fi
counter=0
while [ 1 ]
do
###############################
# Prepare this loop
###############################
# count up
counter=$(($counter+1))
####################################################
# RECHECK DHCP-SERVER
# https://github.com/rootzoll/raspiblitz/issues/160
####################################################
# every 5 minutes
recheckDHCP=$((($counter % 300)+1))
if [ ${recheckDHCP} -eq 1 ]; then
echo "*** RECHECK DHCP-SERVER ***"
# get the local network IP
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "localip(${localip})"
# detect a missing DHCP config
if [ "${localip:0:4}" = "169." ]; then
echo "Missing DHCP detected ... trying emergency reboot"
sudo shutdown -r now
else
echo "DHCP OK"
fi
fi
####################################################
# RECHECK PUBLIC IP
# when public IP changes, restart LND with new IP
####################################################
# every 15min - not too often
# because its a ping to external service
recheckPublicIP=$((($counter % 900)+1))
updateDynDomain=0
if [ ${recheckPublicIP} -eq 1 ]; then
echo "*** RECHECK PUBLIC IP ***"
# execute only after setup when config exists
if [ ${configExists} -eq 1 ]; then
# get actual public IP
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php 2>/dev/null)
echo "freshPublicIP(${freshPublicIP})"
echo "publicIP(${publicIP})"
# check if changed
if [ "${freshPublicIP}" != "${publicIP}" ]; then
# 1) update config file
echo "update config value"
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile}
publicIP=${freshPublicIP}
# 2) restart the LND
echo "restart LND with new environment config"
sudo systemctl restart lnd.service
# 3) trigger update if dnyamic domain (if set)
updateDynDomain=1
else
echo "public IP has not changed"
fi
else
echo "skip - because setup is still running"
fi
fi
###############################
# UPDATE DYNAMIC DOMAIN
# like afraid.org
# ! experimental
###############################
# if not activated above, update every 6 hours
if [ ${updateDynDomain} -eq 0 ]; then
# dont +1 so that it gets executed on first loop
updateDynDomain=$(($counter % 21600))
fi
if [ ${updateDynDomain} -eq 1 ]; then
echo "*** UPDATE DYNAMIC DOMAIN ***"
# check if update URL for dyn Domain is set
if [ ${#dynUpdateUrl} -gt 0 ]; then
# calling the update url
echo "calling: ${dynUpdateUrl}"
echo "to update domain: ${dynDomain}"
curl --connect-timeout 6 ${dynUpdateUrl}
else
echo "'dynUpdateUrl' not set in ${configFile}"
fi
fi
###############################
# Prepare next loop
###############################
# sleep 1 sec
sleep 1
# limit counter to max seconds per week:
# 604800 = 60sec * 60min * 24hours * 7days
if [ ${counter} -gt 604800 ]; then
counter=0
echo "counter zero reset"
fi
done

View File

@@ -27,20 +27,6 @@ fi
# load old or init raspiblitz config
source ${configFile}
# check if config files contains basic: network
if [ ${#network} -eq 0 ]; then
echo "FAIL see ${logFile}"
echo "FAIL: missing network in (${configFile})!"
exit 1
fi
# check if config files contains basic: chain
if [ ${#chain} -eq 0 ]; then
echo "FAIL see ${logFile}"
echo "FAIL: missing chain in (${configFile})!" >> ${logFile}
exit 1
fi
# check if config files contains basic: hostname
if [ ${#hostname} -eq 0 ]; then
echo "FAIL see ${logFile}"

View File

@@ -1,33 +0,0 @@
#!/bin/bash
# LOGFILE - store debug logs of bootstrap
# resets on every start
logFile="/home/admin/raspiblitz.log"
# INFOFILE - state data from bootstrap
# used by display and later setup steps
infoFile="/home/admin/raspiblitz.info"
#echo "presync: waiting 2 secs" >> $logFile
#sleep 2
# just in case an old presync did not shutdown properly
#sudo systemctl stop bitcoind.service 2>/dev/null
#sudo systemctl disable bitcoind.service 2>/dev/null
echo "presync: bitcoind" >> $logFile
#sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
#sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
#sudo chmod +x /etc/systemd/system/bitcoind.service
#sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin
#echo "presync: starting services" >> $logFile
#sudo systemctl daemon-reload
#sudo systemctl enable bitcoind.service
#sudo systemctl start bitcoind.service
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin
sudo -u bitcoin /usr/local/bin/bitcoind -daemon -conf=/home/admin/assets/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid
echo "presync: started" >> $logFile
# update info file
echo "state=presync" > $infoFile
sudo sed -i "s/^message=.*/message='running pre-sync'/g" ${infoFile}

View File

@@ -26,11 +26,16 @@ if [ ${configExists} -eq 0 ]; then
exit 1
fi
# import config values
sudo chmod 777 ${configFile}
source ${configFile}
##########################
# BASIC SYSTEM SETTINGS
##########################
echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup System .'/g" ${infoFile}
# set hostname data
echo "Setting lightning alias: ${hostname}" >> ${logFile}
@@ -59,19 +64,16 @@ sudo mkdir /home/admin/.lnd/data >> ${logFile} 2>&1
sudo cp -r /mnt/hdd/lnd/data/chain /home/admin/.lnd/data/chain >> ${logFile} 2>&1
sudo chown -R admin:admin /home/admin/.${network} >> ${logFile} 2>&1
sudo chown -R admin:admin /home/admin/.lnd >> ${logFile} 2>&1
echo "Enabling Services" >> ${logFile}
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1
sudo chmod +x /etc/systemd/system/${network}d.service >> ${logFile} 2>&1
sudo systemctl daemon-reload >> ${logFile} 2>&1
sudo systemctl enable ${network}d.service >> ${logFile} 2>&1
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
sudo chmod +x /etc/systemd/system/lnd.service >> ${logFile} 2>&1
sudo systemctl enable lnd >> ${logFile} 2>&1
# finish setup (SWAP, Benus, Firewall, Update, ..)
./90finishSetup.sh >> ${logFile} 2>&1
sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile}
/home/admin/90finishSetup.sh >> ${logFile} 2>&1
# set the local network hostname
if [ ${#hostname} -gt 0 ]; then
@@ -84,8 +86,9 @@ fi
##########################
# PROVISIONING SERVICES
##########################
sudo sed -i "s/^message=.*/message='Installing Services'/g" ${infoFile}
echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile}
echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile}
# TESTNET
if [ "${chain}" = "test" ]; then
@@ -99,7 +102,7 @@ fi
# AUTO PILOT
if [ "${autoPilot}" = "on" ]; then
echo "Provisioning AUTO PILOT - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning AutoPilot'/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Setup AutoPilot'/g" ${infoFile}
sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1
else
echo "Provisioning AUTO PILOT - keep default" >> ${logFile}
@@ -108,28 +111,39 @@ fi
# AUTO NAT DISCOVERY
if [ "${autoNatDiscovery}" = "on" ]; then
echo "Provisioning AUTO NAT DISCOVERY - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning AutoNAT'/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Setup AutoNAT'/g" ${infoFile}
sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1
else
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile}
fi
# DYNAMIC DNS
if [ "${#dynDomain}" -gt 0 ]; then
echo "Provisioning DYNAMIC DNS - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup DynamicDNS'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.dyndomain.sh on ${dynDomain} ${dynUpdateUrl} >> ${logFile} 2>&1
else
echo "Provisioning DYNAMIC DNS - keep default" >> ${logFile}
fi
# RTL
if [ "${rtlWebinterface}" = "on" ]; then
echo "Provisioning RTL - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning RTL'/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile}
sudo /home/admin/config.scripts/bonus.rtl.sh on >> ${logFile} 2>&1
else
sudo systemctl disable RTL # will get enabled after recover dialog
else
echo "Provisioning RTL - keep default" >> ${logFile}
fi
# TOR
if [ "${runBehindTor}" = "on" ]; then
echo "Provisioning TOR - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning TOR'/g" ${infoFile}
sudo sed -i "s/^message=.*/message='Setup TOR (takes time)'/g" ${infoFile}
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
else
echo "Provisioning TOR - keep default" >> ${logFile}
fi
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile}
echo "END Provisioning" >> ${logFile}

View File

@@ -5,9 +5,9 @@
# default values or as in the config.
# For more details see background_raspiblitzSettings.md
# unique id
uid=$(date +%s)
echo "started" > /home/admin/${uid}.boot
# use to detect multiple starts of service
#uid=$(date +%s)
#echo "started" > /home/admin/${uid}.boot
# load codeVersion
source /home/admin/_version.info
@@ -38,6 +38,9 @@ echo "***********************************************" >> $logFile
echo "Resetting the InfoFile: ${infoFile}"
echo "state=starting" > $infoFile
echo "network=" >> $infoFile
echo "chain=" >> $infoFile
echo "message=" >> $infoFile
sudo chmod 777 ${infoFile}
################################
@@ -64,15 +67,6 @@ if [ ${afterSetupScriptExists} -eq 1 ]; then
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 & PRE-INIT
################################
@@ -82,14 +76,14 @@ hddExists=$(lsblk | grep -c sda1)
while [ ${hddExists} -eq 0 ]
do
# display will ask user to connect a HDD
echo "state=nohdd" > $infoFile
echo "message='Connect the Hard Drive'" >> $infoFile
sed -i "s/^state=.*/state=nohdd/g" ${infoFile}
sed -i "s/^message=.*/message='Connect the Hard Drive'/g" ${infoFile}
sleep 5
# retry to find HDD
hddExists=$(lsblk | grep -c sda1)
done
# check if the HDD is auto-mounted
# check if the HDD is auto-mounted ( auto-mounted = setup-done)
hddIsAutoMounted=$(sudo cat /etc/fstab | grep -c '/mnt/hdd')
if [ ${hddIsAutoMounted} -eq 0 ]; then
@@ -122,8 +116,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
echo "HDD is NOT formatted in ext4." >> $logFile
# stop the bootstrap here ...
# display will ask user to run setup
echo "state=waitsetup" > $infoFile
echo "message='HDD needs SetUp (1)'" >> $infoFile
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile}
sed -i "s/^message=.*/message='HDD needs SetUp (1)'/g" ${infoFile}
exit 0
fi
@@ -134,8 +128,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
mountOK=$(lsblk | grep -c '/mnt/hdd')
if [ ${mountOK} -eq 0 ]; then
echo "FAIL - not able to temp-mount HDD" >> $logFile
echo "state=waitsetup" > $infoFile
echo "message='HDD failed Mounting'" >> $infoFile
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile}
sed -i "s/^message=.*/message='HDD failed Mounting'/g" ${infoFile}
# no need to unmount the HDD, it failed mounting
exit 0
else
@@ -148,16 +142,43 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "Found existing configuration" >> $logFile
echo "state=recovering" > $infoFile
echo "message='Starting Recover'" > $infoFile
source ${configFile}
# check if config files contains basic: version
if [ ${#raspiBlitzVersion} -eq 0 ]; then
echo "Invalid Config: missing raspiBlitzVersion in (${configFile})!" >> ${logFile}
configExists=0
fi
# check if config files contains basic: network
if [ ${#network} -eq 0 ]; then
echo "Invalid Config: missing network in (${configFile})!" >> ${logFile}
configExists=0
fi
# check if config files contains basic: chain
if [ ${#chain} -eq 0 ]; then
echo "Invalid Config: missing chain in (${configFile})!" >> ${logFile}
configExists=0
fi
if [ ${configExists} -eq 0 ]; then
echo "Moving invalid config to raspiblitz.invalid.conf" >> ${logFile}
sudo mv ${configFile} /mnt/hdd/raspiblitz.invalid.conf
fi
fi
# if config is still valid ...
if [ ${configExists} -eq 1 ]; then
echo "Found valid configuration" >> $logFile
sed -i "s/^state=.*/state=recovering/g" ${infoFile}
sed -i "s/^message=.*/message='Starting Recover'/g" ${infoFile}
echo "Calling Data Migration .." >> $logFile
sudo /home/admin/_bootstrap.migration.sh
echo "Calling Provisioning .." >> $logFile
sudo /home/admin/_bootstrap.provision.sh
echo "state=recovered" > $infoFile
sed -i "s/^state=.*/state=recovered/g" ${infoFile}
sed -i "s/^message=.*/message='Done Recover'/g" ${infoFile}
echo "rebooting" >> $logFile
# set flag that system is freshly recovered and needs setup dialogs
echo "state=recovered" >> /home/admin/raspiblitz.recover.info
# save log file for inspection before reboot
cp $logFile /home/admin/raspiblitz.recover
cp $logFile /home/admin/raspiblitz.recover.log
sudo shutdown -r now
exit 0
else
@@ -169,8 +190,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
lndDataExists=$(ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf')
if [ ${lndDataExists} -eq 1 ]; then
echo "Found existing LND data - old RaspiBlitz?" >> $logFile
echo "state=olddata" > $infoFile
echo "message='No Auto-Update possible'" >> $infoFile
sed -i "s/^state=.*/state=olddata/g" ${infoFile}
sed -i "s/^message=.*/message='No Auto-Update possible'/g" ${infoFile}
# keep HDD mounted if user wants to copy data
exit 0
else
@@ -186,8 +207,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
if [ ${bitcoinDataExists} -eq 1 ]; then
# update info file
echo "state=presync" > $infoFile
echo "message='starting pre-sync'" >> $infoFile
sed -i "s/^state=.*/state=presync/g" ${infoFile}
sed -i "s/^message=.*/message='starting presync'/g" ${infoFile}
# activating presync
# so that on a hackathon you can just connect a RaspiBlitz
@@ -199,9 +220,10 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
echo "starting pre-sync in background" >> $logFile
# starting in background, because this scripts is part of systemd
# so to change systemd needs to happen after delay in seperate process
/home/admin/_bootstrap.presync.sh &
echo "done" >> $logFile
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>> $logFile
sudo -u bitcoin /usr/local/bin/bitcoind -daemon -conf=/home/admin/assets/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid 2>> $logFile
echo "OK Started bitcoind for presync" >> $logFile
sudo sed -i "s/^message=.*/message='running presync'/g" ${infoFile}
# after admin login, presync will be stoped and HDD unmounted
exit 0
@@ -211,30 +233,56 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
# if it got until here: HDD is empty ext4
echo "Waiting for SetUp." >> $logFile
echo "state=waitsetup" > $infoFile
echo "message='HDD needs SetUp (2)'" >> $infoFile
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile}
sed -i "s/^message=.*/message='HDD needs SetUp (2)'/g" ${infoFile}
# unmount HDD to be ready for auto-mount during setup
sudo umount -l /mnt/hdd
exit 0
fi # END - no automount
#####################################
# UPDATE HDD CONFIG FILE (if exists)
# needs to be done before starting LND
# so that environment info is fresh
#####################################
echo "Check if HDD contains configuration .." >> $logFile
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
# load values
echo "load and update publicIP" >> $logFile
source ${configFile}
# update public IP on boot
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
if [ ${#publicIP} -eq 0 ]; then
echo "create value (${freshPublicIP})" >> $logFile
echo "publicIP=${freshPublicIP}" >> $configFile
else
echo "update value (${freshPublicIP})" >> $logFile
sed -i "s/^publicIP=.*/publicIP=${freshPublicIP}/g" ${configFile}
fi
fi
################################
# INFOFILE BASICS
# DETECT FRESHLY RECOVERED SD
################################
# init network and chain values if needed with defaults
valueExists=$(sudo cat ${infoFile} 2>/dev/null | grep -c "network=")
if [ ${valueExists} -eq 0 ]; then
echo "network=bitcoin" >> ${infoFile}
fi
valueExists=$(sudo cat ${infoFile} 2>/dev/null | grep -c "chain=")
if [ ${valueExists} -eq 0 ]; then
echo "chain=main" >> ${infoFile}
recoveredInfoExists=$(ls /home/admin/raspiblitz.recover.info | grep -c '.info')
if [ ${recoveredInfoExists} -eq 1 ]; then
sed -i "s/^state=.*/state=recovered/g" ${infoFile}
sed -i "s/^message=.*/message='login to finish'/g" ${infoFile}
exit 0
fi
# EXIT on BOOTSTRAP HERE AT THE MOMENT
echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile
################################
# SD INFOFILE BASICS
################################
sed -i "s/^state=.*/state=ready/g" ${infoFile}
sed -i "s/^message=.*/message='waiting login'/g" ${infoFile}
echo "DONE BOOTSTRAP" >> $logFile
exit 0

View File

@@ -0,0 +1,24 @@
# Monitor the RaspiBlitz
# /etc/systemd/system/background.service
[Unit]
Description=RaspiBlitz Background Monitoring Service
Wants=bootstrap.service
After=bootstrap.service
# for use with sendmail alert (coming soon)
#OnFailure=systemd-sendmail@%n
[Service]
User=root
Group=root
Type=simple
ExecStart=/home/admin/_background.sh
KillMode=process
Restart=always
TimeoutSec=10
RestartSec=10
StandardOutput=journal
[Install]
WantedBy=multi-user.target

View File

@@ -1,7 +1,7 @@
# litecoind configuration
# mainnet/testnet
testnet=1
testnet=0
# litcoind options
server=1

View File

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

View File

@@ -1,32 +0,0 @@
# 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

View File

@@ -38,7 +38,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# to prevent tls cer auth error
echo "*** Modify lnd.conf ***"
sudo sed -i "s/^rpclisten=0.0.0.0:10009/#rpclisten=0.0.0.0:10009/g" /mnt/hdd/lnd/lnd.conf
sudo systemctl restart lnd
echo ""
# install latest nodejs

View File

@@ -0,0 +1,135 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a dynamic domain like freeDNS"
echo "internet.dyndomain.sh [on|off] [?domainName] [?updateURL]"
exit 1
fi
# 1. parameter [on|off]
turn="off"
if [ "$1" = "1" ] || [ "$1" = "on" ]; then turn="on"; fi
# 2. parameter [?domainName]
dynDomain=$2
# 3. parameter [?domainName]
updateDynDomain=$3
# run interactive if 'turn on' && no further parameters
if [ "${turn}" = "on" ] && [ ${#dynDomain} -eq 0 ]; then
dialog --backtitle "DynamicDNS" --inputbox "ENTER the Dynamic Domain Name:
For more details see chapter in GitHub README
'Public Domain with DynamicDNS'
https://github.com/rootzoll/raspiblitz
example: freedns.afraid.org
" 13 52 2>./.tmp
dynDomain=$( cat ./.tmp )
if [ ${#dynDomain} -eq 0 ]; then
echo "FAIL input cannot be empty"
exit 1
fi
dialog --backtitle "DynamicDNS" --inputbox "OPTIONAL Public IP Update URL:
The RaspiBlitz will call this URL regularly.
4 service freedns.afraid.org use 'DirectURL'
" 10 52 2>./.tmp
dynUpdateUrl=$( cat ./.tmp )
shred ./.tmp
fi
# config file
configFile="/mnt/hdd/raspiblitz.conf"
# lnd conf file
lndConfig="/mnt/hdd/lnd/lnd.conf"
# check if config file exists
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
echo "FAIL - missing ${configFile}"
exit 1
fi
# make sure entry line for 'dynDomain' exists
entryExists=$(cat ${configFile} | grep -c 'dynDomain=')
if [ ${entryExists} -eq 0 ]; then
echo "dynDomain=" >> ${configFile}
fi
# make sure entry line for 'dynUpdateUrl' exists
entryExists=$(cat ${configFile} | grep -c 'dynUpdateUrl')
if [ ${entryExists} -eq 0 ]; then
echo "dynUpdateUrl=" >> ${configFile}
fi
# stop services
echo "making sure services are not running"
sudo systemctl stop lnd 2>/dev/null
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "switching the DynamicDNS ON"
echo "dynDomain(${dynDomain})"
echo "dynUpdateUrl(${dynUpdateUrl})"
# setting value in raspi blitz config
sudo sed -i "s/^dynDomain=.*/dynDomain='${dynDomain}'/g" /mnt/hdd/raspiblitz.conf
sudo sed -i "s/^dynUpdateUrl=.*/dynUpdateUrl='${dynUpdateUrl}'/g" /mnt/hdd/raspiblitz.conf
echo "changing lnd.conf"
# lnd.conf: uncomment tlsextradomain (just if it is still uncommented)
sudo sed -i "s/^#tlsextradomain=.*/tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf
# lnd.conf: domain value
sudo sed -i "s/^tlsextradomain=.*/tlsextradomain=${dynDomain}/g" /mnt/hdd/lnd/lnd.conf
echo "DynamicDNS is now ON"
fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "switching DynamicDNS OFF"
# setting value in raspi blitz config
sudo sed -i "s/^dynDomain=.*/dynDomain=/g" /mnt/hdd/raspiblitz.conf
sudo sed -i "s/^dynUpdateUrl=.*/dynUpdateUrl=/g" /mnt/hdd/raspiblitz.conf
echo "changing lnd.conf"
# lnd.conf: comment tlsextradomain out
sudo sed -i "s/^tlsextradomain=.*/#tlsextradomain=/g" /mnt/hdd/lnd/lnd.conf
echo "DynamicDNS is now OFF"
fi
echo "deleting TLSCert"
sudo rm /mnt/hdd/lnd/tls.* 2>/dev/null
echo "let lnd generate new TLSCert"
sudo systemctl restart lnd
echo "wait until generated"
newCertExists=0
count=0
while [ ${newCertExists} -eq 0 ]
do
count=$(($count + 1))
echo "(${count}/60) check for cert"
if [ ${count} -gt 60 ]; then
echo "FAIL - was not able to generate new LND certs"
exit 1
fi
newCertExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c '.cert')
sleep 2
done
echo "copy new cert to admin user"
sudo cp /mnt/hdd/lnd/tls.cert /home/admin/.lnd
echo "may needs reboot to run normal again"
exit 0

View File

@@ -55,22 +55,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo ""
fi
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 ""
@@ -145,23 +129,23 @@ EOF
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
sudo systemctl enable 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 "*** 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)
@@ -186,49 +170,46 @@ EOF
echo "Chain network already configured for TOR"
fi
echo "*** ${network} re-init - Waiting for Onion Address ***"
#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 "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 ""
#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 "Make sutre LND is disabled"
sudo systemctl disable lnd 2>/dev/null
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 "System LND again"
echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --tor\.active --tor\.v2 --listen=127\.0\.0\.1\:9735/g" /etc/systemd/system/lnd.service
echo "Enable LND again"
sudo systemctl enable lnd
echo "OK"
echo ""
echo ""
echo "OK - TOR is now ON"
echo "needs reboot to activate new setting"
@@ -255,10 +236,10 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
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
echo "editing /etc/systemd/system/lnd.service"
sudo sed -i "s/^ExecStart=\/usr\/local\/bin\/lnd.*/ExecStart=\/usr\/local\/bin\/lnd --externalip=\${publicIP}/g" /etc/systemd/system/lnd.service
sudo systemctl enable lnd
echo "OK"
echo ""
@@ -266,11 +247,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
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 ""

View File

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