big merge of 2388redis & 2669tor (#2790)

This commit is contained in:
/rootzoll 2021-12-14 23:34:35 +01:00 committed by GitHub
parent 1cdb50d38f
commit 85b0c97d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
132 changed files with 4895 additions and 4106 deletions

2
.shellcheckrc Normal file
View File

@ -0,0 +1,2 @@
shell=bash
source=/dev/null

9
FAQ.md
View File

@ -390,6 +390,14 @@ If your RaspiBlitz is not working correctly and you like to get help from the co
*PLEASE NOTICE: It's possible that these logs can contain private information (like IPs, node IDs, ...) - just share publicly what you feel OK with.* *PLEASE NOTICE: It's possible that these logs can contain private information (like IPs, node IDs, ...) - just share publicly what you feel OK with.*
### Can I run my RaspiBlitz on Solar Energy?
Yes - take a look at the project of [Chimezie Chuta](https://twitter.com/mezie16/status/1264513274080636928?s=20)
![RaspiSolar](pictures/raspisolar.jpg)
More details in his book ["A-Z of Building your own Full Bitcoin Lightning Node: A hand Book for Enthusiasts"](https://blockspace.shop/products/a-z-of-building-your-own-full-bitcoin-lightning-node-a-hand-book-for-enthusiasts)
### Why is my "final sync" taking so long? ### Why is my "final sync" taking so long?
First of all if you see a final sync over 90% and you can see from time to time small increase - you should be OK ... this can take a looong time to catch up with the network. Only in the case that you actively choose the `SYNC` option in the `Getting the Blockchain` is a final sync under 90% OK. If you did a torrent or a copy from another computer and you are seeing under 90% something went wrong, and the setup process is ignoring your prepared Blockchain and doing a full sync - which can almost take forever on a raspberryPi. First of all if you see a final sync over 90% and you can see from time to time small increase - you should be OK ... this can take a looong time to catch up with the network. Only in the case that you actively choose the `SYNC` option in the `Getting the Blockchain` is a final sync under 90% OK. If you did a torrent or a copy from another computer and you are seeing under 90% something went wrong, and the setup process is ignoring your prepared Blockchain and doing a full sync - which can almost take forever on a raspberryPi.
@ -909,7 +917,6 @@ It is currently considered completely fine to leave this field empty and not pro
The `acme.sh` script is installed in `/home/admin/.acme.sh/` - the configuration and the certificates are stored on the The `acme.sh` script is installed in `/home/admin/.acme.sh/` - the configuration and the certificates are stored on the
external hard disk in `/mnt/hdd/app-data/letsencrypt`. external hard disk in `/mnt/hdd/app-data/letsencrypt`.
### What is this mnemonic seed word list? ### What is this mnemonic seed word list?
With the 24 word list given you by LND upon wallet creation you can recover your private key. You should write it down and store it at a safe place. Bear in mind that *this 24 word mnemonic seed is not based on the BIP 39* and therefore cannot be recovered using a Bitcoin wallet. With the 24 word list given you by LND upon wallet creation you can recover your private key. You should write it down and store it at a safe place. Bear in mind that *this 24 word mnemonic seed is not based on the BIP 39* and therefore cannot be recovered using a Bitcoin wallet.

View File

@ -10,7 +10,7 @@ cp /vagrant/home.admin/config.scripts/blitz.github.sh /home/admin/config.scripts
# execute 'patch' command to sync laptop with VM # execute 'patch' command to sync laptop with VM
/home/admin/config.scripts/blitz.github.sh -run /home/admin/config.scripts/blitz.github.sh -run
source <(/home/admin/config.scripts/internet.sh status) source <(/home/admin/config.scripts/internet.sh status local)
echo echo
echo "************* NEXT ********************" echo "************* NEXT ********************"

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,72 @@
#!/bin/bash #!/bin/bash
# 00infoBlitz.sh <cl|lnd> <testnet|mainnet|signet> source <(/home/admin/_cache.sh get \
state \
setupPhase \
network \
chain \
lightning \
codeVersion \
hostname \
undervoltageReports \
hdd_used_info \
internet_localip \
internet_public_ip_clean \
internet_rx \
internet_tx \
system_ram_available_mb \
system_ram_mb \
system_ups_status \
system_cpu_load \
system_temp_celsius \
system_temp_fahrenheit \
runBehindTor \
ups \
ElectRS \
BTCRPCexplorer \
)
# load code software version # PARAMETER 1: forcing view on a lightning implementation
source /home/admin/_version.info PARAMETER_LIGHTNING=$1
if [ "${PARAMETER_LIGHTNING}" == "lnd" ]; then
lightning="lnd"
fi
if [ "${PARAMETER_LIGHTNING}" == "cl" ]; then
lightning="cl"
fi
if [ "${PARAMETER_LIGHTNING}" == "none" ]; then
lightning=""
fi
# PARAMETER 2: forcing view on a given network
PARAMETER_CHAIN=$2
if [ "${PARAMETER_CHAIN}" == "mainnet" ]; then
chain="main"
fi
if [ "${PARAMETER_CHAIN}" == "testnet" ]; then
chain="test"
fi
if [ "${PARAMETER_CHAIN}" == "signet" ]; then
chain="sig"
fi
# generate netprefix
netprefix=${chain:0:1}
if [ "${netprefix}" == "m" ]; then
netprefix=""
fi
## get UPS info
upsInfo=""
if [ "${system_ups_status}" = "ONLINE" ]; then
upsInfo="${color_gray}${upsBattery}"
fi
if [ "$system_ups_status}" = "ONBATT" ]; then
upsInfo="${color_red}${upsBattery}"
fi
if [ "${system_ups_status}" = "SHUTTING DOWN" ]; then
upsInfo="${color_red}DOWN"
fi
# set colors # set colors
color_red='\033[0;31m' color_red='\033[0;31m'
@ -12,33 +75,6 @@ color_amber='\033[0;33m'
color_yellow='\033[1;93m' color_yellow='\033[1;93m'
color_gray='\033[0;37m' color_gray='\033[0;37m'
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
## get HDD/SSD info
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
hdd="${hddUsedInfo}"
## get internet info
source <(sudo /home/admin/config.scripts/internet.sh status)
cleanip=$(echo "${publicIP}" | tr -d '[]')
## get UPS info
source <(/home/admin/config.scripts/blitz.ups.sh status)
upsInfo=""
if [ "${upsStatus}" = "ONLINE" ]; then
upsInfo="${color_gray}${upsBattery}"
fi
if [ "${upsStatus}" = "ONBATT" ]; then
upsInfo="${color_red}${upsBattery}"
fi
if [ "${upsStatus}" = "SHUTTING DOWN" ]; then
upsInfo="${color_red}DOWN"
fi
# check hostname # check hostname
if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz"; fi if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz"; fi
@ -48,347 +84,175 @@ if [ ${#chain} -eq 0 ]; then
chain="main" chain="main"
fi fi
# set datadir # ram info string
lnd_dir="/home/bitcoin/.lnd" ram=$(printf "%sM / %sM" "${system_ram_available_mb}" "${system_ram_mb}")
lnd_macaroon_dir="/home/bitcoin/.lnd/data/chain/${network}/${chain}net" if [ "${system_ram_available_mb}" != "" ] && [ ${system_ram_available_mb} -lt 50 ]; then
# get uptime & load
load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
# get CPU temp - no measurement in a VM
cpu=0
if [ -d "/sys/class/thermal/thermal_zone0/" ]; then
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
fi
if [ $cpu = 0 ];then
tempC=""
tempF=""
else
tempC=$((cpu/1000))
tempF=$(((tempC * 18 + 325) / 10))
fi
# get memory
ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")
if [ ${ram_avail} -lt 50 ]; then
color_ram="${color_red}\e[7m" color_ram="${color_red}\e[7m"
else else
color_ram=${color_green} color_ram=${color_green}
fi fi
# Bitcoin blockchain # Tor info string
btc_path=$(command -v ${network}-cli)
blockInfo="-"
if [ -n "${btc_path}" ]; then
btc_title=$network
blockchaininfo="$($bitcoincli_alias getblockchaininfo 2>/dev/null)"
if [ ${#blockchaininfo} -gt 0 ]; then
btc_title="${btc_title} (${chain}net)"
# get sync status
headers="$(echo "${blockchaininfo}" | jq -r '.headers')"
block_verified="$(echo "${blockchaininfo}" | jq -r '.blocks')"
block_diff=$(expr ${headers} - ${block_verified})
blockInfo="${block_verified}/${headers}"
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}')
if [ ${block_diff} -eq 0 ]; then # fully synced
sync="OK"
sync_color="${color_green}"
sync_behind=" "
elif [ ${block_diff} -eq 1 ]; then # fully synced
sync="OK"
sync_color="${color_green}"
sync_behind="-1 block"
elif [ ${block_diff} -le 10 ]; then # <= 2 blocks behind
sync=""
sync_color="${color_red}"
sync_behind="-${block_diff} blocks"
else
sync=""
sync_color="${color_red}"
sync_behind="${sync_percentage}"
fi
# get last known block
if [ ! -z "${last_block}" ]; then
btc_line2="${btc_line2} ${color_gray}(block ${last_block})"
fi
# get mem pool transactions
mempool="$($bitcoincli_alias getmempoolinfo 2>/dev/null | jq -r '.size')"
else
btc_line2="${color_red}NOT RUNNING\t\t"
fi
fi
# get IP address & port
networkInfo=$($bitcoincli_alias getnetworkinfo 2>/dev/null)
local_ip="${localip}" # from internet.sh
public_ip="${cleanip}"
public_port="$(echo ${networkInfo} | jq -r '.localaddresses [0] .port')"
if [ "${public_port}" = "null" ]; then
if [ "${chain}" = "test" ]; then
public_port="18333"
else
public_port="8333"
fi
fi
# check if RTL web interface is installed
webinterfaceInfo=""
runningRTL=$(systemctl status ${netprefix}${typeprefix}RTL.service 2>/dev/null | grep -c active)
if [ ${runningRTL} -eq 1 ]; then
if [ "${lightning}" == "cl" ]; then
RTLHTTP=${portprefix}7000
elif [ "${lightning}" == "lnd" ];then
RTLHTTP=${portprefix}3000
fi
webinterfaceInfo="Web admin --> ${color_green}http://${local_ip}:${RTLHTTP}"
fi
# CHAIN NETWORK
public_addr_pre="Public "
public_addr="??"
torInfo="" torInfo=""
# Version
networkVersion=$($bitcoincli_alias -version 2>/dev/null | cut -d ' ' -f6)
# TOR or IP
networkConnections=$(echo ${networkInfo} | jq -r '.connections')
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections"
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# TOR address
onionAddress=$(echo ${networkInfo} | jq -r '.localaddresses [0] .address')
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}peers"
public_addr="${onionAddress}:${public_port}"
public=""
public_color="${color_green}"
torInfo="+ Tor" torInfo="+ Tor"
else
# IP address
networkConnectionsInfo="${color_green}${networkConnections} ${color_gray}connections"
public_addr="${publicIP}:${public_port}"
public_check=$(nc -z -w6 ${cleanip} ${public_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ] ; then
public=""
# 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_amber}"
else
public=""
public_color="${color_red}"
fi
# DynDomain
if [ ${#dynDomain} -gt 0 ]; then
#check if dynamic domain resolves to correct IP
ipOfDynDNS=$(getent hosts ${dynDomain} | awk '{ print $1 }')
if [ "${ipOfDynDNS}:${public_port}" != "${public_addr}" ]; then
public_color="${color_red}"
else
public_color="${color_amber}"
fi
# replace IP display with dynDN
public_addr_pre="DynDN "
public_addr="${dynDomain}"
fi
if [ ${#public_addr} -gt 25 ]; then
# if a IPv6 address dont show peers to save space
networkConnectionsInfo=""
fi
if [ ${#public_addr} -gt 35 ]; then
# if a LONG IPv6 address dont show "Public" in front to save space
public_addr_pre=""
fi
fi fi
# LIGHTNING NETWORK #######################
if [ "${lightning}" == "cl" ]; then # BITCOIN INFO
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
ln_baseInfo="-"
ln_channelInfo="\n"
ln_external="\n"
ln_alias="$(sudo cat "${CLCONF}" | grep "^alias=*" | cut -f2 -d=)"
if [ ${#ln_alias} -eq 0 ];then
ln_alias=$(echo "${ln_getInfo}" | grep '"alias":' | cut -d '"' -f4)
fi
if [ ${#ln_alias} -eq 0 ];then
ln_alias=${hostname}
fi
ln_publicColor=""
ln_port=$(sudo cat "${CLCONF}" | grep "^bind-addr=*" | cut -f2 -d':')
if [ ${#ln_port} -eq 0 ]; then
ln_port=$(echo "${ln_getInfo}" | grep '"port":' | cut -d: -f2 | tail -1 | bc)
fi
wallet_unlocked=0 #TODO
if [ "$wallet_unlocked" -gt 0 ] ; then
ln_alias="Wallet Locked"
else
pubkey=$(echo "${ln_getInfo}" | grep '"id":' | cut -d '"' -f4)
address=$(echo "${ln_getInfo}" | grep '.onion' | cut -d '"' -f4)
if [ ${#address} -eq 0 ];then
address=$(echo "${ln_getInfo}" | grep '"ipv4"' -A 1 | tail -1 | cut -d '"' -f4)
fi
ln_external="${pubkey}@${address}:${ln_port}"
ln_tor=$(echo "${ln_external}" | grep -c ".onion")
if [ ${ln_tor} -eq 1 ]; then
ln_publicColor="${color_green}"
else
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?)
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure
ln_publicColor="${color_amber}"
else
ln_publicColor="${color_red}"
fi
fi
BLOCKHEIGHT=$(echo "$blockchaininfo"|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$(echo "${ln_getInfo}" | jq .blockheight)
if [ "$BLOCKHEIGHT" == "$CLHEIGHT" ];then
ln_sync=1
else
ln_sync=0
fi
ln_version=$($lightningcli_alias -V)
if [ ${ln_sync} -eq 0 ]; then
if [ ${#ln_getInfo} -eq 0 ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet"
else
ln_baseInfo="
${color_amber}Scanning blocks: ${CLHEIGHT}/${BLOCKHEIGHT}"
fi
else
ln_walletbalance=0
cl_listfunds=$($lightningcli_alias listfunds 2>/dev/null)
for i in $(echo "$cl_listfunds" \
|jq .outputs[]|jq 'select(.status=="confirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
ln_walletbalance=$((ln_walletbalance+i))
done
for i in $(echo "$cl_listfunds" \
|jq .outputs[]|jq 'select(.status=="unconfirmed")'|grep value|awk '{print $2}'|cut -d, -f1);do
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
done
# ln_closedchannelbalance: "state": "ONCHAIN" funds in channels
for i in $(echo "$cl_listfunds" \
|jq .channels[]|jq 'select(.state=="ONCHAIN")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_closedchannelbalance=$((ln_closedchannelbalance+i))
done
# ln_pendingonchain: waiting onchain + waiting closed channel funds
ln_pendingonchain=$((ln_walletbalance_wait+ln_closedchannelbalance))
if [ "${ln_pendingonchain}" = "0" ]; then ln_pendingonchain=""; fi
if [ ${#ln_pendingonchain} -gt 0 ]; then ln_pendingonchain="(+${ln_pendingonchain})"; fi
# ln_channelbalance: "state": "CHANNELD_NORMAL" funds in channels
for i in $(echo "$cl_listfunds" \
|jq .channels[]|jq 'select(.state=="CHANNELD_NORMAL")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance=$((ln_channelbalance+i))
done
if [ ${#ln_channelbalance} -eq 0 ];then
ln_channelbalance=0
fi
# ln_channelbalance_all: all funds in channels
for i in $(echo "$cl_listfunds" \
|jq .channels[]|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance_all=$((ln_channelbalance_all+i))
done
ln_channelbalance_pending=$((ln_channelbalance_all-ln_channelbalance-ln_closedchannelbalance))
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
# - **num_peers** (u32): The total count of peers, connected or with channels
# - **num_pending_channels** (u32): The total count of channels being opened
# - **num_active_channels** (u32): The total count of channels in normal state
# - **num_inactive_channels** (u32): The total count of channels waiting for opening or closing
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
cl_num_pending_channels="$(echo "${ln_getInfo}" | jq -r '.num_pending_channels')" 2>/dev/null
cl_num_inactive_channels="$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')" 2>/dev/null
ln_channels_total=$((ln_channels_online+cl_num_pending_channels+cl_num_inactive_channels))
ln_baseInfo="${color_gray}Wallet ${ln_walletbalance} ${netprefix}sat ${ln_pendingonchain}"
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}"
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers"
# - **fees_collected_msat** (msat): Total routing fees collected by this node
#ln_dailyfees="$($lncli_alias feereport | jq -r '.day_fee_sum')" 2>/dev/null
#ln_weeklyfees="$($lncli_alias feereport | jq -r '.week_fee_sum')" 2>/dev/null
#ln_monthlyfees="$($lncli_alias feereport | jq -r '.month_fee_sum')" 2>/dev/null
#ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat"
ln_feeReport="Fees collected: $(echo "${ln_getInfo}" | jq -r '.fees_collected_msat')"
fi
fi
elif [ "${lightning}" == "lnd" ];then # get block data - use meta on cache to call dynamic variable name
ln_baseInfo="-" source <(/home/admin/_cache.sh meta btc_${chain}net_blocks_headers)
ln_channelInfo="\n" btc_blocks_headers="${value}"
ln_external="\n" source <(/home/admin/_cache.sh meta btc_${chain}net_blocks_verified)
ln_alias="$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^alias=*" | cut -f2 -d=)" btc_blocks_verified="${value}"
if [ ${#ln_alias} -eq 0 ];then source <(/home/admin/_cache.sh meta btc_${chain}net_blocks_behind)
ln_alias=${hostname} btc_blocks_behind="${value}"
fi source <(/home/admin/_cache.sh meta btc_${chain}net_sync_percentage)
ln_publicColor="" if [ "${value}" != "" ]; then
ln_port=$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep "^listen=*" | cut -f2 -d':') sync_percentage="${value}%"
if [ ${#ln_port} -eq 0 ]; then fi
ln_port="9735"
fi # construct blockinfo string
wallet_unlocked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2> /dev/null | grep -c unlock) if [ "${btc_blocks_behind}" == "" ]; then
if [ "$wallet_unlocked" -gt 0 ] ; then sync="WAIT"
ln_alias="Wallet Locked" sync_color="${color_yellow}"
else elif [ ${btc_blocks_behind} -lt 2 ]; then
ln_getInfo=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert getinfo 2>/dev/null) sync="OK"
ln_external=$(echo "${ln_getInfo}" | grep "uris" -A 1 | tr -d '\n' | cut -d '"' -f4) sync_color="${color_green}"
ln_tor=$(echo "${ln_external}" | grep -c ".onion") else
if [ ${ln_tor} -eq 1 ]; then sync=""
ln_publicColor="${color_green}" sync_color="${color_red}"
else fi
public_check=$(nc -z -w6 ${public_ip} ${ln_port} 2>/dev/null; echo $?) blockInfo="Blocks ${btc_blocks_verified}/${btc_blocks_headers} ${color_gray}Sync ${sync_color}${sync}"
if [ $public_check = "0" ] || [ "${ipv6}" == "on" ]; then if [ "${btc_blocks_headers}" == "" ]; then
# only set yellow/normal because netcat can only say that the port is open - not that it points to this device for sure blockInfo="${color_red}Not Started | Not Ready Yet | No Data${color_gray}"
ln_publicColor="${color_amber}" fi
else
ln_publicColor="${color_red}" # get address data - use meta on cache to call dynamic variable name
fi source <(/home/admin/_cache.sh meta btc_${chain}net_version)
networkVersion="${value} "
source <(/home/admin/_cache.sh meta btc_${chain}net_peers)
btc_peers=${value}
if [ "${btc_peers}" == "" ]; then
networkConnectionsInfo=""
elif [ ${btc_peers} -gt 0 ]; then
networkConnectionsInfo="${color_green}${btc_peers} ${color_gray}peers"
else
networkConnectionsInfo="${color_red}${btc_peers} ${color_gray}peers"
fi
#######################
# LIGHTNING INFO
# default values
ln_alias=${hostname}
ln_baseInfo="-"
ln_channelInfo="\n"
ln_external="\n"
ln_feeReport=""
ln_peersInfo=""
ln_version=""
ln_publicColor="${color_green}"
if [ "${lightning}" != "" ]; then
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_version)
ln_version="${value}"
# get alias
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_alias)
if [ "${value}" != "" ]; then
ln_alias="${value}"
fi fi
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1) # consider tor address green for public
if [ ${ln_sync} -eq 0 ]; then # when not Tor use yellow because not sure if public
if [ ${#ln_getInfo} -eq 0 ]; then if [ "${runBehindTor}" != "on" ]; then
ln_baseInfo="${color_red} Not Started | Not Ready Yet" ln_publicColor="${color_yellow}"
else fi
ln_baseInfo="${color_amber} Waiting for Chain Sync"
fi # get the public address/URI
else source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_address)
lnd_walletbalance=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert walletbalance 2>/dev/null) ln_external="${value}"
ln_walletbalance="$(echo "$lnd_walletbalance" | jq -r '.confirmed_balance')" 2>/dev/null
ln_walletbalance_wait="$(echo "$lnd_walletbalance" | jq -r '.unconfirmed_balance')" 2>/dev/null source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_peers)
if [ "${ln_walletbalance_wait}" = "0" ]; then ln_walletbalance_wait=""; fi if [ "${value}" != "" ]; then
if [ ${#ln_walletbalance_wait} -gt 0 ]; then ln_walletbalance_wait="(+${ln_walletbalance_wait})"; fi ln_peersInfo="${color_green}${value} ${color_gray}peers"
lnd_channelbalance=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert channelbalance 2>/dev/null) fi
ln_channelbalance="$(echo "$lnd_channelbalance" | jq -r '.balance')" 2>/dev/null
ln_channelbalance_pending="$(echo "$lnd_channelbalance" | jq -r '.pending_open_balance')" 2>/dev/null source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_ready)
if [ "${ln_channelbalance_pending}" = "0" ]; then ln_channelbalance_pending=""; fi ln_ready="${value}"
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_sync_chain)
ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null ln_sync="${value}"
ln_channels_total="$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert listchannels | jq '.[] | length')" 2>/dev/null source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_locked)
ln_baseInfo="${color_gray}wallet ${ln_walletbalance} ${netprefix}sat ${ln_walletbalance_wait}" ln_locked="${value}"
ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channelbalance} ${netprefix}sat${ln_channelbalance_pending}" # lightning is still starting
ln_peersInfo="${color_green}${ln_peers} ${color_gray}peers" if [ "${ln_ready}" != "1" ]; then
lnd_feereport=$($lncli_alias --macaroonpath=${lnd_macaroon_dir}/readonly.macaroon --tlscertpath=${lnd_dir}/tls.cert feereport 2>/dev/null)
ln_dailyfees="$(echo "$lnd_feereport" | jq -r '.day_fee_sum')" 2>/dev/null ln_baseInfo="\n ${color_red}Not Started | Not Ready Yet | No Data"
ln_weeklyfees="$(echo "$lnd_feereport" | jq -r '.week_fee_sum')" 2>/dev/null ln_peersInfo=""
ln_monthlyfees="$(echo "$lnd_feereport" | jq -r '.month_fee_sum')" 2>/dev/null
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}sat" # lightning is still syncing
fi elif [ "${ln_locked}" == "1" ]; then
fi
ln_baseInfo="${color_amber}Wallet Locked"
ln_peersInfo=""
# lightning is still syncing
elif [ "${ln_sync}" != "1" ]; then
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_sync_progress)
ln_syncprogress="${value}"
ln_baseInfo="${color_amber}Scanning blocks: ${ln_syncprogress}"
ln_peersInfo=""
# OK lightning is ready - get more details
else
# create fee report
if [ "${lightning}" == "lnd" ]; then
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_fees_daily)
ln_dailyfees="${value}"
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_fees_weekly)
ln_weeklyfees="${value}"
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_fees_month)
ln_monthlyfees="${value}"
ln_feeReport="Fee Report (D-W-M): ${color_green}${ln_dailyfees}-${ln_weeklyfees}-${ln_monthlyfees} ${color_gray}${netprefix}sat"
else
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_fees_total)
ln_totalfees="${value}"
ln_feeReport="Fee Report: ${color_green}${ln_totalfees} ${color_gray}${netprefix}sat"
fi
# on-chain wallet info
ln_pendingonchain=""
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_wallet_onchain_pending)
ln_onchain_pending="${value}"
if [ "${ln_onchain_pending}" != "" ] && [ ${ln_onchain_pending} -gt 0 ]; then ln_pendingonchain=" (+${ln_onchain_pending})"; fi
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_wallet_onchain_balance)
ln_walletbalance="${value}"
ln_baseInfo="${color_gray}Wallet ${ln_walletbalance} ${netprefix}sat ${ln_pendingonchain}"
# channel pending info
ln_channelbalance_pending=""
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_wallet_channels_pending)
ln_channels_pending="${value}"
if [ "${ln_channels_pending}" != "" ] && [ ${ln_channels_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channels_pending})"; fi
# get channel infos
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_wallet_channels_balance)
ln_channels_balance="${value}"
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_channels_active)
ln_channels_online="${value}"
source <(/home/admin/_cache.sh meta ln_${lightning}_${chain}net_channels_total)
ln_channels_total="${value}"
# construct channel info string
ln_channelInfo="${ln_channels_online}/${ln_channels_total} Channels ${ln_channels_balance} ${netprefix}sat${ln_channelbalance_pending}"
fi
fi fi
# show JoinMarket stats in place of the LND URI only if the Yield Generator is running # show JoinMarket stats in place of the LND URI only if the Yield Generator is running
@ -411,28 +275,19 @@ else
lastLine="\ lastLine="\
${color_yellow} ${color_yellow}
${color_yellow}${ln_publicColor}${ln_external}${color_gray}" ${color_yellow}${ln_publicColor}${ln_external}${color_gray}"
fi fi
if [ "${lightning}" == "cl" ];then if [ "${lightning}" == "cl" ]; then
LNline="C-LIGHTNING ${color_green}${ln_version}\n ${ln_baseInfo}" LNline="C-LIGHTNING ${color_green}${ln_version} ${ln_baseInfo}"
elif [ "${lightning}" == "lnd" ];then elif [ "${lightning}" == "lnd" ]; then
LNline="LND ${color_green}${ln_version} ${ln_baseInfo}" LNline="LND ${color_green}${ln_version} ${ln_baseInfo}"
fi fi
if [ $cpu = 0 ];then
templine="on $(uname -m) VM%s%s"
else
templine="temp %s°C %s°F"
fi
sleep 5
LNinfo=" + Lightning Network" LNinfo=" + Lightning Network"
if [ "${lightning}" == "" ]; then if [ "${lightning}" == "" ]; then
LNinfo="" LNinfo=""
fi fi
## get uptime and current date & time
uptime=$(uptime --pretty)
datetime=$(date -R) datetime=$(date -R)
stty sane stty sane
@ -449,10 +304,10 @@ ${color_yellow} ,/ ${color_yellow}%s
${color_yellow} ,'/ ${color_gray}%s ${color_yellow} ,'/ ${color_gray}%s
${color_yellow} ,' / ${color_gray}%s, temp %s°C %s°F ${color_yellow} ,' / ${color_gray}%s, temp %s°C %s°F
${color_yellow} ,' /_____ ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray} ${color_yellow} ,' /_____ ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray}
${color_yellow},'_____ ,' ${color_gray}SSH admin@${color_green}${local_ip}${color_gray} d${network_rx} u${network_tx} ${color_yellow},'_____ ,' ${color_gray}SSH admin@${color_green}${internet_localip}${color_gray} d${internet_rx} u${internet_tx}
${color_yellow} / ,' ${color_gray}${webinterfaceInfo} ${color_yellow} / ,' ${color_gray}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion} ${color_gray}${chain}net ${networkConnectionsInfo} ${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion}${color_gray}${chain}net ${networkConnectionsInfo}
${color_yellow} /,' ${color_gray}Blocks ${blockInfo} ${color_gray}Sync ${sync_color}${sync} %s ${color_yellow} /,' ${color_gray}${blockInfo} %s
${color_yellow} /' ${color_gray} ${color_yellow} /' ${color_gray}
${color_yellow} ${color_gray}${LNline} ${color_yellow} ${color_gray}${LNline}
${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo} ${color_yellow} ${color_gray}${ln_channelInfo} ${ln_peersInfo}
@ -462,8 +317,8 @@ $lastLine
"RaspiBlitz v${codeVersion}" \ "RaspiBlitz v${codeVersion}" \
"-------------------------------------------" \ "-------------------------------------------" \
"Refreshed: ${datetime}" \ "Refreshed: ${datetime}" \
"CPU load${load##up*, }" "${tempC}" "${tempF}" \ "CPU load${system_cpu_load##up*, }" "${system_temp_celsius}" "${system_temp_fahrenheit}" \
"${hdd}" "${sync_percentage}" "${hdd_used_info}" "${sync_percentage}"
if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; then if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; then
echo "${undervoltageReports} undervoltage reports - run 'Hardware Test' in menu" echo "${undervoltageReports} undervoltage reports - run 'Hardware Test' in menu"
@ -500,4 +355,3 @@ else
fi fi
# EOF

View File

@ -86,6 +86,8 @@ while :
# get config info if already available (with state value) # get config info if already available (with state value)
source ${infoFile} source ${infoFile}
source <(/home/admin/_cache.sh get state message)
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
source ${configFile} source ${configFile}
@ -101,18 +103,24 @@ while :
fi fi
# TODO: ALSO SEPARATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
# if lightning is syncing or scanning # if lightning is syncing or scanning
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh $lightning) source <(/home/admin/_cache.sh get \
if [ "${walletLocked}" == "1" ] || [ "${CLwalletLocked}" == "1" ]; then lightning \
ln_default_locked \
btc_default_synced \
btc_default_sync_initialblockdownload \
btc_default_blocks_behind \
)
if [ "${lightning}" != "" ] && [ "${lightning}" != "none" ] && [ "${ln_default_locked}" == "1" ]; then
/home/admin/setup.scripts/eventInfoWait.sh "walletlocked" "" lcd /home/admin/setup.scripts/eventInfoWait.sh "walletlocked" "" lcd
sleep 3 sleep 3
continue continue
fi fi
if [ "${syncedToChain}" != "1" ]; then if [ "${btc_default_synced}" != "1" ]; then
/home/admin/setup.scripts/eventBlockchainSync.sh lcd /home/admin/setup.scripts/eventBlockchainSync.sh lcd
sleep 10 sleep 3
continue continue
fi fi

View File

@ -2,15 +2,9 @@
echo "Starting the main menu ..." echo "Starting the main menu ..."
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# MAIN MENU AFTER SETUP # MAIN MENU AFTER SETUP
source ${infoFile} source /home/admin/raspiblitz.info
source ${configFile} source /mnt/hdd/raspiblitz.conf
# FUNCTIONS # FUNCTIONS
@ -38,7 +32,7 @@ confirmation()
} }
# get the local network IP to be displayed on the LCD # get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local) source <(/home/admin/_cache.sh get internet_localip)
if [ ${chain} = test ];then if [ ${chain} = test ];then
netprefix="t" netprefix="t"
@ -64,7 +58,7 @@ fi
if [ ${#lightning} -gt 0 ]; then if [ ${#lightning} -gt 0 ]; then
plus="/ ${lightning} ${plus}" plus="/ ${lightning} ${plus}"
fi fi
BACKTITLE="${localip} / ${hostname} / ${network} ${plus}" BACKTITLE="${internet_localip} / ${hostname} / ${network} ${plus}"
# Basic Options # Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen") OPTIONS+=(INFO "RaspiBlitz Status Screen")

View File

@ -6,9 +6,6 @@
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO # BASIC MENU INFO
WIDTH=64 WIDTH=64
BACKTITLE="RaspiBlitz" BACKTITLE="RaspiBlitz"

View File

@ -8,23 +8,24 @@
echo "Starting SSH user interface ... (please wait)" echo "Starting SSH user interface ... (please wait)"
# CONFIGFILE - configuration of RaspiBlitz # CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf" source /mnt/hdd/raspiblitz.conf 2>/dev/null
source ${configFile} 2>/dev/null
# INFOFILE - state data from bootstrap # INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info" infoFile="/home/admin/raspiblitz.info"
# check if raspiblitz.info exists
systemInfoExists=$(ls ${infoFile} | grep -c "${infoFile}")
if [ "${systemInfoExists}" != "1" ]; then
echo "systemInfoExists(${systemInfoExists})"
echo "FAIL: ${infoFile} does not exist .. which it should at this point."
echo "Check logs & bootstrap.service for errors and report to devs."
exit 1
fi
# get system state information raspiblitz.info
source ${infoFile} source ${infoFile}
source <(/home/admin/_cache.sh get state message)
# only check when first pramater is "newsshsession" (calling from bash.rc)
if [ "$1" == "newsshsession" ]; then
# if already one ssh session is open - ask on the second to exit to terminal
source <(sudo /home/admin/config.scripts/blitz.ssh.sh sessions)
if [ "${ssh_session_count}" != "" ] && [ "${ssh_session_count}" != "1" ]; then
echo "####################################################################"
echo "# You already have another SSH session open ... exiting to terminal."
echo "# To open main menu type command: raspiblitz"
exit 0
fi
fi
# check that basic system phase/state information is available # check that basic system phase/state information is available
if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then
@ -74,13 +75,6 @@ if [ "${state}" = "copystation" ]; then
exit exit
fi fi
# prepare status file
# TODO: this is to be replaced and unified together with raspiblitz.info
# when we move to a background monitoring thread & redis for WebUI with v1.8
sudo touch /var/cache/raspiblitz/raspiblitz.status
sudo chown admin:admin /var/cache/raspiblitz/raspiblitz.status
sudo chmod 740 /var/cache/raspiblitz/raspiblitz.status
##################################### #####################################
# SSH MENU LOOP # SSH MENU LOOP
# this loop runs until user exits or # this loop runs until user exits or
@ -96,6 +90,11 @@ trap quit INT
trap quit TERM trap quit TERM
echo "# start ssh menu loop" echo "# start ssh menu loop"
# put some values on higher scan rate for 10 minute
/home/admin/_cache.sh focus ln_default_locked 2 600 >/dev/null
/home/admin/_cache.sh focus btc_default_synced 2 600 >/dev/null
echo "# starting ssh menu loop ... "
exitMenuLoop=0 exitMenuLoop=0
doneIBD=0 doneIBD=0
while [ ${exitMenuLoop} -eq 0 ] while [ ${exitMenuLoop} -eq 0 ]
@ -105,56 +104,47 @@ do
# Access fresh system info on every loop # Access fresh system info on every loop
# refresh system state information # refresh system state information
source ${infoFile} source <(/home/admin/_cache.sh get \
systemscan_runtime \
# gather fresh status scan and store results in memory state \
# TODO: move this into background loop and unify with redis data storage later setupPhase \
#echo "# blitz.statusscan.sh" btc_default_synced \
ln_default_locked \
firstStatusScanExists=$(ls /var/cache/raspiblitz/raspiblitz.status | grep -c "raspiblitz.status") message \
#echo "firstStatusScanExists(${firstStatusScanExists})" network \
if [ ${firstStatusScanExists} -eq 1 ]; then chain \
lightning \
# run statusscan with timeout - if status scan was not killed it will copy over the internet_localip \
timeout 15 /home/admin/config.scripts/blitz.statusscan.sh ${lightning} > /var/cache/raspiblitz/raspiblitz.status.tmp system_vm_vagrant \
result=$? )
#echo "result(${result})"
if [ "${result}" == "0" ]; then
# statusscan finished in under 10 seconds - use results
cp /var/cache/raspiblitz/raspiblitz.status.tmp /var/cache/raspiblitz/raspiblitz.status
else
# statusscan blocked and was killed - fallback to old results
echo "statusscan blocked (${result}) - fallback to old results"
sleep 1
fi
else
# first time run statusscan without timeout
echo "# running statusscan for the first time ... can take time"
/home/admin/config.scripts/blitz.statusscan.sh ${lightning} > /var/cache/raspiblitz/raspiblitz.status
# background.scan is not ready yet
if [ "${systemscan_runtime}" == "" ]; then
echo "# background.scan not ready yet ... (please wait)"
sleep 4
continue
fi fi
# load statusscan results
source /var/cache/raspiblitz/raspiblitz.status 2>/dev/null
##################################### #####################################
# ALWAYS: Handle System States # ALWAYS: Handle System States
##################################### #####################################
############################ ############################
# LND Wallet Unlock # Wallet Unlock
if [ "${lndActive}" == "1" ] && [ "${walletLocked}" == "1" ] && [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ]; then if [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ] && [ "${ln_default_locked}" == "1" ]; then
#echo "# lnd.unlock.sh"
/home/admin/config.scripts/lnd.unlock.sh # unlock lnd
fi if [ "${lightning}" == "lnd" ]; then
/home/admin/config.scripts/lnd.unlock.sh
fi
# unlock c-lightning
if [ "${lightning}" == "cl" ]; then
/home/admin/config.scripts/cl.hsmtool.sh unlock
sleep 5
fi
# CL Wallet Unlock
if [ "${CLwalletLocked}" == "1" ] && [ "${state}" == "ready" ] && [ "${setupPhase}" == "done" ]; then
/home/admin/config.scripts/cl.hsmtool.sh unlock
sleep 5
fi fi
##################################### #####################################
@ -194,7 +184,7 @@ do
echo "***********************************************************" echo "***********************************************************"
if [ "${state}" == "reboot" ]; then if [ "${state}" == "reboot" ]; then
echo "SSH again into system with:" echo "SSH again into system with:"
echo "ssh admin@${localip}" echo "ssh admin@${internet_localip}"
echo "Use your password A" echo "Use your password A"
echo "***********************************************************" echo "***********************************************************"
fi fi
@ -203,12 +193,11 @@ do
fi fi
##################################### #####################################
# INITIAL BLOCKCHAIN SYNC (SUBLOOP) # MAKE SURE BLOCKCHAIN IS SYNC
##################################### #####################################
if [ "${lightning}" == "" ]; then syncedToChain=1; fi if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ "${btc_default_synced}" != "1" ]; then
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ "${syncedToChain}" != "1" ]; then
/home/admin/setup.scripts/eventBlockchainSync.sh ssh /home/admin/setup.scripts/eventBlockchainSync.sh ssh
sleep 10 sleep 3
continue continue
fi fi
@ -219,6 +208,9 @@ do
# when setup is done & state is ready .. jump to main menu # when setup is done & state is ready .. jump to main menu
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ]; then if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ]; then
# MAIN MENU # MAIN MENU
# remove higher scan rate on values
/home/admin/_cache.sh focus ln_default_locked -1
/home/admin/_cache.sh focus btc_default_synced -1
echo "# 00mainMenu.sh" echo "# 00mainMenu.sh"
/home/admin/00mainMenu.sh /home/admin/00mainMenu.sh
# use the exit code from main menu as signal if menu loop should exited # use the exit code from main menu as signal if menu loop should exited
@ -236,7 +228,7 @@ do
#echo "# DURING SETUP: Handle System State (${state})" #echo "# DURING SETUP: Handle System State (${state})"
# when no HDD on Vagrant - just print info & exit (admin info & exit) # when no HDD on Vagrant - just print info & exit (admin info & exit)
if [ "${state}" == "noHDD" ] && [ ${vagrant} -gt 0 ]; then if [ "${state}" == "noHDD" ] && [ ${system_vm_vagrant} != "0" ]; then
echo "***********************************************************" echo "***********************************************************"
echo "VAGRANT INFO" echo "VAGRANT INFO"
echo "***********************************************************" echo "***********************************************************"

View File

@ -254,7 +254,7 @@ Please keep in mind that thru your LND node id & your previous IP history with y
# change Tor # change Tor
anychange=1 anychange=1
sudo /home/admin/config.scripts/internet.tor.sh ${choice} sudo /home/admin/config.scripts/tor.network.sh ${choice}
needsReboot=1 needsReboot=1
else else
@ -498,7 +498,7 @@ if [ "${testnet}" != "${choice}" ] || \
/home/admin/config.scripts/cl.install.sh on signet /home/admin/config.scripts/cl.install.sh on signet
fi fi
else else
# just turn al lightning testnets off (even if not on before) # just turn all lightning testnets off (even if not on before)
/home/admin/config.scripts/lnd.install.sh off testnet /home/admin/config.scripts/lnd.install.sh off testnet
/home/admin/config.scripts/lnd.install.sh off signet /home/admin/config.scripts/lnd.install.sh off signet
/home/admin/config.scripts/cl.install.sh off testnet /home/admin/config.scripts/cl.install.sh off testnet

View File

@ -130,7 +130,7 @@ case $CHOICE in
# make sure host is named like in the raspiblitz config # make sure host is named like in the raspiblitz config
echo "Setting the Name/Alias/Hostname .." echo "Setting the Name/Alias/Hostname .."
sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${result} sudo /home/admin/config.scripts/lnd.setname.sh mainnet ${result}
sudo sed -i "s/^hostname=.*/hostname=${result}/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set hostname "${result}"
echo "stopping lnd ..." echo "stopping lnd ..."
sudo systemctl stop lnd sudo systemctl stop lnd

View File

@ -7,9 +7,6 @@ source /mnt/hdd/raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $1) source <(/home/admin/config.scripts/network.aliases.sh getvars cl $1)
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
# BASIC MENU INFO # BASIC MENU INFO
WIDTH=64 WIDTH=64
BACKTITLE="RaspiBlitz" BACKTITLE="RaspiBlitz"
@ -108,7 +105,7 @@ case $CHOICE in
clear clear
echo echo
# setting value in the raspiblitz.conf # setting value in the raspiblitz.conf
sudo sed -i "s/^lightning=.*/lightning=cl/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lightning "cl"
echo "# OK - lightning=cl is set in /mnt/hdd/raspiblitz.conf" echo "# OK - lightning=cl is set in /mnt/hdd/raspiblitz.conf"
echo echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."

View File

@ -7,8 +7,6 @@ source /mnt/hdd/raspiblitz.conf
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $1) source <(/home/admin/config.scripts/network.aliases.sh getvars cl $1)
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
NETclEncryptedHSM="${netprefix}clEncryptedHSM" NETclEncryptedHSM="${netprefix}clEncryptedHSM"
# BASIC MENU INFO # BASIC MENU INFO
@ -100,12 +98,8 @@ case $CHOICE in
sudo rm /home/bitcoin/.lightning/${CLNETWORK}/hsm_secret sudo rm /home/bitcoin/.lightning/${CLNETWORK}/hsm_secret
sudo rm /home/bitcoin/.lightning/${CLNETWORK}/*.* sudo rm /home/bitcoin/.lightning/${CLNETWORK}/*.*
# make sure the new hsm_secret is treated as unencrypted and clear autounlock # make sure the new hsm_secret is treated as unencrypted and clear autounlock
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "off"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=off/g" \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clAutoUnlock "off"
/mnt/hdd/raspiblitz.conf
sudo sed -i \
"s/^${netprefix}clAutoUnlock=.*/${netprefix}clEncryptedHSM=off/g" \
/mnt/hdd/raspiblitz.conf
# new # new
/home/admin/config.scripts/cl.hsmtool.sh new $CHAIN /home/admin/config.scripts/cl.hsmtool.sh new $CHAIN
# set the lightningd service file on each active network # set the lightningd service file on each active network

View File

@ -5,8 +5,9 @@ echo "get raspiblitz config"
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD source <(/home/admin/_cache.sh get internet_localip internet_localiprange)
source <(/home/admin/config.scripts/internet.sh status local) localIP="${internet_localip}"
localIPrange="${internet_localiprange}"
# BASIC MENU INFO # BASIC MENU INFO
WIDTH=64 WIDTH=64
@ -163,10 +164,6 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
fi fi
echo "# Running on ${chain}net" echo "# Running on ${chain}net"
echo echo
localIPrange=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\
grep 'eth0\|wlan0\|enp0\|inet' | tail -n1 | awk '{print $2}' |\
awk -F. '{print $1"."$2"."$3".0/24"}')
localIP=$(hostname -I | awk '{print $1}')
allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf) allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf)
bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf) bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc) rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc)
@ -254,7 +251,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
clear clear
echo "# Make sure the bitcoind wallet is on" echo "# Make sure the bitcoind wallet is on"
/home/admin/config.scripts/network.wallet.sh on /home/admin/config.scripts/network.wallet.sh on
/home/admin/config.scripts/internet.hiddenservice.sh bitcoin${BITCOINRPCPORT} ${BITCOINRPCPORT} ${BITCOINRPCPORT} /home/admin/config.scripts/tor.onion-service.sh bitcoin${BITCOINRPCPORT} ${BITCOINRPCPORT} ${BITCOINRPCPORT}
echo echo
echo "The address of the local node is: $TorRPCaddress" echo "The address of the local node is: $TorRPCaddress"
echo echo
@ -275,7 +272,7 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
# remove old entry # remove old entry
sudo sed -i "/# Hidden Service for BITCOIN RPC (mainnet, testnet, signet)/,/^\s*$/{d}" /etc/tor/torrc sudo sed -i "/# Hidden Service for BITCOIN RPC (mainnet, testnet, signet)/,/^\s*$/{d}" /etc/tor/torrc
# remove Hidden Service # remove Hidden Service
/home/admin/config.scripts/internet.hiddenservice.sh off bitcoin${BITCOINRPCPORT} /home/admin/config.scripts/tor.onion-service.sh off bitcoin${BITCOINRPCPORT}
sudo ufw deny from $localIPrange to any port ${BITCOINRPCPORT} sudo ufw deny from $localIPrange to any port ${BITCOINRPCPORT}
restartCore=0 restartCore=0
if [ $allowIPrange -gt 0 ]; then if [ $allowIPrange -gt 0 ]; then

View File

@ -5,9 +5,6 @@ echo "get raspiblitz config"
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# get the local network IP to be displayed on the LCD
source <(/home/admin/config.scripts/internet.sh status local)
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd $1) source <(/home/admin/config.scripts/network.aliases.sh getvars lnd $1)
# make sure lnd wallet is unlocked # make sure lnd wallet is unlocked
@ -136,7 +133,7 @@ case $CHOICE in
clear clear
echo echo
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^lightning=.*/lightning=lnd/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lightning "lnd"
echo "# OK - lightning=lnd is set in /mnt/hdd/raspiblitz.conf" echo "# OK - lightning=lnd is set in /mnt/hdd/raspiblitz.conf"
echo echo
echo "Press ENTER to return to main menu." echo "Press ENTER to return to main menu."

View File

@ -404,9 +404,8 @@ Do you really want to update Bitcoin Core now?
source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh tested) source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh tested)
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
else
sleep 8
fi fi
/home/admin/config.scripts/blitz.shutdown.sh reboot
;; ;;
RECKLESS) RECKLESS)
whiptail --title "UNTESTED Bitcoin Core update to ${bitcoinLatestVersion}" --yes-button "Cancel" \ whiptail --title "UNTESTED Bitcoin Core update to ${bitcoinLatestVersion}" --yes-button "Cancel" \
@ -426,12 +425,12 @@ Do you really want to update Bitcoin Core now?
source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh reckless) source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh reckless)
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
else
sleep 8
fi fi
/home/admin/config.scripts/blitz.shutdown.sh reboot
;; ;;
CUSTOM) CUSTOM)
sudo -u admin /home/admin/config.scripts/bitcoin.update.sh custom sudo -u admin /home/admin/config.scripts/bitcoin.update.sh custom
/home/admin/config.scripts/blitz.shutdown.sh reboot
;; ;;
esac esac
} }
@ -536,7 +535,7 @@ case $CHOICE in
/home/admin/config.scripts/bonus.pyblock.sh update /home/admin/config.scripts/bonus.pyblock.sh update
;; ;;
TOR) TOR)
sudo /home/admin/config.scripts/internet.tor.sh update sudo /home/admin/config.scripts/tor.network.sh update
;; ;;
MEMPOOL) MEMPOOL)
/home/admin/config.scripts/bonus.mempool.sh update /home/admin/config.scripts/bonus.mempool.sh update

View File

@ -90,6 +90,10 @@ echo "******************************"
echo "Sweep all possible Funds" echo "Sweep all possible Funds"
echo "******************************" echo "******************************"
# raise high focus on onchain wallet balance & pending for the next 15min
/home/admin/_cache.sh focus ln_${LNTYPE}_${$chain}net_wallet_onchain_pending 0 900
/home/admin/_cache.sh focus ln_${LNTYPE}_${$chain}net_wallet_onchain_balance 0 900
# execute command # execute command
if [ ${LNTYPE} = "cl" ];then if [ ${LNTYPE} = "cl" ];then
# withdraw destination satoshi [feerate] [minconf] [utxos] # withdraw destination satoshi [feerate] [minconf] [utxos]

View File

@ -67,6 +67,11 @@ else
echo "# OK - the chain is synced" echo "# OK - the chain is synced"
fi fi
# raise high focus on lightning channels next 1 hour
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_active 0 3600
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_inactive 0 3600
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_total 0 3600
echo "#####################################" echo "#####################################"
echo "# Closing All Channels (EXPERIMENTAL)" echo "# Closing All Channels (EXPERIMENTAL)"
echo "#####################################" echo "#####################################"

View File

@ -16,6 +16,9 @@ fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2) source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
# raise high focus on lightning peers next 5min
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_peers 0 300
# let user enter a <pubkey>@host # let user enter a <pubkey>@host
l1="Enter the node pubkey address with host information:" l1="Enter the node pubkey address with host information:"
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735" l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735"

View File

@ -17,7 +17,6 @@ if [ ${#chain} -eq 0 ]; then
fi fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2) source <(/home/admin/config.scripts/network.aliases.sh getvars $1 $2)
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net) source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
# check if chain is in sync # check if chain is in sync
@ -127,6 +126,9 @@ else
sudo apt-get install qrencode -y > /dev/null sudo apt-get install qrencode -y > /dev/null
fi fi
# raise high focus on lightning channel balance next 5min
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_balance 0 300
echo echo
echo "********************" echo "********************"
echo "Here is your invoice" echo "Here is your invoice"

View File

@ -81,6 +81,10 @@ fi
echo "generating QR code ... please wait" echo "generating QR code ... please wait"
/home/admin/config.scripts/blitz.display.sh qr "$network:${address}" /home/admin/config.scripts/blitz.display.sh qr "$network:${address}"
# raise high focus on onchain wallet balance & pending for the next 15min
/home/admin/_cache.sh focus ln_${LNTYPE}_${$chain}net_wallet_onchain_pending 0 900
/home/admin/_cache.sh focus ln_${LNTYPE}_${$chain}net_wallet_onchain_balance 0 900
# dialog with instructions while QR code is shown on LCD # dialog with instructions while QR code is shown on LCD
whiptail --backtitle "Fund your onchain wallet" \ whiptail --backtitle "Fund your onchain wallet" \
--title "Send ${coininfo}" \ --title "Send ${coininfo}" \

View File

@ -79,6 +79,11 @@ if [ ${numConnectedPeers} -eq 0 ]; then
exit 0 exit 0
fi fi
# raise high focus on lightning channels next 1 hour
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_pending 0 3600
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_total 0 3600
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_active 0 3600
# let user pick a peer to open a channels with # let user pick a peer to open a channels with
OPTIONS=() OPTIONS=()
if [ $LNTYPE = cl ];then if [ $LNTYPE = cl ];then

View File

@ -104,6 +104,9 @@ elif [ $LNTYPE = lnd ];then
command="$lncli_alias sendpayment --force --pay_req=${invoice}" command="$lncli_alias sendpayment --force --pay_req=${invoice}"
fi fi
# raise high focus on lightning channel balance next 5min
/home/admin/_cache.sh focus ln_${LNTYPE}_${$CHAIN}_channels_balance 0 300
# info output # info output
clear clear
echo "************************************************************" echo "************************************************************"

938
home.admin/_background.scan.sh Executable file
View File

@ -0,0 +1,938 @@
#!/bin/bash
# This script will loop in the background to gather basic system information.
# It will place those values in the `_cache.sh` system and take care about updates.
# You can use `_cache.sh focus` to make the scanning of a certain value more often.
# LOGS see: sudo journalctl -f -u background.scan
# start with parameter "only-one-loop" (use for testing)
ONLY_ONE_LOOP="0"
if [ "$1" == "only-one-loop" ]; then
ONLY_ONE_LOOP="1"
fi
# start with parameter "install" (to setup service as systemd background running)
if [ "$1" == "install" ]; then
# write systemd service
cat > /etc/systemd/system/background.scan.service <<EOF
# Monitor the RaspiBlitz State
# /etc/systemd/system/background.scan.service
[Unit]
Description=RaspiBlitz Background Monitoring Service
Wants=redis.service
After=redis.service
[Service]
User=root
Group=root
Type=simple
ExecStart=/home/admin/_background.scan.sh
Restart=always
TimeoutSec=10
RestartSec=10
StandardOutput=journal
[Install]
WantedBy=multi-user.target
EOF
# enable systemd service & exit
sudo systemctl enable background.scan
echo "# background.scan.service will start after reboot or calling: sudo systemctl start background.scan"
exit
fi
# check user running
if [ "$EUID" -ne 0 ]; then
echo "FAIL: need to be run as root user"
exit 1
fi
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - persited state data
infoFile="/home/admin/raspiblitz.info"
# better readbale seconds (slightly off to reduce same time window trigger)
MINUTE=60
MINUTE2=115
MINUTE5=290
MINUTE10=585
HOURQUATER=880
HOURHALF=1775
HOUR=3570
DAYHALF=43165
DAY=86360
WEEK=604800
MONTH=2592000
YEAR=31536000
####################################################################
# INIT
####################################################################
# init values
/home/admin/_cache.sh set system_temp_celsius "0"
/home/admin/_cache.sh set system_temp_fahrenheit "0"
/home/admin/_cache.sh set system_count_longscan "0"
/home/admin/_cache.sh set system_count_undervoltage "0"
/home/admin/_cache.sh set system_count_start_blockchain "0"
/home/admin/_cache.sh set system_count_start_lightning "0"
/home/admin/_cache.sh set system_count_start_tui "0"
# import all base values from raspiblitz.info
echo "importing: ${infoFile}"
/home/admin/_cache.sh import $infoFile
# import all base values from raspiblitz.config (if exists)
configFileExists=$(ls ${configFile} | grep -c "${configFile}")
if [ "${configFileExists}" != "0" ]; then
echo "importing: ${configFile}"
/home/admin/_cache.sh import ${configFile}
fi
# version info
echo "importing: _version.info"
/home/admin/_cache.sh import /home/admin/_version.info
# basic hardware info (will not change)
source <(/home/admin/_cache.sh valid \
system_board \
system_ram_mb \
system_ram_gb \
)
if [ "${stillvalid}" == "0" ]; then
source <(/home/admin/config.scripts/blitz.hardware.sh status)
/home/admin/_cache.sh set system_board "${board}"
/home/admin/_cache.sh set system_ram_mb "${ramMB}"
/home/admin/_cache.sh set system_ram_gb "${ramGB}"
fi
# VM detect vagrant
source <(/home/admin/_cache.sh valid system_vm_vagrant)
if [ "${stillvalid}" == "0" ]; then
vagrant=$(df | grep -c "/vagrant")
/home/admin/_cache.sh set system_vm_vagrant "${vagrant}"
fi
# flag that init was done (will be checked on each loop)
/home/admin/_cache.sh set system_init_time "$(date +%s)"
while [ 1 ]
do
####################################################################
# LOOP DATA (BASIC SYSTEM)
# data that is always available
####################################################################
# check that redis contains init data (detect possible restart of redis)
source <(/home/admin/_cache.sh get system_init_time)
if [ "${system_init_time}" == "" ]; then
echo "FAIL: CACHE IS MISSING INIT DATA ... exiting to let systemd restart"
exit 1
fi
# measure time of loop scan
startTime=$(date +%s)
#################
# BASIC SYSTEM
# uptime just do on every run
system_up=$(cat /proc/uptime | grep -o '^[0-9]\+')
/home/admin/_cache.sh set system_up "${system_up}"
# cpu load
cpu_load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
/home/admin/_cache.sh set system_cpu_load "${cpu_load}"
# cpu temp - no measurement in a VM
if [ -d "/sys/class/thermal/thermal_zone0/" ]; then
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
tempC=$((cpu/1000))
tempF=$(((tempC * 18 + 325) / 10))
/home/admin/_cache.sh set system_temp_celsius "${tempC}"
/home/admin/_cache.sh set system_temp_fahrenheit "${tempF}"
fi
# ram
ram=$(free -m | grep Mem | awk '{ print $2 }')
ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
/home/admin/_cache.sh set system_ram_mb "${ram}"
/home/admin/_cache.sh set system_ram_available_mb "${ram_avail}"
# undervoltage
source <(/home/admin/_cache.sh valid system_count_undervoltage)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
echo "updating: undervoltage"
countReports=$(cat /var/log/syslog | grep -c "Under-voltage detected!")
/home/admin/_cache.sh set system_count_undervoltage "${countReports}"
fi
#################
# TOR
source <(/home/admin/_cache.sh valid tor_web_addr)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE5} ]; then
echo "updating: tor"
/home/admin/_cache.sh set tor_web_addr "$(cat /mnt/hdd/tor/web80/hostname 2>/dev/null)"
fi
#################
# UPS (uninterruptible power supply)
source <(/home/admin/_cache.sh valid system_ups_status)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
echo "updating: /home/admin/config.scripts/blitz.ups.sh status"
source <(/home/admin/config.scripts/blitz.ups.sh status)
/home/admin/_cache.sh set system_ups_status "${upsStatus}"
fi
#################
# DATADRIVE
source <(/home/admin/_cache.sh valid \
hdd_mounted \
hdd_ssd \
hdd_btrfs \
hdd_raid \
hdd_uasp \
hdd_capacity_bytes \
hdd_capacity_gb \
hdd_free_bytes \
hdd_free_gb \
hdd_used_info \
hdd_blockchain_data \
)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE2} ]; then
echo "updating: /home/admin/config.scripts/blitz.datadrive.sh status"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
/home/admin/_cache.sh set hdd_mounted "${isMounted}"
/home/admin/_cache.sh set hdd_ssd "${isSSD}"
/home/admin/_cache.sh set hdd_btrfs "${isBTRFS}"
/home/admin/_cache.sh set hdd_raid "${isRaid}"
/home/admin/_cache.sh set hdd_uasp "${hddAdapterUSAP}"
/home/admin/_cache.sh set hdd_capacity_bytes "${hddBytes}"
/home/admin/_cache.sh set hdd_capacity_gb "${hddGigaBytes}"
/home/admin/_cache.sh set hdd_free_bytes "${hddDataFreeBytes}"
/home/admin/_cache.sh set hdd_free_gb "${hddDataFreeGB}"
/home/admin/_cache.sh set hdd_used_info "${hddUsedInfo}"
/home/admin/_cache.sh set hdd_blockchain_data "${hddBlocksBitcoin}"
fi
#################
# INTERNET
# GLOBAL & PUBLIC IP
source <(/home/admin/_cache.sh get runBehindTor)
if [ "${runBehindTor}" == "off" ]; then
source <(/home/admin/_cache.sh valid \
internet_public_ipv6 \
internet_public_ip_detected \
internet_public_ip_forced \
internet_public_ip_clean \
)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${HOUR} ]; then
echo "updating: /home/admin/config.scripts/internet.sh status global"
source <(/home/admin/config.scripts/internet.sh status global)
/home/admin/_cache.sh set internet_public_ipv6 "${ipv6}"
# globalip --> ip detected from the outside
/home/admin/_cache.sh set internet_public_ip_detected "${globalip}"
# publicip --> may consider the static IP overide by raspiblitz config
/home/admin/_cache.sh set internet_public_ip_forced "${publicip}"
# cleanip --> the publicip with no brackets like used on IPv6
/home/admin/_cache.sh set internet_public_ip_clean "${cleanip}"
fi
fi
# LOCAL IP & data
source <(/home/admin/_cache.sh valid \
internet_localip \
internet_localiprange \
internet_dhcp \
internet_rx \
internet_tx \
)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
echo "updating: /home/admin/config.scripts/internet.sh status local"
source <(/home/admin/config.scripts/internet.sh status local)
/home/admin/_cache.sh set internet_localip "${localip}"
/home/admin/_cache.sh set internet_localiprange "${localiprange}"
/home/admin/_cache.sh set internet_dhcp "${dhcp}"
/home/admin/_cache.sh set internet_rx "${network_rx}"
/home/admin/_cache.sh set internet_tx "${network_tx}"
fi
# connection to internet
source <(/home/admin/_cache.sh valid internet_online)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${HOURQUATER} ]; then
echo "updating: /home/admin/config.scripts/internet.sh status online"
source <(/home/admin/config.scripts/internet.sh status online)
/home/admin/_cache.sh set internet_online "${online}"
fi
# exit if still setup or higher system stopped
source <(/home/admin/_cache.sh get setupPhase state)
if [ "${setupPhase}" != "done" ] ||
[ "${state}" == "" ] ||
[ "${state}" == "copysource" ] ||
[ "${state}" == "copytarget" ]; then
# dont skip when setup/recovery is in "waitsync" state
if [ "${state}" != "waitsync" ]; then
endTime=$(date +%s)
runTime=$((${endTime}-${startTime}))
# write info on scan runtime into cache (use as signal that the first systemscan worked)
/home/admin/_cache.sh set systemscan_runtime "${runTime}"
echo "Skipping deeper system scan - setupPhase(${setupPhase}) state(${state})"
sleep 1
continue
fi
fi
####################################################################
# LOOP DATA (DEEPER SYSTEM)
# data that may be based on setup phase or configuration
####################################################################
# by default will only scan the btc & lightning instances that are set to default
# but can scan/monitor all that are switched on when `system_scan_all=on` in config
# read/update config values
source /mnt/hdd/raspiblitz.conf
# check if a one time `system_scan_all_once=1` is set on cache
# will trigger a scan_all for one loop
source <(/home/admin/_cache.sh get system_scan_all_once)
if [ "${system_scan_all_once}" == "1" ]; then
echo "system_scan_all_once found --> TRIGGER system_scan_all for one loop"
/home/admin/_cache.sh set system_scan_all_once "0"
system_scan_all="on"
fi
# check if a temporary `system_scan_all_temp=1` is set on cache
# will trigger a scan_all until its gone or `0`
source <(/home/admin/_cache.sh get system_scan_all_temp)
if [ "${system_scan_all_temp}" == "1" ]; then
echo "system_scan_all_temp found --> TRIGGER system_scan_all"
system_scan_all="on"
fi
###################
# BITCOIN
if [ "${network}" == "bitcoin" ]; then
# loop thru mainet, testnet & signet
networks=( "main" "test" "sig" )
for CHAIN in "${networks[@]}"
do
# check if is default chain (multiple networks can run at the same time - but only one is default)
isDefaultChain=$(echo "${CHAIN}" | grep -c "${chain}")
# skip if network is not on by config
if [ "${CHAIN}" == "main" ] && [ "${mainnet}" != "on" ] && [ "${isDefaultChain}" != "1" ]; then
#echo "skip btc ${CHAIN}net scan - because its off"
continue
fi
if [ "${CHAIN}" == "test" ] && [ "${testnet}" != "on" ]; then
#echo "skip btc ${CHAIN}net scan - because its off"
continue
fi
if [ "${CHAIN}" == "sig" ] && [ "${signet}" != "on" ]; then
#echo "skip btc ${CHAIN}net scan - because its off"
continue
fi
# only scan non defaults when set by parameter from config
if [ "${system_scan_all}" != "on" ]; then
if [ "${isDefaultChain}" != "1" ]; then
#echo "skip btc ${CHAIN}net scan - because its not default"
continue
fi
fi
# update basic status values always
source <(/home/admin/_cache.sh valid \
btc_${CHAIN}net_version \
btc_${CHAIN}net_running \
btc_${CHAIN}net_ready \
btc_${CHAIN}net_online \
btc_${CHAIN}net_error_short \
btc_${CHAIN}net_error_full \
)
if [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
btc_default_version \
btc_default_running \
btc_default_ready \
btc_default_online \
btc_default_error_short \
btc_default_error_full \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt 30 ]; then
echo "updating: /home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net status"
source <(/home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net status)
/home/admin/_cache.sh set btc_${CHAIN}net_activated "1"
/home/admin/_cache.sh set btc_${CHAIN}net_version "${btc_version}"
/home/admin/_cache.sh set btc_${CHAIN}net_running "${btc_running}"
/home/admin/_cache.sh set btc_${CHAIN}net_ready "${btc_ready}"
/home/admin/_cache.sh set btc_${CHAIN}net_online "${btc_online}"
/home/admin/_cache.sh set btc_${CHAIN}net_error_short "${btc_error_short}"
/home/admin/_cache.sh set btc_${CHAIN}net_error_full "${btc_error_full}"
# when default chain transfere values
if [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set btc_default_activated "1"
/home/admin/_cache.sh set btc_default_version "${btc_version}"
/home/admin/_cache.sh set btc_default_running "${btc_running}"
/home/admin/_cache.sh set btc_default_ready "${btc_ready}"
/home/admin/_cache.sh set btc_default_online "${btc_online}"
/home/admin/_cache.sh set btc_default_error_short "${btc_error_short}"
/home/admin/_cache.sh set btc_default_error_full "${btc_error_full}"
fi
fi
# update detail infos only when ready (get as value from cache)
source <(/home/admin/_cache.sh meta btc_${CHAIN}net_ready)
if [ "${value}" == "1" ]; then
# check if network needs update
source <(/home/admin/_cache.sh valid \
btc_${CHAIN}net_synced \
btc_${CHAIN}net_blocks_headers \
btc_${CHAIN}net_blocks_verified \
btc_${CHAIN}net_blocks_behind \
btc_${CHAIN}net_sync_progress \
btc_${CHAIN}net_sync_percentage \
btc_${CHAIN}net_sync_initialblockdownload \
)
if [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
btc_default_synced \
btc_default_blocks_headers \
btc_default_blocks_verified \
btc_default_blocks_behind \
btc_default_sync_progress \
btc_default_sync_percentage \
btc_default_sync_initialblockdownload \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
error=""
echo "updating: /home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net info"
source <(/home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net info)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set btc_${CHAIN}net_synced "${btc_synced}"
/home/admin/_cache.sh set btc_${CHAIN}net_blocks_headers "${btc_blocks_headers}"
/home/admin/_cache.sh set btc_${CHAIN}net_blocks_verified "${btc_blocks_verified}"
/home/admin/_cache.sh set btc_${CHAIN}net_blocks_behind "${btc_blocks_behind}"
/home/admin/_cache.sh set btc_${CHAIN}net_sync_progress "${btc_sync_progress}"
/home/admin/_cache.sh set btc_${CHAIN}net_sync_percentage "${btc_sync_percentage}"
/home/admin/_cache.sh set btc_${CHAIN}net_sync_initialblockdownload "${btc_sync_initialblockdownload}"
if [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set btc_default_synced "${btc_synced}"
/home/admin/_cache.sh set btc_default_blocks_headers "${btc_blocks_headers}"
/home/admin/_cache.sh set btc_default_blocks_verified "${btc_blocks_verified}"
/home/admin/_cache.sh set btc_default_blocks_behind "${btc_blocks_behind}"
/home/admin/_cache.sh set btc_default_sync_progress "${btc_sync_progress}"
/home/admin/_cache.sh set btc_default_sync_percentage "${btc_sync_percentage}"
/home/admin/_cache.sh set btc_default_sync_initialblockdownload "${btc_sync_initialblockdownload}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if network needs update
source <(/home/admin/_cache.sh valid \
btc_${CHAIN}net_peers \
btc_${CHAIN}net_address \
btc_${CHAIN}net_port \
)
if [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
btc_default_peers \
btc_default_address \
btc_default_port \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
error=""
echo "updating: /home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net network"
source <(/home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net network)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set btc_${CHAIN}net_peers "${btc_peers}"
/home/admin/_cache.sh set btc_${CHAIN}net_address "${btc_address}"
/home/admin/_cache.sh set btc_${CHAIN}net_port "${btc_port}"
if [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set btc_default_peers "${btc_peers}"
/home/admin/_cache.sh set btc_default_address "${btc_address}"
/home/admin/_cache.sh set btc_default_port "${btc_port}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if mempool needs update
source <(/home/admin/_cache.sh valid \
btc_${CHAIN}net_mempool_transactions \
)
if [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
btc_default_mempool_transactions \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE5} ]; then
error=""
echo "updating: /home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net mempool"
source <(/home/admin/config.scripts/bitcoin.monitor.sh ${CHAIN}net mempool)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set btc_${CHAIN}net_mempool_transactions "${btc_mempool_transactions}"
if [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set btc_default_mempool_transactions "${btc_mempool_transactions}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
fi
done
fi
###################
# Lightning (lnd)
# loop thru mainet, testnet & signet
networks=( "main" "test" "sig" )
for CHAIN in "${networks[@]}"
do
# skip if network is not on by config
if [ "${CHAIN}" == "main" ] && [ "${lnd}" != "on" ]; then
#echo "skip lnd ${CHAIN}net scan - because its off"
continue
fi
if [ "${CHAIN}" == "test" ] && [ "${tlnd}" != "on" ]; then
#echo "skip lnd ${CHAIN}net scan - because its off"
continue
fi
if [ "${CHAIN}" == "sig" ] && [ "${slnd}" != "on" ]; then
#echo "skip lnd ${CHAIN}net scan - because its off"
continue
fi
# check if default chain & lightning
isDefaultChain=$(echo "${CHAIN}" | grep -c "${chain}")
isDefaultLightning=$(echo "${lightning}" | grep -c "lnd")
# only scan non defaults when set by parameter from config
if [ "${system_scan_all}" != "on" ]; then
if [ "${isDefaultChain}" != "1" ] || [ ${isDefaultLightning} != "1" ]; then
#echo "skip lnd ${CHAIN}net scan - because its not default"
continue
fi
fi
# update basic status values always
source <(/home/admin/_cache.sh valid \
ln_lnd_${CHAIN}net_locked \
ln_lnd_${CHAIN}net_version \
ln_lnd_${CHAIN}net_running \
ln_lnd_${CHAIN}net_ready \
ln_lnd_${CHAIN}net_online \
ln_lnd_${CHAIN}net_error_short \
ln_lnd_${CHAIN}net_error_full \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_locked \
ln_default_version \
ln_default_running \
ln_default_ready \
ln_default_online \
ln_default_error_short \
ln_default_error_full \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt 30 ]; then
echo "updating: /home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net status"
source <(/home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net status)
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_activated "1"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_locked "${ln_lnd_locked}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_version "${ln_lnd_version}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_running "${ln_lnd_running}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_ready "${ln_lnd_ready}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_online "${ln_lnd_online}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_error_short "${ln_lnd_error_short}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_error_full "${ln_lnd_error_full}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_activated "1"
/home/admin/_cache.sh set ln_default_locked "${ln_lnd_locked}"
/home/admin/_cache.sh set ln_default_version "${ln_lnd_version}"
/home/admin/_cache.sh set ln_default_running "${ln_lnd_running}"
/home/admin/_cache.sh set ln_default_ready "${ln_lnd_ready}"
/home/admin/_cache.sh set ln_default_online "${ln_lnd_online}"
/home/admin/_cache.sh set ln_default_error_short "${ln_lnd_error_short}"
/home/admin/_cache.sh set ln_default_error_full "${ln_lnd_error_full}"
fi
fi
# update detail infos only when ready
source <(/home/admin/_cache.sh meta ln_lnd_${CHAIN}net_ready)
if [ "${value}" == "1" ]; then
# check if config needs update
source <(/home/admin/_cache.sh valid ln_lnd_${CHAIN}net_alias)
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE5} ]; then
error=""
echo "updating: /home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net config"
source <(/home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net config)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_alias "${ln_lnd_alias}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_alias "${ln_lnd_alias}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if info needs update
source <(/home/admin/_cache.sh valid \
ln_lnd_${CHAIN}net_address \
ln_lnd_${CHAIN}net_tor \
ln_lnd_${CHAIN}net_sync_chain \
ln_lnd_${CHAIN}net_sync_graph \
ln_lnd_${CHAIN}net_channels_pending \
ln_lnd_${CHAIN}net_channels_active \
ln_lnd_${CHAIN}net_channels_inactive \
ln_lnd_${CHAIN}net_channels_total \
ln_lnd_${CHAIN}net_peers \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_address \
ln_default_tor \
ln_default_sync_chain \
ln_default_sync_progress \
ln_default_channels_pending \
ln_default_channels_active \
ln_default_channels_inactive \
ln_default_channels_total \
ln_default_peers \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
error=""
echo "updating: /home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net info"
source <(/home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net info)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_address "${ln_lnd_address}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_tor "${ln_lnd_tor}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_sync_chain "${ln_lnd_sync_chain}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_sync_progress "${ln_lnd_sync_progress}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_sync_graph "${ln_lnd_sync_graph}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_channels_pending "${ln_lnd_channels_pending}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_channels_active "${ln_lnd_channels_active}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_channels_inactive "${ln_lnd_channels_inactive}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_channels_total "${ln_lnd_channels_total}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_peers "${ln_lnd_peers}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_address "${ln_lnd_address}"
/home/admin/_cache.sh set ln_default_tor "${ln_lnd_tor}"
/home/admin/_cache.sh set ln_default_sync_chain "${ln_lnd_sync_chain}"
/home/admin/_cache.sh set ln_default_sync_progress "${ln_lnd_sync_progress}"
/home/admin/_cache.sh set ln_default_channels_pending "${ln_lnd_channels_pending}"
/home/admin/_cache.sh set ln_default_channels_active "${ln_lnd_channels_active}"
/home/admin/_cache.sh set ln_default_channels_inactive "${ln_lnd_channels_inactive}"
/home/admin/_cache.sh set ln_default_channels_total "${ln_lnd_channels_total}"
/home/admin/_cache.sh set ln_default_peers "${ln_lnd_peers}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if wallet needs update
source <(/home/admin/_cache.sh valid \
ln_lnd_${CHAIN}net_wallet_onchain_balance \
ln_lnd_${CHAIN}net_wallet_onchain_pending \
ln_lnd_${CHAIN}net_wallet_channels_balance \
ln_lnd_${CHAIN}net_wallet_channels_pending \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_wallet_onchain_balance \
ln_default_wallet_onchain_pending \
ln_default_wallet_channels_balance \
ln_default_wallet_channels_pending \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt 22 ]; then
error=""
echo "updating: /home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net wallet"
source <(/home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net wallet)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_wallet_onchain_balance "${ln_lnd_wallet_onchain_balance}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_wallet_onchain_pending "${ln_lnd_wallet_onchain_pending}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_wallet_channels_balance "${ln_lnd_wallet_channels_balance}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_wallet_channels_pending "${ln_lnd_wallet_channels_pending}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_wallet_onchain_balance "${ln_lnd_wallet_onchain_balance}"
/home/admin/_cache.sh set ln_default_wallet_onchain_pending "${ln_lnd_wallet_onchain_pending}"
/home/admin/_cache.sh set ln_default_wallet_channels_balance "${ln_lnd_wallet_channels_balance}"
/home/admin/_cache.sh set ln_default_wallet_channels_pending "${ln_lnd_wallet_channels_pending}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if fees needs update
source <(/home/admin/_cache.sh valid \
ln_lnd_${CHAIN}net_fees_daily \
ln_lnd_${CHAIN}net_fees_weekly \
ln_lnd_${CHAIN}net_fees_month \
ln_lnd_${CHAIN}net_fees_total \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_fees_total \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE5} ]; then
error=""
echo "updating: /home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net fees"
source <(/home/admin/config.scripts/lnd.monitor.sh ${CHAIN}net fees)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_fees_daily "${ln_lnd_fees_daily}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_fees_weekly "${ln_lnd_fees_weekly}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_fees_month "${ln_lnd_fees_month}"
/home/admin/_cache.sh set ln_lnd_${CHAIN}net_fees_total "${ln_lnd_fees_total}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_fees_total "${ln_lnd_fees_total}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
fi
done
###################
# Lightning (c-lightning)
# loop thru mainet, testnet & signet
networks=( "main" "test" "sig" )
for CHAIN in "${networks[@]}"
do
# skip if network is not on by config
if [ "${CHAIN}" == "main" ] && [ "${cl}" != "on" ]; then
#echo "skip c-lightning mainnet scan - because its off"
continue
fi
if [ "${CHAIN}" == "test" ] && [ "${tcl}" != "on" ]; then
#echo "skip c-lightning testnet scan - because its off"
continue
fi
if [ "${CHAIN}" == "sig" ] && [ "${scl}" != "on" ]; then
#echo "skip c-lightning signet scan - because its off"
continue
fi
# check if default chain & lightning
isDefaultChain=$(echo "${CHAIN}" | grep -c "${chain}")
isDefaultLightning=$(echo "${lightning}" | grep -c "cl")
# only scan non defaults when set by parameter from config
if [ "${system_scan_all}" != "on" ]; then
if [ "${isDefaultChain}" != "1" ] || [ ${isDefaultLightning} != "1" ]; then
#echo "skip cl ${CHAIN}net scan - because its not default"
continue
fi
fi
# TODO: c-lightning is seen as "always unlocked" for now - needs to be implemented later #2691
# update basic status values always
source <(/home/admin/_cache.sh valid \
ln_cl_${CHAIN}net_version \
ln_cl_${CHAIN}net_running \
ln_cl_${CHAIN}net_ready \
ln_cl_${CHAIN}net_online \
ln_cl_${CHAIN}net_error_short \
ln_cl_${CHAIN}net_error_full \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_version \
ln_default_running \
ln_default_ready \
ln_default_online \
ln_default_error_short \
ln_default_error_full \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt 30 ]; then
echo "updating: /home/admin/config.scripts/cl.monitor.sh ${CHAIN}net status"
source <(/home/admin/config.scripts/cl.monitor.sh ${CHAIN}net status)
/home/admin/_cache.sh set ln_cl_${CHAIN}net_activated "1"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_version "${ln_cl_version}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_running "${ln_cl_running}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_ready "${ln_cl_ready}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_online "${ln_cl_online}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_locked "0"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_error_short "${ln_cl_error_short}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_error_full "${ln_cl_error_full}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_activated "1"
/home/admin/_cache.sh set ln_default_version "${cl_lnd_version}"
/home/admin/_cache.sh set ln_default_running "${lc_running}"
/home/admin/_cache.sh set ln_default_ready "${cl_ready}"
/home/admin/_cache.sh set ln_default_online "${cl_online}"
/home/admin/_cache.sh set ln_default_locked "0"
/home/admin/_cache.sh set ln_default_error_short "${cl_error_short}"
/home/admin/_cache.sh set ln_default_error_full "${cl_error_full}"
fi
fi
# update detail infos only when ready
source <(/home/admin/_cache.sh meta ln_cl_${CHAIN}net_ready)
if [ "${value}" == "1" ]; then
# check if info needs update
source <(/home/admin/_cache.sh valid \
ln_cl_${CHAIN}net_alias \
ln_cl_${CHAIN}net_address \
ln_cl_${CHAIN}net_tor \
ln_cl_${CHAIN}net_peers \
ln_cl_${CHAIN}net_sync_chain \
ln_cl_${CHAIN}net_channels_pending \
ln_cl_${CHAIN}net_channels_active \
ln_cl_${CHAIN}net_channels_inactive \
ln_cl_${CHAIN}net_channels_total \
ln_cl_${CHAIN}net_fees_total \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_alias \
ln_default_address \
ln_default_tor \
ln_default_peers \
ln_default_sync_chain \
ln_default_channels_pending \
ln_default_channels_active \
ln_default_channels_inactive \
ln_default_channels_total \
ln_default_fees_total \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
error=""
echo "updating: /home/admin/config.scripts/cl.monitor.sh ${CHAIN}net info"
source <(/home/admin/config.scripts/cl.monitor.sh ${CHAIN}net info)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_cl_${CHAIN}net_alias "${ln_cl_alias}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_address "${ln_cl_address}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_tor "${ln_cl_tor}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_peers "${ln_cl_peers}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_sync_chain "${ln_cl_sync_chain}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_sync_progress "${ln_cl_sync_progress}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_channels_pending "${ln_cl_channels_pending}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_channels_active "${ln_cl_channels_active}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_channels_inactive "${ln_cl_channels_inactive}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_channels_total "${ln_cl_channels_total}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_fees_total "${ln_cl_fees_total}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_alias "${ln_cl_alias}"
/home/admin/_cache.sh set ln_default_address "${ln_cl_address}"
/home/admin/_cache.sh set ln_default_tor "${ln_cl_tor}"
/home/admin/_cache.sh set ln_default_peers "${ln_cl_fees_total}"
/home/admin/_cache.sh set ln_default_sync_chain "${ln_cl_sync_chain}"
/home/admin/_cache.sh set ln_default_sync_progress "${ln_cl_sync_progress}"
/home/admin/_cache.sh set ln_default_hannels_pending "${ln_cl_channels_pending}"
/home/admin/_cache.sh set ln_default_channels_active "${ln_cl_channels_active}"
/home/admin/_cache.sh set ln_default_channels_inactive "${ln_cl_channels_inactive}"
/home/admin/_cache.sh set ln_default_channels_total "${ln_cl_channels_total}"
/home/admin/_cache.sh set ln_default_fees_total "${ln_cl_fees_total}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
# check if wallet needs update
source <(/home/admin/_cache.sh valid \
ln_cl_${CHAIN}net_wallet_onchain_balance \
ln_cl_${CHAIN}net_wallet_onchain_pending \
ln_cl_${CHAIN}net_wallet_channels_balance \
ln_cl_${CHAIN}net_wallet_channels_pending \
)
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ] && [ "${stillvalid}" == "1" ]; then
source <(/home/admin/_cache.sh valid \
ln_default_wallet_onchain_balance \
ln_default_wallet_onchain_pending \
ln_default_wallet_channels_balance \
ln_default_wallet_channels_pending \
)
fi
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE} ]; then
error=""
echo "updating: /home/admin/config.scripts/cl.monitor.sh ${CHAIN}net wallet"
source <(/home/admin/config.scripts/cl.monitor.sh ${CHAIN}net wallet)
if [ "${error}" == "" ]; then
/home/admin/_cache.sh set ln_cl_${CHAIN}net_wallet_onchain_balance "${ln_cl_wallet_onchain_balance}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_wallet_onchain_pending "${ln_cl_wallet_onchain_pending}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_wallet_channels_balance "${ln_cl_wallet_channels_balance}"
/home/admin/_cache.sh set ln_cl_${CHAIN}net_wallet_channels_pending "${ln_cl_wallet_channels_pending}"
if [ "${isDefaultLightning}" == "1" ] && [ "${isDefaultChain}" == "1" ]; then
/home/admin/_cache.sh set ln_default_wallet_onchain_balance "${ln_cl_wallet_onchain_balance}"
/home/admin/_cache.sh set ln_default_wallet_onchain_pending "${ln_cl_wallet_onchain_pending}"
/home/admin/_cache.sh set ln_default_wallet_channels_balance "${ln_cl_wallet_channels_balance}"
/home/admin/_cache.sh set ln_default_wallet_channels_pending "${ln_cl_wallet_channels_pending}"
fi
else
echo "!! ERROR --> ${error}"
fi
fi
fi
done
#################
# DONE
# calculate how many seconds the script was running
endTime=$(date +%s)
runTime=$((${endTime}-${startTime}))
# write info on scan runtime into cache (use as signal that the first systemscan worked)
/home/admin/_cache.sh set systemscan_runtime "${runTime}"
echo "SystemScan Loop done in ${runTime} seconds"
# log warning if script took too long
if [ ${runTime} -gt ${MINUTE} ]; then
echo "WARNING: HANGING SYSTEM ... systemscan loop took too long (${runTime} seconds)!" 1>&2
/home/admin/_cache.sh increment system_count_longscan
fi
# small sleep before next loop
sleep 2
# if was started with special parameter
if [ "${ONLY_ONE_LOOP}" == "1" ]; then
echo "Exiting because ONLY_ONE_LOOP==1"
exit 0
fi
done

View File

@ -12,19 +12,11 @@ configFile="/mnt/hdd/raspiblitz.conf"
# LOGS see: sudo journalctl -f -u background # LOGS see: sudo journalctl -f -u background
# Check if HDD contains configuration
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
source ${configFile}
else
source ${infoFile}
fi
echo "_background.sh STARTED" echo "_background.sh STARTED"
# global vars # global vars
blitzTUIHeartBeatLine="" blitzTUIHeartBeatLine=""
blitzTUIRestarts=0 /home/admin/_cache.sh set blitzTUIRestarts "0"
counter=0 counter=0
while [ 1 ] while [ 1 ]
@ -47,8 +39,10 @@ do
# gather the uptime seconds # gather the uptime seconds
upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+') upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+')
# source info file fresh on every loop # source info & config file fresh on every loop
source ${infoFile} 2>/dev/null source ${infoFile} 2>/dev/null
source ${configFile} 2>/dev/null
source <(/home/admin/_cache.sh get state setupPhase)
#################################################### ####################################################
# SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES # SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES
@ -61,16 +55,6 @@ do
continue continue
fi fi
####################################################
# CHECK IF LOCAL IP CHANGED
####################################################
oldLocalIP="${localip}";
source <(/home/admin/config.scripts/internet.sh status)
if [ "${oldLocalIP}" != "${localip}" ]; then
echo "local IP changed old(${oldLocalIP}) new(${localip}) - updating in raspiblitz.info"
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
fi
#################################################### ####################################################
# SKIP REST OF THE TASKS IF STILL IN SETUP PHASE # SKIP REST OF THE TASKS IF STILL IN SETUP PHASE
#################################################### ####################################################
@ -98,32 +82,13 @@ do
# detect a missing DHCP config # detect a missing DHCP config
if [ "${localip:0:4}" = "169." ]; then if [ "${localip:0:4}" = "169." ]; then
echo "Missing DHCP detected ... trying emergency reboot" echo "Missing DHCP detected ... trying emergency reboot"
sudo /home/admin/config.scripts/blitz.shutdown.sh reboot /home/admin/config.scripts/blitz.shutdown.sh reboot
else else
echo "DHCP OK" echo "DHCP OK"
fi fi
fi fi
####################################################
# CHECK FOR UNDERVOLTAGE REPORTS
# every 1 hour scan for undervoltage reports
####################################################
recheckUndervoltage=$(($counter % 3600))
if [ ${recheckUndervoltage} -eq 1 ]; then
echo "*** RECHECK UNDERVOLTAGE ***"
countReports=$(sudo cat /var/log/syslog | grep -c "Under-voltage detected!")
echo "${countReports} undervoltage reports found in syslog"
if ! grep -Eq "^undervoltageReports=" ${infoFile}; then
# write new value to info file
undervoltageReports="${countReports}"
echo "undervoltageReports=${undervoltageReports}" >> ${infoFile}
else
# update value in info file
sed -i "s/^undervoltageReports=.*/undervoltageReports=${countReports}/g" ${infoFile}
fi
fi
#################################################### ####################################################
# RECHECK PUBLIC IP # RECHECK PUBLIC IP
# #
@ -136,6 +101,7 @@ do
# every 15min - not too often # every 15min - not too often
# because its a ping to external service # because its a ping to external service
recheckPublicIP=$((($counter % 900)+1)) recheckPublicIP=$((($counter % 900)+1))
# prevent when lndAddress is set # prevent when lndAddress is set
if [ ${#lndAddress} -gt 3 ]; then if [ ${#lndAddress} -gt 3 ]; then
recheckPublicIP=0 recheckPublicIP=0
@ -151,9 +117,7 @@ do
echo "*** RECHECK PUBLIC IP ***" echo "*** RECHECK PUBLIC IP ***"
# execute only after setup when config exists # execute only after setup when config exists
if [ ${configExists} -eq 1 ]; then publicIPChanged=$(/home/admin/config.scripts/internet.sh update-publicip | grep -c 'ip_changed=1')
publicIPChanged=$(/home/admin/config.scripts/internet.sh update-publicip | grep -c 'ip_changed=1')
fi
# check if changed # check if changed
if [ ${publicIPChanged} -gt 0 ]; then if [ ${publicIPChanged} -gt 0 ]; then
@ -178,18 +142,18 @@ do
# and we will get more connections if this matches our real IP address # and we will get more connections if this matches our real IP address
# otherwise the bitcoin-node connections will slowly decline # otherwise the bitcoin-node connections will slowly decline
echo "IPv6 only is enabled => restart bitcoind to pickup up new publicIP as local IP" echo "IPv6 only is enabled => restart bitcoind to pickup up new publicIP as local IP"
sudo systemctl stop bitcoind systemctl stop bitcoind
sleep 3 sleep 3
sudo systemctl start bitcoind systemctl start bitcoind
# if BTCRPCexplorer is currently running # if BTCRPCexplorer is currently running
# it needs to be restarted to pickup the new IP for its "Node Status Page" # it needs to be restarted to pickup the new IP for its "Node Status Page"
# but this is only needed in IPv6 only mode # but this is only needed in IPv6 only mode
breIsRunning=$(sudo systemctl status btc-rpc-explorer 2>/dev/null | grep -c 'active (running)') breIsRunning=$(systemctl status btc-rpc-explorer 2>/dev/null | grep -c 'active (running)')
if [ ${breIsRunning} -eq 1 ]; then if [ ${breIsRunning} -eq 1 ]; then
echo "BTCRPCexplorer is running => restart BTCRPCexplorer to pickup up new publicIP for the bitcoin node" echo "BTCRPCexplorer is running => restart BTCRPCexplorer to pickup up new publicIP for the bitcoin node"
sudo systemctl stop btc-rpc-explorer systemctl stop btc-rpc-explorer
sudo systemctl start btc-rpc-explorer systemctl start btc-rpc-explorer
else else
echo "new publicIP but no BTCRPCexplorer restart because not running" echo "new publicIP but no BTCRPCexplorer restart because not running"
fi fi
@ -205,8 +169,8 @@ do
if [ "${autoUnlock}" = "on" ]; then if [ "${autoUnlock}" = "on" ]; then
if [ "${publicIP_Old}" != "::1" ] && [ "${publicIP_New}" != "::1" ]; then if [ "${publicIP_Old}" != "::1" ] && [ "${publicIP_New}" != "::1" ]; then
echo "restart LND to pickup up new publicIP" echo "restart LND to pickup up new publicIP"
sudo systemctl stop lnd systemctl stop lnd
sudo systemctl start lnd systemctl start lnd
else else
echo "publicIP_Old OR publicIP_New is equal ::1 => no need to restart LND" echo "publicIP_Old OR publicIP_New is equal ::1 => no need to restart LND"
fi fi
@ -223,18 +187,39 @@ do
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
/home/admin/config.scripts/internet.dyndomain.sh update
else
echo "'dynUpdateUrl' not set in ${configFile}"
fi
fi
############################### ###############################
# Blockchain Sync Monitor # Blockchain Sync Monitor
############################### ###############################
# check every 1min # check every 1min
recheckSync=$(($counter % 60)) recheckSync=$(($counter % 60))
if [ ${recheckSync} -eq 1 ]; then if [ ${recheckSync} -eq 1 ] && [ "${chain}" == "main" ]; then
source <(sudo /home/admin/config.scripts/network.monitor.sh peer-status) source <(/home/admin/config.scripts/bitcoin.monitor.sh mainnet network)
echo "Blockchain Sync Monitoring: peers=${peers}" echo "Blockchain Sync Monitoring: peers=${peers}"
if [ "${peers}" == "0" ] && [ "${running}" == "1" ]; then if [ "${btc_peers}" == "0" ] && [ "${btc_running}" == "1" ]; then
echo "Blockchain Sync Monitoring: ZERO PEERS DETECTED .. doing out-of-band kickstart" echo "Blockchain Sync Monitoring: ZERO PEERS DETECTED .. doing out-of-band kickstart"
sudo /home/admin/config.scripts/network.monitor.sh peer-kickstart /home/admin/config.scripts/bitcoin.monitor.sh mainnet peer-kickstart
fi fi
fi fi
@ -245,23 +230,20 @@ do
# check every 30sec # check every 30sec
recheckBlitzTUI=$(($counter % 30)) recheckBlitzTUI=$(($counter % 30))
if [ "${touchscreen}" == "1" ] && [ ${recheckBlitzTUI} -eq 1 ]; then if [ "${touchscreen}" == "1" ] && [ ${recheckBlitzTUI} -eq 1 ]; then
echo "BlitzTUI Monitoring Check" echo "BlitzTUI Monitoring Check"
if [ -d "/var/cache/raspiblitz" ]; then if [ -d "/var/cache/raspiblitz" ]; then
latestHeartBeatLine=$(sudo tail -n 300 /var/cache/raspiblitz/pi/blitz-tui.log | grep beat | tail -n 1) latestHeartBeatLine=$(tail -n 300 /var/cache/raspiblitz/pi/blitz-tui.log | grep beat | tail -n 1)
else else
latestHeartBeatLine=$(sudo tail -n 300 /home/pi/blitz-tui.log | grep beat | tail -n 1) latestHeartBeatLine=$(tail -n 300 /home/pi/blitz-tui.log | grep beat | tail -n 1)
fi fi
if [ ${#blitzTUIHeartBeatLine} -gt 0 ]; then if [ ${#blitzTUIHeartBeatLine} -gt 0 ]; then
#echo "blitzTUIHeartBeatLine(${blitzTUIHeartBeatLine})" #echo "blitzTUIHeartBeatLine(${blitzTUIHeartBeatLine})"
#echo "latestHeartBeatLine(${latestHeartBeatLine})" #echo "latestHeartBeatLine(${latestHeartBeatLine})"
if [ "${blitzTUIHeartBeatLine}" == "${latestHeartBeatLine}" ]; then if [ "${blitzTUIHeartBeatLine}" == "${latestHeartBeatLine}" ]; then
echo "FAIL - still no new heart beat .. restarting BlitzTUI" echo "FAIL - still no new heart beat .. restarting BlitzTUI"
blitzTUIRestarts=$(($blitzTUIRestarts +1)) source <(/home/admin/_cache.sh increment system_count_start_tui)
if [ $(sudo cat /home/admin/raspiblitz.info | grep -c 'blitzTUIRestarts=') -eq 0 ]; then init 3 ; sleep 2 ; init 5
echo "blitzTUIRestarts=0" >> /home/admin/raspiblitz.info
fi
sudo sed -i "s/^blitzTUIRestarts=.*/blitzTUIRestarts=${blitzTUIRestarts}/g" /home/admin/raspiblitz.info
sudo init 3 ; sleep 2 ; sudo init 5
fi fi
else else
echo "blitzTUIHeartBeatLine is empty - skipping check" echo "blitzTUIHeartBeatLine is empty - skipping check"
@ -273,15 +255,19 @@ do
# SCB Monitoring # SCB Monitoring
############################### ###############################
# check every 1min # check every 1min (only when lnd active)
recheckSCB=$(($counter % 60)) recheckSCB=0
if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
recheckSCB=$(($counter % 60))
fi
if [ ${recheckSCB} -eq 1 ]; then if [ ${recheckSCB} -eq 1 ]; then
#echo "SCB Monitoring ..." #echo "SCB Monitoring ..."
source ${configFile} source ${configFile}
# check if channel.backup exists # check if channel.backup exists
scbPath=/mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup scbPath=/mnt/hdd/lnd/data/chain/${network}/${chain}net/channel.backup
scbExists=$(sudo ls $scbPath 2>/dev/null | grep -c 'channel.backup') scbExists=$(ls $scbPath 2>/dev/null | grep -c 'channel.backup')
if [ ${scbExists} -eq 1 ]; then if [ ${scbExists} -eq 1 ]; then
# timestamp backup filename # timestamp backup filename
timestampedFileName=channel-$(date "+%Y%m%d-%H%M%S").backup timestampedFileName=channel-$(date "+%Y%m%d-%H%M%S").backup
localBackupDir=/home/admin/backups/scb localBackupDir=/home/admin/backups/scb
@ -289,16 +275,16 @@ do
localTimestampedPath=${localBackupDir}/${timestampedFileName} localTimestampedPath=${localBackupDir}/${timestampedFileName}
#echo "Found Channel Backup File .. check if changed .." #echo "Found Channel Backup File .. check if changed .."
md5checksumORG=$(sudo md5sum $scbPath 2>/dev/null | head -n1 | cut -d " " -f1) md5checksumORG=$(md5sum $scbPath 2>/dev/null | head -n1 | cut -d " " -f1)
md5checksumCPY=$(sudo md5sum $localBackupPath 2>/dev/null | head -n1 | cut -d " " -f1) md5checksumCPY=$(md5sum $localBackupPath 2>/dev/null | head -n1 | cut -d " " -f1)
if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then if [ "${md5checksumORG}" != "${md5checksumCPY}" ]; then
echo "--> Channel Backup File changed" echo "--> Channel Backup File changed"
# make copy to sd card (as local basic backup) # make copy to sd card (as local basic backup)
sudo mkdir -p /home/admin/backups/scb/ 2>/dev/null mkdir -p /home/admin/backups/scb/ 2>/dev/null
sudo cp $scbPath $localBackupPath cp $scbPath $localBackupPath
sudo cp $scbPath $localTimestampedPath cp $scbPath $localTimestampedPath
sudo cp $scbPath /boot/channel.backup cp $scbPath /boot/channel.backup
echo "OK channel.backup copied to '${localBackupPath}' and '{$localTimestampedPath}' and '/boot/channel.backup'" echo "OK channel.backup copied to '${localBackupPath}' and '{$localTimestampedPath}' and '/boot/channel.backup'"
# check if a additional local backup target is set # check if a additional local backup target is set
@ -310,8 +296,8 @@ do
if [ ${backupDeviceExists} -gt 0 ]; then if [ ${backupDeviceExists} -gt 0 ]; then
echo "--> Additional Local Backup Device" echo "--> Additional Local Backup Device"
sudo cp ${localBackupPath} /mnt/backup/ cp ${localBackupPath} /mnt/backup/
sudo cp ${localTimestampedPath} /mnt/backup/ cp ${localTimestampedPath} /mnt/backup/
# check results # check results
result=$? result=$?
@ -340,8 +326,8 @@ do
fi fi
# its ok to ignore known host, because data is encrypted (worst case of MiM would be: no offsite channel backup) # its ok to ignore known host, because data is encrypted (worst case of MiM would be: no offsite channel backup)
# but its more likely that without ignoring known host, script might not run thru and that way: no offsite channel backup # but its more likely that without ignoring known host, script might not run thru and that way: no offsite channel backup
sudo scp ${scpBackupOptions} ${localBackupPath} ${scpBackupTarget}/ scp ${scpBackupOptions} ${localBackupPath} ${scpBackupTarget}/
sudo scp ${scpBackupOptions} ${localTimestampedPath} ${scpBackupTarget}/ scp ${scpBackupOptions} ${localTimestampedPath} ${scpBackupTarget}/
result=$? result=$?
if [ ${result} -eq 0 ]; then if [ ${result} -eq 0 ]; then
echo "OK - SCP Backup exited with 0" echo "OK - SCP Backup exited with 0"
@ -350,27 +336,11 @@ do
fi fi
fi fi
# check if a DropBox backup target is set
# parameter in raspiblitz.conf:
# dropboxBackupTarget='[DROPBOX-APP-OAUTH2-TOKEN]'
# see dropbox setup: https://gist.github.com/vindard/e0cd3d41bb403a823f3b5002488e3f90
if [ ${#dropboxBackupTarget} -gt 0 ]; then
echo "--> Offsite-Backup Dropbox"
source <(sudo /home/admin/config.scripts/dropbox.upload.sh upload ${dropboxBackupTarget} ${localBackupPath})
source <(sudo /home/admin/config.scripts/dropbox.upload.sh upload ${dropboxBackupTarget} ${localTimestampedPath})
if [ ${#err} -gt 0 ]; then
echo "FAIL - ${err}"
echo "${errMore}"
else
echo "OK - ${upload}"
fi
fi
# check if Nextcloud backups are enabled # check if Nextcloud backups are enabled
if [ $nextcloudBackupServer ] && [ $nextcloudBackupUser ] && [ $nextcloudBackupPassword ]; then if [ $nextcloudBackupServer ] && [ $nextcloudBackupUser ] && [ $nextcloudBackupPassword ]; then
echo "--> Offsite-Backup Nextcloud" echo "--> Offsite-Backup Nextcloud"
source <(sudo /home/admin/config.scripts/nextcloud.upload.sh upload ${localBackupPath}) source <(/home/admin/config.scripts/nextcloud.upload.sh upload ${localBackupPath})
source <(sudo /home/admin/config.scripts/nextcloud.upload.sh upload ${localTimestampedPath}) source <(/home/admin/config.scripts/nextcloud.upload.sh upload ${localTimestampedPath})
if [ ${#err} -gt 0 ]; then if [ ${#err} -gt 0 ]; then
echo "FAIL - ${err}" echo "FAIL - ${err}"
else else
@ -406,14 +376,11 @@ do
recheckRAID=$((($counter % 3600)+1)) recheckRAID=$((($counter % 3600)+1))
if [ ${recheckRAID} -eq 1 ]; then if [ ${recheckRAID} -eq 1 ]; then
# check if raid is active # check if BTRTFS raid is active & scrub
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${isRaid} -eq 1 ]; then if [ "${isBTRFS}" == "1" ] && [ "${isRaid}" == "1" ]; then
# will run in the background
echo "STARTING BTRFS RAID DATA CHECK ..." echo "STARTING BTRFS RAID DATA CHECK ..."
sudo btrfs scrub start /mnt/hdd/ btrfs scrub start /mnt/hdd/
fi fi
fi fi
@ -422,8 +389,11 @@ do
# LND AUTO-UNLOCK # LND AUTO-UNLOCK
############################### ###############################
# check every 10secs # check every 10secs (only if LND is active)
recheckAutoUnlock=$((($counter % 10)+1)) recheckAutoUnlock=0
if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
recheckAutoUnlock=$((($counter % 10)+1))
fi
if [ ${recheckAutoUnlock} -eq 1 ]; then if [ ${recheckAutoUnlock} -eq 1 ]; then
# check if auto-unlock feature if activated # check if auto-unlock feature if activated
@ -434,33 +404,12 @@ do
if [ "${locked}" != "0" ]; then if [ "${locked}" != "0" ]; then
echo "STARTING AUTO-UNLOCK ..." echo "STARTING AUTO-UNLOCK ..."
sudo /home/admin/config.scripts/lnd.unlock.sh /home/admin/config.scripts/lnd.unlock.sh
fi fi
fi fi
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
/home/admin/config.scripts/internet.dyndomain.sh update
else
echo "'dynUpdateUrl' not set in ${configFile}"
fi
fi
#################################################### ####################################################
# CHECK FOR END OF IBD (self validation) # CHECK FOR END OF IBD (self validation)
#################################################### ####################################################
@ -478,18 +427,22 @@ do
echo "CHECK FOR END OF IBD --> reduce RAM for next reboot" echo "CHECK FOR END OF IBD --> reduce RAM for next reboot"
# remove flag # remove flag
sudo rm /mnt/hdd/${network}/blocks/selfsync.flag rm /mnt/hdd/${network}/blocks/selfsync.flag
# set dbcache back to normal (to give room for other apps after reboot in the future) # set dbcache back to normal (to give room for other apps after reboot in the future)
kbSizeRAM=$(sudo cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g') kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then if [ ${kbSizeRAM} -gt 1500000 ]; then
echo "Detected RAM >1GB --> optimizing ${network}.conf" echo "Detected RAM >1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /mnt/hdd/${network}/${network}.conf sed -i "s/^dbcache=.*/dbcache=512/g" /mnt/hdd/${network}/${network}.conf
else else
echo "Detected RAM 1GB --> optimizing ${network}.conf" echo "Detected RAM 1GB --> optimizing ${network}.conf"
sudo sed -i "s/^dbcache=.*/dbcache=128/g" /mnt/hdd/${network}/${network}.conf sed -i "s/^dbcache=.*/dbcache=128/g" /mnt/hdd/${network}/${network}.conf
fi fi
# relax sanning on sync progress (after 30 more secs)
/home/admin/_cache.sh focus btc_default_sync_progress 10 30
fi fi
fi fi
fi fi
@ -502,4 +455,3 @@ do
sleep 1 sleep 1
done done

View File

@ -35,73 +35,78 @@ echo "Running RaspiBlitz Bootstrap ${codeVersion}" >> $logFile
date >> $logFile date >> $logFile
echo "***********************************************" >> $logFile echo "***********************************************" >> $logFile
# set default values for raspiblitz.info # make sure SSH server is configured & running
network="" sudo /home/admin/config.scripts/blitz.ssh.sh checkrepair >> ${logFile}
chain=""
setupStep=0
setupPhase='boot'
fsexpanded=0
# see https://github.com/rootzoll/raspiblitz/issues/1265#issuecomment-813369284
displayClass="lcd"
displayType=""
fundRecovery=0
################################ ################################
# INIT raspiblitz.info # INIT raspiblitz.info
################################ ################################
# raspiblitz.info contains the persisted system state
# that either given by build or has to survive a reboot
echo "## INIT raspiblitz.info" >> $logFile
# try to load old values if available (overwrites defaults) # set default values for raspiblitz.info (that are not set by build_sdcard.sh)
setupPhase='boot'
setupStep=0
fsexpanded=0
fundRecovery=0
# load already persisted valued (overwriting defaults if exist)
source ${infoFile} 2>/dev/null source ${infoFile} 2>/dev/null
# write fresh raspiblitz.info file
echo "baseimage=${baseimage}" > $infoFile
echo "cpu=${cpu}" >> $infoFile
echo "displayClass=${displayClass}" >> $infoFile
echo "displayType=${displayType}" >> $infoFile
echo "setupPhase=${setupPhase}" >> $infoFile
echo "setupStep=${setupStep}" >> $infoFile
echo "fundRecovery=${fundRecovery}" >> $infoFile
echo "fsexpanded=${fsexpanded}" >> $infoFile
echo "state=starting" >> $infoFile
sudo chmod 664 ${infoFile}
# write content of raspiblitz.info to logs
cat $infoFile >> $logFile
#########################
# INIT RaspiBlitz Cache
#########################
echo "## INIT RaspiBlitz Cache ... wait background.scan.service to finsih first scan loop" >> $logFile
systemscan_runtime=""
while [ "${systemscan_runtime}" == "" ]
do
sleep 1
source <(/home/admin/_cache.sh get systemscan_runtime)
echo "- waiting for background.scan.service --> systemscan_runtime(${systemscan_runtime})" >> $logFile
done
# make sure latest info file is imported
/home/admin/_cache.sh import $infoFile
# setting basic status info
/home/admin/_cache.sh set state "starting"
/home/admin/_cache.sh set message "bootstrap"
# try to load config values if available (config overwrites info) # try to load config values if available (config overwrites info)
source ${configFile} 2>/dev/null source ${configFile} 2>/dev/null
# get first basic network info # monitor LAN connection fast to display local IP changes
source <(/home/admin/config.scripts/internet.sh status) /home/admin/_cache.sh focus internet_localip 0
# get basic hardware info
source <(/home/admin/config.scripts/blitz.hardware.sh status)
# get basic dns info
source <(sudo /home/admin/config.scripts/internet.dns.sh test nodialog)
# resetting info file
echo "Resetting the InfoFile: ${infoFile}"
echo "state=starting" > $infoFile
echo "message=" >> $infoFile
echo "baseimage=${baseimage}" >> $infoFile
echo "cpu=${cpu}" >> $infoFile
echo "board=${board}" >> $infoFile
echo "ramMB=${ramMB}" >> $infoFile
echo "ramGB=${ramGB}" >> $infoFile
echo "network=${network}" >> $infoFile
echo "chain=${chain}" >> $infoFile
echo "localip='${localip}'" >> $infoFile
echo "online='${online}'" >> $infoFile
echo "dnsworking=${dnsworking}" >> $infoFile
echo "fsexpanded=${fsexpanded}" >> $infoFile
echo "displayClass=${displayClass}" >> $infoFile
echo "displayType=${displayType}" >> $infoFile
echo "setupStep=${setupStep}" >> $infoFile
echo "setupPhase=${setupPhase}" >> $infoFile
echo "fundRecovery=${fundRecovery}" >> $infoFile
if [ "${setupStep}" != "100" ]; then
echo "hostname=${hostname}" >> $infoFile
fi
sudo chmod 664 ${infoFile}
###################################### ######################################
# CHECK SD CARD INCONSISTENT STATE # CHECK SD CARD STATE
# make sure SSH server is configured & running
sudo /home/admin/config.scripts/blitz.ssh.sh checkrepair >> ${logFile}
# when a file 'stop' is on the sd card boot partition - stop for manual provision # when a file 'stop' is on the sd card boot partition - stop for manual provision
flagExists=$(sudo ls /boot/stop | grep -c 'stop') flagExists=$(sudo ls /boot/stop | grep -c 'stop')
if [ "${flagExists}" == "1" ]; then if [ "${flagExists}" == "1" ]; then
# remove flag
sudo rm /boot/stop sudo rm /boot/stop
sed -i "s/^state=.*/state=stop/g" ${infoFile} # set state info
sed -i "s/^message=.*/message='stopped for manual provision'/g" ${infoFile} /home/admin/_cache.sh set state "stop"
/home/admin/_cache.sh set message "stopped for manual provision"
# log info
echo "INFO: 'bootstrap stopped - run release after manual provison'" >> ${logFile} echo "INFO: 'bootstrap stopped - run release after manual provison'" >> ${logFile}
exit 0 exit 0
fi fi
@ -110,13 +115,84 @@ fi
provisionFlagExists=$(sudo ls /home/admin/provision.flag | grep -c 'provision.flag') provisionFlagExists=$(sudo ls /home/admin/provision.flag | grep -c 'provision.flag')
if [ "${provisionFlagExists}" == "1" ]; then if [ "${provisionFlagExists}" == "1" ]; then
sudo systemctl stop ${network}d 2>/dev/null sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop lnd 2>/dev/null /home/admin/_cache.sh set state "inconsistentsystem"
sed -i "s/^state=.*/state=inconsistentsystem/g" ${infoFile} /home/admin/_cache.sh set message "provision did not ran thru"
sed -i "s/^message=.*/message='provision did not ran thru'/g" ${infoFile}
echo "FAIL: 'provision did not ran thru' - need fresh sd card!" >> ${logFile} echo "FAIL: 'provision did not ran thru' - need fresh sd card!" >> ${logFile}
exit 1 exit 1
fi fi
################################
# BOOT LOGO
################################
# display 3 secs logo - try to kickstart LCD
# see https://github.com/rootzoll/raspiblitz/issues/195#issuecomment-469918692
# see https://github.com/rootzoll/raspiblitz/issues/647
# see https://github.com/rootzoll/raspiblitz/pull/1580
randnum=$(shuf -i 0-7 -n 1)
/home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/startlogo${randnum}.png
sleep 5
/home/admin/config.scripts/blitz.display.sh hide
################################
# CLEANING BOOT SYSTEM
################################
# Emergency cleaning logs when over 1GB (to prevent SD card filling up)
# see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944
echo "*** Checking Log Size ***"
logsMegaByte=$(sudo du -c -m /var/log | grep "total" | awk '{print $1;}')
if [ ${logsMegaByte} -gt 1000 ]; then
echo "WARN !! Logs /var/log in are bigger then 1GB" >> $logFile
# dont delete directories - can make services crash
sudo rm /var/log/*
sudo service rsyslog restart
/home/admin/_cache.sh set message "WARNING: /var/log/ >1GB"
echo "WARN !! Logs in /var/log in were bigger then 1GB and got emergency delete to prevent fillup." >> $logFile
echo "If you see this in the logs please report to the GitHub issues, so LOG config needs to be optimized." >> $logFile
sleep 10
else
echo "OK - logs are at ${logsMegaByte} MB - within safety limit" >> $logFile
fi
echo ""
# get the state of data drive
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
################################
# WAIT LOOP: HDD CONNECTED
################################
echo "Waiting for HDD/SSD ..." >> $logFile
sudo ls -la /etc/ssh >> $logFile
until [ ${isMounted} -eq 1 ] || [ ${#hddCandidate} -gt 0 ]
do
# recheck HDD/SSD
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
echo "isMounted: $isMounted" >> $logFile
echo "hddCandidate: $hddCandidate" >> $logFile
# in case of HDD analyse ERROR
if [ "${hddError}" != "" ]; then
echo "FAIL - error on HDD analysis: ${hddError}" >> $logFile
/home/admin/_cache.sh set state "errorHDD"
/home/admin/_cache.sh set message "${hddError}"
elif [ "${isMounted}" == "0" ] && [ "${hddCandidate}" == "" ]; then
/home/admin/_cache.sh set state "noHDD"
/home/admin/_cache.sh set message ">=1TB"
fi
# wait for next check
sleep 2
done
echo "HDD/SSD connected: ${$hddCandidate}" >> $logFile
# write info for LCD
/home/admin/_cache.sh set state "system-init"
/home/admin/_cache.sh set message "please wait"
###################################### ######################################
# SECTION FOR POSSIBLE REBOOT ACTIONS # SECTION FOR POSSIBLE REBOOT ACTIONS
systemInitReboot=0 systemInitReboot=0
@ -136,7 +212,7 @@ if [ ${forceHDMIoutput} -eq 1 ]; then
echo "HDMI switch found ... activating HDMI display output & reboot" >> $logFile echo "HDMI switch found ... activating HDMI display output & reboot" >> $logFile
sudo /home/admin/config.scripts/blitz.display.sh set-display hdmi >> $logFile sudo /home/admin/config.scripts/blitz.display.sh set-display hdmi >> $logFile
systemInitReboot=1 systemInitReboot=1
sed -i "s/^message=.*/message='HDMI'/g" ${infoFile} /home/admin/_cache.sh set message "HDMI"
else else
echo "No HDMI switch found. " >> $logFile echo "No HDMI switch found. " >> $logFile
fi fi
@ -152,12 +228,12 @@ if [ "${needsExpansion}" == "1" ] && [ "${fsexpanded}" == "0" ]; then
sudo /home/admin/config.scripts/blitz.bootdrive.sh status >> $logFile sudo /home/admin/config.scripts/blitz.bootdrive.sh status >> $logFile
sudo /home/admin/config.scripts/blitz.bootdrive.sh fsexpand >> $logFile sudo /home/admin/config.scripts/blitz.bootdrive.sh fsexpand >> $logFile
systemInitReboot=1 systemInitReboot=1
sed -i "s/^message=.*/message='FSEXPAND'/g" ${infoFile} /home/admin/_cache.sh set message "FSEXPAND"
elif [ "${tooSmall}" == "1" ]; then elif [ "${tooSmall}" == "1" ]; then
echo "!!! FAIL !!!!!!!!!!!!!!!!!!!!" >> $logFile echo "!!! FAIL !!!!!!!!!!!!!!!!!!!!" >> $logFile
echo "SDCARD TOO SMALL 16G minimum" >> $logFile echo "SDCARD TOO SMALL 16G minimum" >> $logFile
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> $logFile echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> $logFile
sed -i "s/^state=.*/state=sdtoosmall/g" ${infoFile} /home/admin/_cache.sh set state "sdtoosmall"
echo "System stopped. Please cut power." >> $logFile echo "System stopped. Please cut power." >> $logFile
sleep 6000 sleep 6000
sudo shutdown -r now sudo shutdown -r now
@ -167,6 +243,36 @@ else
echo "No FS EXPAND needed. needsExpansion(${needsExpansion}) fsexpanded(${fsexpanded})" >> $logFile echo "No FS EXPAND needed. needsExpansion(${needsExpansion}) fsexpanded(${fsexpanded})" >> $logFile
fi fi
# now that HDD/SSD is connected ... if relevant data from a previous RaspiBlitz was available
# /var/cache/raspiblitz/hdd-inspect exists with copy of config data to init system with
# NOTE: /var/cache/raspiblitz/hdd-inspect will not exist when HDD/SSD is already regulary mounted
####################################
# WIFI RESTORE from HDD works with
# mem copy from datadrive inspection
####################################
# check if there is a WIFI configuration to backup or restore
if [ -f "/var/cache/raspiblitz/hdd-inspect/wpa_supplicant.conf" ]; then
echo "WIFI RESTORE from /var/cache/raspiblitz/hdd-inspect/wpa_supplicant.conf" >> $logFile
/home/admin/config.scripts/internet.wifi.sh backup-restore >> $logFile
else
echo "No WIFI RESTORE because no /var/cache/raspiblitz/hdd-inspect/wpa_supplicant.conf" >> $logFile
fi
################################
# SSH SERVER CERTS RESTORE
# if backup is available on HDD/SSD
################################
if [ -d "/var/cache/raspiblitz/hdd-inspect/ssh" ]; then
# INIT OLD SSH HOST KEYS on Update/Recovery to prevent "Unknown Host" on ssh client
echo "SSH SERVER CERTS RESTORE activating old SSH host keys" >> $logFile
/home/admin/config.scripts/blitz.ssh.sh restore /var/cache/raspiblitz/hdd-inspect >> $logFile
else
echo "No SSH SERVER CERTS RESTORE because no /var/cache/raspiblitz/hdd-inspect/ssh" >> $logFile
fi
################################ ################################
# SSH SERVER CERTS RESET # SSH SERVER CERTS RESET
# if a file called 'ssh.reset' gets # if a file called 'ssh.reset' gets
@ -177,29 +283,57 @@ fi
sshReset=$(sudo ls /boot/ssh.reset* 2>/dev/null | grep -c reset) sshReset=$(sudo ls /boot/ssh.reset* 2>/dev/null | grep -c reset)
if [ ${sshReset} -eq 1 ]; then if [ ${sshReset} -eq 1 ]; then
# delete that file (to prevent loop) # delete that file (to prevent loop)
sudo rm /boot/ssh.reset* >> $logFile rm /boot/ssh.reset* >> $logFile
# delete ssh certs # delete ssh certs
echo "SSHRESET switch found ... stopping SSH and deleting old certs" >> $logFile echo "SSHRESET switch found ... stopping SSH and deleting old certs" >> $logFile
sudo /home/admin/config.scripts/blitz.ssh.sh renew >> $logFile /home/admin/config.scripts/blitz.ssh.sh renew >> $logFile
sudo /home/admin/config.scripts/blitz.ssh.sh backup >> $logFile /home/admin/config.scripts/blitz.ssh.sh backup >> $logFile
sudo ufw allow ssh
systemInitReboot=1 systemInitReboot=1
sed -i "s/^message=.*/message='SSHRESET'/g" ${infoFile} /home/admin/_cache.sh set message "SSHRESET"
else else
echo "No SSHRESET switch found. " >> $logFile echo "No SSHRESET switch found. " >> $logFile
fi fi
##################################
# DISPLAY RESTORE (if needed)
##################################
if [ -f "/var/cache/raspiblitz/hdd-inspect/raspiblitz.conf" ]; then
echo "check that display class in raspiblitz.conf from HDD is different from as it is ow in raspiblitz.info ..." >> $logFile
# get display class value from raspiblitz.info
source <(cat ${infoFile} | grep "^displayClass=")
infoFileDisplayClass="${displayClass}"
echo "infoFileDisplayClass(${infoFileDisplayClass})" >> $logFile
# get display class value from raspiblitz.conf
source <(cat /var/cache/raspiblitz/hdd-inspect/raspiblitz.conf | grep "^displayClass=")
confFileDisplayClass="${displayClass}"
echo "confFileDisplayClass(${confFileDisplayClass})" >> $logFile
# check if values are different and need to change
if [ "${confFileDisplayClass}" != "" ] && [ "${infoFileDisplayClass}" != "${displayClass}" ]; then
echo "DISPLAY RESTORE - need to update displayClass from (${infoFileDisplayClass}) to (${confFileDisplayClass})'" >> ${logFile}
/home/admin/config.scripts/blitz.display.sh set-display ${confFileDisplayClass} >> ${logFile}
systemInitReboot=1
else
echo "No DISPLAY RESTORE because no need to change" >> $logFile
fi
else
echo "No DISPLAY RESTORE because no /var/cache/raspiblitz/hdd-inspect/raspiblitz.conf" >> $logFile
fi
################################ ################################
# UASP FIX - first try # UASP FIX
# if HDD is connected on start
################################ ################################
/home/admin/_cache.sh set message "checking HDD"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh uasp-fix) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh uasp-fix)
if [ "${neededReboot}" == "1" ]; then if [ "${neededReboot}" == "1" ]; then
echo "UASP FIX applied (1st-try) ... reboot needed." >> $logFile echo "UASP FIX applied ... reboot needed." >> $logFile
sed -i "s/^message=.*/message='UASP'/g" ${infoFile}
systemInitReboot=1 systemInitReboot=1
else else
echo "No UASP FIX needed (1st-try)." >> $logFile echo "No UASP FIX needed" >> $logFile
fi fi
###################################### ######################################
@ -208,127 +342,13 @@ fi
if [ "${systemInitReboot}" == "1" ]; then if [ "${systemInitReboot}" == "1" ]; then
sudo cp ${logFile} /home/admin/raspiblitz.systeminit.log sudo cp ${logFile} /home/admin/raspiblitz.systeminit.log
sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile} /home/admin/_cache.sh set state "reboot"
sleep 8 sleep 8
sudo shutdown -r now sudo shutdown -r now
sleep 100 sleep 100
exit 0 exit 0
fi fi
################################
# BOOT LOGO
################################
# display 3 secs logo - try to kickstart LCD
# see https://github.com/rootzoll/raspiblitz/issues/195#issuecomment-469918692
# see https://github.com/rootzoll/raspiblitz/issues/647
# see https://github.com/rootzoll/raspiblitz/pull/1580
randnum=$(shuf -i 0-7 -n 1)
/home/admin/config.scripts/blitz.display.sh image /home/admin/raspiblitz/pictures/startlogo${randnum}.png
sleep 5
/home/admin/config.scripts/blitz.display.sh hide
################################
# CLEANING BOOT SYSTEM
################################
# resetting start count files
echo "SYSTEMD RESTART LOG: blockchain (bitcoind)" > /home/admin/systemd.blockchain.log
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
sudo chmod 666 /home/admin/systemd.blockchain.log
sudo chmod 666 /home/admin/systemd.lightning.log
# Emergency cleaning logs when over 1GB (to prevent SD card filling up)
# see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944
echo "*** Checking Log Size ***"
logsMegaByte=$(sudo du -c -m /var/log | grep "total" | awk '{print $1;}')
if [ ${logsMegaByte} -gt 1000 ]; then
echo "WARN !! Logs /var/log in are bigger then 1GB"
echo "ACTION --> DELETED ALL LOGS"
if [ -d "/var/log/nginx" ]; then
nginxLog=1
echo "/var/log/nginx is present"
fi
sudo rm -r /var/log/*
sudo service rsyslog restart
if [ $nginxLog == 1 ]; then
sudo mkdir /var/log/nginx
echo "Recreated /var/log/nginx"
fi
sleep 3
echo "WARN !! Logs in /var/log in were bigger then 1GB and got emergency delete to prevent fillup."
echo "If you see this in the logs please report to the GitHub issues, so LOG config needs to be optimized."
else
echo "OK - logs are at ${logsMegaByte} MB - within safety limit"
fi
echo ""
###############################
# WAIT FOR ALL SERVICES
# get the state of data drive
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
################################
# WAIT LOOP: HDD CONNECTED
################################
echo "Waiting for HDD/SSD ..." >> $logFile
sudo ls -la /etc/ssh >> $logFile
until [ ${isMounted} -eq 1 ] || [ ${#hddCandidate} -gt 0 ]
do
# recheck HDD/SSD
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
echo "isMounted: $isMounted"
echo "hddCandidate: $hddCandidate"
# in case of HDD analyse ERROR
if [ "${hddError}" != "" ]; then
echo "FAIL - error on HDD analysis: ${hddError}" >> $logFile
sed -i "s/^state=.*/state=errorHDD/g" ${infoFile}
sed -i "s/^message=.*/message='${hddError}'/g" ${infoFile}
elif [ "${isMounted}" == "0" ] && [ "${hddCandidate}" == "" ]; then
sed -i "s/^state=.*/state=noHDD/g" ${infoFile}
sed -i "s/^message=.*/message='>=1TB'/g" ${infoFile}
fi
# wait for next check
sleep 2
done
echo "HDD/SSD connected: ${hddCandidate}" >> $logFile
# write info for LCD
sed -i "s/^state=.*/state=system-init/g" ${infoFile}
sed -i "s/^message=.*/message='please wait'/g" ${infoFile}
####################################
# WIFI RESTORE from HDD works with
# mem copy from datadrive inspection
####################################
# check if there is a WIFI configuration to backup or restore
/home/admin/config.scripts/internet.wifi.sh backup-restore >> $logFile
################################
# UASP FIX - second try
# when HDD gets connected later
################################
sed -i "s/^message=.*/message='checking HDD'/g" ${infoFile}
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh uasp-fix)
if [ "${neededReboot}" == "1" ]; then
echo "UASP FIX applied (2nd-try) ... reboot needed." >> $logFile
sudo cp ${logFile} ${logFile}.uasp
sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile}
sleep 8
sudo shutdown -r now
sleep 100
exit 0
else
echo "No UASP FIX needed (2nd-try)." >> $logFile
fi
################################### ###################################
# WAIT LOOP: LOCALNET / INTERNET # WAIT LOOP: LOCALNET / INTERNET
# after HDD > can contain WIFI conf # after HDD > can contain WIFI conf
@ -337,30 +357,28 @@ gotLocalIP=0
until [ ${gotLocalIP} -eq 1 ] until [ ${gotLocalIP} -eq 1 ]
do do
# get latest network info & update raspiblitz.info # get latest network info directly
source <(/home/admin/config.scripts/internet.sh status) source <(/home/admin/config.scripts/internet.sh status online)
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
# check state of network # check state of network
if [ ${dhcp} -eq 0 ]; then if [ ${dhcp} -eq 0 ]; then
# display user waiting for DHCP # display user waiting for DHCP
sed -i "s/^state=.*/state=noDHCP/g" ${infoFile} /home/admin/_cache.sh set state "noDHCP"
sed -i "s/^message=.*/message='Waiting for DHCP'/g" ${infoFile} /home/admin/_cache.sh set message "Waiting for DHCP"
elif [ ${#localip} -eq 0 ]; then elif [ ${#localip} -eq 0 ]; then
configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null| grep -c "network=")
if [ ${configWifiExists} -eq 0 ]; then if [ ${configWifiExists} -eq 0 ]; then
# display user to connect LAN # display user to connect LAN
sed -i "s/^state=.*/state=noIP-LAN/g" ${infoFile} /home/admin/_cache.sh set state "noIP-LAN"
sed -i "s/^message=.*/message='Connect the LAN/WAN'/g" ${infoFile} /home/admin/_cache.sh set message "Connect the LAN/WAN"
else else
# display user that wifi settings are not working # display user that wifi settings are not working
sed -i "s/^state=.*/state=noIP-WIFI/g" ${infoFile} /home/admin/_cache.sh set state "noIP-WIFI"
sed -i "s/^message=.*/message='WIFI Settings not working'/g" ${infoFile} /home/admin/_cache.sh set message "WIFI Settings not working"
fi fi
elif [ ${online} -eq 0 ]; then elif [ ${online} -eq 0 ]; then
# display user that wifi settings are not working # display user that wifi settings are not working
sed -i "s/^state=.*/state=noInternet/g" ${infoFile} /home/admin/_cache.sh set state "noInternet"
sed -i "s/^message=.*/message='No connection to Internet'/g" ${infoFile} /home/admin/_cache.sh set message "No connection to Internet"
else else
gotLocalIP=1 gotLocalIP=1
fi fi
@ -368,40 +386,14 @@ do
done done
# write info for LCD # write info for LCD
sed -i "s/^state=.*/state=inspect-hdd/g" ${infoFile} /home/admin/_cache.sh set state "inspect-hdd"
sed -i "s/^message=.*/message='please wait'/g" ${infoFile} /home/admin/_cache.sh set message "please wait"
# get fresh info about data drive to continue # get fresh info about data drive to continue
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
echo "isMounted: $isMounted" >> $logFile echo "isMounted: $isMounted" >> $logFile
# check if UASP is already deactivated (on RaspiOS)
# https://www.pragmaticlinux.com/2021/03/fix-for-getting-your-ssd-working-via-usb-3-on-your-raspberry-pi/
cmdlineExists=$(sudo ls /boot/cmdline.txt 2>/dev/null | grep -c "cmdline.txt")
if [ ${cmdlineExists} -eq 1 ] && [ ${#hddAdapterUSB} -gt 0 ] && [ ${hddAdapterUSAP} -eq 0 ]; then
echo "Checking for UASP deactivation ..." >> $logFile
usbQuirkActive=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=")
# check if its maybe other device
usbQuirkDone=$(sudo cat /boot/cmdline.txt | grep -c "usb-storage.quirks=${hddAdapterUSB}:u")
if [ ${usbQuirkActive} -gt 0 ] && [ ${usbQuirkDone} -eq 0 ]; then
# remove old usb-storage.quirks
sudo sed -i "s/usb-storage.quirks=[^ ]* //g" /boot/cmdline.txt
fi
if [ ${usbQuirkDone} -eq 0 ]; then
# add new usb-storage.quirks
sudo sed -i "1s/^/usb-storage.quirks=${hddAdapterUSB}:u /" /boot/cmdline.txt
sudo cat /boot/cmdline.txt >> $logFile
# go into reboot to activate new setting
echo "DONE deactivating UASP for ${hddAdapterUSB} ... one more reboot needed ... " >> $logFile
sudo cp ${logFile} ${logFile}.uasp
sudo shutdown -r now
sleep 100
fi
else
echo "Skipping UASP deactivation ... cmdlineExists(${cmdlineExists}) hddAdapterUSB(${hddAdapterUSB}) hddAdapterUSAP(${hddAdapterUSAP})" >> $logFile
fi
# check if the HDD is auto-mounted ( auto-mounted = setup-done) # check if the HDD is auto-mounted ( auto-mounted = setup-done)
echo "HDD already part of system: $isMounted" >> $logFile echo "HDD already part of system: $isMounted" >> $logFile
@ -422,10 +414,11 @@ if [ ${isMounted} -eq 0 ]; then
echo "Temp mounting (1) result: ${isMounted}" >> $logFile echo "Temp mounting (1) result: ${isMounted}" >> $logFile
# write data needed for setup process into raspiblitz.info # write data needed for setup process into raspiblitz.info
echo "hddCandidate='${hddCandidate}'" >> ${infoFile} /home/admin/_cache.sh set hddCandidate "${hddCandidate}"
echo "hddGigaBytes=${hddGigaBytes}" >> ${infoFile} /home/admin/_cache.sh set hddGigaBytes "${hddGigaBytes}"
echo "hddBlocksBitcoin=${hddBlocksBitcoin}" >> ${infoFile} /home/admin/_cache.sh set hddBlocksBitcoin "${hddBlocksBitcoin}"
echo "hddGotMigrationData=${hddGotMigrationData}" >> ${infoFile} /home/admin/_cache.sh set hddBlocksLitecoin "${hddBlocksLitecoin}"
/home/admin/_cache.sh set hddGotMigrationData "${hddGotMigrationData}"
echo "" echo ""
echo "HDD is there but not AutoMounted yet - Waiting for user Setup/Update" >> $logFile echo "HDD is there but not AutoMounted yet - Waiting for user Setup/Update" >> $logFile
@ -445,10 +438,6 @@ if [ ${isMounted} -eq 0 ]; then
setupPhase="migration" setupPhase="migration"
elif [ "${hddRaspiData}" == "1" ]; then elif [ "${hddRaspiData}" == "1" ]; then
# INIT OLD SSH HOST KEYS on Update/Recovery to prevent "Unknown Host" on ssh client
echo "COPY und Activating old SSH host keys" >> $logFile
/home/admin/config.scripts/blitz.ssh.sh restore >> $logFile
# determine if this is a recovery or an update # determine if this is a recovery or an update
# TODO: improve version/update detection later # TODO: improve version/update detection later
isRecovery=$(echo "${hddRaspiVersion}" | grep -c "${codeVersion}") isRecovery=$(echo "${hddRaspiVersion}" | grep -c "${codeVersion}")
@ -464,9 +453,9 @@ if [ ${isMounted} -eq 0 ]; then
# signal "WAIT LOOP: SETUP" to LCD, SSH & WEBAPI # signal "WAIT LOOP: SETUP" to LCD, SSH & WEBAPI
echo "Displaying Info Message: ${infoMessage}" >> $logFile echo "Displaying Info Message: ${infoMessage}" >> $logFile
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile} /home/admin/_cache.sh set state "waitsetup"
sed -i "s/^message=.*/message='${infoMessage}'/g" ${infoFile} /home/admin/_cache.sh set message "${infoMessage}"
sed -i "s/^setupPhase=.*/setupPhase='${setupPhase}'/g" ${infoFile} /home/admin/_cache.sh set setupPhase "${setupPhase}"
############################################# #############################################
# WAIT LOOP: USER SETUP/UPDATE/MIGRATION # WAIT LOOP: USER SETUP/UPDATE/MIGRATION
@ -480,19 +469,16 @@ if [ ${isMounted} -eq 0 ]; then
# get fresh info about data drive (in case the hdd gets disconnected) # get fresh info about data drive (in case the hdd gets disconnected)
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${hddCandidate}" == "" ]; then if [ "${hddCandidate}" == "" ]; then
echo "!!! WARNING !!! Lost HDD connection .. triggering reboot, to restart system-init." >> ${logFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "lost-hdd" "Lost HDD connection .. triggering reboot." "happened during WAIT LOOP: USER SETUP/UPDATE/MIGRATION" ${logFile}
sed -i "s/^state=.*/state=errorHDD/g" ${infoFile}
sed -i "s/^message=.*/message='lost HDD - rebooting'/g" ${infoFile}
sudo cp ${logFile} ${logFile}.error
sleep 8 sleep 8
sudo shutdown -r now sudo shutdown -r now
sleep 100 sleep 100
exit 0 exit 0
fi fi
# detect if network get deconnected again # detect if network get deconnected again (call directly instead of cache)
# --> "removing network cable" can be used as signal to shutdown clean on test startup # --> "removing network cable" can be used as signal to shutdown clean on test startup
source <(/home/admin/config.scripts/internet.sh status) source <(/home/admin/config.scripts/internet.sh status local)
if [ "${localip}" == "" ]; then if [ "${localip}" == "" ]; then
sed -i "s/^state=.*/state=errorNetwork/g" ${infoFile} sed -i "s/^state=.*/state=errorNetwork/g" ${infoFile}
sleep 8 sleep 8
@ -504,9 +490,8 @@ if [ ${isMounted} -eq 0 ]; then
# give the loop a little bed time # give the loop a little bed time
sleep 4 sleep 4
# check info file for updated values # check for updated state value from SSH-UI or WEB-UI for loop
# especially the state for checking loop source <(/home/admin/_cache.sh get state)
source ${infoFile}
done done
@ -515,7 +500,7 @@ if [ ${isMounted} -eq 0 ]; then
############################################# #############################################
# refresh data from info file # refresh data from info file
source ${infoFile} source <(/home/admin/_cache.sh get state setupPhase)
echo "# PROVISION PROCESS with setupPhase(${setupPhase})" >> ${logFile} echo "# PROVISION PROCESS with setupPhase(${setupPhase})" >> ${logFile}
# mark system on sd card as in setup process # mark system on sd card as in setup process
@ -548,17 +533,12 @@ if [ ${isMounted} -eq 0 ]; then
sudo cp /var/cache/raspiblitz/temp/raspiblitz.conf ${configFile} sudo cp /var/cache/raspiblitz/temp/raspiblitz.conf ${configFile}
fi fi
# kick-off provision process # enable tor service
sed -i "s/^state=.*/state=provision/g" ${infoFile} sudo /home/admin/config.scripts/tor.install.sh enable >> ${logFile}
sed -i "s/^message=.*/message='Starting Provision'/g" ${infoFile}
# load setup data # kick-off provision process
echo "# Sourcing ${configFile} " >> ${logFile} /home/admin/_cache.sh set state "provision"
source ${configFile} /home/admin/_cache.sh set message "Starting Provision"
cat ${configFile} >> ${logFile}
echo "# Sourcing ${setupFile} " >> ${logFile}
source ${setupFile}
sed -e '/^password/d' ${setupFile} >> ${logFile}
# add some debug info to logfile # add some debug info to logfile
echo "# df " >> ${logFile} echo "# df " >> ${logFile}
@ -566,30 +546,45 @@ if [ ${isMounted} -eq 0 ]; then
echo "# lsblk -o NAME,FSTYPE,LABEL " >> ${logFile} echo "# lsblk -o NAME,FSTYPE,LABEL " >> ${logFile}
lsblk -o NAME,FSTYPE,LABEL >> ${logFile} lsblk -o NAME,FSTYPE,LABEL >> ${logFile}
# make sure basic info is in raspiblitz.info
echo "# Update ${infoFile} " >> ${logFile}
sudo sed -i "s/^network=.*/network=${network}/g" ${infoFile}
sudo sed -i "s/^chain=.*/chain=${chain}/g" ${infoFile}
sudo sed -i "s/^lightning=.*/lightning=${lightning}/g" ${infoFile}
cat ${infoFile} >> ${logFile}
# if migrationFile was uploaded - now import it # if migrationFile was uploaded - now import it
echo "# migrationFile(${migrationFile})" >> ${logFile} echo "# migrationFile(${migrationFile})" >> ${logFile}
if [ "${migrationFile}" != "" ]; then if [ "${migrationFile}" != "" ]; then
# unpack
sed -i "s/^message=.*/message='Unpacking Migration Data'/g" ${infoFile} sed -i "s/^message=.*/message='Unpacking Migration Data'/g" ${infoFile}
/home/admin/config.scripts/blitz.migration.sh import "${migrationFile}" >> ${logFile} source <(/home/admin/config.scripts/blitz.migration.sh import "${migrationFile}")
sed -i "s/^setupPhase=.*/setupPhase='recovery'/g" ${infoFile}
# check for errors
if [ "${error}" != "" ]; then
/home/admin/config.scripts/blitz.error.sh _bootstrap.sh "migration-import-error" "blitz.migration.sh import exited with error" "/home/admin/config.scripts/blitz.migration.sh import ${migrationFile} --> ${error}" ${logFile}
exit 1
fi
# signal recovery provision phase
setupPhase="recovery" setupPhase="recovery"
/home/admin/_cache.sh set setupPhase "${setupPhase}"
fi fi
# load fresh config data
echo "# Sourcing ${configFile} " >> ${logFile}
cat ${configFile} >> ${logFile}
source ${configFile}
# load fresh setup data
echo "# Sourcing ${setupFile} " >> ${logFile}
cat ${setupFile} >> ${logFile}
source ${setupFile}
# make sure basic info is in raspiblitz.info
/home/admin/_cache.sh set network "${network}"
/home/admin/_cache.sh set chain "${chain}"
/home/admin/_cache.sh set lightning "${lightning}"
################################### ###################################
# Set Password A (in all cases) # Set Password A (in all cases)
if [ "${passwordA}" == "" ]; then if [ "${passwordA}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "missing-passworda" "missing passwordA in (${setupFile})" "" ${logFile}
sed -i "s/^message=.*/message='config: missing passwordA'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing passwordA in (${setupFile})!" >> ${logFile}
exit 1 exit 1
fi fi
@ -605,10 +600,11 @@ if [ ${isMounted} -eq 0 ]; then
errorState=$? errorState=$?
sudo cat /home/admin/raspiblitz.provision-setup.log sudo cat /home/admin/raspiblitz.provision-setup.log
if [ "$errorState" != "0" ]; then if [ "$errorState" != "0" ]; then
echo "EXIT _provision.setup.sh BECAUSE OF ERROR STATE ($errorState)" >> $logFile # only trigger an error message if the script hasnt itself triggered an error message already
echo "This can also happen if _provision.setup.sh has syntax errors" >> $logFile source <(/home/admin/_cache.sh get state)
sed -i "s/^state=.*/state='error'/g" ${infoFile} if [ "${state}" != "error" ]; then
sed -i "s/^message=.*/message='_provision.setup.sh fail'/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "provision-setup-exit" "unknown or syntax error on (${errorState}) _provision.setup.sh" "" ${logFile}
fi
exit 1 exit 1
fi fi
fi fi
@ -621,10 +617,11 @@ if [ ${isMounted} -eq 0 ]; then
errorState=$? errorState=$?
cat /home/admin/raspiblitz.provision-migration.log cat /home/admin/raspiblitz.provision-migration.log
if [ "$errorState" != "0" ]; then if [ "$errorState" != "0" ]; then
echo "EXIT _provision.migration.sh BECAUSE OF ERROR STATE ($errorState)" >> $logFile # only trigger an error message if the script hasnt itself triggered an error message already
echo "This can also happen if _provision.migration.sh has syntax errros" >> $logFile source <(/home/admin/_cache.sh get state)
sed -i "s/^state=.*/state='error'/g" ${infoFile} if [ "${state}" != "error" ]; then
sed -i "s/^message=.*/message='_provision.migration.sh fail'/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "provision-migration-exit" "unknown or syntax error on (${errorState}) _provision.migration.sh" "" ${logFile}
fi
exit 1 exit 1
fi fi
fi fi
@ -637,10 +634,11 @@ if [ ${isMounted} -eq 0 ]; then
errorState=$? errorState=$?
cat /home/admin/raspiblitz.provision-update.log cat /home/admin/raspiblitz.provision-update.log
if [ "$errorState" != "0" ]; then if [ "$errorState" != "0" ]; then
echo "EXIT _provision.update.sh BECAUSE OF ERROR STATE ($errorState)" >> $logFile # only trigger an error message if the script hasnt itself triggered an error message already
echo "This can also happen if _provision.update.sh has syntax errors" >> $logFile source <(/home/admin/_cache.sh get state)
sed -i "s/^state=.*/state='error'/g" ${infoFile} if [ "${state}" != "error" ]; then
sed -i "s/^message=.*/message='_provision.update.sh fail'/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "provision-update-exit" "unknown or syntax error on (${errorState}) _provision.update.sh" "" ${logFile}
fi
exit 1 exit 1
fi fi
fi fi
@ -651,30 +649,32 @@ if [ ${isMounted} -eq 0 ]; then
/home/admin/_provision_.sh /home/admin/_provision_.sh
errorState=$? errorState=$?
if [ "$errorState" != "0" ]; then if [ "$errorState" != "0" ]; then
echo "EXIT _provision_.sh BECAUSE OF ERROR STATE ($errorState)" >> $logFile # only trigger an error message if the script hasnt itself triggered an error message already
echo "This can also happen if _provision_.sh has syntax errors" >> $logFile source <(/home/admin/_cache.sh get state)
sed -i "s/^state=.*/state='error'/g" ${infoFile} if [ "${state}" != "error" ]; then
sed -i "s/^message=.*/message='_provision_.sh fail'/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _bootstrap.sh "provision-exit" "unknown or syntax error on (${errorState}) _provision_.sh" "" ${logFile}
fi
exit 1 exit 1
fi fi
# everyone can read the config but it can only be # everyone can read the config but it can only be
# edited/written by root ot admin user (part of group sudo) # edited/written by root ot admin user (part of group sudo)
sudo chown root:sudo ${configFile} chown root:sudo ${configFile}
sudo chmod 664 ${configFile} chmod 664 ${configFile}
# delete provision in progress flag # delete provision in progress flag
sudo rm /home/admin/provision.flag rm /home/admin/provision.flag
# mark provision process done # mark provision process done
sed -i "s/^message=.*/message='Provision Done'/g" ${infoFile} /home/admin/_cache.sh set message "Provision Done"
# wait until syncProgress is available (neeed for final dialogs) # wait until syncProgress is available (neeed for final dialogs)
while [ "${syncProgress}" == "" ] /home/admin/_cache.sh set state "waitsync"
btc_default_ready="0"
while [ "${btc_default_ready}" != "1" ]
do do
echo "# Waiting for blockchain sync progress info ..." >> $logFile source <(/home/admin/_cache.sh get btc_default_ready)
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) echo "# waitsync loop ... btc_default_ready(${btc_default_ready})" >> $logFile
sed -i "s/^state=.*/state=waitsync/g" ${infoFile}
sleep 2 sleep 2
done done
@ -683,8 +683,8 @@ if [ ${isMounted} -eq 0 ]; then
################################################### ###################################################
echo "# HANDOVER TO FINAL SETUP CONTROLLER ..." >> $logFile echo "# HANDOVER TO FINAL SETUP CONTROLLER ..." >> $logFile
sed -i "s/^state=.*/state=waitfinal/g" ${infoFile} /home/admin/_cache.sh set state "waitfinal"
sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Done"
# system has to wait before reboot to present like seed words and other info/options to user # system has to wait before reboot to present like seed words and other info/options to user
echo "BOOTSTRAP EXIT ... waiting for final setup controller to initiate final reboot." >> $logFile echo "BOOTSTRAP EXIT ... waiting for final setup controller to initiate final reboot." >> $logFile
@ -702,14 +702,14 @@ else
# FIX BLOCKCHAINDATA OWNER (just in case) # FIX BLOCKCHAINDATA OWNER (just in case)
# https://github.com/rootzoll/raspiblitz/issues/239#issuecomment-450887567 # https://github.com/rootzoll/raspiblitz/issues/239#issuecomment-450887567
################################# #################################
sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null
################################# #################################
# FIX BLOCKING FILES (just in case) # FIX BLOCKING FILES (just in case)
# https://github.com/rootzoll/raspiblitz/issues/1901#issue-774279088 # https://github.com/rootzoll/raspiblitz/issues/1901#issue-774279088
# https://github.com/rootzoll/raspiblitz/issues/1836#issue-755342375 # https://github.com/rootzoll/raspiblitz/issues/1836#issue-755342375
sudo rm -f /mnt/hdd/bitcoin/bitcoind.pid 2>/dev/null rm -f /mnt/hdd/bitcoin/bitcoind.pid 2>/dev/null
sudo rm -f /mnt/hdd/bitcoin/.lock 2>/dev/null rm -f /mnt/hdd/bitcoin/.lock 2>/dev/null
################################ ################################
# DELETE LOG & LOCK FILES # DELETE LOG & LOCK FILES
@ -717,11 +717,11 @@ else
# LND and Blockchain Errors will be still in systemd journals # LND and Blockchain Errors will be still in systemd journals
# /mnt/hdd/bitcoin/debug.log # /mnt/hdd/bitcoin/debug.log
sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null rm /mnt/hdd/${network}/debug.log 2>/dev/null
# /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log # /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log
sudo rm /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null rm /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null
# https://github.com/rootzoll/raspiblitz/issues/1700 # https://github.com/rootzoll/raspiblitz/issues/1700
sudo rm /mnt/storage/app-storage/electrs/db/mainnet/LOCK 2>/dev/null rm /mnt/storage/app-storage/electrs/db/mainnet/LOCK 2>/dev/null
fi fi
@ -729,57 +729,23 @@ fi
############################## ##############################
# BOOSTRAP IN EVERY SITUATION # BOOSTRAP IN EVERY SITUATION
############################## ##############################
/home/admin/_cache.sh set setupPhase "starting"
sed -i "s/^setupPhase=.*/setupPhase='starting'/g" ${infoFile}
# if a WIFI config exists backup to HDD
configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null| grep -c "network=")
if [ ${configWifiExists} -eq 1 ]; then
echo "Making Backup Copy of WIFI config to HDD" >> $logFile
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /mnt/hdd/app-data/wpa_supplicant.conf
fi
# make sure lndAddress & lndPort exist in configfile
valueExists=$(cat ${configFile} | grep -c 'lndPort=')
if [ ${valueExists} -eq 0 ]; then
lndPort=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':')
if [ ${#lndPort} -eq 0 ]; then
lndPort="9735"
fi
echo "lndPort='${lndPort}'" >> ${configFile}
fi
valueExists=$(cat ${configFile} | grep -c 'lndAddress=')
if [ ${valueExists} -eq 0 ]; then
echo "lndAddress=''" >> ${configFile}
fi
# load data from config file fresh # load data from config file fresh
echo "load configfile data" >> $logFile echo "load configfile data" >> $logFile
source ${configFile} source ${configFile}
# update public IP on boot - set to domain if available # if a WIFI config exists backup to HDD
/home/admin/config.scripts/internet.sh update-publicip ${lndAddress} source <(/home/admin/config.scripts/internet.sh status)
if [ ${configWifiExists} -eq 1 ]; then
# make constant UASP entry in raspiblitz.conf if still done by flag file echo "Making Backup Copy of WIFI config to HDD" >> $logFile
# uaspForced comes from blitz.datadrive.sh status cp /etc/wpa_supplicant/wpa_supplicant.conf /mnt/hdd/app-data/wpa_supplicant.conf
if [ ${uaspForced} -eq 1 ]; then
entryExists=$(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c 'forceUasp=on')
if [ ${entryExists} -eq 0 ]; then
sudo sed -i '/forceUasp=.*/d' /mnt/hdd/raspiblitz.conf
echo "forceUasp=on" >> /mnt/hdd/raspiblitz.conf
echo "DONE forceUasp=on recorded in raspiblitz.conf" >> $logFile
fi
fi fi
################################# # make sure users have latest credentials (if lnd is on)
# MAKE SURE USERS HAVE LATEST LND CREDENTIALS if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
#################################
source ${configFile}
if [ ${#network} -gt 0 ] && [ ${#chain} -gt 0 ]; then
echo "running LND users credentials update" >> $logFile echo "running LND users credentials update" >> $logFile
sudo /home/admin/config.scripts/lnd.credentials.sh sync >> $logFile /home/admin/config.scripts/lnd.credentials.sh sync >> $logFile
else else
echo "skipping LND credentials sync" >> $logFile echo "skipping LND credentials sync" >> $logFile
fi fi
@ -789,11 +755,10 @@ fi
# if "localBackupDeviceUUID" is set in # if "localBackupDeviceUUID" is set in
# raspiblitz.conf mount it on boot # raspiblitz.conf mount it on boot
################################ ################################
source ${configFile}
echo "Checking if additional backup device is configured .. (${localBackupDeviceUUID})" >> $logFile echo "Checking if additional backup device is configured .. (${localBackupDeviceUUID})" >> $logFile
if [ "${localBackupDeviceUUID}" != "" ] && [ "${localBackupDeviceUUID}" != "off" ]; then if [ "${localBackupDeviceUUID}" != "" ] && [ "${localBackupDeviceUUID}" != "off" ]; then
echo "Yes - Mounting BackupDrive: ${localBackupDeviceUUID}" >> $logFile echo "Yes - Mounting BackupDrive: ${localBackupDeviceUUID}" >> $logFile
sudo /home/admin/config.scripts/blitz.backupdevice.sh mount >> $logFile /home/admin/config.scripts/blitz.backupdevice.sh mount >> $logFile
else else
echo "No additional backup device was configured." >> $logFile echo "No additional backup device was configured." >> $logFile
fi fi
@ -801,7 +766,6 @@ fi
##################################### #####################################
# CLEAN HDD TEMP # CLEAN HDD TEMP
##################################### #####################################
echo "CLEANING TEMP DRIVE/FOLDER" >> $logFile echo "CLEANING TEMP DRIVE/FOLDER" >> $logFile
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh clean temp) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh clean temp)
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
@ -818,7 +782,17 @@ fi
if [ ${isRaid} -eq 1 ]; then if [ ${isRaid} -eq 1 ]; then
echo "TRIGGERING BTRFS RAID DATA CHECK ..." echo "TRIGGERING BTRFS RAID DATA CHECK ..."
echo "Check status with: sudo btrfs scrub status /mnt/hdd/" echo "Check status with: sudo btrfs scrub status /mnt/hdd/"
sudo btrfs scrub start /mnt/hdd/ btrfs scrub start /mnt/hdd/
fi
####################
# FORCE UASP FLAG
####################
# if uasp.force flag was set on sd card - now move into raspiblitz.conf
if [ -f "/boot/uasp.force" ]; then
/home/admin/config.scripts/blitz.conf.sh set forceUasp "on"
echo "DONE forceUasp=on recorded in raspiblitz.conf" >> $logFile
fi fi
###################################### ######################################
@ -830,18 +804,27 @@ if [ -d "/mnt/hdd/app-data/subscriptions" ]; then
sudo chown admin:admin /mnt/hdd/app-data/subscriptions sudo chown admin:admin /mnt/hdd/app-data/subscriptions
else else
echo "CREATE: subscription data directory" echo "CREATE: subscription data directory"
sudo mkdir /mnt/hdd/app-data/subscriptions mkdir /mnt/hdd/app-data/subscriptions
sudo chown admin:admin /mnt/hdd/app-data/subscriptions chown admin:admin /mnt/hdd/app-data/subscriptions
fi fi
# make sure that bitcoin service is active # make sure that bitcoin service is active
sudo systemctl enable ${network}d sudo systemctl enable ${network}d
# make sure setup/provision is marked as done # make sure setup/provision is marked as done
sudo rm /home/admin/provision.flag /home/admin/_cache.sh set setupPhase "done"
sed -i "s/^setupPhase=.*/setupPhase='done'/g" ${infoFile} /home/admin/_cache.sh set state "ready"
sed -i "s/^state=.*/state=ready/g" ${infoFile} /home/admin/_cache.sh set message "Node Running"
sed -i "s/^message=.*/message='Node Running'/g" ${infoFile}
# relax systemscan on certain values
/home/admin/_cache.sh focus internet_localip -1
# if node is stil in inital blockchain download
source <(/home/admin/_cache.sh get btc_default_sync_initialblockdownload)
if [ "${btc_default_sync_initialblockdownload}" == "1" ]; then
echo "Node is still in IBD .. refresh btc_default_sync_progress faster" >> $logFile
/home/admin/_cache.sh focus btc_default_sync_progress 0
fi
echo "DONE BOOTSTRAP" >> $logFile echo "DONE BOOTSTRAP" >> $logFile
exit 0 exit 0

474
home.admin/_cache.sh Executable file
View File

@ -0,0 +1,474 @@
#!/usr/bin/env bash
# the cache concept of RaspiBlitz has two options
# 1) RAMDISK for files under /var/cache/raspiblitz
# 2) KEY-VALUE STORE for system state infos (REDIS)
# SECURITY NOTE: The files on the RAMDISK can be set with unix file permissions and so restrict certain users access.
# But all data stored in the KEY-VALUE STORE has to be asumed as system-wide public information.
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "RaspiBlitz Cache"
echo
echo "_cache.sh ramdisk [on|off]"
echo "_cache.sh keyvalue [on|off]"
echo
echo "_cache.sh set [key] [value] [?expire-seconds]"
echo "_cache.sh get [key1] [?key2] [?key3] ..."
echo
echo "_cache.sh increment [key1]"
echo
echo "_cache.sh focus [key] [update-seconds] [?duration-seconds]"
echo "# set in how many seconds value is marked to be rescanned"
echo "# -1 = slowest default update cycle"
echo "# 0 = update on every cycle"
echo "# set a 'duration-seconds' after defaults to -1 (optional)"
echo
echo "_cache.sh meta [key] [?default]"
echo "# get single key with additional metadata:"
echo "# updateseconds= see above"
echo "# stillvalid=0/1 if value is still valid or outdated"
echo "# lasttouch= last update timestamp in unix seconds"
echo
echo "_cache.sh valid [key1] [?key2] [?key3] ..."
echo "# check multiple keys if all are still not outdated"
echo "# use for example to check if a complex call needs"
echo "# to be made that covers multiple single data points"
echo
echo "_cache.sh import [bash-keyvalue-file]"
echo "# import a bash style key-value file into store"
echo
echo "_cache.sh export [?key-prefix]"
echo "# export bash-style key-value to stdout"
echo "# can be used with a key-prefix just get a subset"
echo
exit 1
fi
# BACKGROUND: we need to build outdated meta info manually,
# because there is nothing as "AGE" in redis: https://github.com/redis/redis/issues/1147
# only feature that can be used uis the EXPIRE feature to determine if a value is still valid
# postfixes for metadata in key/value store
META_OUTDATED_SECONDS=":out"
META_LASTTOUCH_TS=":ts"
META_VALID_FLAG=":val"
# path of the raspiblitz.info file (persiting cache values)
infoFile="/home/admin/raspiblitz.info"
###################
# RAMDISK
# will be available under /var/cache/raspiblitz
###################
# install
if [ "$1" = "ramdisk" ] && [ "$2" = "on" ]; then
echo "# Turn ON: RAMDISK"
if ! grep -Eq '^tmpfs.*/var/cache/raspiblitz' /etc/fstab; then
if grep -Eq '/var/cache/raspiblitz' /etc/fstab; then
# entry is in file but most likely just disabled -> re-enable it
sudo sed -i -E 's|^#(tmpfs.*/var/cache/raspiblitz.*)$|\1|g' /etc/fstab
else
# missing -> add
echo "" | sudo tee -a /etc/fstab >/dev/null
echo "tmpfs /var/cache/raspiblitz tmpfs nodev,nosuid,size=32M 0 0" | sudo tee -a /etc/fstab >/dev/null
fi
fi
if ! findmnt -l /var/cache/raspiblitz >/dev/null; then
sudo mkdir -p /var/cache/raspiblitz
sudo mount /var/cache/raspiblitz
fi
# uninstall
elif [ "$1" = "ramdisk" ] && [ "$2" = "off" ]; then
echo "# Turn OFF: RAMDISK"
if grep -Eq '/var/cache/raspiblitz' /etc/fstab; then
sudo sed -i -E 's|^(tmpfs.*/var/cache/raspiblitz.*)$|#\1|g' /etc/fstab
fi
if findmnt -l /var/cache/raspiblitz >/dev/null; then
sudo umount /var/cache/raspiblitz
fi
###################
# KEYVALUE (REDIS)
###################
# install
elif [ "$1" = "keyvalue" ] && [ "$2" = "on" ]; then
echo "# Turn ON: KEYVALUE-STORE (REDIS)"
sudo apt install -y redis-server
# edit config: dont save to disk
sudo sed -i "/^save .*/d" /etc/redis/redis.conf
# restart with new config
sudo systemctl restart redis-server
# clean old databases if exist
sudo rm /var/lib/redis/dump.rdb 2>/dev/null
# restart again this time there is no old data dump to load
sudo systemctl restart redis-server
# uninstall
elif [ "$1" = "keyvalue" ] && [ "$2" = "off" ]; then
echo "# Turn OFF: KEYVALUE-STORE (REDIS)"
sudo apt remove -y redis-server
###################
# SET/GET/IMPORT
# basic key value
###################
# set
elif [ "$1" = "set" ]; then
# get parameters
keystr=$2
valuestr=$3
expire=$4
# check that key & value are given
if [ "${keystr}" == "" ]; then
echo "# Fail: missing parameter"
exit 1
fi
# filter from expire just numbers
expire="${expire//[^0-9.]/}"
# add an expire flag if given
additionalParams=""
if [ "${expire}" != "" ]; then
additionalParams="EX ${expire}"
fi
# set in redis key value cache
redis-cli set ${keystr} "${valuestr}" ${additionalParams} 1>/dev/null
# set in redis the timestamp
timestamp=$(date +%s)
redis-cli set ${keystr}${META_LASTTOUCH_TS} "${timestamp}" ${additionalParams} 1>/dev/null
#echo "# lasttouch(${timestamp})"
# check if the value has a outdate policy
outdatesecs=$(redis-cli get ${keystr}${META_OUTDATED_SECONDS})
if [ "${outdatesecs}" == "" ]; then
outdatesecs="-1"
fi
#echo "# outdatesecs(${outdatesecs})"
if [ "${outdatesecs}" != "-1" ]; then
# set exipire valid flag (if its gone - value is considered as outdated)
redis-cli set ${keystr}${META_VALID_FLAG} "1" EX ${outdatesecs} 1>/dev/null
fi
# also update value if part of raspiblitz.info (persiting values to survice boot)
persistKey=$(cat ${infoFile} | grep -c "^${keystr}=")
if [ ${persistKey} -gt 0 ]; then
sudo sed -i "s/^${keystr}=.*/${keystr}='${valuestr}'/g" ${infoFile}
fi
# get
elif [ "$1" = "get" ]; then
position=0
for keystr in $@
do
# skip first parameter
((position++))
if [ $position -eq 1 ]; then
echo "# _cache.sh $@"
continue
fi
# get redis value
valuestr=$(redis-cli get ${keystr})
# output key value in bash script compatible way
echo "${keystr}=\"${valuestr}\""
done
# import values from bash key-value store
elif [ "$1" = "import" ]; then
# get parameter
filename=$2
# source values from given file (to be used for import later)
source ${filename}
# read file and go thru line by line
n=1
while read line; do
# skip comment lines
isComment=$(echo "${line}" | grep -c "^#")
if [ ${isComment} -eq 1 ]; then
continue
fi
# skip if not a value line
isValueLine=$(echo "${line}" | grep -c "=")
if [ ${isValueLine} -eq 0 ]; then
continue
fi
# import key from line & value from source above (that way quotes are habdled correctly)
keyValue=$(echo "$line" | cut -d "=" -f1)
echo "# redis-cli set ${keyValue} ${!keyValue}"
redis-cli set ${keyValue} "${!keyValue}" 1>/dev/null
# also set the timestamp on import for each value
timestamp=$(date +%s)
redis-cli set ${keyValue}${META_LASTTOUCH_TS} "${timestamp}" 1>/dev/null
done < $filename
# import values from bash key-value store
elif [ "$1" = "export" ]; then
# get parameter
keyfilter="${2}*"
# go thru all keys by keyfilter
keylist=$(redis-cli KEYS "${keyfilter}")
readarray -t arr <<< "${keylist}"
for key in "${arr[@]}";do
# skip empty keys
if [ "${key}" == "" ]; then
continue
fi
# skip metadata keys
isMeta=$(echo "${key}" | grep -c ":")
if [ ${isMeta} -gt 0 ]; then
continue
fi
# print out key/value
value=$(redis-cli get "${key}")
echo "${key}=\"${value}\""
done
##################################
# COUNT
# count value up
##################################
# set
elif [ "$1" = "increment" ]; then
# get parameters
keystr=$2
# check that key & value are given
if [ "${keystr}" == "" ]; then
echo "# Fail: missing parameter"
exit 1
fi
# set in redis key value cache
redis-cli incr ${keystr} 1>/dev/null
# set in redis the timestamp
timestamp=$(date +%s)
redis-cli set ${keystr}${META_LASTTOUCH_TS} "${timestamp}" 1>/dev/null
##################################
# FOCUS
# signal update rate on value
##################################
# focus (set outdated policy)
elif [ "$1" = "focus" ]; then
# get parameters
keystr=$2
outdatesecs=$3
durationsecs=$4
# if no further parameters - list all values with running focus
if [ "${keystr}" == "" ]; then
echo "# cache values with active focus:"
keylist=$(redis-cli KEYS "*:out")
readarray -t arr <<< "${keylist}"
for key in "${arr[@]}";do
if [ "${key}" == "" ]; then
continue
fi
keyClean=$(echo $key | cut -d ":" -f1)
value=$(redis-cli get "${key}")
echo "${keyClean}=${value}"
done
exit
fi
# delete outdate policy field ==> default
if [ "${outdatesecs}" == "-1" ]; then
echo "# redis-cli del ${keystr}${META_OUTDATED_SECONDS}"
redis-cli del ${keystr}${META_OUTDATED_SECONDS}
exit
fi
# sanatize parameters (if not -1)
outdatesecs="${outdatesecs//[^0-9.]/}"
# check that key & value are given
if [ "${outdatesecs}" == "" ]; then
echo "# Fail: missing parameter"
exit 1
fi
# add an expire flag if given
additionalParams=""
if [ "${durationsecs//[^0-9.]/}" != "" ]; then
additionalParams="EX ${durationsecs//[^0-9.]/}"
fi
# store the seconds policy
echo "# redis-cli set ${keystr}${META_OUTDATED_SECONDS} ${outdatesecs} ${additionalParams}"
redis-cli set ${keystr}${META_OUTDATED_SECONDS} "${outdatesecs}" ${additionalParams}
# set/renew exipire valid flag (important in case the key had before no expire)
redis-cli set ${keystr}${META_VALID_FLAG} "1" EX ${outdatesecs} 1>/dev/null
##################################
# META
# metadata on values
##################################
# meta
elif [ "$1" = "meta" ]; then
# get parameters
keystr=$2
default=$3
# check that key & value are given
if [ "${keystr}" == "" ]; then
echo "# Fail: missing parameter"
exit 1
fi
# get redis basic value
valuestr=$(redis-cli get ${keystr})
echo "value=\"${valuestr}\""
# get META_LASTTOUCH_TS
lasttouch=$(redis-cli get ${keystr}${META_LASTTOUCH_TS})
if [ "${lasttouch}" == "" ]; then
echo "initiated=0"
exit 0
fi
echo "initiated=1"
echo "lasttouch=\"${lasttouch}\""
# get META_OUTDATED_SECONDS
outdatesecs=$(redis-cli get ${keystr}${META_OUTDATED_SECONDS})
if [ "${outdatesecs}" == "" ]; then
# default is -1 --> never outdate
outdatesecs="-1"
fi
echo "outdatesecs=\"${outdatesecs}\""
# get META_VALID_FLAG
valuestr=$(redis-cli get ${keystr}${META_VALID_FLAG})
if [ "${valuestr}" == "" ] && [ "${outdatesecs}" != "-1" ]; then
stillvalid=0
else
stillvalid=1
fi
echo "stillvalid=\"${stillvalid}\""
##################################
# VALID
# check if a value needs update
##################################
# valid
elif [ "$1" = "valid" ]; then
position=0
lasttouch_overall=""
for keystr in $@
do
# skip first parameter from script - thats the action string
((position++))
if [ $position -eq 1 ]; then
echo "# _cache.sh $@"
continue
fi
# check lasttouch for value
lasttouch=$(redis-cli get ${keystr}${META_LASTTOUCH_TS})
#echo "# lasttouch(${lasttouch})"
# no lasttouch entry ==> was not initiated ==> not valid
if [ "${lasttouch}" == "" ]; then
# break loop on first unvalid value found
echo "stillvalid=\"0\""
exit 0
fi
# record the smallest timestamp (oldest date) of all values
if [ "${lasttouch}" != "" ]; then
# find smallest lasttouch
if [ "${lasttouch_overall}" == "" ] || [ ${lasttouch_overall} -gt ${lasttouch} ]; then
lasttouch_overall="${lasttouch}"
fi
fi
# get outdate police of value (outdated = not valid anymore)
outdatesecs=$(redis-cli get ${keystr}${META_OUTDATED_SECONDS})
#echo "# ${keystr}${META_OUTDATED_SECONDS}=\"${outdatesecs}\""
# if outdate policy is default or -1 ==> never outdated
if [ "${outdatesecs}" == "" ] || [ "${outdatesecs}" == "-1" ]; then
continue
fi
# so outdate policy is active - check if valid flag exists
validflag=$(redis-cli get ${keystr}${META_VALID_FLAG})
#echo "# ${keystr}${META_VALID_FLAG}=\"${validflag}\""
# if valid flag exists this value is valid
if [ "${valuestr}" != "" ]; then
continue
fi
# so valid flag does not exists anymore
# ==> this means value is outdated
# break loop and
echo "stillvalid=\"0\""
exit 0
done
# so if all were valid
echo "stillvalid=\"1\""
# calculate age in seconds of oldest entry
if [ "${lasttouch_overall}" != "" ]; then
timestamp=$(date +%s)
age=$(($timestamp-$lasttouch_overall))
echo "age=\"${age}\""
fi
else
echo "# FAIL: parameter not known - run with -h for help"
fi

View File

@ -33,6 +33,7 @@ function blitzhelp() {
echo " debug print debug logs" echo " debug print debug logs"
echo " debug -l print debug logs with bin link" echo " debug -l print debug logs with bin link"
echo " patch sync scripts with latest set github and branch" echo " patch sync scripts with latest set github and branch"
echo " cache check on chache system state"
echo " github jumping directly into the options to change branch/repo/pr" echo " github jumping directly into the options to change branch/repo/pr"
echo echo
echo "Power:" echo "Power:"
@ -157,6 +158,11 @@ function headless() {
restart restart
} }
# command: cache
function cache() {
sudo /home/admin/_cache.sh $@
}
# command: torthistx # command: torthistx
function torthistx() { function torthistx() {
if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "runBehindTor=on") -eq 1 ]; then if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "runBehindTor=on") -eq 1 ]; then
@ -164,14 +170,18 @@ function torthistx() {
curl --socks5-hostname localhost:9050 -d $1 -X POST http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/api/tx curl --socks5-hostname localhost:9050 -d $1 -X POST http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/api/tx
else else
echo "Not running behind Tor - to install run:" echo "Not running behind Tor - to install run:"
echo "sudo /home/admin/config.scripts/internet.tor.sh on" echo "sudo /home/admin/config.scripts/tor.network.sh on"
fi fi
} }
# command: status # command: status
# start the status screen in the terminal # start the status screen in the terminal
function status() { function status() {
echo "Gathering data - please wait a moment..." echo
echo "Keep X pressed to EXIT loop ... (please wait)"
echo
/home/admin/_cache.sh set system_scan_all_temp "1"
sleep 4
while : while :
do do
# show the same info as on LCD screen # show the same info as on LCD screen
@ -181,10 +191,10 @@ function status() {
#echo #echo
#echo -en "Screen is updating in a loop .... press 'x' now to get back to menu." #echo -en "Screen is updating in a loop .... press 'x' now to get back to menu."
read -n 1 -t 6 keyPressed read -n 1 -t 6 keyPressed
#echo -en "\rGathering information to update info ... please wait. \n"
# check if user wants to abort session # check if user wants to abort session
if [ "${keyPressed}" = "x" ]; then if [ "${keyPressed}" = "x" ]; then
echo echo
/home/admin/_cache.sh set system_scan_all_temp "0"
echo "Returning to menu ....." echo "Returning to menu ....."
sleep 4 sleep 4
break break

View File

@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# LOGFILE - store debug logs of bootstrap # LOGFILE - store debug logs of bootstrap
logFile="/home/admin/raspiblitz.provision-migration.log" logFile="/home/admin/raspiblitz.provision-migration.log"
@ -10,26 +16,20 @@ source ${infoFile}
# SETUPFILE - data from setup process # SETUPFILE - data from setup process
source /var/cache/raspiblitz/temp/raspiblitz.setup source /var/cache/raspiblitz/temp/raspiblitz.setup
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# log header # log header
echo "" > ${logFile} echo "" > ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
echo "# _provision.migration.sh" >> ${logFile} echo "# _provision.migration.sh" >> ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provision Migration'/g" ${infoFile} /home/admin/_cache.sh set message "Provision Migration"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${hddGotMigrationData}" == "" ]; then if [ "${hddGotMigrationData}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.migration.sh "missing-hostnamemigrationdata" "missing hddGotMigrationData" "" ${logFile}
sed -i "s/^message=.*/message='config: missing hddGotMigrationData'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing hddGotMigrationData in (${infoFile})!" >> ${logFile}
exit 2 exit 2
fi fi
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
err="" err=""
nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]") nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]")
echo "**************************************************" >> ${logFile} echo "**************************************************" >> ${logFile}
@ -38,16 +38,13 @@ echo "**************************************************" >> ${logFile}
echo "- started ..." >> ${logFile} echo "- started ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData}) source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
if [ "${err}" != "" ]; then if [ "${err}" != "" ]; then
echo "MIGRATION FAILED: ${err}" >> ${logFile} /home/admin/config.scripts/blitz.error.sh _provision.migration.sh "migration-failed" "${err}" "Recover funds with fresh sd card using seed words + static channel backup." ${logFile}
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup." >> ${logFile}
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='migration failed'/g" ${infoFile}
exit 3 exit 3
fi fi
# make sure for the rest of the seup info is set correctly # make sure for the rest of the seup info is set correctly
sudo sed -i "s/^network=.*/network=bitcoin/g" ${infoFile} /home/admin/config.scripts/blitz.conf.sh set network "bitcoin"
sudo sed -i "s/^chain=.*/chain=main/g" ${infoFile} /home/admin/config.scripts/blitz.conf.sh set chain "main"
# set Password B # set Password B
echo "## SETTING PASSWORD B" >> ${logFile} echo "## SETTING PASSWORD B" >> ${logFile}
@ -57,20 +54,21 @@ if [ "${setPasswordB}" == "1" ]; then
echo "# setting PASSWORD B" >> ${logFile} echo "# setting PASSWORD B" >> ${logFile}
/home/admin/config.scripts/blitz.setpassword.sh b "${passwordB}" >> ${logFile} /home/admin/config.scripts/blitz.setpassword.sh b "${passwordB}" >> ${logFile}
else else
echo "FAIL: Password B should be set but was empty! Running with default." >> ${logFile} /home/admin/config.scripts/blitz.error.sh _provision.migration.sh "missing-passwordb" "FAIL: Password B should be set but was empty! Running with default." "" ${logFile}
exit 4
fi fi
else else
echo "WARN: setPasswordB!=1 this not normal on migration! Running with default." >> ${logFile} /home/admin/config.scripts/blitz.error.sh _provision.migration.sh "missing-setpasswordb" "setPasswordB!=1 this not normal on migration! Running with default." "" ${logFile}
exit 5
fi fi
# if free space is lower than 100GB (100000000) delete backup files # if free space is lower than 100GB (100000000) delete backup files
if [ "${hddDataFreeKB}" != "" ] && [ ${hddDataFreeKB} -lt 407051412 ]; then if [ "${hddDataFreeKB}" != "" ] && [ ${hddDataFreeKB} -lt 407051412 ]; then
echo "- free space of data disk is low ... deleting 'backup_migration'" >> ${logFile} echo "- free space of data disk is low ... deleting 'backup_migration'" >> ${logFile}
sudo rm -R /mnt/hdd/backup_migration rm -R /mnt/hdd/backup_migration
else else
echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'" >> ${logFile} echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'" >> ${logFile}
fi fi
echo "OK MIGRATION" >> ${logFile} echo "OK MIGRATION" >> ${logFile}
echo "END Migration" >> ${logFile} echo "END Migration" >> ${logFile}
exit 0 exit 0

View File

@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# this provision file is just executed on fresh setups # this provision file is just executed on fresh setups
# not on recoveries or updates # not on recoveries or updates
@ -23,35 +29,29 @@ echo "" > ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
echo "# _provision.setup.sh" >> ${logFile} echo "# _provision.setup.sh" >> ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provision Setup'/g" ${infoFile}
################################### ###################################
# Preserve SSH keys # Preserve SSH keys
# just copy dont link anymore # just copy dont link anymore
# see: https://github.com/rootzoll/raspiblitz/issues/1798 # see: https://github.com/rootzoll/raspiblitz/issues/1798
sed -i "s/^message=.*/message='SSH Keys'/g" ${infoFile} /home/admin/_cache.sh set message "SSH Keys"
# link ssh directory from SD card to HDD # link ssh directory from SD card to HDD
/home/admin/config.scripts/blitz.ssh.sh backup /home/admin/config.scripts/blitz.ssh.sh backup
################################### ###################################
# Prepare Blockchain Service # Prepare Blockchain Service
sed -i "s/^message=.*/message='Blockchain Setup'/g" ${infoFile} /home/admin/_cache.sh set message "Blockchain Setup"
source <(/home/admin/_cache.sh get network chain hddBlocksBitcoin)
if [ "${network}" == "" ]; then if [ "${network}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "missing-network" "" "" ${logFile}
sed -i "s/^message=.*/message='config: missing network'/g" ${infoFile} exit 2
echo "FAIL see ${logFile}"
echo "FAIL: missing network in (${setupFile})!" >> ${logFile}
exit 20
fi fi
if [ "${chain}" == "" ]; then if [ "${chain}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "missing-chain" "" "" ${logFile}
sed -i "s/^message=.*/message='config: missing chain'/g" ${infoFile} exit 3
echo "FAIL see ${logFile}"
echo "FAIL: missing chain in (${setupFile})!" >> ${logFile}
exit 2
fi fi
# copy configs files and directories # copy configs files and directories
@ -74,7 +74,7 @@ chown -R admin:admin /home/admin/.${network} >>${logFile} 2>&1
confExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c "${network}.conf") confExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c "${network}.conf")
echo "File Exists: /mnt/hdd/${network}/${network}.conf --> ${confExists}" >> ${logFile} echo "File Exists: /mnt/hdd/${network}/${network}.conf --> ${confExists}" >> ${logFile}
# set password B as RPC password # set password B as RPC password (from setup file)
echo "# setting PASSWORD B" >> ${logFile} echo "# setting PASSWORD B" >> ${logFile}
/home/admin/config.scripts/blitz.setpassword.sh b "${passwordB}" >> ${logFile} /home/admin/config.scripts/blitz.setpassword.sh b "${passwordB}" >> ${logFile}
@ -119,9 +119,7 @@ do
sync sync
loopcount=$(($loopcount +1)) loopcount=$(($loopcount +1))
if [ ${loopcount} -gt 50 ]; then if [ ${loopcount} -gt 50 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "btc-testrun-fail" "${network}d not running" "sudo -u bitcoin ${network}-cli getblockchaininfo | grep "initialblockdownload" -c --> ${bitcoinRunning}" ${logFile}
sed -i "s/^message=.*/message='setup: failed ${network}'/g" ${infoFile}
echo "FAIL: setup: failed ${network}" >> ${logFile}
exit 4 exit 4
fi fi
done done
@ -130,14 +128,20 @@ echo "OK ${network} startup successful " >> ${logFile}
################################### ###################################
# Prepare Lightning # Prepare Lightning
source /mnt/hdd/raspiblitz.conf
echo "Prepare Lightning (${lightning})" >> ${logFile} echo "Prepare Lightning (${lightning})" >> ${logFile}
if [ "${hostname}" == "" ]; then
/home/admin/config.scripts/blitz.error.sh _provision.setup.sh "missing-hostname" "" "" ${logFile}
exit 41
fi
if [ "${lightning}" != "lnd" ]; then if [ "${lightning}" != "lnd" ]; then
################################### ###################################
# Remove LND from systemd # Remove LND from systemd
echo "Remove LND" >> ${logFile} echo "Remove LND" >> ${logFile}
sudo sed -i "s/^message=.*/message='Deactivate Lightning'/g" ${infoFile} /home/admin/_cache.sh set message "Deactivate Lightning"
sudo systemctl disable lnd sudo systemctl disable lnd
sudo rm /etc/systemd/system/lnd.service 2>/dev/null sudo rm /etc/systemd/system/lnd.service 2>/dev/null
sudo systemctl daemon-reload sudo systemctl daemon-reload
@ -148,30 +152,24 @@ if [ "${lightning}" == "lnd" ]; then
################################### ###################################
# LND # LND
echo "############## Setup LND" >> ${logFile} echo "############## Setup LND" >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Setup'/g" ${infoFile} /home/admin/_cache.sh set message "LND Setup"
# password C (raspiblitz.setup)
if [ "${passwordC}" == "" ]; then if [ "${passwordC}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "missing-passwordc" "config: missing passwordC" "" ${logFile}
sed -i "s/^message=.*/message='config: missing passwordC'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing passwordC in (${setupFile})!" >> ${logFile}
exit 5 exit 5
fi fi
# if user uploaded an LND rescue file # if user uploaded an LND rescue file (raspiblitz.setup)
if [ "${lndrescue}" != "" ]; then if [ "${lndrescue}" != "" ]; then
echo "Restore LND data from uploaded rescue file ${lndrescue} ..." >> ${logFile} echo "Restore LND data from uploaded rescue file ${lndrescue} ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/lnd.backup.sh lnd-import ${lndrescue}) source <(sudo /home/admin/config.scripts/lnd.backup.sh lnd-import ${lndrescue})
if [ "${error}" != "" ]; then if [ "${error}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lndrescue-import" "setup: lnd import backup failed" "${error}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd import backup failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd import backup failed" >> ${logFile}
echo "${error}" >> ${logFile}
exit 6 exit 6
fi fi
else else
# preparing new LND config # preparing new LND config (raspiblitz.setup)
echo "Creating new LND config ..." >> ${logFile} echo "Creating new LND config ..." >> ${logFile}
sudo -u bitcoin mkdir /mnt/hdd/lnd 2> /dev/null sudo -u bitcoin mkdir /mnt/hdd/lnd 2> /dev/null
sudo cp /home/admin/assets/lnd.bitcoin.conf /mnt/hdd/lnd/lnd.conf sudo cp /home/admin/assets/lnd.bitcoin.conf /mnt/hdd/lnd/lnd.conf
@ -186,16 +184,13 @@ if [ "${lightning}" == "lnd" ]; then
# check if now a config exists # check if now a config exists
configLinkedCorrectly=$(sudo ls sudo ls /home/bitcoin/.lnd/lnd.conf | grep -c "lnd.conf") configLinkedCorrectly=$(sudo ls sudo ls /home/bitcoin/.lnd/lnd.conf | grep -c "lnd.conf")
if [ "${configLinkedCorrectly}" != "1" ]; then if [ "${configLinkedCorrectly}" != "1" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-link-broken" "link /home/bitcoin/.lnd/lnd.conf broken" "" ${logFile}
sed -i "s/^message=.*/message='setup: lnd conf link broken'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd conf link broken" >> ${logFile}
exit 7 exit 7
fi fi
# Init LND service & start # Init LND service & start
echo "*** Init LND Service & Start ***" >> ${logFile} echo "*** Init LND Service & Start ***" >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Testrun'/g" ${infoFile} /home/admin/_cache.sh set message "LND Testrun"
# just in case # just in case
sudo systemctl stop lnd 2>/dev/null sudo systemctl stop lnd 2>/dev/null
@ -208,13 +203,14 @@ if [ "${lightning}" == "lnd" ]; then
echo "Starting LND Service ..." >> ${logFile} echo "Starting LND Service ..." >> ${logFile}
sudo systemctl enable lnd >> ${logFile} sudo systemctl enable lnd >> ${logFile}
sudo systemctl start lnd >> ${logFile} sudo systemctl start lnd >> ${logFile}
echo "Starting LND Service ... executed" >> ${logFile}
# check that lnd started # check that lnd started
lndRunning=0 lndRunning=0
loopcount=0 loopcount=0
while [ ${lndRunning} -eq 0 ] while [ ${lndRunning} -eq 0 ]
do do
lndRunning=$(sudo systemctl status lnd.service | grep -c running) lndRunning=$(systemctl status lnd.service | grep -c running)
if [ ${lndRunning} -eq 0 ]; then if [ ${lndRunning} -eq 0 ]; then
date +%s >> ${logFile} date +%s >> ${logFile}
echo "LND not ready yet ... waiting another 60 seconds." >> ${logFile} echo "LND not ready yet ... waiting another 60 seconds." >> ${logFile}
@ -222,10 +218,7 @@ if [ "${lightning}" == "lnd" ]; then
fi fi
loopcount=$(($loopcount +1)) loopcount=$(($loopcount +1))
if [ ${loopcount} -gt 100 ]; then if [ ${loopcount} -gt 100 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-start-fail" "lnd service not getting to running status" "sudo systemctl status lnd.service | grep -c running --> ${lndRunning}" ${logFile}
sed -i "s/^message=.*/message='setup: failed lnd start'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: failed lnd start" >> ${logFile}
exit 8 exit 8
fi fi
done done
@ -233,25 +226,18 @@ if [ "${lightning}" == "lnd" ]; then
sleep 10 sleep 10
# Check LND health/fails (to be extended) # Check LND health/fails (to be extended)
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert") tlsExists=$(ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert")
if [ ${tlsExists} -eq 0 ]; then if [ ${tlsExists} -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-no-tls" "lnd not created TLS cert" "no /mnt/hdd/lnd/tls.cert" ${logFile}
sed -i "s/^message=.*/message='setup: missing lnd tls'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: missing lnd tls" >> ${logFile}
exit 9 exit 9
fi fi
# import static channel backup if was uploaded # import static channel backup if was uploaded
if [ "${staticchannelbackup}" != "" ]; then if [ "${staticchannelbackup}" != "" ]; then
echo "Preparing static channel backup file ${staticchannelbackup} ..." >> ${logFile} echo "Preparing static channel backup file ${staticchannelbackup} ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/lnd.backup.sh scb-import ${staticchannelbackup}) source <(/home/admin/config.scripts/lnd.backup.sh scb-import ${staticchannelbackup})
if [ "${error}" != "" ]; then if [ "${error}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-scb-import" "lnd.backup.sh scb-import returned error" "/home/admin/config.scripts/lnd.backup.sh scb-import ${staticchannelbackup} --> ${error}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd import SCB failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd import SCB failed" >> ${logFile}
echo "${error}" >> ${logFile}
exit 10 exit 10
fi fi
fi fi
@ -260,16 +246,11 @@ if [ "${lightning}" == "lnd" ]; then
if [ "${seedWords}" != "" ] && [ "${staticchannelbackup}" != "" ]; then if [ "${seedWords}" != "" ] && [ "${staticchannelbackup}" != "" ]; then
echo "WALLET --> SEED + SCB " >> ${logFile} echo "WALLET --> SEED + SCB " >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Wallet (SEED & SCB)'/g" ${infoFile} /home/admin/_cache.sh set message "LND Wallet (SEED & SCB)"
if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi
sudo /home/admin/config.scripts/lnd.initwallet.py scb mainnet ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword} source <(/home/admin/config.scripts/lnd.initwallet.py scb mainnet ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword})
if [ "${err}" != "" ]; then if [ "${err}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-wallet-seed+scb" "lnd.initwallet.py scb returned error" "/home/admin/config.scripts/lnd.initwallet.py scb mainnet ... --> ${err} + ${errMore}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd wallet SCB failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd wallet SCB failed" >> ${logFile}
echo "${err}" >> ${logFile}
echo "${errMore}" >> ${logFile}
exit 11 exit 11
fi fi
@ -277,16 +258,11 @@ if [ "${lightning}" == "lnd" ]; then
elif [ "${seedWords}" != "" ]; then elif [ "${seedWords}" != "" ]; then
echo "WALLET --> SEED" >> ${logFile} echo "WALLET --> SEED" >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Wallet (SEED)'/g" ${infoFile} /home/admin/_cache.sh set message "LND Wallet (SEED)"
if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi
sudo /home/admin/config.scripts/lnd.initwallet.py seed mainnet ${passwordC} "${seedWords}" ${seedPassword} source <(/home/admin/config.scripts/lnd.initwallet.py seed mainnet ${passwordC} "${seedWords}" ${seedPassword})
if [ "${err}" != "" ]; then if [ "${err}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-wallet-seed" "lnd.initwallet.py seed returned error" "/home/admin/config.scripts/lnd.initwallet.py seed mainnet ... --> ${err} + ${errMore}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
echo "${err}" >> ${logFile}
echo "${errMore}" >> ${logFile}
exit 12 exit 12
fi fi
@ -294,14 +270,15 @@ if [ "${lightning}" == "lnd" ]; then
else else
echo "WALLET --> NEW" >> ${logFile} echo "WALLET --> NEW" >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Wallet (NEW)'/g" ${infoFile} /home/admin/_cache.sh set message "LND Wallet (NEW)"
if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi if ! pip list | grep grpc; then sudo -H python3 -m pip install grpcio==1.38.1; fi
source <(sudo /home/admin/config.scripts/lnd.initwallet.py new mainnet ${passwordC}) source <(/home/admin/config.scripts/lnd.initwallet.py new mainnet ${passwordC})
if [ "${err}" != "" ]; then if [ "${err}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-wallet-new" "lnd.initwallet.py new returned error" "/home/admin/config.scripts/lnd.initwallet.py new mainnet ... --> ${err} + ${errMore}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile} /home/admin/_cache.sh set state "error"
/home/admin/_cache.sh set message "setup: lnd wallet NEW failed"
echo "FAIL see ${logFile}" echo "FAIL see ${logFile}"
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile} echo "FAIL: setup: lnd wallet SEED failed (2)" >> ${logFile}
echo "${err}" >> ${logFile} echo "${err}" >> ${logFile}
echo "${errMore}" >> ${logFile} echo "${errMore}" >> ${logFile}
exit 13 exit 13
@ -315,14 +292,12 @@ if [ "${lightning}" == "lnd" ]; then
# sync macaroons & TLS to other users # sync macaroons & TLS to other users
echo "*** Copy LND Macaroons to user admin ***" >> ${logFile} echo "*** Copy LND Macaroons to user admin ***" >> ${logFile}
sudo sed -i "s/^message=.*/message='LND Credentials'/g" ${infoFile} /home/admin/_cache.sh set message "LND Credentials"
# check if macaroon exists now - if not fail # check if macaroon exists now - if not fail
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon) macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
if [ ${macaroonExists} -eq 0 ]; then if [ ${macaroonExists} -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-no-macaroons" "lnd did not create macaroons" "/home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon --> missing" ${logFile}
sed -i "s/^message=.*/message='setup: lnd no macaroons'/g" ${infoFile}
echo "FAIL: setup: lnd no macaroons" >> ${logFile}
exit 14 exit 14
fi fi
@ -332,10 +307,7 @@ if [ "${lightning}" == "lnd" ]; then
# make a final lnd check # make a final lnd check
source <(/home/admin/config.scripts/lnd.check.sh basic-setup) source <(/home/admin/config.scripts/lnd.check.sh basic-setup)
if [ "${err}" != "" ]; then if [ "${err}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "lnd-check-error" "lnd.check.sh basic-setup with error" "/home/admin/config.scripts/lnd.check.sh basic-setup --> ${err}" ${logFile}
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
echo "${err}" >> ${logFile}
exit 15 exit 15
fi fi
@ -351,21 +323,17 @@ if [ "${lightning}" == "cl" ]; then
# c-lightning # c-lightning
echo "############## c-lightning" >> ${logFile} echo "############## c-lightning" >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Install'/g" ${infoFile} /home/admin/_cache.sh set message "C-Lightning Install"
sudo /home/admin/config.scripts/cl.install.sh on mainnet >> ${logFile} sudo /home/admin/config.scripts/cl.install.sh on mainnet >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Setup'/g" ${infoFile} /home/admin/_cache.sh set message "C-Lightning Setup"
# OLD WALLET FROM CLIGHTNING RESCUE # OLD WALLET FROM CLIGHTNING RESCUE
if [ "${clrescue}" != "" ]; then if [ "${clrescue}" != "" ]; then
echo "Restore CL data from uploaded rescue file ${clrescue} ..." >> ${logFile} echo "Restore CL data from uploaded rescue file ${clrescue} ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/cl.backup.sh cl-import ${clrescue}) source <(/home/admin/config.scripts/cl.backup.sh cl-import ${clrescue})
if [ "${error}" != "" ]; then if [ "${error}" != "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "cl-import-backup" "cl.backup.sh cl-import with error" "/home/admin/config.scripts/cl.backup.sh cl-import ${clrescue} --> ${error}" ${logFile}
sed -i "s/^message=.*/message='setup: cl import backup failed'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: setup: cl import backup failed" >> ${logFile}
echo "${error}" >> ${logFile}
exit 16 exit 16
fi fi
@ -373,14 +341,12 @@ if [ "${lightning}" == "cl" ]; then
elif [ "${seedWords}" != "" ]; then elif [ "${seedWords}" != "" ]; then
echo "Restore CL wallet from seedWords ..." >> ${logFile} echo "Restore CL wallet from seedWords ..." >> ${logFile}
source <(sudo /home/admin/config.scripts/cl.hsmtool.sh seed-force mainnet "${seedWords}" "${seedPassword}") source <(/home/admin/config.scripts/cl.hsmtool.sh seed-force mainnet "${seedWords}" "${seedPassword}")
# check if wallet really got created # check if wallet really got created
walletExistsNow=$(sudo ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret") walletExistsNow=$(ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret")
if [ $walletExistsNow -eq 0 ]; then if [ $walletExistsNow -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "cl-wallet-seed" "cl.hsmtool.sh seed-force not created wallet" "ls /home/bitcoin/.lightning/bitcoin/hsm_secret --> 0" ${logFile}
sed -i "s/^message=.*/message='setup: seed maybe wrong'/g" ${infoFile}
echo "FAIL: setup: no cl wallet created - seed maybe wrong" >> ${logFile}
exit 17 exit 17
fi fi
@ -390,22 +356,18 @@ if [ "${lightning}" == "cl" ]; then
echo "Generate new CL wallet ..." >> ${logFile} echo "Generate new CL wallet ..." >> ${logFile}
# generate new wallet # generate new wallet
source <(sudo /home/admin/config.scripts/cl.hsmtool.sh new-force mainnet) source <(/home/admin/config.scripts/cl.hsmtool.sh new-force mainnet)
# check if got new seedwords # check if got new seedwords
if [ "${seedwords}" == "" ] || [ "${seedwords6x4}" == "" ]; then if [ "${seedwords}" == "" ] || [ "${seedwords6x4}" == "" ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "cl-wallet-new-noseeds" "cl.hsmtool.sh new-force did not returned seedwords" "/home/admin/config.scripts/cl.hsmtool.sh new-force mainnet --> seedwords=''" ${logFile}
sed -i "s/^message=.*/message='setup: no cl seedwords'/g" ${infoFile}
echo "FAIL: setup: no cl seedwords" >> ${logFile}
exit 18 exit 18
fi fi
# check if wallet really got created # check if wallet really got created
walletExistsNow=$(sudo ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret") walletExistsNow=$(sudo ls /home/bitcoin/.lightning/bitcoin/hsm_secret 2>/dev/null | grep -c "hsm_secret")
if [ $walletExistsNow -eq 0 ]; then if [ $walletExistsNow -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.setup.sh "cl-wallet-new-nowallet" "cl.hsmtool.sh new-force did not created wallet" "/home/bitcoin/.lightning/bitcoin/hsm_secret --> missing" ${logFile}
sed -i "s/^message=.*/message='setup: no cl wallet created'/g" ${infoFile}
echo "FAIL: setup: no cl wallet created" >> ${logFile}
exit 19 exit 19
fi fi
@ -425,6 +387,6 @@ fi
echo "stopping bitcoind for the rest provision again (will start on next boot)" >> ${logFile} echo "stopping bitcoind for the rest provision again (will start on next boot)" >> ${logFile}
systemctl stop bitcoind >> ${logFile} systemctl stop bitcoind >> ${logFile}
sudo sed -i "s/^message=.*/message='Provision Setup Finish'/g" ${infoFile} /home/admin/_cache.sh set message "Provision Setup Finish"
echo "END Setup" >> ${logFile} echo "END Setup" >> ${logFile}
exit 0 exit 0

View File

@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# LOGFILE - store debug logs of bootstrap # LOGFILE - store debug logs of bootstrap
logFile="/home/admin/raspiblitz.provision-update.log" logFile="/home/admin/raspiblitz.provision-update.log"
@ -18,7 +24,7 @@ echo "" > ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
echo "# _provision.update.sh" >> ${logFile} echo "# _provision.update.sh" >> ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Running Data Update'/g" ${infoFile} /home/admin/_cache.sh set message "Running Data Update"
# HDD BTRFS RAID REPAIR IF NEEDED # HDD BTRFS RAID REPAIR IF NEEDED
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
@ -40,15 +46,13 @@ source ${configFile}
# check if config files contains basic: hostname # check if config files contains basic: hostname
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.update.sh "missing-hostname" "${setupFile} or ${configFile} contains no hostname" "" ${logFile}
sed -i "s/^message=.*/message='config: missing hostname'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: missing hostname in (${configFile})!" >> ${logFile}
exit 1 exit 1
fi fi
# check if config files contain lightning (lnd is default) # check if config files contain lightning (lnd is default) introduced in v1.7.1
if [ "${lightning}" == "" ]; then entryExists=$(cat ${configFile} | grep -c "^lightning=")
if [ "${entryExists}" != "1" ]; then
lightning="lnd" lightning="lnd"
echo "lightning=${lightning}" >> ${configFile} echo "lightning=${lightning}" >> ${configFile}
fi fi
@ -58,10 +62,7 @@ source /home/admin/_version.info
# check if code version was loaded # check if code version was loaded
if [ ${#codeVersion} -eq 0 ]; then if [ ${#codeVersion} -eq 0 ]; then
sed -i "s/^state=.*/state=error/g" ${infoFile} /home/admin/config.scripts/blitz.error.sh _provision.update.sh "missing-version" "missing /home/admin/_version.info" "" ${logFile}
sed -i "s/^message=.*/message='missing /home/admin/_version.info'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: no code version (/home/admin/_version.info) found!" >> ${logFile}
exit 1 exit 1
fi fi
@ -143,7 +144,7 @@ if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script" >> ${logFile} echo "detected version change ... starting migration script" >> ${logFile}
# nothing specific here yet # nothing specific here yet
echo "OK Done - Updating version in config" echo "OK Done - Updating version in config"
sudo sed -i "s/^raspiBlitzVersion=.*/raspiBlitzVersion='${codeVersion}'/g" ${configFile} /home/admin/config.scripts/blitz.conf.sh set raspiBlitzVersion "${codeVersion}"
else else
echo "OK - version of config data is up to date" >> ${logFile} echo "OK - version of config data is up to date" >> ${logFile}
fi fi
@ -151,26 +152,25 @@ fi
# start network service # start network service
echo "" echo ""
echo "*** Start ${network} (UPDATE) ***" >> ${logFile} echo "*** Start ${network} (UPDATE) ***" >> ${logFile}
sudo sed -i "s/^message=.*/message='Blockchain Testrun'/g" ${infoFile} /home/admin/_cache.sh set message "Blockchain Testrun"
echo "- This can take a while .." >> ${logFile} echo "- This can take a while .." >> ${logFile}
sudo chown -R bitcoin:bitcoin /mnt/hdd/${network} >>${logFile} 2>&1 chown -R bitcoin:bitcoin /mnt/hdd/${network} >>${logFile} 2>&1
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload >> ${logFile} systemctl daemon-reload >> ${logFile}
sudo systemctl enable ${network}d.service >> ${logFile} systemctl enable ${network}d.service >> ${logFile}
sudo systemctl start ${network}d.service >> ${logFile} systemctl start ${network}d.service >> ${logFile}
# INSTALL LND on Upadte/Recovery # INSTALL LND on Upadte/Recovery
if [ "${lightning}" == "lnd" ]; then if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
# prepare lnd service # prepare lnd service
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1 cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
# convert old keysend by lndExtraParameter to raspiblitz.conf setting (will be enforced by lnd.check.sh prestart) since 1.7.1 # convert old keysend by lndExtraParameter to raspiblitz.conf setting (will be enforced by lnd.check.sh prestart) since 1.7.1
if [ "${lndExtraParameter}" == "--accept-keysend" ]; then if [ "${lndExtraParameter}" == "--accept-keysend" ]; then
echo "# MIGRATION KEYSEND from lndExtraParameter --> raspiblitz.conf" >> ${logFile} echo "# MIGRATION KEYSEND from lndExtraParameter --> raspiblitz.conf" >> ${logFile}
sudo sed -i '/lndKeysend=.*/d' /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lndKeysend "on"
echo "lndKeysend=on" >> /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh delete lndExtraParameter
sudo sed -i "/^lndExtraParameter=/d" /mnt/hdd/raspiblitz.conf 2>/dev/null
fi fi
# if old lnd.conf exists ... # if old lnd.conf exists ...
@ -178,61 +178,61 @@ if [ "${lightning}" == "lnd" ]; then
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
# make sure correct file permisions are set # make sure correct file permisions are set
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
sudo chmod 664 /mnt/hdd/lnd/lnd.conf chmod 664 /mnt/hdd/lnd/lnd.conf
# make sure additional values are added to [Application Options] since v1.7 # make sure additional values are added to [Application Options] since v1.7
echo "- lnd.conf --> checking additional [Application Options] since v1.7" >> ${logFile} echo "- lnd.conf --> checking additional [Application Options] since v1.7" >> ${logFile}
applicationOptionsLineNumber=$(sudo grep -n "\[Application Options\]" /mnt/hdd/lnd/lnd.conf | cut -d ":" -f1) applicationOptionsLineNumber=$(grep -n "\[Application Options\]" /mnt/hdd/lnd/lnd.conf | cut -d ":" -f1)
if [ "${applicationOptionsLineNumber}" != "" ]; then if [ "${applicationOptionsLineNumber}" != "" ]; then
applicationOptionsLineNumber="$(($applicationOptionsLineNumber+1))" applicationOptionsLineNumber="$(($applicationOptionsLineNumber+1))"
# Avoid historical graph data sync # Avoid historical graph data sync
# ignore-historical-gossip-filters=1 # ignore-historical-gossip-filters=1
configParamExists=$(sudo grep -c "^ignore-historical-gossip-filters=" /mnt/hdd/lnd/lnd.conf) configParamExists=$(grep -c "^ignore-historical-gossip-filters=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'ignore-historical-gossip-filters'" >> ${logFile} echo " - ADDING 'ignore-historical-gossip-filters'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}iignore-historical-gossip-filters=1" /mnt/hdd/lnd/lnd.conf sed -i "${applicationOptionsLineNumber}iignore-historical-gossip-filters=1" /mnt/hdd/lnd/lnd.conf
else else
echo " - OK 'ignore-historical-gossip-filters' exists (${configParamExists})" >> ${logFile} echo " - OK 'ignore-historical-gossip-filters' exists (${configParamExists})" >> ${logFile}
fi fi
# Avoid slow startup time # Avoid slow startup time
# sync-freelist=1 # sync-freelist=1
configParamExists=$(sudo grep -c "^sync-freelist=" /mnt/hdd/lnd/lnd.conf) configParamExists=$(grep -c "^sync-freelist=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'sync-freelist'" >> ${logFile} echo " - ADDING 'sync-freelist'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}isync-freelist=1" /mnt/hdd/lnd/lnd.conf sed -i "${applicationOptionsLineNumber}isync-freelist=1" /mnt/hdd/lnd/lnd.conf
else else
echo " - OK 'sync-freelist' exists (${configParamExists})" >> ${logFile} echo " - OK 'sync-freelist' exists (${configParamExists})" >> ${logFile}
fi fi
# Avoid high startup overhead # Avoid high startup overhead
# stagger-initial-reconnect=1 # stagger-initial-reconnect=1
configParamExists=$(sudo grep -c "^stagger-initial-reconnect=" /mnt/hdd/lnd/lnd.conf) configParamExists=$(grep -c "^stagger-initial-reconnect=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'stagger-initial-reconnect'" >> ${logFile} echo " - ADDING 'stagger-initial-reconnect'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}istagger-initial-reconnect=1" /mnt/hdd/lnd/lnd.conf sed -i "${applicationOptionsLineNumber}istagger-initial-reconnect=1" /mnt/hdd/lnd/lnd.conf
else else
echo " - OK 'stagger-initial-reconnect' exists (${configParamExists})" >> ${logFile} echo " - OK 'stagger-initial-reconnect' exists (${configParamExists})" >> ${logFile}
fi fi
# Delete and recreate RPC TLS certificate when details change or cert expires # Delete and recreate RPC TLS certificate when details change or cert expires
# tlsautorefresh=1 # tlsautorefresh=1
configParamExists=$(sudo grep -c "^tlsautorefresh=" /mnt/hdd/lnd/lnd.conf) configParamExists=$(grep -c "^tlsautorefresh=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsautorefresh'" >> ${logFile} echo " - ADDING 'tlsautorefresh'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsautorefresh=1" /mnt/hdd/lnd/lnd.conf sed -i "${applicationOptionsLineNumber}itlsautorefresh=1" /mnt/hdd/lnd/lnd.conf
else else
echo " - OK 'tlsautorefresh' exists (${configParamExists})" >> ${logFile} echo " - OK 'tlsautorefresh' exists (${configParamExists})" >> ${logFile}
fi fi
# Do not include IPs in the RPC TLS certificate # Do not include IPs in the RPC TLS certificate
# tlsdisableautofill=1 # tlsdisableautofill=1
configParamExists=$(sudo grep -c "^tlsdisableautofill=" /mnt/hdd/lnd/lnd.conf) configParamExists=$(grep -c "^tlsdisableautofill=" /mnt/hdd/lnd/lnd.conf)
if [ "${configParamExists}" == "0" ]; then if [ "${configParamExists}" == "0" ]; then
echo " - ADDING 'tlsdisableautofill'" >> ${logFile} echo " - ADDING 'tlsdisableautofill'" >> ${logFile}
sudo sed -i "${applicationOptionsLineNumber}itlsdisableautofill=1" /mnt/hdd/lnd/lnd.conf sed -i "${applicationOptionsLineNumber}itlsdisableautofill=1" /mnt/hdd/lnd/lnd.conf
else else
echo " - OK 'tlsdisableautofill' exists (${configParamExists})" >> ${logFile} echo " - OK 'tlsdisableautofill' exists (${configParamExists})" >> ${logFile}
fi fi
@ -246,27 +246,17 @@ if [ "${lightning}" == "lnd" ]; then
# start LND service # start LND service
echo "Starting LND Service ..." >> ${logFile} echo "Starting LND Service ..." >> ${logFile}
sudo systemctl enable lnd >> ${logFile} systemctl enable lnd >> ${logFile}
sudo systemctl start lnd >> ${logFile} systemctl start lnd >> ${logFile}
elif [ "${lightning}" == "cl" ]; then fi
if [ "${lightning}" == "cl" ] || [ "${cl}" == "on" ]; then
echo "Install C-lightning on update" >> ${logFile} echo "Install C-lightning on update" >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Install'/g" ${infoFile} /home/admin/_cache.sh set message "C-Lightning Install"
sudo /home/admin/config.scripts/cl.install.sh on mainnet >> ${logFile} /home/admin/config.scripts/cl.install.sh on mainnet >> ${logFile}
sudo sed -i "s/^message=.*/message='C-Lightning Setup'/g" ${infoFile} /home/admin/_cache.sh set message "C-Lightning Setup"
elif [ "${lightning}" == "none" ]; then
echo "No Lightning" >> ${logFile}
else
sed -i "s/^state=.*/state=error/g" ${infoFile}
sed -i "s/^message=.*/message='unknown lightning (${lightning})'/g" ${infoFile}
echo "FAIL see ${logFile}"
echo "FAIL: unknown lightning (${lightning}) in (${configFile})!" >> ${logFile}
exit 1
fi fi

View File

@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# This script gets called from a fresh SD card # This script gets called from a fresh SD card
# starting up that has an config file on HDD # starting up that has an config file on HDD
# from old RaspiBlitz or manufacturer to # from old RaspiBlitz or manufacturer to
@ -10,7 +16,6 @@ logFile="/home/admin/raspiblitz.log"
# INFOFILE - state data from bootstrap # INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info" infoFile="/home/admin/raspiblitz.info"
infoFileDisplayClass="${displayClass}"
# CONFIGFILE - configuration of RaspiBlitz # CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf" configFile="/mnt/hdd/raspiblitz.conf"
@ -25,78 +30,24 @@ echo "" >> ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
echo "# _provision_.sh" >> ${logFile} echo "# _provision_.sh" >> ${logFile}
echo "###################################" >> ${logFile} echo "###################################" >> ${logFile}
sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile} /home/admin/_cache.sh set message "Provisioning from Config"
# check if there is a config file # check if there is a config file
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 0 ]; then
echo "FAIL: no config file (${configFile}) found to run provision!" >> ${logFile} /home/admin/config.scripts/blitz.error.sh _provision_.sh "missing-config" "no config file (${configFile}) found to run provision" "" ${logFile}
exit 1 exit 1
fi fi
# import config values # import config values
source ${configFile} source ${configFile}
##########################
# DISPLAY SETTINGS
##########################
# check if the raspiblitz config has a different display mode than the build image
echo "### DISPLAY SETTINGS ###" >> ${logFile}
# OLD: when nothing is set in raspiblitz.conf (<1.7)
existsDisplayClass=$(sudo cat ${configFile} | grep -c "displayClass=")
if [ "${existsDisplayClass}" == "0" ]; then
displayClass="lcd"
fi
# OLD: lcd2hdmi (deprecated)
if [ "${lcd2hdmi}" == "on" ]; then
echo "Convert lcd2hdmi=on to displayClass='hdmi'" >> ${logFile}
sudo sed -i "s/^lcd2hdmi=.*//g" ${configFile}
echo "displayClass=hdmi" >> ${configFile}
displayClass="hdmi"
elif [ "${lcd2hdmi}" != "" ]; then
echo "Remove old lcd2hdmi pramater from config" >> ${logFile}
sudo sed -i "s/^lcd2hdmi=.*//g" ${configFile}
displayClass="lcd"
fi
# OLD: headless (deprecated)
if [ "${headless}" == "on" ]; then
echo "Convert headless=on to displayClass='headless'" >> ${logFile}
sudo sed -i "s/^headless=.*//g" ${configFile}
echo "displayClass=headless" >> ${configFile}
displayClass="headless"
elif [ "${headless}" != "" ]; then
echo "Remove old headless parameter from config" >> ${logFile}
sudo sed -i "s/^headless=.*//g" ${configFile}
displayClass="lcd"
fi
# NEW: decide by displayClass
echo "raspiblitz.info(${infoFileDisplayClass}) raspiblitz.conf(${displayClass})" >> ${logFile}
if [ "${infoFileDisplayClass}" != "" ] && [ "${displayClass}" != "" ]; then
if [ "${infoFileDisplayClass}" != "${displayClass}" ]; then
echo "Need to update displayClass from (${infoFileDisplayClass}) to (${displayClass})'" >> ${logFile}
sudo /home/admin/config.scripts/blitz.display.sh set-display ${displayClass} >> ${logFile}
echo "going into reboot" >> ${logFile}
sudo cp ${logFile} ${logFile}.display.recover
sudo shutdown -r now
exit 0
else
echo "Display Setting is correct ... no need for change" >> ${logFile}
fi
else
echo "WARN values in raspiblitz info and/or conf file seem broken" >> ${logFile}
fi
########################## ##########################
# BASIC SYSTEM SETTINGS # BASIC SYSTEM SETTINGS
########################## ##########################
echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile} echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup System .'/g" ${infoFile} /home/admin/_cache.sh set message "Setup System ."
echo "# Make sure the user bitcoin is in the debian-tor group" echo "# Make sure the user bitcoin is in the debian-tor group"
sudo usermod -a -G debian-tor bitcoin sudo usermod -a -G debian-tor bitcoin
@ -160,7 +111,7 @@ echo "" >> ${logFile}
########################## ##########################
# finish setup (SWAP, Benus, Firewall, Update, ..) # finish setup (SWAP, Benus, Firewall, Update, ..)
sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile} /home/admin/_cache.sh set message "Setup System .."
# add bonus scripts (auto install deactivated to reduce third party repos) # add bonus scripts (auto install deactivated to reduce third party repos)
mkdir /home/admin/tmpScriptDL mkdir /home/admin/tmpScriptDL
@ -231,7 +182,7 @@ sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
########################## ##########################
# PROVISIONING SERVICES # PROVISIONING SERVICES
########################## ##########################
sudo sed -i "s/^message=.*/message='Installing Services'/g" ${infoFile} /home/admin/_cache.sh set message "Installing Services"
echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile} echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile}
@ -241,7 +192,7 @@ echo "Provisioning BLITZ WEB SERVICE - run config script" >> ${logFile}
# BITCOIN INTERIMS UPDATE # BITCOIN INTERIMS UPDATE
if [ ${#bitcoinInterimsUpdate} -gt 0 ]; then if [ ${#bitcoinInterimsUpdate} -gt 0 ]; then
sudo sed -i "s/^message=.*/message='Provisioning Bitcoin Core update'/g" ${infoFile} /home/admin/_cache.sh set message "Provisioning Bitcoin Core update"
if [ "${bitcoinInterimsUpdate}" == "reckless" ]; then if [ "${bitcoinInterimsUpdate}" == "reckless" ]; then
# recklessly update Bitcoin Core to latest release on GitHub # recklessly update Bitcoin Core to latest release on GitHub
echo "Provisioning Bitcoin Core reckless interims update" >> ${logFile} echo "Provisioning Bitcoin Core reckless interims update" >> ${logFile}
@ -250,7 +201,7 @@ if [ ${#bitcoinInterimsUpdate} -gt 0 ]; then
# when installing the same sd image - this will re-trigger the secure interims update # when installing the same sd image - this will re-trigger the secure interims update
# if this a update with a newer RaspiBlitz version .. interims update will be ignored # if this a update with a newer RaspiBlitz version .. interims update will be ignored
# because standard Bitcoin Core version is most more up to date # because standard Bitcoin Core version is most more up to date
echo "Provisioning BItcoin Core tested interims update" >> ${logFile} echo "Provisioning Bitcoin Core tested interims update" >> ${logFile}
sudo /home/admin/config.scripts/bitcoin.update.sh tested ${bitcoinInterimsUpdate} >> ${logFile} sudo /home/admin/config.scripts/bitcoin.update.sh tested ${bitcoinInterimsUpdate} >> ${logFile}
fi fi
else else
@ -259,7 +210,7 @@ fi
# LND INTERIMS UPDATE # LND INTERIMS UPDATE
if [ ${#lndInterimsUpdate} -gt 0 ]; then if [ ${#lndInterimsUpdate} -gt 0 ]; then
sudo sed -i "s/^message=.*/message='Provisioning LND update'/g" ${infoFile} /home/admin/_cache.sh set message "Provisioning LND update"
if [ "${lndInterimsUpdate}" == "reckless" ]; then if [ "${lndInterimsUpdate}" == "reckless" ]; then
# recklessly update LND to latest release on GitHub (just for test & dev nodes) # recklessly update LND to latest release on GitHub (just for test & dev nodes)
echo "Provisioning LND reckless interims update" >> ${logFile} echo "Provisioning LND reckless interims update" >> ${logFile}
@ -277,7 +228,7 @@ fi
# CL INTERIMS UPDATE # CL INTERIMS UPDATE
if [ ${#clInterimsUpdate} -gt 0 ]; then if [ ${#clInterimsUpdate} -gt 0 ]; then
sudo sed -i "s/^message=.*/message='Provisioning CL update'/g" ${infoFile} /home/admin/_cache.sh set message "Provisioning CL update"
if [ "${clInterimsUpdate}" == "reckless" ]; then if [ "${clInterimsUpdate}" == "reckless" ]; then
# recklessly update CL to latest release on GitHub (just for test & dev nodes) # recklessly update CL to latest release on GitHub (just for test & dev nodes)
echo "Provisioning CL reckless interims update" >> ${logFile} echo "Provisioning CL reckless interims update" >> ${logFile}
@ -364,16 +315,16 @@ fi
# TOR # TOR
if [ "${runBehindTor}" == "on" ]; then if [ "${runBehindTor}" == "on" ]; then
echo "Provisioning TOR - run config script" >> ${logFile} echo "Provisioning TOR - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Tor (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Tor (takes time)"
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
else else
echo "Provisioning TOR - keep default" >> ${logFile} echo "Provisioning Tor - keep default" >> ${logFile}
fi fi
# AUTO PILOT # AUTO PILOT
if [ "${autoPilot}" = "on" ]; then if [ "${autoPilot}" = "on" ]; then
echo "Provisioning AUTO PILOT - run config script" >> ${logFile} echo "Provisioning AUTO PILOT - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup AutoPilot'/g" ${infoFile} /home/admin/_cache.sh set message "Setup AutoPilot"
sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1
else else
echo "Provisioning AUTO PILOT - keep default" >> ${logFile} echo "Provisioning AUTO PILOT - keep default" >> ${logFile}
@ -382,7 +333,7 @@ fi
# NETWORK UPNP # NETWORK UPNP
if [ "${networkUPnP}" = "on" ]; then if [ "${networkUPnP}" = "on" ]; then
echo "Provisioning NETWORK UPnP - run config script" >> ${logFile} echo "Provisioning NETWORK UPnP - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup UPnP'/g" ${infoFile} /home/admin/_cache.sh set message "Setup UPnP"
sudo /home/admin/config.scripts/network.upnp.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/network.upnp.sh on >> ${logFile} 2>&1
else else
echo "Provisioning NETWORK UPnP - keep default" >> ${logFile} echo "Provisioning NETWORK UPnP - keep default" >> ${logFile}
@ -391,7 +342,7 @@ fi
# LND AUTO NAT DISCOVERY # LND AUTO NAT DISCOVERY
if [ "${autoNatDiscovery}" = "on" ]; then if [ "${autoNatDiscovery}" = "on" ]; then
echo "Provisioning LND AUTO NAT DISCOVERY - run config script" >> ${logFile} echo "Provisioning LND AUTO NAT DISCOVERY - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup AutoNAT'/g" ${infoFile} /home/admin/_cache.sh set message "Setup AutoNAT"
sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1
else else
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile} echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile}
@ -400,7 +351,7 @@ fi
# DYNAMIC DOMAIN # DYNAMIC DOMAIN
if [ "${#dynDomain}" -gt 0 ]; then if [ "${#dynDomain}" -gt 0 ]; then
echo "Provisioning DYNAMIC DOMAIN - run config script" >> ${logFile} echo "Provisioning DYNAMIC DOMAIN - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup DynamicDomain'/g" ${infoFile} /home/admin/_cache.sh set message "Setup DynamicDomain"
sudo /home/admin/config.scripts/internet.dyndomain.sh on ${dynDomain} ${dynUpdateUrl} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/internet.dyndomain.sh on ${dynDomain} ${dynUpdateUrl} >> ${logFile} 2>&1
else else
echo "Provisioning DYNAMIC DOMAIN - keep default" >> ${logFile} echo "Provisioning DYNAMIC DOMAIN - keep default" >> ${logFile}
@ -409,7 +360,7 @@ fi
# RTL (LND) # RTL (LND)
if [ "${rtlWebinterface}" = "on" ]; then if [ "${rtlWebinterface}" = "on" ]; then
echo "Provisioning RTL LND - run config script" >> ${logFile} echo "Provisioning RTL LND - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup RTL LND (takes time)"
sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on lnd mainnet >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on lnd mainnet >> ${logFile} 2>&1
else else
echo "Provisioning RTL LND - keep default" >> ${logFile} echo "Provisioning RTL LND - keep default" >> ${logFile}
@ -418,7 +369,7 @@ fi
# RTL (CL) # RTL (CL)
if [ "${crtlWebinterface}" = "on" ]; then if [ "${crtlWebinterface}" = "on" ]; then
echo "Provisioning RTL CL - run config script" >> ${logFile} echo "Provisioning RTL CL - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup RTL CL (takes time)"
sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on cl mainnet >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on cl mainnet >> ${logFile} 2>&1
else else
echo "Provisioning RTL CL - keep default" >> ${logFile} echo "Provisioning RTL CL - keep default" >> ${logFile}
@ -427,7 +378,7 @@ fi
# SPARKO # SPARKO
if [ "${sparko}" = "on" ]; then if [ "${sparko}" = "on" ]; then
echo "Provisioning Sparko - run config script" >> ${logFile} echo "Provisioning Sparko - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup SPARKO'/g" ${infoFile} /home/admin/_cache.sh set message "Setup SPARKO"
sudo -u admin /home/admin/config.scripts/cl-plugin.sparko.sh on mainnet >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/cl-plugin.sparko.sh on mainnet >> ${logFile} 2>&1
else else
echo "Provisioning Sparko - keep default" >> ${logFile} echo "Provisioning Sparko - keep default" >> ${logFile}
@ -436,7 +387,7 @@ fi
# clHTTPplugin # clHTTPplugin
if [ "${clHTTPplugin}" = "on" ]; then if [ "${clHTTPplugin}" = "on" ]; then
echo "Provisioning clHTTPplugin - run config script" >> ${logFile} echo "Provisioning clHTTPplugin - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup clHTTPplugin'/g" ${infoFile} /home/admin/_cache.sh set message "Setup clHTTPplugin"
sudo -u admin /home/admin/config.scripts/cl-plugin.http.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/cl-plugin.http.sh on >> ${logFile} 2>&1
else else
echo "Provisioning clHTTPplugin - keep default" >> ${logFile} echo "Provisioning clHTTPplugin - keep default" >> ${logFile}
@ -445,7 +396,7 @@ fi
# SPARK # SPARK
if [ "${spark}" = "on" ]; then if [ "${spark}" = "on" ]; then
echo "Provisioning Spark Wallet - run config script" >> ${logFile} echo "Provisioning Spark Wallet - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup SPARK WALLET'/g" ${infoFile} /home/admin/_cache.sh set message "Setup SPARK WALLET"
sudo -u admin /home/admin/config.scripts/cl.spark.sh on mainnet >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/cl.spark.sh on mainnet >> ${logFile} 2>&1
else else
echo "Provisioning Spark Wallet - keep default" >> ${logFile} echo "Provisioning Spark Wallet - keep default" >> ${logFile}
@ -454,7 +405,7 @@ fi
#LOOP - install only if LiT won't be installed #LOOP - install only if LiT won't be installed
if [ "${loop}" = "on" ] && [ "${lit}" != "on" ]; then if [ "${loop}" = "on" ] && [ "${lit}" != "on" ]; then
echo "Provisioning Lightning Loop - run config script" >> ${logFile} echo "Provisioning Lightning Loop - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Lightning Loop'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Lightning Loop"
sudo -u admin /home/admin/config.scripts/bonus.loop.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.loop.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Lightning Loop - keep default" >> ${logFile} echo "Provisioning Lightning Loop - keep default" >> ${logFile}
@ -463,7 +414,7 @@ fi
#BTC RPC EXPLORER #BTC RPC EXPLORER
if [ "${BTCRPCexplorer}" = "on" ]; then if [ "${BTCRPCexplorer}" = "on" ]; then
echo "Provisioning BTCRPCexplorer - run config script" >> ${logFile} echo "Provisioning BTCRPCexplorer - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup BTCRPCexplorer (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup BTCRPCexplorer (takes time)"
sudo -u admin /home/admin/config.scripts/bonus.btc-rpc-explorer.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.btc-rpc-explorer.sh on >> ${logFile} 2>&1
else else
echo "Provisioning BTCRPCexplorer - keep default" >> ${logFile} echo "Provisioning BTCRPCexplorer - keep default" >> ${logFile}
@ -472,7 +423,7 @@ fi
#ELECTRS #ELECTRS
if [ "${ElectRS}" = "on" ]; then if [ "${ElectRS}" = "on" ]; then
echo "Provisioning ElectRS - run config script" >> ${logFile} echo "Provisioning ElectRS - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup ElectRS (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup ElectRS (takes time)"
sudo -u admin /home/admin/config.scripts/bonus.electrs.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.electrs.sh on >> ${logFile} 2>&1
else else
echo "Provisioning ElectRS - keep default" >> ${logFile} echo "Provisioning ElectRS - keep default" >> ${logFile}
@ -482,7 +433,7 @@ fi
if [ "${BTCPayServer}" = "on" ]; then if [ "${BTCPayServer}" = "on" ]; then
echo "Provisioning BTCPAYSERVER on TOR - running setup" >> ${logFile} echo "Provisioning BTCPAYSERVER on TOR - running setup" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup BTCPay (takes time)'/g" ${infoFile} /home/admin/_cache.sh set message "Setup BTCPay (takes time)"
sudo -u admin /home/admin/config.scripts/bonus.btcpayserver.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.btcpayserver.sh on >> ${logFile} 2>&1
else else
@ -493,7 +444,7 @@ fi
# LNDMANAGE # LNDMANAGE
#if [ "${lndmanage}" = "on" ]; then #if [ "${lndmanage}" = "on" ]; then
# echo "Provisioning lndmanage - run config script" >> ${logFile} # echo "Provisioning lndmanage - run config script" >> ${logFile}
# sudo sed -i "s/^message=.*/message='Setup lndmanage '/g" ${infoFile} # /home/admin/_cache.sh set message "Setup lndmanage"
# sudo -u admin /home/admin/config.scripts/bonus.lndmanage.sh on >> ${logFile} 2>&1 # sudo -u admin /home/admin/config.scripts/bonus.lndmanage.sh on >> ${logFile} 2>&1
#else #else
# echo "Provisioning lndmanage - not active" >> ${logFile} # echo "Provisioning lndmanage - not active" >> ${logFile}
@ -526,6 +477,7 @@ fi
# CHANTOOLS # CHANTOOLS
if [ "${chantools}" == "on" ]; then if [ "${chantools}" == "on" ]; then
echo "Provisioning chantools - run config script" >> ${logFile} echo "Provisioning chantools - run config script" >> ${logFile}
/home/admin/_cache.sh set message "Setup Chantools"
sudo /home/admin/config.scripts/bonus.chantools.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/bonus.chantools.sh on >> ${logFile} 2>&1
else else
echo "Provisioning chantools - keep default" >> ${logFile} echo "Provisioning chantools - keep default" >> ${logFile}
@ -534,7 +486,7 @@ fi
# SSH TUNNEL # SSH TUNNEL
if [ "${#sshtunnel}" -gt 0 ]; then if [ "${#sshtunnel}" -gt 0 ]; then
echo "Provisioning SSH Tunnel - run config script" >> ${logFile} echo "Provisioning SSH Tunnel - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup SSH Tunnel'/g" ${infoFile} /home/admin/_cache.sh set message "Setup SSH Tunnel"
sudo /home/admin/config.scripts/internet.sshtunnel.py restore ${sshtunnel} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/internet.sshtunnel.py restore ${sshtunnel} >> ${logFile} 2>&1
else else
echo "Provisioning SSH Tunnel - not active" >> ${logFile} echo "Provisioning SSH Tunnel - not active" >> ${logFile}
@ -543,7 +495,7 @@ fi
# ZEROTIER # ZEROTIER
if [ "${#zerotier}" -gt 0 ] && [ "${zerotier}" != "off" ]; then if [ "${#zerotier}" -gt 0 ] && [ "${zerotier}" != "off" ]; then
echo "Provisioning ZeroTier - run config script" >> ${logFile} echo "Provisioning ZeroTier - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup ZeroTier'/g" ${infoFile} /home/admin/_cache.sh set message "Setup ZeroTier"
sudo /home/admin/config.scripts/bonus.zerotier.sh on ${zerotier} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/bonus.zerotier.sh on ${zerotier} >> ${logFile} 2>&1
else else
echo "Provisioning ZeroTier - not active" >> ${logFile} echo "Provisioning ZeroTier - not active" >> ${logFile}
@ -556,7 +508,7 @@ if [ ${#lcdrotate} -eq 0 ]; then
fi fi
if [ "${lcdrotate}" == "0" ]; then if [ "${lcdrotate}" == "0" ]; then
echo "Provisioning LCD rotate - run config script" >> ${logFile} echo "Provisioning LCD rotate - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='LCD Rotate'/g" ${infoFile} /home/admin/_cache.sh set message "LCD Rotate"
sudo /home/admin/config.scripts/blitz.display.sh rotate ${lcdrotate} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/blitz.display.sh rotate ${lcdrotate} >> ${logFile} 2>&1
else else
echo "Provisioning LCD rotate - not needed, keep default rotate on" >> ${logFile} echo "Provisioning LCD rotate - not needed, keep default rotate on" >> ${logFile}
@ -565,7 +517,7 @@ fi
# TOUCHSCREEN # TOUCHSCREEN
if [ "${#touchscreen}" -gt 0 ]; then if [ "${#touchscreen}" -gt 0 ]; then
echo "Provisioning Touchscreen - run config script" >> ${logFile} echo "Provisioning Touchscreen - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Touchscreen'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Touchscreen"
sudo /home/admin/config.scripts/blitz.touchscreen.sh ${touchscreen} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/blitz.touchscreen.sh ${touchscreen} >> ${logFile} 2>&1
else else
echo "Provisioning Touchscreen - not active" >> ${logFile} echo "Provisioning Touchscreen - not active" >> ${logFile}
@ -574,7 +526,7 @@ fi
# UPS # UPS
if [ "${#ups}" -gt 0 ]; then if [ "${#ups}" -gt 0 ]; then
echo "Provisioning UPS - run config script" >> ${logFile} echo "Provisioning UPS - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup UPS'/g" ${infoFile} /home/admin/_cache.sh set message "Setup UPS"
sudo /home/admin/config.scripts/blitz.ups.sh on ${ups} >> ${logFile} 2>&1 sudo /home/admin/config.scripts/blitz.ups.sh on ${ups} >> ${logFile} 2>&1
else else
echo "Provisioning UPS - not active" >> ${logFile} echo "Provisioning UPS - not active" >> ${logFile}
@ -583,7 +535,7 @@ fi
# LNbits # LNbits
if [ "${LNBits}" = "on" ]; then if [ "${LNBits}" = "on" ]; then
echo "Provisioning LNbits - run config script" >> ${logFile} echo "Provisioning LNbits - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup LNbits '/g" ${infoFile} /home/admin/_cache.sh set message "Setup LNbits"
sudo -u admin /home/admin/config.scripts/bonus.lnbits.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.lnbits.sh on >> ${logFile} 2>&1
else else
echo "Provisioning LNbits - keep default" >> ${logFile} echo "Provisioning LNbits - keep default" >> ${logFile}
@ -592,7 +544,7 @@ fi
# JoinMarket # JoinMarket
if [ "${joinmarket}" = "on" ]; then if [ "${joinmarket}" = "on" ]; then
echo "Provisioning JoinMarket - run config script" >> ${logFile} echo "Provisioning JoinMarket - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup JoinMarket'/g" ${infoFile} /home/admin/_cache.sh set message "Setup JoinMarket"
sudo /home/admin/config.scripts/bonus.joinmarket.sh on >> ${logFile} 2>&1 sudo /home/admin/config.scripts/bonus.joinmarket.sh on >> ${logFile} 2>&1
else else
echo "Provisioning JoinMarket - keep default" >> ${logFile} echo "Provisioning JoinMarket - keep default" >> ${logFile}
@ -601,7 +553,7 @@ fi
# Specter # Specter
if [ "${specter}" = "on" ]; then if [ "${specter}" = "on" ]; then
echo "Provisioning Specter - run config script" >> ${logFile} echo "Provisioning Specter - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Specter'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Specter"
sudo -u admin /home/admin/config.scripts/bonus.specter.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.specter.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Specter - keep default" >> ${logFile} echo "Provisioning Specter - keep default" >> ${logFile}
@ -610,7 +562,7 @@ fi
# Faraday # Faraday
if [ "${faraday}" = "on" ]; then if [ "${faraday}" = "on" ]; then
echo "Provisioning Faraday - run config script" >> ${logFile} echo "Provisioning Faraday - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Faraday'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Faraday"
sudo -u admin /home/admin/config.scripts/bonus.faraday.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.faraday.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Faraday - keep default" >> ${logFile} echo "Provisioning Faraday - keep default" >> ${logFile}
@ -619,7 +571,7 @@ fi
# BOS # BOS
if [ "${bos}" = "on" ]; then if [ "${bos}" = "on" ]; then
echo "Provisioning Balance of Satoshis - run config script" >> ${logFile} echo "Provisioning Balance of Satoshis - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Balance of Satoshis'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Balance of Satoshis"
sudo -u admin /home/admin/config.scripts/bonus.bos.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.bos.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Balance of Satoshis - keep default" >> ${logFile} echo "Provisioning Balance of Satoshis - keep default" >> ${logFile}
@ -628,7 +580,7 @@ fi
# thunderhub # thunderhub
if [ "${thunderhub}" = "on" ]; then if [ "${thunderhub}" = "on" ]; then
echo "Provisioning ThunderHub - run config script" >> ${logFile} echo "Provisioning ThunderHub - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup ThunderHub'/g" ${infoFile} /home/admin/_cache.sh set message "Setup ThunderHub"
sudo -u admin /home/admin/config.scripts/bonus.thunderhub.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.thunderhub.sh on >> ${logFile} 2>&1
else else
echo "Provisioning ThunderHub - keep default" >> ${logFile} echo "Provisioning ThunderHub - keep default" >> ${logFile}
@ -637,7 +589,7 @@ fi
# mempool space # mempool space
if [ "${mempoolExplorer}" = "on" ]; then if [ "${mempoolExplorer}" = "on" ]; then
echo "Provisioning MempoolSpace - run config script" >> ${logFile} echo "Provisioning MempoolSpace - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Mempool Space'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Mempool Space"
sudo -u admin /home/admin/config.scripts/bonus.mempool.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.mempool.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Mempool Explorer - keep default" >> ${logFile} echo "Provisioning Mempool Explorer - keep default" >> ${logFile}
@ -646,7 +598,7 @@ fi
# letsencrypt # letsencrypt
if [ "${letsencrypt}" = "on" ]; then if [ "${letsencrypt}" = "on" ]; then
echo "Provisioning letsencrypt - run config script" >> ${logFile} echo "Provisioning letsencrypt - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup letsencrypt'/g" ${infoFile} /home/admin/_cache.sh set message "Setup letsencrypt"
sudo -u admin /home/admin/config.scripts/bonus.letsencrypt.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.letsencrypt.sh on >> ${logFile} 2>&1
else else
echo "Provisioning letsencrypt - keep default" >> ${logFile} echo "Provisioning letsencrypt - keep default" >> ${logFile}
@ -655,7 +607,7 @@ fi
# kindle-display # kindle-display
if [ "${kindleDisplay}" = "on" ]; then if [ "${kindleDisplay}" = "on" ]; then
echo "Provisioning kindle-display - run config script" >> ${logFile} echo "Provisioning kindle-display - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup kindle-display'/g" ${infoFile} /home/admin/_cache.sh set message "Setup kindle-display"
sudo -u admin /home/admin/config.scripts/bonus.kindle-display.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.kindle-display.sh on >> ${logFile} 2>&1
else else
echo "Provisioning kindle-display - keep default" >> ${logFile} echo "Provisioning kindle-display - keep default" >> ${logFile}
@ -664,7 +616,7 @@ fi
# pyblock # pyblock
if [ "${pyblock}" = "on" ]; then if [ "${pyblock}" = "on" ]; then
echo "Provisioning pyblock - run config script" >> ${logFile} echo "Provisioning pyblock - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup pyblock'/g" ${infoFile} /home/admin/_cache.sh set message "Setup pyblock"
sudo -u admin /home/admin/config.scripts/bonus.pyblock.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.pyblock.sh on >> ${logFile} 2>&1
else else
echo "Provisioning pyblock - keep default" >> ${logFile} echo "Provisioning pyblock - keep default" >> ${logFile}
@ -673,7 +625,7 @@ fi
# stacking-sats-kraken # stacking-sats-kraken
if [ "${stackingSatsKraken}" = "on" ]; then if [ "${stackingSatsKraken}" = "on" ]; then
echo "Provisioning Stacking Sats Kraken - run config script" >> ${logFile} echo "Provisioning Stacking Sats Kraken - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Stacking Sats Kraken'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Stacking Sats Kraken"
sudo -u admin /home/admin/config.scripts/bonus.stacking-sats-kraken.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.stacking-sats-kraken.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Stacking Sats Kraken - keep default" >> ${logFile} echo "Provisioning Stacking Sats Kraken - keep default" >> ${logFile}
@ -682,7 +634,7 @@ fi
# Pool - install only if LiT won't be installed # Pool - install only if LiT won't be installed
if [ "${pool}" = "on" ] && [ "${lit}" != "on" ]; then if [ "${pool}" = "on" ] && [ "${lit}" != "on" ]; then
echo "Provisioning Pool - run config script" >> ${logFile} echo "Provisioning Pool - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Pool'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Pool"
sudo -u admin /home/admin/config.scripts/bonus.pool.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.pool.sh on >> ${logFile} 2>&1
else else
echo "Provisioning Pool - keep default" >> ${logFile} echo "Provisioning Pool - keep default" >> ${logFile}
@ -691,7 +643,7 @@ fi
# lit (make sure to be installed after RTL) # lit (make sure to be installed after RTL)
if [ "${lit}" = "on" ]; then if [ "${lit}" = "on" ]; then
echo "Provisioning LIT - run config script" >> ${logFile} echo "Provisioning LIT - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup LIT'/g" ${infoFile} /home/admin/_cache.sh set message "Setup LIT"
sudo -u admin /home/admin/config.scripts/bonus.lit.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.lit.sh on >> ${logFile} 2>&1
else else
echo "Provisioning LIT - keep default" >> ${logFile} echo "Provisioning LIT - keep default" >> ${logFile}
@ -700,7 +652,7 @@ fi
# sphinxrelay # sphinxrelay
if [ "${sphinxrelay}" = "on" ]; then if [ "${sphinxrelay}" = "on" ]; then
echo "Sphinx-Relay - run config script" >> ${logFile} echo "Sphinx-Relay - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup Sphinx-Relay'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Sphinx-Relay"
sudo -u admin /home/admin/config.scripts/bonus.sphinxrelay.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.sphinxrelay.sh on >> ${logFile} 2>&1
else else
echo "Sphinx-Relay - keep default" >> ${logFile} echo "Sphinx-Relay - keep default" >> ${logFile}
@ -709,7 +661,7 @@ fi
# circuitbreaker # circuitbreaker
if [ "${circuitbreaker}" = "on" ]; then if [ "${circuitbreaker}" = "on" ]; then
echo "Provisioning CircuitBreaker - run config script" >> ${logFile} echo "Provisioning CircuitBreaker - run config script" >> ${logFile}
sudo sed -i "s/^message=.*/message='Setup CircuitBreaker'/g" ${infoFile} /home/admin/_cache.sh set message "Setup CircuitBreaker"
sudo -u admin /home/admin/config.scripts/bonus.circuitbreaker.sh on >> ${logFile} 2>&1 sudo -u admin /home/admin/config.scripts/bonus.circuitbreaker.sh on >> ${logFile} 2>&1
else else
echo "Provisioning CircuitBreaker - keep default" >> ${logFile} echo "Provisioning CircuitBreaker - keep default" >> ${logFile}
@ -719,6 +671,7 @@ fi
customInstallAvailable=$(sudo ls /mnt/hdd/app-data/custom-installs.sh 2>/dev/null | grep -c "custom-installs.sh") customInstallAvailable=$(sudo ls /mnt/hdd/app-data/custom-installs.sh 2>/dev/null | grep -c "custom-installs.sh")
if [ ${customInstallAvailable} -gt 0 ]; then if [ ${customInstallAvailable} -gt 0 ]; then
echo "Running the custom install script .." >> ${logFile} echo "Running the custom install script .." >> ${logFile}
/home/admin/_cache.sh set message "Running Custom Install Script"
# copy script over to admin (in case HDD is not allowing exec) # copy script over to admin (in case HDD is not allowing exec)
sudo cp -av /mnt/hdd/app-data/custom-installs.sh /home/admin/custom-installs.sh >> ${logFile} sudo cp -av /mnt/hdd/app-data/custom-installs.sh /home/admin/custom-installs.sh >> ${logFile}
# make sure script is executable # make sure script is executable
@ -760,7 +713,7 @@ if [ ${confExists} -eq 0 ]; then
fi fi
# signal setup done # signal setup done
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile} /home/admin/_cache.sh set message "Setup Done"
# set the local network hostname (just if set in config - will not be set anymore by default in newer version) # set the local network hostname (just if set in config - will not be set anymore by default in newer version)
# have at the end - see https://github.com/rootzoll/raspiblitz/issues/462 # have at the end - see https://github.com/rootzoll/raspiblitz/issues/462

View File

@ -1,10 +1,8 @@
#!/bin/bash #!/bin/bash
# script for custom tmux status bar # script for custom tmux status bar
configFile="/mnt/hdd/raspiblitz.conf" if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ -f "$configFile" ]; then
source ${configFile} 2>/dev/null
echo "${hostname}" echo "${hostname}"
else else
#echo "$configFile does not exist" #echo "$configFile does not exist"

View File

@ -1,10 +1,8 @@
#!/bin/bash #!/bin/bash
# script for custom tmux status bar # script for custom tmux status bar
configFile="/mnt/hdd/raspiblitz.conf" if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ -f "$configFile" ]; then
source ${configFile} 2>/dev/null
echo " ${chain}net " echo " ${chain}net "
else else
#echo "$configFile does not exist" #echo "$configFile does not exist"

View File

@ -1,10 +1,8 @@
#!/bin/bash #!/bin/bash
# script for custom tmux status bar # script for custom tmux status bar
configFile="/mnt/hdd/raspiblitz.conf" if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ -f "$configFile" ]; then
source ${configFile} 2>/dev/null
echo " ${network} " echo " ${network} "
else else
#echo "$configFile does not exist" #echo "$configFile does not exist"

View File

@ -185,48 +185,48 @@ datadir=/mnt/hdd/bitcoin
fi fi
# make sure rpcbind is correctly configured # make sure rpcbind is correctly configured
sudo sed -i s/^rpcbind=/main.rpcbind=/g /mnt/hdd/${network}/${network}.conf sudo sed -i s/^rpcbind=/main.rpcbind=/g /mnt/hdd/bitcoin/bitcoin.conf
if [ $(grep -c "rpcallowip" < /mnt/hdd/${network}/${network}.conf) -gt 0 ];then if [ $(grep -c "rpcallowip" < /mnt/hdd/bitcoin/bitcoin.conf) -gt 0 ];then
if [ $(grep -c "${bitcoinprefix}.rpcbind=" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then if [ $(grep -c "${bitcoinprefix}.rpcbind=" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ];then
echo "\ echo "\
${bitcoinprefix}.rpcbind=127.0.0.1"|\ ${bitcoinprefix}.rpcbind=127.0.0.1"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
fi fi
fi fi
# correct rpcport entry # correct rpcport entry
sudo sed -i s/^rpcport=/main.rpcport=/g /mnt/hdd/${network}/${network}.conf sudo sed -i s/^rpcport=/main.rpcport=/g /mnt/hdd/bitcoin/bitcoin.conf
if [ $(grep -c "${bitcoinprefix}.rpcport" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then if [ $(grep -c "${bitcoinprefix}.rpcport" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ];then
echo "\ echo "\
${bitcoinprefix}.rpcport=${rpcprefix}8332"|\ ${bitcoinprefix}.rpcport=${rpcprefix}8332"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
fi fi
# correct zmq entry # correct zmq entry
sudo sed -i s/^zmqpubraw/main.zmqpubraw/g /mnt/hdd/${network}/${network}.conf sudo sed -i s/^zmqpubraw/main.zmqpubraw/g /mnt/hdd/bitcoin/bitcoin.conf
if [ $(grep -c "${bitcoinprefix}.zmqpubrawblock" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then if [ $(grep -c "${bitcoinprefix}.zmqpubrawblock" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ];then
echo "\ echo "\
${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332 ${bitcoinprefix}.zmqpubrawblock=tcp://127.0.0.1:${zmqprefix}332
${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333"|\ ${bitcoinprefix}.zmqpubrawtx=tcp://127.0.0.1:${zmqprefix}333"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
fi fi
# addnode # addnode
if [ ${bitcoinprefix} = signet ];then if [ ${bitcoinprefix} = signet ];then
if [ $(grep -c "${bitcoinprefix}.addnode" < /mnt/hdd/${network}/${network}.conf) -eq 0 ];then if [ $(grep -c "${bitcoinprefix}.addnode" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ];then
echo "\ echo "\
signet.addnode=s7fcvn5rblem7tiquhhr7acjdhu7wsawcph7ck44uxyd6sismumemcyd.onion:38333 signet.addnode=s7fcvn5rblem7tiquhhr7acjdhu7wsawcph7ck44uxyd6sismumemcyd.onion:38333
signet.addnode=6megrst422lxzsqvshkqkg6z2zhunywhyrhy3ltezaeyfspfyjdzr3qd.onion:38333 signet.addnode=6megrst422lxzsqvshkqkg6z2zhunywhyrhy3ltezaeyfspfyjdzr3qd.onion:38333
signet.addnode=jahtu4veqnvjldtbyxjiibdrltqiiighauai7hmvknwxhptsb4xat4qd.onion:38333 signet.addnode=jahtu4veqnvjldtbyxjiibdrltqiiighauai7hmvknwxhptsb4xat4qd.onion:38333
signet.addnode=f4kwoin7kk5a5kqpni7yqe25z66ckqu6bv37sqeluon24yne5rodzkqd.onion:38333 signet.addnode=f4kwoin7kk5a5kqpni7yqe25z66ckqu6bv37sqeluon24yne5rodzkqd.onion:38333
signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38333"|\ signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38333"|\
sudo tee -a /mnt/hdd/${network}/${network}.conf sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
fi fi
fi fi
removeParallelService removeParallelService
if [ ${CHAIN} = mainnet ];then if [ ${CHAIN} = mainnet ];then
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
else else
# /etc/systemd/system/${prefix}bitcoind.service # /etc/systemd/system/${prefix}bitcoind.service
echo " echo "
@ -281,7 +281,8 @@ alias ${prefix}bitcoinlog=\"sudo tail -n 30 -f ${bitcoinlogpath}\"\
fi fi
sudo chown admin:admin /home/admin/_aliases sudo chown admin:admin /home/admin/_aliases
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the ${prefix}bitcoind.service is enabled, system is ready so starting service" echo "# OK - the ${prefix}bitcoind.service is enabled, system is ready so starting service"
sudo systemctl start ${prefix}bitcoind sudo systemctl start ${prefix}bitcoind
@ -307,17 +308,11 @@ alias ${prefix}bitcoinlog=\"sudo tail -n 30 -f ${bitcoinlogpath}\"\
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^${CHAIN}=" /mnt/hdd/raspiblitz.conf; then
NEWENTRY="${CHAIN}=off"
sudo /bin/sh -c "echo '$NEWENTRY' >> /mnt/hdd/raspiblitz.conf"
fi
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
installParallelService installParallelService
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${CHAIN} "on"
exit 0 exit 0
fi fi
@ -326,7 +321,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# Uninstall Bitcoin Core instance on ${CHAIN}" echo "# Uninstall Bitcoin Core instance on ${CHAIN}"
removeParallelService removeParallelService
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${CHAIN}=.*/${CHAIN}=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${CHAIN} "off"
exit 0 exit 0
fi fi

View File

@ -0,0 +1,309 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "monitor and troubleshot the bitcoin network"
echo "bitcoin.monitor.sh [mainnet|testnet|signet] status"
echo "bitcoin.monitor.sh [mainnet|testnet|signet] info"
echo "bitcoin.monitor.sh [mainnet|testnet|signet] mempool"
echo "bitcoin.monitor.sh [mainnet|testnet|signet] network"
echo "bitcoin.monitor.sh [mainnet] peer-kickstart [ipv4|ipv6|tor|auto]"
echo "bitcoin.monitor.sh [mainnet] peer-disconnectall"
exit 1
fi
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# set based on network type
if [ "$1" == "mainnet" ]; then
bitcoincli_alias="/usr/local/bin/bitcoin-cli -datadir=/home/bitcoin/.bitcoin -rpcport=8332"
service_alias="bitcoind"
elif [ "$1" == "testnet" ]; then
bitcoincli_alias="/usr/local/bin/bitcoin-cli -datadir=/home/bitcoin/.bitcoin -rpcport=18332"
service_alias="tbitcoind"
elif [ "$1" == "signet" ]; then
bitcoincli_alias="/usr/local/bin/bitcoin-cli -datadir=/home/bitcoin/.bitcoin -rpcport=38332"
service_alias="sbitcoind"
else
echo "error='not supported net'"
exit 1
fi
######################################################
# STATUS
# check general status info
######################################################
if [ "$2" = "status" ]; then
btc_version=$($bitcoincli_alias -version 2>/dev/null | cut -d ' ' -f6)
btc_running=$(systemctl status $service_alias 2>/dev/null | grep -c "active (running)")
btc_ready="0"
btc_online="0"
btc_error_short=""
btc_error_full=""
if [ "${btc_running}" != "0" ]; then
btc_running="1"
# test connection - record win & fail info
randStr=$(echo "$RANDOM")
rm /var/cache/raspiblitz/.bitcoind-${randStr}.out 2>/dev/null
rm /var/cache/raspiblitz/.bitcoind-${randStr}.error 2>/dev/null
touch /var/cache/raspiblitz/.bitcoind-${randStr}.out
touch /var/cache/raspiblitz/.bitcoind-${randStr}.error
$bitcoincli_alias getnetworkinfo 1>/var/cache/raspiblitz/.bitcoind-${randStr}.out 2>/var/cache/raspiblitz/.bitcoind-${randStr}.error
winData=$(cat /var/cache/raspiblitz/.bitcoind-${randStr}.out 2>/dev/null)
failData=$(cat /var/cache/raspiblitz/.bitcoind-${randStr}.error 2>/dev/null)
rm /var/cache/raspiblitz/.bitcoind-${randStr}.out
rm /var/cache/raspiblitz/.bitcoind-${randStr}.error
# check for errors
if [ "${failData}" != "" ]; then
btc_ready="0"
btc_error_short=$(echo ${failData/error*:/} | sed 's/[^a-zA-Z0-9 ]//g')
btc_error_full=$(echo ${failData} | tr -d "'" | tr -d '"')
btc_ready="0"
# check results if proof for online
else
btc_ready="1"
connections=$( echo "${winData}" | grep "connections\"" | tr -cd '[[:digit:]]')
if [ "${connections}" != "" ] && [ "${connections}" != "0" ]; then
btc_online="1"
fi
fi
fi
# print results
echo "btc_version='${btc_version}'"
echo "btc_running='${btc_running}'"
echo "btc_ready='${btc_ready}'"
echo "btc_online='${btc_online}'"
echo "btc_error_short='${btc_error_short}'"
echo "btc_error_full='${btc_error_full}'"
exit 0
fi
######################################################
# NETWORK
######################################################
if [ "$2" = "network" ]; then
# get data
getnetworkinfo=$($bitcoincli_alias getnetworkinfo 2>/dev/null)
if [ "${getnetworkinfo}" == "" ]; then
echo "error='no data'"
exit 1
fi
# parse data
btc_peers=$(echo "${getnetworkinfo}" | grep "connections\"" | tr -cd '[[:digit:]]')
btc_address=$(echo ${getnetworkinfo} | jq -r '.localaddresses [0] .address')
btc_port=$(echo "${getnetworkinfo}" | jq -r '.localaddresses [0] .port')
# print data
echo "btc_peers='${btc_peers}'"
echo "btc_address='${btc_address}'"
echo "btc_port='${btc_port}'"
exit 0
fi
######################################################
# INFO
######################################################
if [ "$2" = "info" ]; then
# get data
blockchaininfo=$($bitcoincli_alias getblockchaininfo 2>/dev/null)
if [ "${blockchaininfo}" == "" ]; then
echo "error='no data'"
exit 1
fi
# parse data
btc_blocks_headers=$(echo "${blockchaininfo}" | jq -r '.headers')
btc_blocks_verified=$(echo "${blockchaininfo}" | jq -r '.blocks')
btc_blocks_behind=$((${btc_blocks_headers} - ${btc_blocks_verified}))
btc_sync_initialblockdownload=$(echo "${blockchaininfo}" | jq -r '.initialblockdownload' | grep -c 'true')
btc_sync_progress=$(echo "${blockchaininfo}" | jq -r '.verificationprogress')
btc_sync_percentage=$(echo ${btc_sync_progress} | awk '{printf( "%.2f%%", 100 * $1)}')
if [ "${btc_blocks_headers}" != "" ] && [ "${btc_blocks_headers}" == "${btc_blocks_verified}" ]; then
btc_sync_percentage="100.00"
fi
# determine if synced (tolerate falling 1 block behind)
# and be sure that initial blockdownload is done
btc_synced=0
if [ "${btc_sync_initialblockdownload}" == "0" ] && [ ${btc_blocks_behind} -lt 2 ]; then
btc_synced=1
fi
# print data
echo "btc_synced='${btc_synced}'"
echo "btc_blocks_headers='${btc_blocks_headers}'"
echo "btc_blocks_verified='${btc_blocks_verified}'"
echo "btc_blocks_behind='${btc_blocks_behind}'"
echo "btc_sync_progress='${btc_sync_progress}'"
echo "btc_sync_percentage='${btc_sync_percentage//[^0-9\..]/}'"
echo "btc_sync_initialblockdownload='${btc_sync_initialblockdownload}'"
exit 0
fi
######################################################
# MEMPOOL
######################################################
if [ "$2" = "mempool" ]; then
# get data
mempoolinfo=$($bitcoincli_alias getmempoolinfo 2>/dev/null)
if [ "${mempoolinfo}" == "" ]; then
echo "error='no data'"
exit 1
fi
# parse data
btc_mempool_transactions=$(echo "${mempoolinfo}" | jq -r '.size')
# print data
echo "btc_mempool_transactions=${btc_mempool_transactions}"
exit 0
fi
###################
# PEER KICK START
###################
if [ "$2" = "peer-kickstart" ]; then
# check calling only for mainnet
if [ "$1" != "mainnet" ]; then
echo "error='only available for mainnet yet'"
exit 1
fi
# get raw node data from bitnodes.io (use Tor if available)
#if [ "${runBehindTor}" == "on" ]; then
# call over tor proxy (CAPTCHA BLOCKED)
#bitnodesRawData=$(curl --socks5-hostname 127.0.0.1:9050 -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ 2>/dev/null)
#else
# call over clearnet
# bitnodesRawData=$(curl -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ 2>/dev/null)
#fi
bitnodesRawData=$(sudo -u admin cat /home/admin/fallback.nodes)
if [ ${#bitnodesRawData} -lt 100 ]; then
echo "error='no valid data from bitnodes.io'"
exit 1
fi
# determine which address to choose
addressFormat="$3"
# set default to auto
if [ "${addressFormat}" == "" ]; then
addressFormat="auto"
fi
# check valid value
if [ "${addressFormat}" != "ipv4" ] && [ "${addressFormat}" != "ipv6" ] && [ "${addressFormat}" != "tor" ] && [ "${addressFormat}" != "auto" ]; then
echo "error='invalid address type'"
exit 1
fi
# if auto then determine whats running
if [ "${addressFormat}" == "auto" ]; then
source <()
if [ "$(cat /mnt/hdd/raspiblitz.conf | grep -c "^runBehindTor=on")" != "0" ]; then
addressFormat="tor"
else
source <(sudo ./config.scripts/internet.sh status global)
if [ "${ipv6}" == "off" ]; then
addressFormat="ipv4"
else
addressFormat="ipv6"
fi
fi
fi
echo "addressFormat='${addressFormat}'"
# filter raw data for node addresses based on what kind of connection is running
if [ "${addressFormat}" == "tor" ]; then
# get Tor nodes (v2 or v3)
nodeList=$(echo "${bitnodesRawData}" | grep -o '[0-9a-z]\{16,56\}\.onion')
elif [ "${addressFormat}" == "ipv4" ]; then
# get IPv4 nodes
nodeList=$(echo "${bitnodesRawData}" | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\:[0-9]\{3,5\}')
elif [ "${addressFormat}" == "ipv6" ]; then
# get IPv6 nodes
nodeList=$(echo "${bitnodesRawData}" | grep -o '\[.\{5,45\}\]\:[0-9]\{3,5\}')
else
# invalid address
echo "error='invalid address format'"
exit 1
fi
#echo "${nodeList}"
nodesAvailable=$(echo "${nodeList}" | wc -l)
echo "nodesAvailable=${nodesAvailable}"
if [ "${nodesAvailable}" == "0" ]; then
echo "error='no nodes available'"
exit 1
fi
# pick random node from list
randomLineNumber=$((1 + RANDOM % ${nodesAvailable}))
echo "randomNumber=${randomLineNumber}"
nodeAddress=$(echo "${nodeList}" | sed -n "${randomLineNumber}p")
if [ "${nodeAddress}" == "" ]; then
# if random pick fails pick first line
nodeAddress=$(echo "${nodeList}" | sed -n "1p")
fi
if [ "${nodeAddress}" == "" ]; then
echo "error='selecting node from list failed'"
exit 1
fi
echo "newpeer='${nodeAddress}"
# kick start node with
$bitcoincli_alias addnode "${nodeAddress}" "onetry" 1>/dev/null
echo "exitcode=$?"
exit 0
fi
###################
# DISCONNECT ALL PEERS
# for testing peer kick-start
###################
if [ "$2" = "peer-disconnectall" ]; then
# check calling only for mainnet
if [ "$1" != "mainnet" ]; then
echo "error='only available for mainnet yet'"
exit 1
fi
# get all peer id and disconnect them
$bitcoincli_alias getpeerinfo | grep '"addr": "' | while read line
do
peerID=$(echo $line | cut -d '"' -f4)
echo "# disconnecting peer with ID: ${peerID}"
$bitcoincli_alias disconnectnode ${peerID}
done
echo "#### FINAL PEER INFO FROM BITCOIND"
$bitcoincli_alias getpeerinfo
exit 0
fi
echo "FAIL - Unknown Parameter $2"
exit 1

View File

@ -13,8 +13,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
source /home/admin/raspiblitz.info
# 1. parameter [info|tested|reckless] # 1. parameter [info|tested|reckless]
mode="$1" mode="$1"
@ -231,9 +229,10 @@ fi
if [ "${mode}" = "tested" ]||[ "${mode}" = "reckless" ]||[ "${mode}" = "custom" ];then if [ "${mode}" = "tested" ]||[ "${mode}" = "reckless" ]||[ "${mode}" = "custom" ];then
# install # install
echo "# Stopping bitcoind and lnd ..." echo "# Stopping bitcoind ..."
sudo systemctl stop lnd sudo systemctl stop bitcoind 2>/dev/null
sudo systemctl stop bitcoind sudo systemctl stop tbitcoind 2>/dev/null
sudo systemctl stop sbitcoind 2>/dev/null
echo echo
echo "# Installing Bitcoin Core v${bitcoinVersion}" echo "# Installing Bitcoin Core v${bitcoinVersion}"
tar -xvf ${binaryName} tar -xvf ${binaryName}
@ -245,29 +244,11 @@ if [ "${mode}" = "tested" ]||[ "${mode}" = "reckless" ]||[ "${mode}" = "custom"
echo "# !!! BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})" echo "# !!! BUILD FAILED --> Was not able to install bitcoind version(${bitcoinVersion})"
exit 1 exit 1
fi fi
echo "# flag update in raspiblitz config"
source /mnt/hdd/raspiblitz.conf echo "# mark update in raspiblitz config"
if [ ${#bitcoinInterimsUpdate} -eq 0 ]; then /home/admin/config.scripts/blitz.conf.sh set bitcoinInterimsUpdate "${bitcoinInterimsUpdateNew}"
echo "bitcoinInterimsUpdate='${bitcoinInterimsUpdateNew}'" >> /mnt/hdd/raspiblitz.conf
else
sudo sed -i "s/^bitcoinInterimsUpdate=.*/bitcoinInterimsUpdate='${bitcoinInterimsUpdateNew}'/g" /mnt/hdd/raspiblitz.conf
fi
echo "# OK Bitcoin Core ${bitcoinVersion} is installed" echo "# OK Bitcoin Core ${bitcoinVersion} is installed"
if [ "${state}" == "ready" ]; then
echo
echo "# Starting ..."
sudo systemctl start bitcoind
sleep 10
echo
sudo systemctl start lnd
echo "# Starting LND ..."
sleep 10
echo
echo "# Press ENTER to proceed to unlock the LND wallet ..."
read key
sudo /home/admin/config.scripts/lnd.unlock.sh
fi
exit 0 exit 0
else else

View File

@ -169,11 +169,7 @@ THIS WILL DELETE ALL DATA ON THAT DEVICE!
fi fi
# change raspiblitz.conf # change raspiblitz.conf
entryExists=$(cat /mnt/hdd/raspiblitz.conf | grep -c 'localBackupDeviceUUID=') /home/admin/config.scripts/blitz.conf.sh set localBackupDeviceUUID "${uuid}"
if [ ${entryExists} -eq 0 ]; then
echo "localBackupDeviceUUID='off'" >> /mnt/hdd/raspiblitz.conf
fi
sudo sed -i "s/^localBackupDeviceUUID=.*/localBackupDeviceUUID='${uuid}'/g" /mnt/hdd/raspiblitz.conf
echo "activated=1" echo "activated=1"
# mount device (so that no reboot is needed) # mount device (so that no reboot is needed)
@ -188,7 +184,7 @@ THIS WILL DELETE ALL DATA ON THAT DEVICE!
if [ ${userinteraction} -eq 1 ]; then if [ ${userinteraction} -eq 1 ]; then
if [ ${isMounted} -eq 0 ]; then if [ ${isMounted} -eq 0 ]; then
sudo sed -i "s/^localBackupDeviceUUID=.*/localBackupDeviceUUID=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set localBackupDeviceUUID "off"
dialog --title ' Adding Backup Device ' --msgbox '\nFAIL - Not able to add device.' 7 40 dialog --title ' Adding Backup Device ' --msgbox '\nFAIL - Not able to add device.' 7 40
else else
dialog --title ' Adding Backup Device ' --msgbox '\nOK - Device added for Backup.' 7 40 dialog --title ' Adding Backup Device ' --msgbox '\nOK - Device added for Backup.' 7 40
@ -240,7 +236,7 @@ fi
if [ "$1" = "off" ]; then if [ "$1" = "off" ]; then
echo "# BACKUP DEVICE REMOVE" echo "# BACKUP DEVICE REMOVE"
sudo sed -i "s/^localBackupDeviceUUID=.*/localBackupDeviceUUID=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set localBackupDeviceUUID "off"
sudo umount /mnt/backup 2>/dev/null sudo umount /mnt/backup 2>/dev/null
echo "# OK backup device is off" echo "# OK backup device is off"
exit 0 exit 0

View File

@ -61,7 +61,7 @@ if [ "${action}" == "fsexpand" ]; then
echo "# starting expand of file system of sd card" echo "# starting expand of file system of sd card"
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" /home/admin/raspiblitz.info
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then if [ "${baseimage}" = "raspios_arm64" ]; then
resizeRaspbian="/usr/bin/raspi-config" resizeRaspbian="/usr/bin/raspi-config"
if [ -x ${resizeRaspbian} ]; then if [ -x ${resizeRaspbian} ]; then
echo "# RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}" echo "# RUNNING EXPAND RASPBERRYPI: ${resizeRaspbian}"

View File

@ -1,52 +0,0 @@
#!/usr/bin/env bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "RaspiBlitz Cache RAM disk"
echo "blitz.cache.sh [on|off]"
exit 1
fi
###################
# SWITCH ON
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "Turn ON: Cache"
if ! grep -Eq '^tmpfs.*/var/cache/raspiblitz' /etc/fstab; then
if grep -Eq '/var/cache/raspiblitz' /etc/fstab; then
# entry is in file but most likely just disabled -> re-enable it
sudo sed -i -E 's|^#(tmpfs.*/var/cache/raspiblitz.*)$|\1|g' /etc/fstab
else
# missing -> add
echo "" | sudo tee -a /etc/fstab >/dev/null
echo "tmpfs /var/cache/raspiblitz tmpfs nodev,nosuid,size=32M 0 0" | sudo tee -a /etc/fstab >/dev/null
fi
fi
if ! findmnt -l /var/cache/raspiblitz >/dev/null; then
sudo mkdir -p /var/cache/raspiblitz
sudo mount /var/cache/raspiblitz
fi
###################
# SWITCH OFF
###################
elif [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "Turn OFF: Cache"
if grep -Eq '/var/cache/raspiblitz' /etc/fstab; then
sudo sed -i -E 's|^(tmpfs.*/var/cache/raspiblitz.*)$|#\1|g' /etc/fstab
fi
if findmnt -l /var/cache/raspiblitz >/dev/null; then
sudo umount /var/cache/raspiblitz
fi
else
echo "# FAIL: parameter not known - run with -h for help"
fi

View File

@ -0,0 +1,78 @@
#!/usr/bin/env bash
configFile="/mnt/hdd/raspiblitz.conf"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "RaspiBlitz Config Edit - adds value to file & cache and creates entries if needed:"
echo "blitz.conf.sh set [key] [value]"
echo "blitz.conf.sh delete [key]"
echo "To use values use in shell scripts: source ${configFile}"
echo
exit 1
fi
if [ "$1" = "set" ]; then
# get parameters
keystr=$2
valuestr=$3
overflow=$4
# check that key & value are given
if [ "${keystr}" == "" ] || [ "${valuestr}" == "" ]; then
echo "# blitz.conf.sh $@"
echo "# FAIL: missing parameter"
exit 1
fi
# check if input quotes are missing (there should be no 4th parameter)
if [ "${overflow}" != "" ]; then
echo "# blitz.conf.sh $@"
echo "# FAIL: possible missing quotes in value string"
exit 2
fi
# update config value in cache
/home/admin/_cache.sh set ${keystr} "${valuestr}"
# check that config file exists
raspiblitzConfExists=$(ls ${configFile} 2>/dev/null | grep -c "${configFile}")
if [ ${raspiblitzConfExists} -eq 0 ]; then
echo "# blitz.conf.sh $@"
echo "# FAIL: missing config file: ${configFile}"
exit 3
fi
# check if key needs to be added (prepare new entry)
entryExists=$(grep -c "^${keystr}=" ${configFile})
if [ ${entryExists} -eq 0 ]; then
echo "${keystr}=" | tee -a ${configFile}
fi
# add valuestr quotes if not standard values
if [ "${valuestr}" != "on" ] && [ "${valuestr}" != "off" ] && [ "${valuestr}" != "1" ] && [ "${valuestr}" != "0" ]; then
valuestr="'${valuestr}'"
fi
# set value (sed needs sudo to operate when user is not root)
sudo sed -i "s/^${keystr}=.*/${keystr}=${valuestr}/g" ${configFile}
elif [ "$1" = "delete" ]; then
# get parameters
keystr=$2
# check that key & value are given
if [ "${keystr}" == "" ]; then
echo "# FAIL: missing parameter"
exit 1
fi
# delete value
sudo sed -i "/^${keystr}=/d" ${configFile} 2>/dev/null
else
echo "# FAIL: parameter not known - run with -h for help"
fi

View File

@ -22,7 +22,7 @@ fi
# check if started with sudo # check if started with sudo
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "error='missing sudo'" echo "error='run as root'"
exit 1 exit 1
fi fi
@ -218,24 +218,30 @@ if [ "$1" = "status" ]; then
##################################### #####################################
# Pre-Setup Investigation of DATA-PART # Pre-Setup Investigation of DATA-PART
# make copy of raspiblitz.conf &
# check for recoverable RaspiBlitz data (if config file exists) and raid # check for recoverable RaspiBlitz data (if config file exists) and raid
hddRaspiData=$(sudo ls -l /mnt/hdd${subVolumeDir} 2>/dev/null | grep -c raspiblitz.conf) hddRaspiData=$(ls -l /mnt/hdd${subVolumeDir} 2>/dev/null | grep -c raspiblitz.conf)
#isRaid=$(btrfs filesystem df /mnt/hdd 2>/dev/null | grep -c "Data, RAID1")
echo "hddRaspiData=${hddRaspiData}" echo "hddRaspiData=${hddRaspiData}"
hddRaspiVersion="" hddRaspiVersion=""
if [ ${hddRaspiData} -eq 1 ]; then if [ ${hddRaspiData} -eq 1 ]; then
source /mnt/hdd${subVolumeDir}/raspiblitz.conf
hddRaspiVersion="${raspiBlitzVersion}"
fi
echo "hddRaspiVersion='${hddRaspiVersion}'"
# check if there is a wifi configuration as backup # output version data from raspiblitz.conf
hddGotWifiConf=$(ls /mnt/hdd${subVolumeDir}/app-data/wpa_supplicant.conf 2>/dev/null | grep -c "wpa_supplicant.conf") source /mnt/hdd${subVolumeDir}/raspiblitz.conf
if [ ${hddGotWifiConf} -eq 1 ]; then echo "hddRaspiVersion='${raspiBlitzVersion}'"
# make a copy to the mem cache drive (so that Wifi can be connected before setup & final HDD mount)
sudo cp /mnt/hdd${subVolumeDir}/app-data/wpa_supplicant.conf /var/cache/raspiblitz/wpa_supplicant.conf # create hdd-inspect data dir on RAMDISK
echo "wifiBackupConfigCopy='/var/cache/raspiblitz/wpa_supplicant.conf'" mkdir /var/cache/raspiblitz/hdd-inspect
# make copy of raspiblitz.conf to RAMDISK
cp /mnt/hdd${subVolumeDir}/raspiblitz.conf /var/cache/raspiblitz/hdd-inspect/raspiblitz.conf
# make copy of WIFI config to RAMDISK (if available)
cp /mnt/hdd${subVolumeDir}/app-data/wpa_supplicant.conf /var/cache/raspiblitz/hdd-inspect/wpa_supplicant.conf 2>/dev/null
# make copy of SSH keys to RAMDISK (if available)
cp /mnt/hdd${subVolumeDir}/ssh /var/cache/raspiblitz/hdd-inspect/ssh 2>/dev/null
fi fi
# comment this line out if case to study the contect of the data section # comment this line out if case to study the contect of the data section
@ -277,7 +283,11 @@ if [ "$1" = "status" ]; then
# BRTS # BRTS
hdd_data_free1Kblocks=$(df -h -k /dev/${hdd}1 | grep "/dev/${hdd}1" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9') hdd_data_free1Kblocks=$(df -h -k /dev/${hdd}1 | grep "/dev/${hdd}1" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
fi fi
hddDataFreeBytes=$((${hdd_data_free1Kblocks} * 1024))
hddDataFreeGB=$((${hdd_data_free1Kblocks} / (1024 * 1024)))
echo "hddDataFreeBytes=${hddDataFreeBytes}"
echo "hddDataFreeKB=${hdd_data_free1Kblocks}" echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
echo "hddDataFreeGB=${hddDataFreeGB}"
# check if its another fullnode implementation data disk # check if its another fullnode implementation data disk
hddGotMigrationData="" hddGotMigrationData=""
@ -372,7 +382,11 @@ if [ "$1" = "status" ]; then
hddUsedInfo="${datadrive} & ${storageDrive}" hddUsedInfo="${datadrive} & ${storageDrive}"
fi fi
echo "hddUsedInfo='${hddUsedInfo}'" echo "hddUsedInfo='${hddUsedInfo}'"
hddDataFreeBytes=$((${hdd_data_free1Kblocks} * 1024))
hddDataFreeGB=$((${hdd_data_free1Kblocks} / (1024 * 1024)))
echo "hddDataFreeBytes=${hddDataFreeBytes}"
echo "hddDataFreeKB=${hdd_data_free1Kblocks}" echo "hddDataFreeKB=${hdd_data_free1Kblocks}"
echo "hddDataFreeGB=${hddDataFreeGB}"
fi fi
@ -393,11 +407,12 @@ if [ "$1" = "status" ]; then
hddAdapterUSAP=0 hddAdapterUSAP=0
# check if user wants to force UASP on # check if force UASP flag is set on sd card
if [ -f "/boot/uasp.force" ]; then if [ -f "/boot/uasp.force" ]; then
hddAdapterUSAP=1 hddAdapterUSAP=1
echo "uaspForced=1"
fi fi
# or UASP is set by config file
if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "forceUasp=on") -eq 1 ]; then if [ $(cat /mnt/hdd/raspiblitz.conf 2>/dev/null | grep -c "forceUasp=on") -eq 1 ]; then
hddAdapterUSAP=1 hddAdapterUSAP=1
fi fi
@ -411,6 +426,7 @@ if [ "$1" = "status" ]; then
# SupTronics 2.5" SATA HDD Shield X825 v1.5 # SupTronics 2.5" SATA HDD Shield X825 v1.5
hddAdapterUSAP=1 hddAdapterUSAP=1
fi fi
echo "hddAdapterUSAP=${hddAdapterUSAP}" echo "hddAdapterUSAP=${hddAdapterUSAP}"
fi fi

View File

@ -7,6 +7,7 @@ source /home/admin/_version.info
## get basic info (its OK if not set yet) ## get basic info (its OK if not set yet)
source /home/admin/raspiblitz.info 2>/dev/null source /home/admin/raspiblitz.info 2>/dev/null
source <(/home/admin/_cache.sh get state setupPhase)
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
# for old nodes # for old nodes
@ -54,7 +55,6 @@ echo
echo "*** LAST BLOCKCHAIN (MAINNET) ERROR LOGS ***" echo "*** LAST BLOCKCHAIN (MAINNET) ERROR LOGS ***"
echo "sudo journalctl -u ${network}d -b --no-pager -n8" echo "sudo journalctl -u ${network}d -b --no-pager -n8"
sudo journalctl -u ${network}d -b --no-pager -n8 sudo journalctl -u ${network}d -b --no-pager -n8
cat /home/admin/systemd.blockchain.log | grep "ERROR" | tail -n -2
echo echo
echo "*** LAST BLOCKCHAIN (MAINNET) 20 INFO LOGS ***" echo "*** LAST BLOCKCHAIN (MAINNET) 20 INFO LOGS ***"
echo "sudo tail -n 20 /mnt/hdd/${network}/debug.log" echo "sudo tail -n 20 /mnt/hdd/${network}/debug.log"
@ -68,7 +68,6 @@ if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ] || [ "${lnd}" == "1" ]; t
echo "*** LAST LND (MAINNET) ERROR LOGS ***" echo "*** LAST LND (MAINNET) ERROR LOGS ***"
echo "sudo journalctl -u lnd -b --no-pager -n12" echo "sudo journalctl -u lnd -b --no-pager -n12"
sudo journalctl -u lnd -b --no-pager -n12 sudo journalctl -u lnd -b --no-pager -n12
cat /home/admin/systemd.lightning.log | grep "ERROR" | tail -n -1
echo echo
echo "*** LAST 30 LND (MAINNET) INFO LOGS ***" echo "*** LAST 30 LND (MAINNET) INFO LOGS ***"
echo "sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/mainnet/lnd.log" echo "sudo tail -n 30 /mnt/hdd/lnd/logs/${network}/mainnet/lnd.log"
@ -337,19 +336,22 @@ sudo /home/admin/config.scripts/internet.sh status | grep 'network_device\|local
echo echo
echo "*** HARDWARE TEST RESULTS ***" echo "*** HARDWARE TEST RESULTS ***"
source <(/home/admin/_cache.sh get system_count_undervoltage)
showImproveInfo=0 showImproveInfo=0
if [ ${#undervoltageReports} -gt 0 ]; then if [ ${#system_count_undervoltage} -gt 0 ]; then
echo "UndervoltageReports in Logs: ${undervoltageReports}" echo "UndervoltageReports in Logs: ${system_count_undervoltage}"
if [ ${undervoltageReports} -gt 0 ]; then if [ ${system_count_undervoltage} -gt 0 ]; then
showImproveInfo=1 showImproveInfo=1
fi fi
fi fi
echo echo
echo "*** SYSTEM STATUS (can take some seconds to gather) ***" echo "*** SYSTEM CACHE STATUS ***"
sudo /home/admin/config.scripts/blitz.statusscan.sh /home/admin/_cache.sh "export" system_
echo /home/admin/_cache.sh "export" ln_default | grep -v "ln_default_address"
/home/admin/_cache.sh "export" btc_default | grep -v "btc_default_address"
echo
echo "*** OPTION: SHARE THIS DEBUG OUTPUT ***" echo "*** OPTION: SHARE THIS DEBUG OUTPUT ***"
echo "An easy way to share this debug output on GitHub or on a support chat" echo "An easy way to share this debug output on GitHub or on a support chat"
echo "use the following command and share the resulting link:" echo "use the following command and share the resulting link:"

View File

@ -3,19 +3,23 @@
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# make changes to the LCD screen" echo "# make changes to the LCD screen"
echo "# blitz.display.sh rotate [on|off]" echo
echo "# blitz.display.sh image [path]" echo "# blitz.display.sh image [path]"
echo "# blitz.display.sh qr [datastring]" echo "# blitz.display.sh qr [datastring]"
echo "# blitz.display.sh qr-console [datastring]" echo "# blitz.display.sh qr-console [datastring]"
echo "# blitz.display.sh hide" echo "# blitz.display.sh hide"
echo "# blitz.display.sh hdmi [on|off] ---> DEPRECATED use set-display" echo
echo "# blitz.display.sh rotate [on|off]"
echo "# blitz.display.sh test-lcd-connect" echo "# blitz.display.sh test-lcd-connect"
echo "# blitz.display.sh set-display [hdmi|lcd|headless]" echo "# blitz.display.sh set-display [hdmi|lcd|headless]"
exit 1 exit 1
fi fi
# load config # 1. Parameter: lcd command
source /home/admin/raspiblitz.info 2>/dev/null command=$1
# its OK if its not exist yet
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
# Make sure needed packages are installed # Make sure needed packages are installed
@ -26,9 +30,6 @@ if [ $(sudo dpkg-query -l | grep "ii qrencode" | wc -l) = 0 ]; then
sudo apt-get install qrencode -y > /dev/null sudo apt-get install qrencode -y > /dev/null
fi fi
# 1. Parameter: lcd command
command=$1
# check if LCD (/dev/fb1) or HDMI (/dev/fb0) # check if LCD (/dev/fb1) or HDMI (/dev/fb0)
# see https://github.com/rootzoll/raspiblitz/pull/1580 # see https://github.com/rootzoll/raspiblitz/pull/1580
# but basically this just says if the driver for GPIO LCD is installed - not if connected # but basically this just says if the driver for GPIO LCD is installed - not if connected
@ -44,18 +45,12 @@ if [ "${command}" == "rotate" ]; then
# TURN ROTATE ON (the new default) # TURN ROTATE ON (the new default)
if [ "$2" = "1" ] || [ "$2" = "on" ]; then if [ "$2" = "1" ] || [ "$2" = "on" ]; then
# add default 'lcdrotate' raspiblitz.conf if needed
if [ ${#lcdrotate} -eq 0 ]; then
echo "lcdrotate=0" >> /mnt/hdd/raspiblitz.conf
fi
# change rotation config # change rotation config
echo "# Turn ON: LCD ROTATE" echo "# Turn ON: LCD ROTATE"
sudo sed -i "s/^dtoverlay=.*/dtoverlay=waveshare35a:rotate=90/g" /boot/config.txt sudo sed -i "s/^dtoverlay=.*/dtoverlay=waveshare35a:rotate=90/g" /boot/config.txt
sudo rm /etc/X11/xorg.conf.d/40-libinput.conf >/dev/null sudo rm /etc/X11/xorg.conf.d/40-libinput.conf >/dev/null
# update raspiblitz conf file /home/admin/config.scripts/blitz.conf.sh set lcdrotate 1
sudo sed -i "s/^lcdrotate=.*/lcdrotate=1/g" /mnt/hdd/raspiblitz.conf
echo "# OK - a restart is needed: sudo shutdown -r now" echo "# OK - a restart is needed: sudo shutdown -r now"
# TURN ROTATE OFF # TURN ROTATE OFF
@ -79,8 +74,8 @@ EndSection
EOF EOF
fi fi
# update raspiblitz conf file # update raspiblitz conf
sudo sed -i "s/^lcdrotate=.*/lcdrotate=0/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lcdrotate 0
echo "OK - a restart is needed: sudo shutdown -r now" echo "OK - a restart is needed: sudo shutdown -r now"
else else
@ -133,14 +128,14 @@ if [ "${command}" == "qr" ]; then
exit 1 exit 1
fi fi
qrencode -l L -o /home/admin/qr.png "${datastring}" > /dev/null qrencode -l L -o /var/cache/raspiblitz/qr.png "${datastring}" > /dev/null
# see https://github.com/rootzoll/raspiblitz/pull/1580 # see https://github.com/rootzoll/raspiblitz/pull/1580
if [ ${lcdExists} -eq 1 ] ; then if [ ${lcdExists} -eq 1 ] ; then
# LCD # LCD
sudo fbi -a -T 1 -d /dev/fb1 --noverbose /home/admin/qr.png 2> /dev/null sudo fbi -a -T 1 -d /dev/fb1 --noverbose /var/cache/raspiblitz/qr.png 2> /dev/null
else else
# HDMI # HDMI
sudo fbi -a -T 1 -d /dev/fb0 --noverbose /home/admin/qr.png 2> /dev/null sudo fbi -a -T 1 -d /dev/fb0 --noverbose /var/cache/raspiblitz/qr.png 2> /dev/null
fi fi
exit 0 exit 0
fi fi
@ -175,7 +170,7 @@ fi
if [ "${command}" == "hide" ]; then if [ "${command}" == "hide" ]; then
sudo killall -3 fbi sudo killall -3 fbi
shred -u /home/admin/qr.png 2> /dev/null rm /var/cache/raspiblitz/qr.png 2> /dev/null
exit 0 exit 0
fi fi
@ -201,22 +196,6 @@ if [ "${command}" == "test-lcd-connect" ]; then
exit 0 exit 0
fi fi
###############################
# HDMI (deprecated - redirect)
###############################
if [ "${command}" == "hdmi" ]; then
secondParameter=$2
if [ "${secondParameter}" == "on" ]; then
sudo /home/admin/config.scripts/blitz.display.sh set-display hdmi
elif [ "${secondParameter}" == "off" ]; then
sudo /home/admin/config.scripts/blitz.display.sh set-display lcd
else
echo "error='unknown second parameter'"
exit 1
fi
exit 0
fi
####################################### #######################################
# DISPLAY TYPED INSTALLS & UN-INSTALLS # DISPLAY TYPED INSTALLS & UN-INSTALLS
# HDMI is the default - every added # HDMI is the default - every added
@ -360,36 +339,7 @@ function uninstall_lcd() {
# not being used - can be deleted after mid 2021 # not being used - can be deleted after mid 2021
function install_lcd_legacy() { function install_lcd_legacy() {
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ]; then if [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "*** 32bit LCD DRIVER ***"
echo "--> Downloading LCD Driver from Github"
cd /home/admin/
sudo -u admin git clone https://github.com/MrYacha/LCD-show.git
sudo -u admin chmod -R 755 LCD-show
sudo -u admin chown -R admin:admin LCD-show
cd LCD-show/
# not signed
sudo -u admin git reset --hard 53dd0bf || exit 1
# install xinput calibrator package
echo "--> install xinput calibrator package"
sudo apt install -y libxi6
sudo dpkg -i xinput-calibrator_0.7.5-1_armhf.deb
if [ "${baseimage}" = "dietpi" ]; then
echo "--> dietpi preparations"
sudo rm -rf /etc/X11/xorg.conf.d/40-libinput.conf
sudo mkdir /etc/X11/xorg.conf.d
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/
sudo cp ./usr/tft35a-overlay.dtb /boot/overlays/tft35a.dtbo
sudo cp -rf ./usr/99-calibration.conf-35 /etc/X11/xorg.conf.d/99-calibration.conf
sudo cp -rf ./usr/99-fbturbo.conf /usr/share/X11/xorg.conf.d/
sudo cp ./usr/cmdline.txt /DietPi/
sudo cp ./usr/inittab /etc/
sudo cp ./boot/config-35.txt /DietPi/config.txt
# make LCD screen rotation correct
sudo sed -i "s/dtoverlay=tft35a/dtoverlay=tft35a:rotate=270/" /DietPi/config.txt
fi
elif [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "*** 64bit LCD DRIVER ***" echo "*** 64bit LCD DRIVER ***"
echo "--> Downloading LCD Driver from Github" echo "--> Downloading LCD Driver from Github"
cd /home/admin/ cd /home/admin/
@ -433,13 +383,7 @@ function install_lcd_legacy() {
# activate LCD and trigger reboot # activate LCD and trigger reboot
# dont do this on dietpi to allow for automatic build # dont do this on dietpi to allow for automatic build
if [ "${baseimage}" = "raspbian" ]; then if [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "Installing 32-bit LCD drivers ..."
sudo chmod +x -R /home/admin/LCD-show
cd /home/admin/LCD-show/
sudo apt-mark hold raspberrypi-bootloader
sudo ./LCD35-show
elif [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
echo "Installing 64-bit LCD drivers ..." echo "Installing 64-bit LCD drivers ..."
sudo chmod +x -R /home/admin/wavesharelcd-64bit-rpi sudo chmod +x -R /home/admin/wavesharelcd-64bit-rpi
cd /home/admin/wavesharelcd-64bit-rpi cd /home/admin/wavesharelcd-64bit-rpi
@ -452,7 +396,7 @@ function install_lcd_legacy() {
} }
function install_headless() { function install_headless() {
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]|| [ "${baseimage}" = "debian_rpi64" ]; then if [ "${baseimage}" = "raspios_arm64" ]|| [ "${baseimage}" = "debian_rpi64" ]; then
modificationExists=$(sudo cat /etc/systemd/system/getty@tty1.service.d/autologin.conf | grep -c "autologin pi") modificationExists=$(sudo cat /etc/systemd/system/getty@tty1.service.d/autologin.conf | grep -c "autologin pi")
if [ "${modificationExists}" == "1" ]; then if [ "${modificationExists}" == "1" ]; then
echo "# deactivating auto-login of pi user" echo "# deactivating auto-login of pi user"
@ -476,7 +420,7 @@ function install_headless() {
} }
function uninstall_headless() { function uninstall_headless() {
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]|| [ "${baseimage}" = "debian_rpi64" ]; then if [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ]; then
# activate auto-login # activate auto-login
sudo raspi-config nonint do_boot_behaviour B2 sudo raspi-config nonint do_boot_behaviour B2
modificationExists=$(sudo cat /etc/systemd/system/getty@tty1.service.d/autologin.conf | grep -c "autologin pi") modificationExists=$(sudo cat /etc/systemd/system/getty@tty1.service.d/autologin.conf | grep -c "autologin pi")
@ -510,19 +454,6 @@ function uninstall_headless() {
fi fi
} }
function prepareDisplayClassEntryRaspiblitzConf() {
# check if file exists / hdd is mounted
if [ -f "/mnt/hdd/raspiblitz.conf" ]; then
echo "file does exists"
entryExists=$(grep -c "displayClass=" /mnt/hdd/raspiblitz.conf)
if [ ${entryExists} -eq 0 ]; then
echo "displayClass=${displayClass}" >> /mnt/hdd/raspiblitz.conf
fi
else
echo "# /mnt/hdd/raspiblitz.conf does not exists (yet) - change is just part of raspiblitz.info"
fi
}
################### ###################
# SET DISPLAY TYPE # SET DISPLAY TYPE
################### ###################
@ -532,6 +463,7 @@ if [ "${command}" == "set-display" ]; then
paramDisplayClass=$2 paramDisplayClass=$2
paramDisplayType=$3 paramDisplayType=$3
echo "# blitz.display.sh set-display ${paramDisplayClass} ${paramDisplayType}" echo "# blitz.display.sh set-display ${paramDisplayClass} ${paramDisplayType}"
echo "baseimage(${baseimage})"
# check if started with sudo # check if started with sudo
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
@ -539,6 +471,12 @@ if [ "${command}" == "set-display" ]; then
exit 1 exit 1
fi fi
# check if display class parameter is given
if [ "${baseimage}" == "" ]; then
echo "err='missing baseimage info'"
exit 1
fi
# check if display class parameter is given # check if display class parameter is given
if [ "${paramDisplayClass}" == "" ]; then if [ "${paramDisplayClass}" == "" ]; then
echo "err='missing parameter'" echo "err='missing parameter'"
@ -561,10 +499,9 @@ if [ "${command}" == "set-display" ]; then
exit 1 exit 1
fi fi
# mark new display class in configs # mark new display class in config (if exist)
prepareDisplayClassEntryRaspiblitzConf /home/admin/config.scripts/blitz.conf.sh set displayClass ${paramDisplayClass}
sudo sed -i "s/^displayClass=.*/displayClass=${paramDisplayClass}/g" /home/admin/raspiblitz.info sudo sed -i "s/^displayClass=.*/displayClass=${paramDisplayClass}/g" /home/admin/raspiblitz.info
sudo sed -i "s/^displayClass=.*/displayClass=${paramDisplayClass}/g" /mnt/hdd/raspiblitz.conf 2>/dev/null
exit 0 exit 0
fi fi

View File

@ -13,11 +13,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^docker=" /mnt/hdd/raspiblitz.conf; then
echo "docker=off" >> /mnt/hdd/raspiblitz.conf
fi
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
@ -48,7 +43,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo pip3 install docker-compose sudo pip3 install docker-compose
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^docker=.*/docker=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set docker "on"
echo "# docker install done" echo "# docker install done"
exit 0 exit 0
fi fi
@ -56,7 +51,7 @@ fi
# switch off # switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^docker=.*/docker=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set docker "off"
echo "*** REMOVING docker & docker-compose ***" echo "*** REMOVING docker & docker-compose ***"
sudo pip3 uninstall -y docker-compose sudo pip3 uninstall -y docker-compose
sudo apt-get purge -y docker-ce docker-ce-cli sudo apt-get purge -y docker-ce docker-ce-cli

View File

@ -0,0 +1,66 @@
#!/usr/bin/env bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "RaspiBlitz Error Handling"
echo
echo "blitz.error.sh [source-script-name] [fixed-short-code] [?detail-message] [?additional-debugdata] [?logfile]"
echo
exit 1
fi
###################
# ERROR HANDLING
###################
# get required parameters
script=$2
shortcode=$3
# check reqired parameters
if [ "${script}" == "" ]; then
/home/admin/config.scripts/blitz.error.sh blitz.error.sh "error-missing-script" "missing any parameter" "$@"
exit 1
fi
if [ "${shortcode}" == "" ]; then
/home/admin/config.scripts/blitz.error.sh blitz.error.sh "error-missing-code" "script ${script} missing error code" "$@"
exit 1
fi
# set error info in cache system state (for DISPLAY on lcd, report to webui, etc)
/home/admin/_cache.sh set state "error"
/home/admin/_cache.sh set message "${shortcode}"
# prepare log error report
dateStr=$(date)
errorReport="ERROR in ${script} --> ${shortcode} on ${dateStr}"
# get optional parameters & extend error report if given
detail=$4
debugdata=$5
if [ "${detail}" != "" ] || [ "${debugdata}" != "" ]; then
errorReport="${errorReport}\nDETAIL --> ${detail}\nDEBUG --> ${debugdata}"
fi
# A) write error reports to /home/admin
timestampStr=$(date +%s)
filename="/home/admin/error-${script}-${timestampStr}.log"
echo "${errorReport}" > ${filename}
chown admin:admin ${filename}
# B) write error to std outs
>&2 echo "${errorReport} --> ${filename}"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${errorReport}"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
# C) write error report to given logfile (optional)
logfile=$6
if [ "${logfile}" != "" ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ${logFile}
echo "${errorReport}" >> ${logFile}
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ${logFile}
fi
# on serial calls make sure that at least a second is between error reports
sleep 1

View File

@ -86,17 +86,18 @@ migrate_raspiblitz_conf () {
# write default raspiblitz config # write default raspiblitz config
source /home/admin/_version.info source /home/admin/_version.info
echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf
echo "raspiBlitzVersion='${codeVersion}'" >> /home/admin/raspiblitz.conf
echo "network=bitcoin" >> /home/admin/raspiblitz.conf
echo "chain=main" >> /home/admin/raspiblitz.conf
echo "hostname=${nodename}" >> /home/admin/raspiblitz.conf
echo "displayClass=lcd" >> /home/admin/raspiblitz.conf
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
echo "runBehindTor=on" >> /home/admin/raspiblitz.conf
sudo mv /home/admin/raspiblitz.conf /mnt/hdd/raspiblitz.conf sudo mv /home/admin/raspiblitz.conf /mnt/hdd/raspiblitz.conf
sudo chown root:sudo /mnt/hdd/raspiblitz.conf sudo chown root:sudo /mnt/hdd/raspiblitz.conf
sudo chmod 664 /mnt/hdd/raspiblitz.conf sudo chmod 664 /mnt/hdd/raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set raspiBlitzVersion "${codeVersion}"
/home/admin/config.scripts/blitz.conf.sh set network "bitcoin"
/home/admin/config.scripts/blitz.conf.sh set chain "main"
/home/admin/config.scripts/blitz.conf.sh set hostname "${nodename}"
/home/admin/config.scripts/blitz.conf.sh set displayClass "lcd"
/home/admin/config.scripts/blitz.conf.sh set lcdrotate "1"
/home/admin/config.scripts/blitz.conf.sh set runBehindTor "on"
# rename ext4 data drive # rename ext4 data drive
sudo e2label /dev/sda1 BLOCKCHAIN sudo e2label /dev/sda1 BLOCKCHAIN
} }

View File

@ -12,65 +12,43 @@ fi
# load config values # load config values
source /home/admin/raspiblitz.info 2>/dev/null source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then
echo "FAIL - was not able to load config data / network"
exit 1
fi
# make sure main "notify" setting is present (add with default if not) # write default values if no custum values in raspiblitz config yet
if ! grep -Eq "^notify=.*" /mnt/hdd/raspiblitz.conf; then
echo "notify=off" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null
fi
# check all other settings and add if missing
if ! grep -Eq "^notifyMethod=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMethod=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMethod=mail" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMethod "mail"
fi fi
# Mail
if ! grep -Eq "^notifyMailTo=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailTo=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailTo=mail@example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailTo "mail@example.com"
fi fi
if ! grep -Eq "^notifyMailServer=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailServer=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailServer=mail.example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailServer "mail.example.com"
fi fi
if ! grep -Eq "^notifyMailPort=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailPort=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailPort=587" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailPort "587"
fi fi
if ! grep -Eq "^notifyMailHostname=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailHostname=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailHostname=$(hostname)" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailHostname "${hostname}"
fi fi
if ! grep -Eq "^notifyMailFromAddress=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailFromAddress=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailFromAddress=rb@example.com" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailFromAddress "rb@example.com"
fi fi
if ! grep -Eq "^notifyMailFromName=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailFromName=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailFromName=\"RB User\"" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailFromName "RB User"
fi fi
if ! grep -Eq "^notifyMailUser=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailUser=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailUser=username" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailUser "username"
fi fi
if ! grep -Eq "^notifyMailPass=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailPass=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailPass=password" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailPass "password"
fi fi
if ! grep -Eq "^notifyMailEncrypt=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailEncrypt=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailEncrypt=off" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailEncrypt "off"
fi fi
if ! grep -Eq "^notifyMailToCert=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyMailToCert=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyMailToCert=/mnt/hdd/notify_mail_cert.pem" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyMailToCert "/mnt/hdd/notify_mail_cert.pem"
fi fi
# Ext
if ! grep -Eq "^notifyExtCmd=.*" /mnt/hdd/raspiblitz.conf; then if ! grep -Eq "^notifyExtCmd=.*" /mnt/hdd/raspiblitz.conf; then
echo "notifyExtCmd=/usr/bin/printf" | sudo tee -a /mnt/hdd/raspiblitz.conf >/dev/null /home/admin/config.scripts/blitz.conf.sh set notifyExtCmd "/usr/bin/printf"
fi fi
# reload settings # reload settings
@ -114,7 +92,7 @@ EOF
# edit raspi blitz config # edit raspi blitz config
echo "editing /mnt/hdd/raspiblitz.conf" echo "editing /mnt/hdd/raspiblitz.conf"
sudo sed -i "s/^notify=.*/notify=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set notify "on"
exit 0 exit 0
fi fi
@ -126,7 +104,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "switching the NOTIFY OFF" echo "switching the NOTIFY OFF"
# edit raspi blitz config # edit raspi blitz config
echo "editing /mnt/hdd/raspiblitz.conf" echo "editing /mnt/hdd/raspiblitz.conf"
sudo sed -i "s/^notify=.*/notify=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set notify "off"
exit 0 exit 0
fi fi

View File

@ -3,15 +3,21 @@
# Just run this script once after a fresh sd card build # Just run this script once after a fresh sd card build
# to prepare the image for release as a downloadable sd card image # to prepare the image for release as a downloadable sd card image
# raspiblitz.info & logs # cleaning logs
echo "cleaning raspiblitz info .." echo "deleting raspiblitz & system logs .."
sudo rm /var/log/* 2>/dev/null
sudo rm /var/log/redis/* 2>/dev/null
sudo rm /var/log/private/* 2>/dev/null
sudo rm /var/log/nginx/* 2>/dev/null
sudo rm /home/admin/*.log 2>/dev/null
echo "OK"
# clean raspiblitz.info toward the values set by sd card build script
echo "cleaning raspiblitz.info"
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info
echo "cpu=${cpu}" >> /home/admin/raspiblitz.info echo "cpu=${cpu}" >> /home/admin/raspiblitz.info
echo "displayClass=${displayClass}" >> /home/admin/raspiblitz.info echo "displayClass=${displayClass}" >> /home/admin/raspiblitz.info
echo "deleting raspiblitz logs .."
sudo rm /home/admin/*.log
echo "OK"
# SSH Pubkeys (make unique for every sd card image install) # SSH Pubkeys (make unique for every sd card image install)
echo "" echo ""

View File

@ -5,15 +5,7 @@
# 1) give UI the info that a reboot/shutdown is now happening # 1) give UI the info that a reboot/shutdown is now happening
# 2) shutdown/reboot in a safe way to prevent data corruption # 2) shutdown/reboot in a safe way to prevent data corruption
# INFOFILE - state data from bootstrap source <(/home/admin/_cache.sh get network)
infoFile="/home/admin/raspiblitz.info"
# get network info from config
source ${infoFile} 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then
network=bitcoin
fi
# display info # display info
echo "" echo ""
@ -21,13 +13,13 @@ echo "Green activity light stays dark and LCD turns white when shutdown complete
if [ "$1" = "reboot" ]; then if [ "$1" = "reboot" ]; then
shutdownParams="-h -r now" shutdownParams="-h -r now"
echo "It will then reboot again automatically." echo "It will then reboot again automatically."
sed -i "s/^state=.*/state=reboot/g" ${infoFile} /home/admin/_cache.sh set state "reboot"
sed -i "s/^message=.*/message='$2'/g" ${infoFile} /home/admin/_cache.sh set message "$2"
else else
shutdownParams="-h now" shutdownParams="-h now"
echo "Then wait 5 seconds and disconnect power." echo "Then wait 5 seconds and disconnect power."
sed -i "s/^state=.*/state=shutdown/g" ${infoFile} /home/admin/_cache.sh set state "shutdown"
sed -i "s/^message=.*/message=''/g" ${infoFile} /home/admin/_cache.sh set message ""
fi fi
# do shutdown/reboot # do shutdown/reboot

View File

@ -7,7 +7,8 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ];
echo "blitz.ssh.sh clear --> make sure old sshd host certs are cleared" echo "blitz.ssh.sh clear --> make sure old sshd host certs are cleared"
echo "blitz.ssh.sh checkrepair --> check sshd & repair just in case" echo "blitz.ssh.sh checkrepair --> check sshd & repair just in case"
echo "blitz.ssh.sh backup --> copy ssh keys to backup (if exist)" echo "blitz.ssh.sh backup --> copy ssh keys to backup (if exist)"
echo "blitz.ssh.sh restore --> restore ssh keys from backup (if exist)" echo "blitz.ssh.sh sessions --> count open sessions"
echo "blitz.ssh.sh restore [?backup-root] --> restore ssh keys from backup (if exist)"
exit 1 exit 1
fi fi
@ -42,6 +43,16 @@ if [ "$1" = "clear" ]; then
exit 0 exit 0
fi fi
###################
# SESSIONS
###################
if [ "$1" = "sessions" ]; then
echo "# *** blitz.ssh.sh sessions"
sessionsCount=$(ss | grep -c ":ssh")
echo "ssh_session_count=${sessionsCount}"
exit 0
fi
################### ###################
# CHECK & REPAIR # CHECK & REPAIR
################### ###################
@ -117,6 +128,13 @@ fi
################### ###################
if [ "$1" = "restore" ]; then if [ "$1" = "restore" ]; then
echo "# *** blitz.ssh.sh restore" echo "# *** blitz.ssh.sh restore"
# second parameter (optional)
ALTBACKUPBASEDIR=$2
if [ "${ALTBACKUPBASEDIR}" != "" ]; then
DEFAULTBACKUPBASEDIR="${ALTBACKUPBASEDIR}"
fi
echo "# backup dir: ${DEFAULTBACKUPBASEDIR}/ssh" echo "# backup dir: ${DEFAULTBACKUPBASEDIR}/ssh"
if [ -d "${DEFAULTBACKUPBASEDIR}/ssh" ]; then if [ -d "${DEFAULTBACKUPBASEDIR}/ssh" ]; then

View File

@ -1,327 +0,0 @@
#!/bin/bash
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf 2>/dev/null
# LNTYPE is lnd | cl
if [ $# -gt 0 ];then
LNTYPE=$1
else
LNTYPE=${lightning}
fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# script to scan the state of the system after setup"
exit 1
fi
# measure time of scan
startTime=$(date +%s)
# localIP
localip=$(hostname -I | awk '{print $1}')
echo "localIP='${localip}'"
# temp - no measurement in a VM
tempC=0
if [ -d "/sys/class/thermal/thermal_zone0/" ]; then
tempC=$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc)
echo "tempCelsius='${tempC}'"
fi
# uptime in seconds
uptime=$(awk '{printf("%d\n",$1 + 0.5)}' /proc/uptime)
echo "uptime=${uptime}"
# get UPS info (if configured)
/home/admin/config.scripts/blitz.ups.sh status
# count restarts of bitcoind/litecoind
startcountBlockchain=$(cat /home/admin/systemd.blockchain.log 2>/dev/null | grep -c "STARTED")
echo "startcountBlockchain=${startcountBlockchain}"
# is bitcoind running
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
echo "bitcoinActive=${bitcoinRunning}"
if [ ${bitcoinRunning} -eq 1 ]; then
# get blockchain info
sudo touch /var/cache/raspiblitz/.bitcoind.out
sudo touch /var/cache/raspiblitz/.bitcoind.error
sudo chown root:sudo /var/cache/raspiblitz/.bitcoind.out
sudo chown root:sudo /var/cache/raspiblitz/.bitcoind.error
sudo chmod 660 /var/cache/raspiblitz/.bitcoind.out
sudo chmod 660 /var/cache/raspiblitz/.bitcoind.error
$bitcoincli_alias getblockchaininfo 1>/var/cache/raspiblitz/.bitcoind.out 2>/var/cache/raspiblitz/.bitcoind.error
# check if error on request
blockchaininfo=$(cat /var/cache/raspiblitz/.bitcoind.out 2>/dev/null)
bitcoinError=$(cat /var/cache/raspiblitz/.bitcoind.error 2>/dev/null)
#rm /var/cache/raspiblitz/.bitcoind.error 2>/dev/null
if [ ${#bitcoinError} -gt 0 ]; then
bitcoinErrorShort=$(echo ${bitcoinError/error*:/} | sed 's/[^a-zA-Z0-9 ]//g')
echo "bitcoinErrorShort='${bitcoinErrorShort}'"
bitcoinErrorFull=$(echo ${bitcoinError} | tr -d "'")
echo "bitcoinErrorFull='${bitcoinErrorFull}'"
else
###################################
# Get data from blockchain network
###################################
source <(sudo /home/admin/config.scripts/network.monitor.sh peer-status)
echo "blockchainPeers=${peers}"
##############################
# Get data from blockchaininfo
##############################
# get total number of blocks
total=$(echo ${blockchaininfo} | jq -r '.blocks')
echo "blockchainHeight=${total}"
# is initial sync of blockchain
initialSync=$(echo ${blockchaininfo} | jq -r '.initialblockdownload' | grep -c 'true')
echo "initialSync=${initialSync}"
# get blockchain sync progress
syncProgress="$(echo ${blockchaininfo} | jq -r '.verificationprogress')"
syncProgress=$(echo $syncProgress | awk '{printf( "%.2f%%", 100 * $1)}' | tr '%' ' ' | tr -s " ")
echo "syncProgress=${syncProgress}"
fi
else
# find out why Bitcoin not running
pathAdd=""
if [ "${chain}" = "test" ]; then
pathAdd="/testnet3"
fi
#### POSSIBLE/SOFT PROBLEMS
# place here in future analysis
#### HARD PROBLEMS
# LOW DISK SPACE
lowDiskSpace=$(sudo tail -n 100 /mnt/hdd/${network}${pathAdd}/debug.log 2>/dev/null | grep -c "Error: Disk space is low!")
if [ ${lowDiskSpace} -gt 0 ]; then
bitcoinErrorShort="HDD DISK SPACE LOW"
bitcoinErrorFull="HDD DISK SPACE LOW - check what data you can delete on HDD and restart"
fi
#### GENERIC ERROR FIND
# if still no error identified - search logs for generic error (after 4min uptime)
if [ ${#bitcoinErrorShort} -eq 0 ] && [ ${uptime} -gt 240 ]; then
bitcoinErrorFull=$(sudo tail -n 100 /mnt/hdd/${network}${pathAdd}/debug.log 2>/dev/null | grep -c "Error:" | tail -1 | tr -d "'")
if [ ${#bitcoinErrorFull} -gt 0 ]; then
bitcoinErrorShort="Error found in Logs"
fi
fi
# output error if found
if [ ${#bitcoinErrorShort} -gt 0 ]; then
echo "bitcoinErrorShort='${bitcoinErrorShort}'"
echo "bitcoinErrorFull='${bitcoinErrorFull}'"
/home/admin/config.scripts/blitz.systemd.sh log blockchain "ERROR: ${bitcoinErrorShort}"
fi
fi
# count restarts of bitcoind/litecoind
startcountLightning=$(cat /home/admin/systemd.lightning.log 2>/dev/null | grep -c "STARTED")
echo "startcountLightning=${startcountLightning}"
# is LND running
lndRunning=$(systemctl status ${netprefix}lnd.service 2>/dev/null | grep -c running)
echo "lndActive=${lndRunning}"
if [ ${lndRunning} -eq 1 ] && [ "${LNTYPE}" == "lnd" ]; then
# get LND info
lndRPCReady=1
sudo touch /var/cache/raspiblitz/.lnd.error
sudo chown root:sudo /var/cache/raspiblitz/.lnd.error
sudo chmod 660 /var/cache/raspiblitz/.lnd.error
lndinfo=$($lncli_alias getinfo 2>/var/cache/raspiblitz/.lnd.error)
# check if error on request
lndErrorFull=$(cat /var/cache/raspiblitz/.lnd.error 2>/dev/null)
lndErrorShort=''
#rm /var/cache/raspiblitz/.lnd.error 2>/dev/null
if [ ${#lndErrorFull} -gt 0 ]; then
# flag if error could be resoled by analysis
errorResolved=0
### analyse LND logs since start
# find a the line number in logs of start of LND
# just do this on error case to save on processing memory
lndStartLineNumber=$(sudo cat /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -in "LTND: Active chain:" | tail -1 | cut -d ":" -f1)
# get logs of last LND start
lndLogsAfterStart=$(sudo tail --lines=+${lndStartLineNumber} /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null)
# check RPC server ready (can take some time after wallet was unlocked)
lndRPCReady=$(echo "${lndLogsAfterStart}" | grep -c "RPCS: RPC server listening on")
echo "lndRPCReady=${lndRPCReady}"
# check wallet if wallet was opened (after correct password)
lndWalletOpened=$(echo "${lndLogsAfterStart}" | grep -c "LNWL: Opened wallet")
echo "walletOpened=${lndWalletOpened}"
# check wallet if wallet is ready (can take some time after wallet was opened)
lndWalletReady=$(echo "${lndLogsAfterStart}" | grep -c "LTND: LightningWallet opened")
echo "walletReady=${lndWalletReady}"
### check errors
# scan error for walletLocked as common error
locked=$(echo ${lndErrorFull} | grep -c 'Wallet is encrypted')
if [ "${locked}" == "0" ]; then
locked=$(echo ${lndErrorFull} | grep -c 'wallet locked')
fi
if [ ${locked} -gt 0 ]; then
echo "walletLocked=1"
else
echo "walletLocked=0"
rpcNotWorking=$(echo ${lndErrorFull} | grep -c 'connection refused')
if [ ${rpcNotWorking} -gt 0 ]; then
# this can happen for a long time when LND is starting fresh sync
# on first startup - check if logs since start signaled RPC ready before
if [ ${lndRPCReady} -eq 0 ]; then
# nullify error - this is normal
lndErrorFull=""
errorResolved=1
# output basic data because no error
echo "# LND RPC is still warming up - no scan progress: prepare scan"
echo "scanTimestamp=-2"
echo "syncedToChain=0"
else
echo "# LND RPC was started - some other problem going on"
lndErrorShort='LND RPC not responding'
lndErrorFull=$(echo "LND RPC is not responding. LND may have problems starting up. Check logs, config files and systemd service. Org-Error: ${lndErrorFull}" | tr -d "'")
fi
fi
# if not known error and not resolved before - keep generic
if [ ${#lndErrorShort} -eq 0 ] && [ ${errorResolved} -eq 0 ]; then
lndErrorShort='Unknown Error - see logs'
lndErrorFull=$(echo ${lndErrorFull} | tr -d "'")
fi
# write to results
if [ ${#lndErrorFull} -gt 0 ]; then
echo "lndErrorShort='${lndErrorShort}'"
echo "lndErrorFull='${lndErrorFull}'"
/home/admin/config.scripts/blitz.systemd.sh log lightning "ERROR: ${lndErrorFull}"
fi
fi
else
# check if wallet is locked
locked=$(echo ${lndinfo} | grep -c unlock)
if [ ${locked} -gt 0 ]; then
echo "walletLocked=1"
else
echo "walletLocked=0"
fi
# number of lnd peers
lndPeers=$(echo ${lndinfo} | jq -r '.num_peers')
echo "lndPeers=${lndPeers}"
# synced to chain
syncedToChain=$(echo ${lndinfo} | jq -r '.synced_to_chain' | grep -c 'true')
echo "syncedToChain=${syncedToChain}"
# lnd scan progress
scanTimestamp=$(echo ${lndinfo} | jq -r '.best_header_timestamp')
nowTimestamp=$(date +%s)
if [ ${#scanTimestamp} -gt 0 ] && [ ${scanTimestamp} -gt ${nowTimestamp} ]; then
scanTimestamp=${nowTimestamp}
fi
if [ ${#scanTimestamp} -gt 0 ]; then
echo "scanTimestamp=${scanTimestamp}"
scanDate=$(date -d @${scanTimestamp} 2>/dev/null)
echo "scanDate='${scanDate}'"
# calculate LND scan progress by seconds since Genesis block
genesisTimestamp=1230940800
totalSeconds=$(echo "${nowTimestamp}-${genesisTimestamp}" | bc)
scannedSeconds=$(echo "${scanTimestamp}-${genesisTimestamp}" | bc)
scanProgress=$(echo "scale=2; $scannedSeconds*100/$totalSeconds" | bc)
echo "scanProgress=${scanProgress}"
else
echo "# was not able to parse 'best_header_timestamp' from: lncli getinfo"
echo "scanTimestamp=-1"
fi
fi
# output if lnd-RPC is ready
echo "lndRPCReady=${lndRPCReady}"
fi
# is CL running
clRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
echo "clActive=${clRunning}"
echo "CLwalletLocked=0"
if [ "${clRunning}" != "1" ] && [ "${LNTYPE}" == "cl" ]; then
# check if locked
if [ "$(sudo journalctl -n5 -u ${netprefix}lightningd | \
grep -cE 'Could not read pass from stdin|pass the --encrypted-hsm|Wrong password')" -gt 0 ];then
echo "CLwalletLocked=1"
fi
fi
if [ "${clRunning}" == "1" ] && [ "${LNTYPE}" == "cl" ]; then
clInfo=$($lightningcli_alias getinfo 2>&1)
clBlockHeight=$(echo "${clInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')
scanProgress=$(echo "scale=2; $clBlockHeight*100/$total" | bc)
echo "scanProgress=${scanProgress}"
clBlockHeightPlusOne=$(expr $clBlockHeight + 1)
if [ "${total}" == "${clBlockHeight}" ] || [ "${total}" == "${clBlockHeightPlusOne}" ]; then
echo "syncedToChain=1"
else
echo "syncedToChain=0"
fi
fi
# touchscreen statistics
if [ "${touchscreen}" == "1" ]; then
echo "blitzTUIActive=1"
if [ ${#blitzTUIRestarts} -gt 0 ]; then
echo "blitzTUIRestarts=${blitzTUIRestarts}"
else
echo "blitzTUIRestarts=0"
fi
else
echo "blitzTUIActive=0"
echo "blitzTUIRestarts=0"
fi
# check if runnig in vagrant
vagrant=$(df | grep -c "/vagrant")
echo "vagrant=${vagrant}"
# check if online if problem with other stuff
# info on scan run time
endTime=$(date +%s)
runTime=$(echo "${endTime}-${startTime}" | bc)
echo "scriptRuntime=${runTime}"

View File

@ -13,7 +13,5 @@ if [ "${1}" != "log" ]; then
echo "# FAIL: unknown parameter" echo "# FAIL: unknown parameter"
fi fi
# writing log file entry # count for statistics in cache
logFile="/home/admin/systemd.${2}.log" /home/admin/_cache.sh increment system_count_start_${2}
echo "$(date +%s) ${3}" >> ${logFile}
echo "# OK: log '${3}' written to ${logFile}"

View File

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
# see issue: https://github.com/rootzoll/raspiblitz/issues/646 # see issue: https://github.com/rootzoll/raspiblitz/issues/646
# and issue: https://github.com/rootzoll/raspiblitz/issues/809 # and issue: https://github.com/rootzoll/raspiblitz/issues/809
# to work it needs to be based on Raspbian Desktop base image
# to check debug logs: sudo cat /home/pi/.cache/lxsession/LXDE-pi/run.log # to check debug logs: sudo cat /home/pi/.cache/lxsession/LXDE-pi/run.log
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
@ -136,11 +135,7 @@ EOF
echo "LCD is rotated into default - no touchscreen rotate" echo "LCD is rotated into default - no touchscreen rotate"
fi fi
# mark touchscreen as switched ON in config /home/admin/config.scripts/blitz.conf.sh set touchscreen "1"
if [ ${#touchscreen} -eq 0 ]; then
echo "touchscreen=0" >> /mnt/hdd/raspiblitz.conf
fi
sudo sed -i 's/^touchscreen=.*/touchscreen=1/g' /mnt/hdd/raspiblitz.conf
echo "OK - a restart is needed: sudo shutdown -r now" echo "OK - a restart is needed: sudo shutdown -r now"
exit 0 exit 0
@ -236,7 +231,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo rm -f /etc/X11/xorg.conf.d/40-libinput.conf >/dev/null sudo rm -f /etc/X11/xorg.conf.d/40-libinput.conf >/dev/null
# mark touchscreen as switched OFF in config # mark touchscreen as switched OFF in config
sudo sed -i 's/^touchscreen=.*/touchscreen=0/g' /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set touchscreen "0"
echo "OK - a restart is needed: sudo shutdown -r now" echo "OK - a restart is needed: sudo shutdown -r now"
exit 0 exit 0

View File

@ -53,8 +53,9 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ ${#ups} -eq 0 ]; then if [ ${#ups} -eq 0 ]; then
echo "ups=on" >> /mnt/hdd/raspiblitz.conf echo "ups=on" >> /mnt/hdd/raspiblitz.conf
fi fi
# set ups config value (in case of update) # set ups config value (in case of update)
sudo sed -i "s/^ups=.*/ups='apcusb'/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ups "apcusb"
echo "OK - UPS is now connected" echo "OK - UPS is now connected"
echo "Check status/connection with command: apcaccess" echo "Check status/connection with command: apcaccess"
@ -116,7 +117,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo systemctl stop apcupsd sudo systemctl stop apcupsd
sudo systemctl disable apcupsd sudo systemctl disable apcupsd
sudo apt-get remove -y apcupsd sudo apt-get remove -y apcupsd
sudo sed -i "s/^ups=.*/ups=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ups "off"
else else
echo "FAIL: unknown UPSTYPE: ${ups}" echo "FAIL: unknown UPSTYPE: ${ups}"
exit 1 exit 1

View File

@ -57,6 +57,9 @@ EOF
# ToDo(frennkie) verify this # ToDo(frennkie) verify this
sudo sed -i -E '/^.*server_names_hash_bucket_size [0-9]*;$/a \\tserver_names_hash_bucket_size 128;' /etc/nginx/nginx.conf sudo sed -i -E '/^.*server_names_hash_bucket_size [0-9]*;$/a \\tserver_names_hash_bucket_size 128;' /etc/nginx/nginx.conf
fi fi
if [ $(sudo cat /etc/nginx/nginx.conf | grep -c "# server_tokens off") -gt 0 ]; then
sudo sed -i "s/# server_tokens off;/server_tokens off;/g" /etc/nginx/nginx.conf
fi
echo "# Checking dhparam.pem ..." echo "# Checking dhparam.pem ..."
if [ ! -f /etc/ssl/certs/dhparam.pem ]; then if [ ! -f /etc/ssl/certs/dhparam.pem ]; then

View File

@ -9,11 +9,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^angular_cli=" /mnt/hdd/raspiblitz.conf; then
echo "angular_cli=off" >> /mnt/hdd/raspiblitz.conf
fi
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check if angular_cli was installed # check if angular_cli was installed
@ -62,7 +57,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^angular_cli=.*/angular_cli=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set angular_cli "on"
echo "Installed angular_cli $(node -v)" echo "Installed angular_cli $(node -v)"
exit 0 exit 0
fi fi
@ -70,7 +65,7 @@ fi
# switch off # switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^angular_cli=.*/angular_cli=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set angular_cli "off"
echo "*** REMOVING angular_cli ***" echo "*** REMOVING angular_cli ***"
npm uninstall @angular/cli -g npm uninstall @angular/cli -g
echo "OK angular_cli removed." echo "OK angular_cli removed."

View File

@ -13,11 +13,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^bos=" /mnt/hdd/raspiblitz.conf; then
echo "bos=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Info Balance of Satoshis " --msgbox " dialog --title " Info Balance of Satoshis " --msgbox "
@ -86,7 +81,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u bos bash -c 'echo "source <(bos completion bash)" >> /home/bos/.bashrc' sudo -u bos bash -c 'echo "source <(bos completion bash)" >> /home/bos/.bashrc'
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^bos=.*/bos=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set bos "on"
echo "# Usage: https://github.com/alexbosworth/balanceofsatoshis/blob/master/README.md" echo "# Usage: https://github.com/alexbosworth/balanceofsatoshis/blob/master/README.md"
echo "# To start type: 'sudo su bos' in the command line." echo "# To start type: 'sudo su bos' in the command line."
@ -101,7 +96,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^bos=.*/bos=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set bos "off"
echo "*** REMOVING BALANCE OF SATOSHIS ***" echo "*** REMOVING BALANCE OF SATOSHIS ***"
sudo userdel -rf bos sudo userdel -rf bos

View File

@ -80,11 +80,6 @@ Activate TOR to access the web block explorer from outside your local network.
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^BTCRPCexplorer=" /mnt/hdd/raspiblitz.conf; then
echo "BTCRPCexplorer=off" >> /mnt/hdd/raspiblitz.conf
fi
# status # status
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
@ -314,7 +309,7 @@ EOF
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^BTCRPCexplorer=.*/BTCRPCexplorer=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set BTCRPCexplorer "on"
echo "# needs to finish creating txindex to be functional" echo "# needs to finish creating txindex to be functional"
echo "# monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log" echo "# monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log"
@ -325,8 +320,8 @@ EOF
# Hidden Service for BTC-RPC-explorer if Tor is active # Hidden Service for BTC-RPC-explorer if Tor is active
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh btc-rpc-explorer 80 3022 443 3023 /home/admin/config.scripts/tor.onion-service.sh btc-rpc-explorer 80 3022 443 3023
fi fi
exit 0 exit 0
fi fi
@ -339,7 +334,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^BTCRPCexplorer=.*/BTCRPCexplorer=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set BTCRPCexplorer "off"
isInstalled=$(sudo ls /etc/systemd/system/btc-rpc-explorer.service 2>/dev/null | grep -c 'btc-rpc-explorer.service') isInstalled=$(sudo ls /etc/systemd/system/btc-rpc-explorer.service 2>/dev/null | grep -c 'btc-rpc-explorer.service')
if [ ${isInstalled} -eq 1 ]; then if [ ${isInstalled} -eq 1 ]; then
@ -361,8 +356,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh off btc-rpc-explorer /home/admin/config.scripts/tor.onion-service.sh off btc-rpc-explorer
fi fi
echo "# OK BTC-RPC-explorer removed." echo "# OK BTC-RPC-explorer removed."

View File

@ -26,6 +26,7 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# get cpu architecture # get cpu architecture
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source <(/home/admin/_cache.sh get state)
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
@ -162,14 +163,6 @@ MAINMENU > CONNECT > BTCPay Server"
exit 0 exit 0
fi fi
# add default values to raspi config if needed
if ! grep -Eq "^BTCPayServer=" /mnt/hdd/raspiblitz.conf; then
echo "BTCPayServer=off" >> /mnt/hdd/raspiblitz.conf
fi
if ! grep -Eq "^BTCPayDomain=" /mnt/hdd/raspiblitz.conf; then
echo "BTCPayDomain=off" >> /mnt/hdd/raspiblitz.conf
fi
# write-tls-macaroon # write-tls-macaroon
if [ "$1" = "write-tls-macaroon" ]; then if [ "$1" = "write-tls-macaroon" ]; then
@ -249,8 +242,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# Hidden Service for BTCPay if Tor is active # Hidden Service for BTCPay if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh btcpay 80 23002 443 23003 /home/admin/config.scripts/tor.onion-service.sh btcpay 80 23002 443 23003
fi fi
# check for $BTCPayDomain # check for $BTCPayDomain
@ -502,7 +495,7 @@ WantedBy=multi-user.target
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^BTCPayServer=.*/BTCPayServer=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set BTCPayServer "on"
exit 0 exit 0
fi fi
@ -525,11 +518,11 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# deleteData(${deleteData})" echo "# deleteData(${deleteData})"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^BTCPayServer=.*/BTCPayServer=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set BTCPayServer "off"
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off btcpay /home/admin/config.scripts/tor.onion-service.sh off btcpay
fi fi
isInstalled=$(sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service') isInstalled=$(sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service')

View File

@ -25,11 +25,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^chantools=" /mnt/hdd/raspiblitz.conf; then
echo "chantools=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Channel Tools ${pinnedVersion} " --msgbox "\n dialog --title " Channel Tools ${pinnedVersion} " --msgbox "\n
@ -130,7 +125,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
exit 1 exit 1
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^chantools=.*/chantools=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set chantools "on"
echo echo
echo "Installed ${installed}" echo "Installed ${installed}"
@ -147,7 +142,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^chantools=.*/chantools=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set chantools "off"
echo "# REMOVING Channel Tools" echo "# REMOVING Channel Tools"
sudo rm -rf /home/admin/download/chantools* sudo rm -rf /home/admin/download/chantools*

View File

@ -18,11 +18,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspiblitz.conf if needed
if ! grep -Eq "^circuitbreaker=" /mnt/hdd/raspiblitz.conf; then
echo "circuitbreaker=off" >> /mnt/hdd/raspiblitz.conf
fi
isInstalled=$(sudo ls /etc/systemd/system/circuitbreaker.service 2>/dev/null | grep -c 'circuitbreaker.service') isInstalled=$(sudo ls /etc/systemd/system/circuitbreaker.service 2>/dev/null | grep -c 'circuitbreaker.service')
# switch on # switch on
@ -124,13 +119,13 @@ WantedBy=multi-user.target
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^circuitbreaker=.*/circuitbreaker=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set circuitbreaker "on"
isInstalled=$(sudo -u circuitbreaker /home/circuitbreaker/go/bin/circuitbreaker --version | grep -c "circuitbreaker version") isInstalled=$(sudo -u circuitbreaker /home/circuitbreaker/go/bin/circuitbreaker --version | grep -c "circuitbreaker version")
if [ ${isInstalled} -eq 1 ]; then if [ ${isInstalled} -eq 1 ]; then
echo echo
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the circuitbreaker.service is enabled, system is on ready so starting service" echo "# OK - the circuitbreaker.service is enabled, system is on ready so starting service"
sudo systemctl start circuitbreaker sudo systemctl start circuitbreaker
@ -163,7 +158,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
fi fi
# setting value in raspiblitz.conf # setting value in raspiblitz.conf
sudo sed -i "s/^circuitbreaker=.*/circuitbreaker=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set circuitbreaker "off"
exit 0 exit 0
fi fi

View File

@ -246,11 +246,6 @@ Check 'sudo nginx -t' for a detailed error message.
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^ElectRS=" /mnt/hdd/raspiblitz.conf; then
echo "ElectRS=off" >> /mnt/hdd/raspiblitz.conf
fi
# stop service # stop service
echo "# Making sure services are not running" echo "# Making sure services are not running"
sudo systemctl stop electrs 2>/dev/null sudo systemctl stop electrs 2>/dev/null
@ -428,12 +423,12 @@ WantedBy=multi-user.target
fi fi
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^ElectRS=.*/ElectRS=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ElectRS "on"
# Hidden Service for electrs if Tor active # Hidden Service for electrs if Tor active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh electrs 50002 50002 50001 50001 /home/admin/config.scripts/tor.onion-service.sh electrs 50002 50002 50001 50001
fi fi
# whitelist downloading to localhost from bitcoind # whitelist downloading to localhost from bitcoind
@ -442,7 +437,7 @@ WantedBy=multi-user.target
bitcoindRestart=yes bitcoindRestart=yes
fi fi
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
if [ "${bitcoindRestart}" == "yes" ]; then if [ "${bitcoindRestart}" == "yes" ]; then
sudo systemctl restart bitcoind sudo systemctl restart bitcoind
@ -467,7 +462,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^ElectRS=.*/ElectRS=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ElectRS "off"
# if second parameter is "deleteindex" # if second parameter is "deleteindex"
if [ "$2" == "deleteindex" ]; then if [ "$2" == "deleteindex" ]; then
@ -477,7 +472,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off electrs /home/admin/config.scripts/tor.onion-service.sh off electrs
fi fi
isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service') isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service')

View File

@ -24,6 +24,7 @@ mode="$1"
# GATHER DATA # GATHER DATA
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source <(/home/admin/_cache.sh get state)
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# setting download directory # setting download directory
@ -242,10 +243,7 @@ WantedBy=multi-user.target
sudo chown -R faraday:faraday /home/faraday/.faraday sudo chown -R faraday:faraday /home/faraday/.faraday
echo "# flag in raspiblitz config" echo "# flag in raspiblitz config"
if [ ${#faraday} -eq 0 ]; then /home/admin/config.scripts/blitz.conf.sh set faraday "on"
echo "faraday='on'" >> /mnt/hdd/raspiblitz.conf
fi
sudo sed -i "s/^faraday=.*/faraday=on/g" /mnt/hdd/raspiblitz.conf
echo "# OK Faraday is installed" echo "# OK Faraday is installed"
echo "# please 'restart' for clean creation of faraday tls/macaroons" echo "# please 'restart' for clean creation of faraday tls/macaroons"
@ -267,7 +265,7 @@ if [ "${mode}" = "off" ] || [ "${mode}" = "0" ]; then
sudo userdel -r -f faraday sudo userdel -r -f faraday
echo "# modify config file" echo "# modify config file"
sudo sed -i "s/^faraday=.*/faraday=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set faraday "off"
exit 1 exit 1

View File

@ -22,7 +22,7 @@ elif [ "${chain}net" == "signet" ]; then
fi fi
# check and set up the HS # check and set up the HS
/home/admin/config.scripts/internet.hiddenservice.sh bitcoin${BITCOINRPCPORT} ${BITCOINRPCPORT} ${BITCOINRPCPORT} /home/admin/config.scripts/tor.onion-service.sh bitcoin${BITCOINRPCPORT} ${BITCOINRPCPORT} ${BITCOINRPCPORT}
hiddenService=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname) hiddenService=$(sudo cat /mnt/hdd/tor/bitcoin${BITCOINRPCPORT}/hostname)
# https://github.com/rootzoll/raspiblitz/issues/2339 # https://github.com/rootzoll/raspiblitz/issues/2339

View File

@ -27,11 +27,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^joinmarket=" /mnt/hdd/raspiblitz.conf; then
echo "joinmarket=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
whiptail --title " JoinMarket info " --msgbox " whiptail --title " JoinMarket info " --msgbox "
@ -183,7 +178,7 @@ fi
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^joinmarket=.*/joinmarket=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set joinmarket "on"
# starting info # starting info
echo echo
echo "# Start to use by logging in to the 'joinmarket' user with:" echo "# Start to use by logging in to the 'joinmarket' user with:"
@ -202,7 +197,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^joinmarket=.*/joinmarket=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set joinmarket "off"
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
echo "# REMOVING JOINMARKET" echo "# REMOVING JOINMARKET"

View File

@ -21,6 +21,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
fi fi
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source <(/home/admin/_cache.sh get state)
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
@ -164,7 +165,7 @@ PATH=/bin:/usr/bin:/usr/local/bin
echo "Switch to the '$USERNAME' user and adapt the settings in $CONFIG_FILE" echo "Switch to the '$USERNAME' user and adapt the settings in $CONFIG_FILE"
# setting value in raspi blitz config # setting value in raspi blitz config
grep -q '^kindleDisplay' $RASPIBLITZ_FILE && sudo sed -i "s/^kindleDisplay=.*/kindleDisplay=on/g" $RASPIBLITZ_FILE || echo 'kindleDisplay=on' >> $RASPIBLITZ_FILE /home/admin/config.scripts/blitz.conf.sh set kindleDisplay "on"
else else
echo "KINDLE-DISPLAY already installed." echo "KINDLE-DISPLAY already installed."
fi fi
@ -181,7 +182,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "*** REMOVING KINDLE-DISPLAY ***" echo "*** REMOVING KINDLE-DISPLAY ***"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^kindleDisplay=.*/kindleDisplay=off/g" $RASPIBLITZ_FILE /home/admin/config.scripts/blitz.conf.sh set kindleDisplay "off"
# uninstall service # uninstall service
sudo systemctl stop kindle-display sudo systemctl stop kindle-display

View File

@ -183,7 +183,6 @@ function refresh_certs_with_nginx() {
} }
################### ###################
# running as admin # running as admin
################### ###################
@ -193,13 +192,6 @@ if [ "${EUID}" != "${adminUserId}" ]; then
exit 1 exit 1
fi fi
# add default value to RaspiBlitz config if needed
if ! grep -Eq "^letsencrypt" /mnt/hdd/raspiblitz.conf; then
echo "letsencrypt=off" >> /mnt/hdd/raspiblitz.conf
fi
################### ###################
# update status # update status
################### ###################
@ -213,7 +205,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "*** INSTALLING Let's Encrypt Client 'acme.sh' ***" echo "*** INSTALLING Let's Encrypt Client 'acme.sh' ***"
# setting value in RaspiBlitz config # setting value in RaspiBlitz config
sudo sed -i "s/^letsencrypt=.*/letsencrypt=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set letsencrypt "on"
address="$2" address="$2"
if [ "$2" == "enter-email" ]; then if [ "$2" == "enter-email" ]; then
@ -391,7 +383,7 @@ elif [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "*** UNINSTALLING Let's Encrypt Client 'acme.sh' ***" echo "*** UNINSTALLING Let's Encrypt Client 'acme.sh' ***"
# setting value in RaspiBlitz config # setting value in RaspiBlitz config
sudo sed -i "s/^letsencrypt=.*/letsencrypt=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set letsencrypt "off"
"${ACME_INSTALL_HOME}/acme.sh" --uninstall \ "${ACME_INSTALL_HOME}/acme.sh" --uninstall \
--home "${ACME_INSTALL_HOME}" \ --home "${ACME_INSTALL_HOME}" \

View File

@ -24,11 +24,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^lit=" /mnt/hdd/raspiblitz.conf; then
echo "lit=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
@ -325,12 +320,12 @@ alias lit-frcli=\"frcli --rpcserver=localhost:8443 \
sudo ufw allow 8443 comment "Lightning Terminal" sudo ufw allow 8443 comment "Lightning Terminal"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^lit=.*/lit=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lit "on"
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh lit 443 8443 /home/admin/config.scripts/tor.onion-service.sh lit 443 8443
fi fi
# in case RTL is installed - check to connect # in case RTL is installed - check to connect
@ -339,7 +334,7 @@ alias lit-frcli=\"frcli --rpcserver=localhost:8443 \
sudo systemctl restart RTL 2>/dev/null sudo systemctl restart RTL 2>/dev/null
fi fi
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the litd.service is enabled, system is ready so starting service" echo "# OK - the litd.service is enabled, system is ready so starting service"
sudo systemctl start litd sudo systemctl start litd
@ -367,7 +362,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# OK, the lit.service is removed." echo "# OK, the lit.service is removed."
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off lit /home/admin/config.scripts/tor.onion-service.sh off lit
fi fi
else else
echo "# LiT is not installed." echo "# LiT is not installed."
@ -379,7 +374,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# delete group # delete group
sudo groupdel lit sudo groupdel lit
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^lit=.*/lit=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lit "off"
exit 0 exit 0
fi fi

View File

@ -74,11 +74,6 @@ consider adding a IP2TOR Bridge (MAINMENU > SUBSCRIBE)."
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^LNBits=" /mnt/hdd/raspiblitz.conf; then
echo "LNBits=off" >> /mnt/hdd/raspiblitz.conf
fi
# status # status
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
@ -340,7 +335,7 @@ EOF
sudo systemctl enable lnbits sudo systemctl enable lnbits
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - lnbits service is enabled, system is on ready so starting lnbits service" echo "# OK - lnbits service is enabled, system is on ready so starting lnbits service"
sudo systemctl start lnbits sudo systemctl start lnbits
@ -369,13 +364,13 @@ EOF
sudo systemctl reload nginx sudo systemctl reload nginx
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^LNBits=.*/LNBits=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set LNBits "on"
# Hidden Service if Tor is active # Hidden Service if Tor is active
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh lnbits 80 5002 443 5003 /home/admin/config.scripts/tor.onion-service.sh lnbits 80 5002 443 5003
fi fi
exit 0 exit 0
fi fi
@ -399,7 +394,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# deleteData(${deleteData})" echo "# deleteData(${deleteData})"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^LNBits=.*/LNBits=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set LNBits "off"
# remove nginx symlinks # remove nginx symlinks
sudo rm -f /etc/nginx/sites-enabled/lnbits_ssl.conf sudo rm -f /etc/nginx/sites-enabled/lnbits_ssl.conf
@ -413,7 +408,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off lnbits /home/admin/config.scripts/tor.onion-service.sh off lnbits
fi fi
isInstalled=$(sudo ls /etc/systemd/system/lnbits.service 2>/dev/null | grep -c 'lnbits.service') isInstalled=$(sudo ls /etc/systemd/system/lnbits.service 2>/dev/null | grep -c 'lnbits.service')

View File

@ -15,11 +15,6 @@ gpgFingerprint="0453B9F5071261A40FDB34181965063FC13BEBE2"
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^lndmanage=" /mnt/hdd/raspiblitz.conf; then
echo "lndmanage=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Info lndmanage " --msgbox "\n\ dialog --title " Info lndmanage " --msgbox "\n\
@ -92,7 +87,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^lndmanage=.*/lndmanage=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lndmanage "on"
echo "#######################################################################" echo "#######################################################################"
echo "# OK install done" echo "# OK install done"
echo "#######################################################################" echo "#######################################################################"
@ -107,7 +102,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^lndmanage=.*/lndmanage=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lndmanage "off"
echo "*** REMOVING LNDMANAGE ***" echo "*** REMOVING LNDMANAGE ***"
sudo rm -rf /home/admin/lndmanage sudo rm -rf /home/admin/lndmanage

View File

@ -15,13 +15,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^loop=" /mnt/hdd/raspiblitz.conf; then
echo "loop=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Info Loop Service " --msgbox "\n\ dialog --title " Info Loop Service " --msgbox "\n\
@ -152,7 +145,7 @@ WantedBy=multi-user.target
sudo /home/admin/config.scripts/bonus.rtl.sh connect-services sudo /home/admin/config.scripts/bonus.rtl.sh connect-services
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^loop=.*/loop=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set loop "on"
isInstalled=$(sudo -u loop /home/loop/go/bin/loop | grep -c loop) isInstalled=$(sudo -u loop /home/loop/go/bin/loop | grep -c loop)
if [ ${isInstalled} -gt 0 ] ; then if [ ${isInstalled} -gt 0 ] ; then
@ -169,7 +162,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^loop=.*/loop=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set loop "off"
isInstalled=$(sudo ls /etc/systemd/system/loopd.service 2>/dev/null | grep -c 'loopd.service') isInstalled=$(sudo ls /etc/systemd/system/loopd.service 2>/dev/null | grep -c 'loopd.service')
if [ ${isInstalled} -eq 1 ]; then if [ ${isInstalled} -eq 1 ]; then

View File

@ -67,11 +67,6 @@ Activate TOR to access the web block explorer from outside your local network.
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^mempoolExplorer=" /mnt/hdd/raspiblitz.conf; then
echo "mempoolExplorer=off" >> /mnt/hdd/raspiblitz.conf
fi
# status # status
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
@ -280,7 +275,7 @@ EOF
fi fi
# start the service if ready # start the service if ready
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the mempool.service is enabled, system is on ready so starting service" echo "# OK - the mempool.service is enabled, system is on ready so starting service"
sudo systemctl start mempool sudo systemctl start mempool
@ -289,17 +284,16 @@ EOF
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^mempoolExplorer=.*/mempoolExplorer=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set mempoolExplorer "on"
echo "# needs to finish creating txindex to be functional" echo "# needs to finish creating txindex to be functional"
echo "# monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log" echo "# monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log"
# Hidden Service for Mempool if Tor is active # Hidden Service for Mempool if Tor is active
source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh mempool 80 4082 443 4083 /home/admin/config.scripts/tor.onion-service.sh mempool 80 4082 443 4083
fi fi
exit 0 exit 0
fi fi
@ -308,7 +302,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^mempoolExplorer=.*/mempoolExplorer=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set mempoolExplorer "off"
isInstalled=$(sudo ls /etc/systemd/system/mempool.service 2>/dev/null | grep -c 'mempool.service') isInstalled=$(sudo ls /etc/systemd/system/mempool.service 2>/dev/null | grep -c 'mempool.service')
if [ ${isInstalled} -eq 1 ]; then if [ ${isInstalled} -eq 1 ]; then
@ -336,8 +330,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh off mempool /home/admin/config.scripts/tor.onion-service.sh off mempool
fi fi
echo "# OK Mempool removed." echo "# OK Mempool removed."

View File

@ -16,13 +16,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^pool=" /mnt/hdd/raspiblitz.conf; then
echo "pool=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
whiptail --title " Info Pool Service " --msgbox "\ whiptail --title " Info Pool Service " --msgbox "\
@ -228,7 +221,7 @@ WantedBy=multi-user.target
echo "the poold.service already installed." echo "the poold.service already installed."
fi fi
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the poold.service is enabled, system is on ready so starting service" echo "# OK - the poold.service is enabled, system is on ready so starting service"
sudo systemctl start poold sudo systemctl start poold
@ -236,7 +229,7 @@ WantedBy=multi-user.target
echo "# OK - the poold.service is enabled, to start manually use: sudo systemctl start poold" echo "# OK - the poold.service is enabled, to start manually use: sudo systemctl start poold"
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^pool=.*/pool=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set pool "on"
isInstalled=$(sudo -u pool /usr/local/bin/poold | grep -c pool) isInstalled=$(sudo -u pool /usr/local/bin/poold | grep -c pool)
if [ ${isInstalled} -gt 0 ]; then if [ ${isInstalled} -gt 0 ]; then
@ -258,7 +251,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^pool=.*/pool=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set pool "off"
isInstalled=$(sudo ls /etc/systemd/system/poold.service 2>/dev/null | grep -c 'poold.service') isInstalled=$(sudo ls /etc/systemd/system/poold.service 2>/dev/null | grep -c 'poold.service')
if [ ${isInstalled} -eq 1 ]; then if [ ${isInstalled} -eq 1 ]; then

View File

@ -7,13 +7,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^pyblock=" /mnt/hdd/raspiblitz.conf; then
echo "pyblock=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Info PyBlock " --msgbox " dialog --title " Info PyBlock " --msgbox "
@ -74,7 +67,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo chown pyblock:pyblock /home/pyblock/blndconnect.conf sudo chown pyblock:pyblock /home/pyblock/blndconnect.conf
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^pyblock=.*/pyblock=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set pyblock "on"
## pyblock short command ## pyblock short command
sudo bash -c "echo 'alias pyblock=\"cd ~; python3 ~/PyBLOCK/PyBlock.py\"' >> /home/pyblock/.bashrc" sudo bash -c "echo 'alias pyblock=\"cd ~; python3 ~/PyBLOCK/PyBlock.py\"' >> /home/pyblock/.bashrc"
@ -91,7 +84,7 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^pyblock=.*/pyblock=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set pyblock "off"
echo "*** REMOVING PyBLOCK ***" echo "*** REMOVING PyBLOCK ***"
sudo userdel -rf pyblock sudo userdel -rf pyblock

View File

@ -5,7 +5,6 @@ RTLVERSION="v0.11.2"
# check and load raspiblitz config # check and load raspiblitz config
# to know which network is running # to know which network is running
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@ -112,15 +111,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# Installing RTL for ${LNTYPE} ${CHAIN}" echo "# Installing RTL for ${LNTYPE} ${CHAIN}"
# prepare raspiblitz.conf --> add default value
configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}")
if [ "${configEntryExists}" == "0" ]; then
echo "# adding default config entry for '${configEntry}'"
sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf"
else
echo "# default config entry for '${configEntry}' exists"
fi
# check and install NodeJS # check and install NodeJS
/home/admin/config.scripts/bonus.nodejs.sh on /home/admin/config.scripts/bonus.nodejs.sh on
@ -240,8 +230,8 @@ WantedBy=multi-user.target
# Hidden Service for RTL if Tor is active # Hidden Service for RTL if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh ${netprefix}${typeprefix}RTL 80 $((RTLHTTP+2)) 443 $((RTLHTTP+3)) /home/admin/config.scripts/tor.onion-service.sh ${netprefix}${typeprefix}RTL 80 $((RTLHTTP+2)) 443 $((RTLHTTP+3))
fi fi
# nginx configuration # nginx configuration
@ -264,8 +254,8 @@ WantedBy=multi-user.target
# run config as root to connect prepare services (lit, pool, ...) # run config as root to connect prepare services (lit, pool, ...)
sudo /home/admin/config.scripts/bonus.rtl.sh connect-services sudo /home/admin/config.scripts/bonus.rtl.sh connect-services
# raspiblitz.config # ig
sudo sed -i "s/^${configEntry}=.*/${configEntry}=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${configEntry} "on"
sudo systemctl enable ${systemdService} sudo systemctl enable ${systemdService}
sudo systemctl start ${systemdService} sudo systemctl start ${systemdService}
@ -439,7 +429,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo systemctl stop ${systemdService} 2>/dev/null sudo systemctl stop ${systemdService} 2>/dev/null
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${configEntry}=.*/${configEntry}=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${configEntry} "off"
# remove nginx symlinks # remove nginx symlinks
sudo rm -f /etc/nginx/sites-enabled/${netprefix}${typeprefix}rtl_ssl.conf 2>/dev/null sudo rm -f /etc/nginx/sites-enabled/${netprefix}${typeprefix}rtl_ssl.conf 2>/dev/null
@ -453,7 +443,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off ${systemdService} /home/admin/config.scripts/tor.onion-service.sh off ${systemdService}
fi fi
isInstalled=$(sudo ls /etc/systemd/system/${systemdService}.service 2>/dev/null | grep -c "${systemdService}.service") isInstalled=$(sudo ls /etc/systemd/system/${systemdService}.service 2>/dev/null | grep -c "${systemdService}.service")

View File

@ -11,7 +11,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
source /mnt/hdd/raspiblitz.conf
echo "# bonus.specter.sh $1 $2" echo "# bonus.specter.sh $1 $2"
if [ $# -gt 1 ];then if [ $# -gt 1 ];then
@ -91,11 +90,6 @@ Activate TOR to access the web block explorer from outside your local network.
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^specter=" /mnt/hdd/raspiblitz.conf; then
echo "specter=off" >> /mnt/hdd/raspiblitz.conf
fi
# blockfilterindex # blockfilterindex
# add blockfilterindex with default value (0) to bitcoin.conf if missing # add blockfilterindex with default value (0) to bitcoin.conf if missing
if ! grep -Eq "^blockfilterindex=.*" /mnt/hdd/${network}/${network}.conf; then if ! grep -Eq "^blockfilterindex=.*" /mnt/hdd/${network}/${network}.conf; then
@ -368,14 +362,13 @@ EOF
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^specter=.*/specter=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set specter "on"
# Hidden Service for SERVICE if Tor is active # Hidden Service for SERVICE if Tor is active
source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
# port 25441 is HTTPS with self-signed cert - specte only makes sense to be served over HTTPS # port 25441 is HTTPS with self-signed cert - specte only makes sense to be served over HTTPS
/home/admin/config.scripts/internet.hiddenservice.sh specter 443 25441 /home/admin/config.scripts/tor.onion-service.sh specter 443 25441
fi fi
# blockfilterindex on # blockfilterindex on
@ -403,11 +396,11 @@ fi
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^specter=.*/specter=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set specter "off"
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off specter /home/admin/config.scripts/tor.onion-service.sh off specter
fi fi
isInstalled=$(sudo ls /etc/systemd/system/specter.service 2>/dev/null | grep -c 'specter.service') isInstalled=$(sudo ls /etc/systemd/system/specter.service 2>/dev/null | grep -c 'specter.service')

View File

@ -48,7 +48,7 @@ if [ "$1" = "menu" ]; then
--no-button "Other Options" \ --no-button "Other Options" \
--yesno "\nYou can connect Sphinx App over Tor. Its build in for iOS and on Android you need to use it together with the Orbot App." 10 72 --yesno "\nYou can connect Sphinx App over Tor. Its build in for iOS and on Android you need to use it together with the Orbot App." 10 72
if [ "$?" != "1" ]; then if [ "$?" != "1" ]; then
echo "sphinxrelay_connection='tor'" >> /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set sphinxrelay_connection "tor"
echo "Please wait (+1min) ... restarting sphinx relay to use tor" echo "Please wait (+1min) ... restarting sphinx relay to use tor"
sudo systemctl restart sphinxrelay sudo systemctl restart sphinxrelay
sleep 60 sleep 60
@ -183,11 +183,6 @@ ${extraPairInfo}" 17 76
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^sphinxrelay=" /mnt/hdd/raspiblitz.conf; then
echo "sphinxrelay=off" >> /mnt/hdd/raspiblitz.conf
fi
# write environment configs fresh before every start # write environment configs fresh before every start
# IMPORTANT: all this needs to work without sudo because will run from systemd as sphinxrelay user # IMPORTANT: all this needs to work without sudo because will run from systemd as sphinxrelay user
if [ "$1" = "write-environment" ]; then if [ "$1" = "write-environment" ]; then
@ -448,8 +443,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh sphinxrelay 80 3302 443 3303 /home/admin/config.scripts/tor.onion-service.sh sphinxrelay 80 3302 443 3303
# get TOR address and store it readable for sphinxrelay user # get TOR address and store it readable for sphinxrelay user
toraddress=$(sudo cat /mnt/hdd/tor/sphinxrelay/hostname 2>/dev/null) toraddress=$(sudo cat /mnt/hdd/tor/sphinxrelay/hostname 2>/dev/null)
sudo -u sphinxrelay bash -c "echo '${toraddress}' > /home/sphinxrelay/sphinx-relay/dist/toraddress.txt" sudo -u sphinxrelay bash -c "echo '${toraddress}' > /home/sphinxrelay/sphinx-relay/dist/toraddress.txt"
@ -495,7 +490,7 @@ EOF
sudo systemctl enable sphinxrelay sudo systemctl enable sphinxrelay
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - sphinxrelay service is enabled, system is on ready so starting service" echo "# OK - sphinxrelay service is enabled, system is on ready so starting service"
sudo systemctl start sphinxrelay sudo systemctl start sphinxrelay
@ -524,7 +519,7 @@ EOF
sudo systemctl reload nginx sudo systemctl reload nginx
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^sphinxrelay=.*/sphinxrelay=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set sphinxrelay "on"
exit 0 exit 0
fi fi
@ -584,8 +579,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# deleteData(${deleteData})" echo "# deleteData(${deleteData})"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^sphinxrelay=.*/sphinxrelay=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set sphinxrelay "off"
sudo sed -i "/^sphinxrelay_connection=.*/d" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh delete sphinxrelay_connection
# remove nginx symlinks # remove nginx symlinks
sudo rm -f /etc/nginx/sites-enabled/sphinxrelay_ssl.conf sudo rm -f /etc/nginx/sites-enabled/sphinxrelay_ssl.conf
@ -599,7 +594,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off sphinxrelay /home/admin/config.scripts/tor.onion-service.sh off sphinxrelay
fi fi
isInstalled=$(sudo ls /etc/systemd/system/sphinxrelay.service 2>/dev/null | grep -c 'sphinxrelay.service') isInstalled=$(sudo ls /etc/systemd/system/sphinxrelay.service 2>/dev/null | grep -c 'sphinxrelay.service')

View File

@ -128,7 +128,7 @@ fi
echo "Switch to the '$USERNAME' user and adapt the settings in $CONFIG_FILE" echo "Switch to the '$USERNAME' user and adapt the settings in $CONFIG_FILE"
# setting value in raspi blitz config # setting value in raspi blitz config
grep -q '^stackingSatsKraken' $RASPIBLITZ_FILE && sudo sed -i "s/^stackingSatsKraken=.*/stackingSatsKraken=on/g" $RASPIBLITZ_FILE || echo 'stackingSatsKraken=on' >> $RASPIBLITZ_FILE /home/admin/config.scripts/blitz.conf.sh set stackingSatsKraken "on"
else else
echo "STACKING-SATS-KRAKEN already installed." echo "STACKING-SATS-KRAKEN already installed."
fi fi
@ -158,7 +158,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "*** REMOVING STACKING-SATS-KRAKEN ***" echo "*** REMOVING STACKING-SATS-KRAKEN ***"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^stackingSatsKraken=.*/stackingSatsKraken=off/g" $RASPIBLITZ_FILE /home/admin/config.scripts/blitz.conf.sh set stackingSatsKraken "off"
# remove config # remove config
sudo rm -rf $APP_DATA_DIR sudo rm -rf $APP_DATA_DIR

View File

@ -17,11 +17,6 @@ PGPpubkeyFingerprint="91F3B339B9A02A3D"
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^suez=" /mnt/hdd/raspiblitz.conf; then
echo "suez=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Info Suez" --msgbox " dialog --title " Info Suez" --msgbox "
@ -56,7 +51,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
| sudo tee -a /home/admin/_aliases | sudo tee -a /home/admin/_aliases
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^suez=.*/suez=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set suez "on"
echo "# To use the alias in /home/admin/_aliases:" echo "# To use the alias in /home/admin/_aliases:"
echo "source /home/admin/_aliases" echo "source /home/admin/_aliases"
@ -75,7 +70,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# OK, suez is removed." echo "# OK, suez is removed."
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^suez=.*/suez=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set suez "off"
exit 0 exit 0

View File

@ -13,22 +13,12 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# Check if HDD contains configuration
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -ne 1 ]; then
echo "RaspiBlitz config file '${configFile}' not found"
exit 1
fi
# at this point the config file exists and can be sourced # at this point the config file exists and can be sourced
source ${configFile} source /mnt/hdd/raspiblitz.conf
# this variables is used repeatedly in this script # this variables is used repeatedly in this script
resources_dir=/home/admin/assets/telegraf/etc-telegraf resources_dir=/home/admin/assets/telegraf/etc-telegraf
############################### ###############################
# give status # give status
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
@ -147,9 +137,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sleep 2 sleep 2
sudo systemctl status telegraf.service --no-page 2>/dev/null sudo systemctl status telegraf.service --no-page 2>/dev/null
echo "*** telegraf installation: set 'telegrafMonitoring=on' in config file '${configFile}'" echo "*** telegraf installation: set 'telegrafMonitoring=on' in config file 'raspiblitz.conf'"
sudo sed -i "s/^telegrafMonitoring=.*/telegrafMonitoring=on/g" ${configFile} /home/admin/config.scripts/blitz.conf.sh set telegrafMonitoring "on"
echo "*** install telegraf done ***" echo "*** install telegraf done ***"
@ -165,8 +154,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# let apt-get remove the package # let apt-get remove the package
sudo apt-get remove -y telegraf sudo apt-get remove -y telegraf
echo "*** telegraf remove: set 'telegrafMonitoring=off' in config file '${configFile}'" echo "*** telegraf remove: set 'telegrafMonitoring=off' in config file 'raspiblitz.conf'"
sudo sed -i "s/^telegrafMonitoring=.*/telegrafMonitoring=off/g" ${configFile} /home/admin/config.scripts/blitz.conf.sh set telegrafMonitoring "off"
echo "*** remove telegraf done ***" echo "*** remove telegraf done ***"

View File

@ -19,10 +19,6 @@ PGPpubkeyFingerprint="4403F1DFBE779457"
# to know which network is running # to know which network is running
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
if [ ${#network} -eq 0 ]; then
echo "FAIL - missing /mnt/hdd/raspiblitz.conf"
exit 1
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
@ -57,11 +53,6 @@ Activate TOR to access the web interface from outside your local network.
exit 0 exit 0
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^thunderhub=" /mnt/hdd/raspiblitz.conf; then
echo "thunderhub=off" >> /mnt/hdd/raspiblitz.conf
fi
# stop services # stop services
echo "making sure services are not running" echo "making sure services are not running"
sudo systemctl stop thunderhub 2>/dev/null sudo systemctl stop thunderhub 2>/dev/null
@ -247,14 +238,14 @@ WantedBy=multi-user.target
sudo systemctl enable thunderhub sudo systemctl enable thunderhub
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^thunderhub=.*/thunderhub=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set thunderhub "on"
# Hidden Service for thunderhub if Tor is active # Hidden Service for thunderhub if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
# make sure to keep in sync with internet.tor.sh script # make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/internet.hiddenservice.sh thunderhub 80 3012 443 3013 /home/admin/config.scripts/tor.onion-service.sh thunderhub 80 3012 443 3013
fi fi
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the thunderhub.service is enabled, system is ready so starting service" echo "# OK - the thunderhub.service is enabled, system is ready so starting service"
sudo systemctl start thunderhub sudo systemctl start thunderhub
@ -290,13 +281,13 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# Hidden Service if Tor is active # Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/internet.hiddenservice.sh off thunderhub /home/admin/config.scripts/tor.onion-service.sh off thunderhub
fi fi
echo "OK ThunderHub removed." echo "OK ThunderHub removed."
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^thunderhub=.*/thunderhub=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set thunderhub "off"
exit 0 exit 0
fi fi

View File

@ -9,11 +9,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^typescript=" /mnt/hdd/raspiblitz.conf; then
echo "typescript=off" >> /mnt/hdd/raspiblitz.conf
fi
# switch on # switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check if typescript was installed # check if typescript was installed
@ -55,7 +50,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi fi
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^typescript=.*/typescript=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set typescript "on"
echo "Installed typescript $(node -v)" echo "Installed typescript $(node -v)"
exit 0 exit 0
fi fi
@ -63,7 +58,7 @@ fi
# switch off # switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i "s/^typescript=.*/typescript=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set typescript "off"
echo "*** REMOVING typescript ***" echo "*** REMOVING typescript ***"
npm uninstall typescript -g npm uninstall typescript -g
echo "OK typescript removed." echo "OK typescript removed."

View File

@ -16,11 +16,6 @@ fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# add default value to raspi config if needed
if ! grep -Eq "^whitepaper=" /mnt/hdd/raspiblitz.conf; then
echo "whitepaper=off" >> /mnt/hdd/raspiblitz.conf
fi
# show info menu # show info menu
if [ "$1" = "menu" ]; then if [ "$1" = "menu" ]; then
dialog --title " Whitepaper Info" --msgbox " dialog --title " Whitepaper Info" --msgbox "
@ -50,7 +45,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# transfor pdf to txt to view with less through the terminal # transfor pdf to txt to view with less through the terminal
pdftotext $DownloadPath$WhitepaperFilename pdftotext $DownloadPath$WhitepaperFilename
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^whitepaper=.*/whitepaper=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set whitepaper "on"
echo "# OK - Whitepaper downloaded to $DownloadPath$WhitepaperFilename" echo "# OK - Whitepaper downloaded to $DownloadPath$WhitepaperFilename"
exit 0 exit 0
fi fi
@ -65,7 +60,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# ***" echo "# ***"
echo "" echo ""
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^whitepaper=.*/whitepaper=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set whitepaper "off"
rm $DownloadPath$WhitepaperFilename rm $DownloadPath$WhitepaperFilename
rm $DownloadPath/bitcoin.txt rm $DownloadPath/bitcoin.txt
echo "# OK - Whitepaper removed." echo "# OK - Whitepaper removed."

View File

@ -9,10 +9,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1 exit 1
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^zerotier=" /mnt/hdd/raspiblitz.conf; then
echo "zerotier=off" >> /mnt/hdd/raspiblitz.conf
fi
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# show info menu # show info menu
@ -66,7 +62,8 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# OK - joined" echo "# OK - joined"
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^zerotier=.*/zerotier=${networkID}/g" /mnt/hdd/raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set zerotier "${networkID}"
# adding zero tier IP to LND TLS cert # adding zero tier IP to LND TLS cert
# sudo /home/admin/config.scripts/lnd.tlscert.sh ip-add 172.X # sudo /home/admin/config.scripts/lnd.tlscert.sh ip-add 172.X
@ -90,7 +87,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo -u admin sudo apt -y purge zerotier-one 1>&2 sudo -u admin sudo apt -y purge zerotier-one 1>&2
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^zerotier=.*/zerotier=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set zerotier "off"
echo "# OK, ZeroTier is removed." echo "# OK, ZeroTier is removed."
exit 0 exit 0

View File

@ -74,7 +74,7 @@ if [ $1 = on ];then
--lightning-dir /home/bitcoin/.lightning/${CLNETWORK} \ --lightning-dir /home/bitcoin/.lightning/${CLNETWORK} \
file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd sudo systemctl start ${netprefix}lightningd
echo "# Started the ${netprefix}lightningd.service" echo "# Started the ${netprefix}lightningd.service"
@ -120,7 +120,7 @@ elif [ $1 = restore ];then
file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup \ file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup \
/home/bitcoin/.lightning/${CLNETWORK}/lightningd.sqlite3 /home/bitcoin/.lightning/${CLNETWORK}/lightningd.sqlite3
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd sudo systemctl start ${netprefix}lightningd
echo "# Started the ${netprefix}lightningd.service" echo "# Started the ${netprefix}lightningd.service"

View File

@ -18,16 +18,6 @@ fi
# source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>) # source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>)
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2) source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
# add default value to raspi config if needed
configEntry="${netprefix}clboss"
configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}")
if [ "${configEntryExists}" == "0" ]; then
echo "# adding default config entry for '${configEntry}'"
sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf"
else
echo "# default config entry for '${configEntry}' exists"
fi
if [ $1 = on ];then if [ $1 = on ];then
if [ ! -f /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}.tar.gz ];then if [ ! -f /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}.tar.gz ];then
@ -58,9 +48,9 @@ if [ $1 = on ];then
fi fi
# setting value in raspiblitz.conf # setting value in raspiblitz.conf
sudo sed -i "s/^${netprefix}clboss=.*/${netprefix}clboss=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "on"
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# Restart the ${netprefix}lightningd.service to activate clboss" echo "# Restart the ${netprefix}lightningd.service to activate clboss"
sudo systemctl restart ${netprefix}lightningd sudo systemctl restart ${netprefix}lightningd
@ -89,7 +79,7 @@ if [ $1 = off ];then
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}clboss=.*/${netprefix}clboss=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "off"
echo "# clboss was uninstalled for $CHAIN" echo "# clboss was uninstalled for $CHAIN"
fi fi

View File

@ -10,16 +10,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
exit 1 exit 1
fi fi
# add default value to raspi config if needed
configEntry="${netprefix}feeadjuster"
configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}")
if [ "${configEntryExists}" == "0" ]; then
echo "# adding default config entry for '${configEntry}'"
sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf"
else
echo "# default config entry for '${configEntry}' exists"
fi
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2) source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
if [ "$1" = "on" ];then if [ "$1" = "on" ];then
@ -37,9 +27,9 @@ if [ "$1" = "on" ];then
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}feeadjuster=.*/${netprefix}feeadjuster=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}feeadjuster "on"
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ] && [ "$3" != "norestart" ]; then if [ "${state}" == "ready" ] && [ "$3" != "norestart" ]; then
echo "# Start ${netprefix}${plugin}" echo "# Start ${netprefix}${plugin}"
$lightningcli_alias plugin start /home/bitcoin/cl-plugins-enabled/${plugin}.py $lightningcli_alias plugin start /home/bitcoin/cl-plugins-enabled/${plugin}.py
@ -59,7 +49,7 @@ if [ "$1" = "off" ];then
sudo sed -i "/^feeadjuster/d" ${CLCONF} sudo sed -i "/^feeadjuster/d" ${CLCONF}
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}feeadjuster=.*/${netprefix}feeadjuster=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}feeadjuster "off"
echo "# The ${plugin} was uninstalled" echo "# The ${plugin} was uninstalled"
fi fi

View File

@ -22,16 +22,6 @@ PGPpubkeyFingerprint="4AEE18F83AFDEB23"
# source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>) # source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>)
source <(/home/admin/config.scripts/network.aliases.sh getvars cl mainnet) source <(/home/admin/config.scripts/network.aliases.sh getvars cl mainnet)
# add default value to raspi config if needed
configEntry="clHTTPplugin"
configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}")
if [ "${configEntryExists}" == "0" ]; then
echo "# adding default config entry for '${configEntry}'"
sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf"
else
echo "# default config entry for '${configEntry}' exists"
fi
if [ $1 = connect ];then if [ $1 = connect ];then
toraddress=$(sudo cat /mnt/hdd/tor/clHTTPplugin/hostname) toraddress=$(sudo cat /mnt/hdd/tor/clHTTPplugin/hostname)
PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-) PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-)
@ -130,12 +120,12 @@ http-pass=${PASSWORD_B}
fi fi
# hidden service to https://xx.onion # hidden service to https://xx.onion
/home/admin/config.scripts/internet.hiddenservice.sh clHTTPplugin 9080 9080 /home/admin/config.scripts/tor.onion-service.sh clHTTPplugin 9080 9080
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^clHTTPplugin=.*/clHTTPplugin=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set clHTTPplugin "on"
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ] && [ "$2" != "norestart" ]; then if [ "${state}" == "ready" ] && [ "$2" != "norestart" ]; then
echo "# Restart the lightningd.service to activate clHTTPplugin" echo "# Restart the lightningd.service to activate clHTTPplugin"
sudo systemctl restart lightningd sudo systemctl restart lightningd
@ -158,7 +148,7 @@ if [ "$1" = "off" ];then
echo "# Restart the lightningd.service to deactivate clHTTPplugin" echo "# Restart the lightningd.service to deactivate clHTTPplugin"
sudo systemctl restart lightningd sudo systemctl restart lightningd
/home/admin/config.scripts/internet.hiddenservice.sh off clHTTPplugin /home/admin/config.scripts/tor.onion-service.sh off clHTTPplugin
# purge # purge
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
@ -166,7 +156,7 @@ if [ "$1" = "off" ];then
sudo rm -rf /home/bitcoin/cl-plugins-available/c-lightning-http-plugin sudo rm -rf /home/bitcoin/cl-plugins-available/c-lightning-http-plugin
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^clHTTPplugin=.*/clHTTPplugin=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set clHTTPplugin "off"
echo "# clHTTPplugin was uninstalled" echo "# clHTTPplugin was uninstalled"
fi fi

View File

@ -50,16 +50,6 @@ ${toraddresstext}
exit 0 exit 0
fi fi
# add default value to raspi config if needed
configEntry="${netprefix}sparko"
configEntryExists=$(sudo cat /mnt/hdd/raspiblitz.conf | grep -c "${configEntry}")
if [ "${configEntryExists}" == "0" ]; then
echo "# adding default config entry for '${configEntry}'"
sudo /bin/sh -c "echo '${configEntry}=off' >> /mnt/hdd/raspiblitz.conf"
else
echo "# default config entry for '${configEntry}' exists"
fi
if [ $1 = connect ];then if [ $1 = connect ];then
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}sparko/hostname) toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}sparko/hostname)
@ -170,12 +160,12 @@ sparko-keys=${masterkeythatcandoeverything}; ${secretaccesskeythatcanreadstuff}:
sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko" sudo ufw allow "${portprefix}9000" comment "${netprefix}sparko"
# hidden service to https://xx.onion # hidden service to https://xx.onion
/home/admin/config.scripts/internet.hiddenservice.sh ${netprefix}sparko 443 ${portprefix}9000 /home/admin/config.scripts/tor.onion-service.sh ${netprefix}sparko 443 ${portprefix}9000
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}sparko "on"
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ] && [ "$3" != "norestart" ]; then if [ "${state}" == "ready" ] && [ "$3" != "norestart" ]; then
echo "# Restart the ${netprefix}lightningd.service to activate Sparko" echo "# Restart the ${netprefix}lightningd.service to activate Sparko"
sudo systemctl restart ${netprefix}lightningd sudo systemctl restart ${netprefix}lightningd
@ -201,7 +191,7 @@ if [ "$1" = "off" ];then
echo "# Deny port ${portprefix}9000 through the firewall" echo "# Deny port ${portprefix}9000 through the firewall"
sudo ufw deny "${portprefix}9000" sudo ufw deny "${portprefix}9000"
/home/admin/config.scripts/internet.hiddenservice.sh off ${netprefix}sparko /home/admin/config.scripts/tor.onion-service.sh off ${netprefix}sparko
# purge # purge
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
@ -209,7 +199,7 @@ if [ "$1" = "off" ];then
sudo rm -rf /home/bitcoin/cl-plugins-available/sparko sudo rm -rf /home/bitcoin/cl-plugins-available/sparko
fi fi
# setting value in raspi blitz config # setting value in raspi blitz config
sudo sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}sparko "off"
echo "# Sparko was uninstalled" echo "# Sparko was uninstalled"
fi fi

View File

@ -35,7 +35,7 @@ if [ "$1" = "on" ];then
sudo ln -s /home/bitcoin/cl-plugins-available/plugins/${plugin}/${plugin}.py \ sudo ln -s /home/bitcoin/cl-plugins-available/plugins/${plugin}/${plugin}.py \
/home/bitcoin/${netprefix}cl-plugins-enabled /home/bitcoin/${netprefix}cl-plugins-enabled
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# Restart the ${netprefix}lightningd.service to activate the ${plugin} plugin" echo "# Restart the ${netprefix}lightningd.service to activate the ${plugin} plugin"
sudo systemctl restart ${netprefix}lightningd sudo systemctl restart ${netprefix}lightningd

View File

@ -288,9 +288,7 @@ if [ ${mode} = "cl-import-gui" ]; then
if [ "$(grep -c "hsm_secret is not encrypted" < "$output")" -gt 0 ];then if [ "$(grep -c "hsm_secret is not encrypted" < "$output")" -gt 0 ];then
echo "# The hsm_secret is not encrypted" echo "# The hsm_secret is not encrypted"
echo "# Record in raspiblitz.conf" echo "# Record in raspiblitz.conf"
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "off"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=off/g" \
/mnt/hdd/raspiblitz.conf
else else
cat $output cat $output
echo "# Starting cl.hsmtool.sh unlock" echo "# Starting cl.hsmtool.sh unlock"

View File

@ -32,7 +32,7 @@ if [ $(grep -c "^sparko" < ${CLCONF}) -gt 0 ];then
echo "# The Sparko plugin is not present but in config" echo "# The Sparko plugin is not present but in config"
sed -i "/^sparko/d" ${CLCONF} sed -i "/^sparko/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/sparko rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/sparko
sed -i "s/^${netprefix}sparko=.*/${netprefix}sparko=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}sparko "off"
fi fi
fi fi
@ -42,7 +42,7 @@ if [ $(grep -c "^http-pass" < ${CLCONF}) -gt 0 ];then
echo "# The clHTTPplugin is not present but in config" echo "# The clHTTPplugin is not present but in config"
sed -i "/^http-pass/d" ${CLCONF} sed -i "/^http-pass/d" ${CLCONF}
rm -rf /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin rm -rf /home/bitcoin/cl-plugins-enabled/c-lightning-http-plugin
sed -i "s/^clHTTPplugin=.*/clHTTPplugin=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set clHTTPplugin "off"
fi fi
fi fi
@ -52,6 +52,6 @@ if [ $(grep -c "^feeadjuster" < ${CLCONF}) -gt 0 ];then
echo "# The feeadjuster plugin is not present but in config" echo "# The feeadjuster plugin is not present but in config"
sed -i "/^feeadjuster/d" ${CLCONF} sed -i "/^feeadjuster/d" ${CLCONF}
rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/feeadjuster.py
sed -i "s/^${netprefix}feeadjuster=.*/${netprefix}feeadjuster=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}feeadjuster "off"
fi fi
fi fi

View File

@ -45,15 +45,6 @@ if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
fi fi
fi fi
# add default value to raspi config if needed
if ! grep -Eq "^${netprefix}clEncryptedHSM=" /mnt/hdd/raspiblitz.conf; then
echo "${netprefix}clEncryptedHSM=off" >> /mnt/hdd/raspiblitz.conf
fi
# add default value to raspi config if needed
if ! grep -Eq "^${netprefix}clAutoUnlock=" /mnt/hdd/raspiblitz.conf; then
echo "${netprefix}clAutoUnlock=off" >> /mnt/hdd/raspiblitz.conf
fi
############# #############
# Functions # # Functions #
############# #############
@ -122,9 +113,7 @@ function encryptHSMsecret() {
(echo $walletPassword; echo $walletPassword) | \ (echo $walletPassword; echo $walletPassword) | \
sudo -u bitcoin lightning-hsmtool encrypt $hsmSecretPath || exit 1 sudo -u bitcoin lightning-hsmtool encrypt $hsmSecretPath || exit 1
# setting value in raspiblitz.conf # setting value in raspiblitz.conf
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "on"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=on/g" \
/mnt/hdd/raspiblitz.conf
echo "# Encrypted the hsm_secret for C-lightning $CHAIN" echo "# Encrypted the hsm_secret for C-lightning $CHAIN"
} }
@ -141,9 +130,7 @@ function decryptHSMsecret() {
echo "# Continue to record in the raspiblitz.conf" echo "# Continue to record in the raspiblitz.conf"
else else
# setting value in raspiblitz.conf # setting value in raspiblitz.conf
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "on"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=on/g" \
/mnt/hdd/raspiblitz.conf
if [ -f $passwordFile ];then if [ -f $passwordFile ];then
echo "# Getting the password from $passwordFile" echo "# Getting the password from $passwordFile"
else else
@ -162,9 +149,7 @@ function decryptHSMsecret() {
fi fi
shredPasswordFile shredPasswordFile
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "off"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=off/g" \
/mnt/hdd/raspiblitz.conf
echo "# Decrypted the hsm_secret for C-lightning $CHAIN" echo "# Decrypted the hsm_secret for C-lightning $CHAIN"
} }
@ -269,9 +254,7 @@ elif [ "$1" = "unlock" ]; then
echo "# The hsm_secret is encrypted, but unlock is not configured" echo "# The hsm_secret is encrypted, but unlock is not configured"
passwordToFile passwordToFile
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clEncryptedHSM "on"
"s/^${netprefix}clEncryptedHSM=.*/${netprefix}clEncryptedHSM=on/g" \
/mnt/hdd/raspiblitz.conf
/home/admin/config.scripts/cl.install-service.sh $CHAIN /home/admin/config.scripts/cl.install-service.sh $CHAIN
# get new password # get new password
@ -345,9 +328,8 @@ elif [ "$1" = "autounlock-on" ]; then
passwordToFile passwordToFile
fi fi
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clAutoUnlock "on"
"s/^${netprefix}clAutoUnlock=.*/${netprefix}clAutoUnlock=on/g" \
/mnt/hdd/raspiblitz.conf
echo "# Autounlock is on for C-lightning $CHAIN" echo "# Autounlock is on for C-lightning $CHAIN"
elif [ "$1" = "autounlock-off" ]; then elif [ "$1" = "autounlock-off" ]; then
@ -358,9 +340,7 @@ elif [ "$1" = "autounlock-off" ]; then
sudo chown bitcoin:bitcoin /dev/shm/.${netprefix}cl.pw sudo chown bitcoin:bitcoin /dev/shm/.${netprefix}cl.pw
fi fi
# setting value in raspiblitz config # setting value in raspiblitz config
sudo sed -i \ /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clAutoUnlock "off"
"s/^${netprefix}clAutoUnlock=.*/${netprefix}clAutoUnlock=off/g" \
/mnt/hdd/raspiblitz.conf
echo "# Autounlock is off for C-lightning $CHAIN" echo "# Autounlock is off for C-lightning $CHAIN"
elif [ "$1" = "change-password" ]; then elif [ "$1" = "change-password" ]; then

View File

@ -81,7 +81,7 @@ sudo systemctl daemon-reload
sudo systemctl enable ${netprefix}lightningd sudo systemctl enable ${netprefix}lightningd
echo "# Enabled the ${netprefix}lightningd.service" echo "# Enabled the ${netprefix}lightningd.service"
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd sudo systemctl start ${netprefix}lightningd
echo "# Started the ${netprefix}lightningd.service" echo "# Started the ${netprefix}lightningd.service"

View File

@ -145,16 +145,6 @@ fi
echo "# Running: 'cl.install.sh $*'" echo "# Running: 'cl.install.sh $*'"
echo "# Using the settings for: ${network} ${CHAIN}" echo "# Using the settings for: ${network} ${CHAIN}"
# add default value to raspi config if needed
if ! grep -Eq "^lightning=" /mnt/hdd/raspiblitz.conf; then
echo "lightning=cl" | sudo tee -a /mnt/hdd/raspiblitz.conf
fi
# add default value to raspi config if needed
if ! grep -Eq "^${netprefix}cl=" /mnt/hdd/raspiblitz.conf; then
echo "${netprefix}cl=off" | sudo tee -a /mnt/hdd/raspiblitz.conf
fi
source /mnt/hdd/raspiblitz.conf
if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = testPR ];then if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = testPR ];then
if [ "${CHAIN}" == "testnet" ] && [ "${testnet}" != "on" ]; then if [ "${CHAIN}" == "testnet" ] && [ "${testnet}" != "on" ]; then
@ -363,12 +353,12 @@ alias ${netprefix}clconf=\"sudo\
echo echo
# setting value in the raspiblitz.conf # setting value in the raspiblitz.conf
sudo sed -i "s/^${netprefix}cl=.*/${netprefix}cl=on/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}cl on
# if this is the first lightning mainnet turned on - make default # if this is the first lightning mainnet turned on - make default
if [ "${CHAIN}" == "mainnet" ] && [ "${lightning}" == "" ]; then if [ "${CHAIN}" == "mainnet" ] && [ "${lightning}" == "" ]; then
echo "# CL is now the default lightning implementation" echo "# CL is now the default lightning implementation"
sudo sed -i "s/^lightning=.*/lightning=cl/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lightning cl
fi fi
exit 0 exit 0
@ -429,15 +419,15 @@ if [ "$1" = "off" ];then
sudo rm -f /usr/local/bin/lightning-cli sudo rm -f /usr/local/bin/lightning-cli
fi fi
# setting value in the raspiblitz.conf # setting value in the raspiblitz.conf
sudo sed -i "s/^${netprefix}cl=.*/${netprefix}cl=off/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}cl "off"
# if cl mainnet was default - remove # if cl mainnet was default - remove
if [ "${CHAIN}" == "mainnet" ] && [ "${lightning}" == "cl" ]; then if [ "${CHAIN}" == "mainnet" ] && [ "${lightning}" == "cl" ]; then
echo "# CL is REMOVED as the default lightning implementation" echo "# CL is REMOVED as the default lightning implementation"
sudo sed -i "s/^lightning=.*/lightning=/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lightning ""
if [ "${lnd}" == "on" ]; then if [ "${lnd}" == "on" ]; then
echo "# LND is now the new default lightning implementation" echo "# LND is now the new default lightning implementation"
sudo sed -i "s/^lightning=.*/lightning=lnd/g" /mnt/hdd/raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set lightning "lnd"
fi fi
fi fi
fi fi

View File

@ -0,0 +1,240 @@
#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "monitor and troubleshot the c-lightning network"
echo "cl.monitor.sh [mainnet|testnet|signet] status"
echo "cl.monitor.sh [mainnet|testnet|signet] config"
echo "cl.monitor.sh [mainnet|testnet|signet] info"
echo "cl.monitor.sh [mainnet|testnet|signet] wallet"
exit 1
fi
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='run as root'"
exit 1
fi
# set based on network type (using own mapping to be able to run without calling sudo -u bitcoin)
if [ "$1" == "mainnet" ]; then
clConfigDir="/home/bitcoin/.lightning"
lightningcli_alias="/usr/local/bin/lightning-cli --lightning-dir=/home/bitcoin/.lightning --conf=${clConfigDir}/config"
blockchainHeightKey="btc_mainnet_blocks_verified"
netprefix=""
elif [ "$1" == "testnet" ]; then
clConfigDir="/home/bitcoin/.lightning/testnet"
lightningcli_alias="/usr/local/bin/lightning-cli --lightning-dir=/home/bitcoin/.lightning --conf=${clConfigDir}/config"
blockchainHeightKey="btc_testnet_blocks_verified"
netprefix="t"
elif [ "$1" == "signet" ]; then
clConfigDir="/home/bitcoin/.lightning/signet"
lightningcli_alias="/usr/local/bin/lightning-cli --lightning-dir=/home/bitcoin/.lightning --conf=${clConfigDir}/config"
blockchainHeightKey="btc_signet_blocks_verified"
netprefix="s"
else
echo "error='not supported net'"
exit 1
fi
######################################################
# STATUS
# check general status info
######################################################
if [ "$2" = "status" ]; then
cl_version=$($lightningcli_alias --version 2>/dev/null | cut -d ' ' -f3)
cl_running=$(systemctl status ${netprefix}lightningd 2>/dev/null | grep -c "active (running)")
cl_ready="0"
cl_online="0"
cl_error_short=""
cl_error_full=""
if [ "${cl_running}" != "0" ]; then
cl_running="1"
# test connection - record win & fail info
randStr=$(echo "$RANDOM")
rm /var/cache/raspiblitz/.cl-${randStr}.out 2>/dev/null
rm /var/cache/raspiblitz/.cl-${randStr}.error 2>/dev/null
touch /var/cache/raspiblitz/.cl-${randStr}.out
touch /var/cache/raspiblitz/.cl-${randStr}.error
echo "# ${lightningcli_alias} getinfo"
$lightningcli_alias getinfo 1>/var/cache/raspiblitz/.cl-${randStr}.out 2>/var/cache/raspiblitz/.cl-${randStr}.error
winData=$(cat /var/cache/raspiblitz/.cl-${randStr}.out 2>/dev/null)
failData=$(cat /var/cache/raspiblitz/.cl-${randStr}.error 2>/dev/null)
rm /var/cache/raspiblitz/.cl-${randStr}.out
rm /var/cache/raspiblitz/.cl-${randStr}.error
# check for errors
if [ "${failData}" != "" ]; then
cl_ready="0"
cl_error_short=""
cl_error_full=$(echo ${failData} | tr -d "'" | tr -d '"')
# check results if proof for online
else
cl_ready="1"
connections=$( echo "${winData}" | grep "num_peers\"" | tr -cd '[[:digit:]]')
if [ "${connections}" != "" ] && [ "${connections}" != "0" ]; then
cl_online="1"
fi
fi
fi
# print results
echo "ln_cl_version='${cl_version}'"
echo "ln_cl_running='${cl_running}'"
echo "ln_cl_ready='${cl_ready}'"
echo "ln_cl_online='${cl_online}'"
echo "ln_cl_error_short='${cl_error_short}'"
echo "ln_cl_error_full='${cl_error_full}'"
exit 0
fi
######################################################
# CONFIG
######################################################
if [ "$2" = "config" ]; then
# get data
clConfigData=$(cat $clConfigDir/config)
if [ "${clConfigData}" == "" ]; then
echo "error='no config'"
exit 1
fi
# no usesul data to monitor in config yet
exit 1
fi
######################################################
# INFO
######################################################
if [ "$2" = "info" ]; then
# raw data demo:
# sudo /usr/local/bin/lightning-cli --lightning-dir=/home/bitcoin/.lightning --conf=/home/bitcoin/.lightning/config getinfo
# get data
ln_getInfo=$($lightningcli_alias getinfo 2>/dev/null)
if [ "${ln_getInfo}" == "" ]; then
echo "error='no data'"
exit 1
fi
# parse data
cl_alias=$(echo "${ln_getInfo}" | grep '"alias":' | cut -d '"' -f4)
port=$(echo "${ln_getInfo}" | grep '"port":' | cut -d: -f2 | tail -1 | bc)
pubkey=$(echo "${ln_getInfo}" | grep '"id":' | cut -d '"' -f4)
address=$(echo "${ln_getInfo}" | grep '.onion' | cut -d '"' -f4)
if [ ${#address} -eq 0 ]; then
address=$(echo "${ln_getInfo}" | grep '"ipv4"' -A 1 | tail -1 | cut -d '"' -f4)
fi
cl_address="${pubkey}@${address}:${port}"
cl_tor=$(echo "${cl_address}" | grep -c ".onion")
cl_channels_pending=$(echo "${ln_getInfo}" | jq -r '.num_pending_channels')
cl_channels_active=$(echo "${ln_getInfo}" | jq -r '.num_active_channels')
cl_channels_inactive=$(echo "${ln_getInfo}" | jq -r '.num_inactive_channels')
cl_channels_total=$(( cl_channels_pending + cl_channels_active + cl_channels_inactive ))
cl_peers=$(echo "${ln_getInfo}" | jq -r '.num_peers')
cl_fees_collected_msat=$(echo "${ln_getInfo}" | jq -r '.fees_collected_msat')
# calculate with cached value if c-lightning is fully synced
source <(/home/admin/_cache.sh get ${blockchainHeightKey})
#echo "#blockchainHeightKey(${!blockchainHeightKey})"
blockheight="${!blockchainHeightKey}"
#echo "#blockheight(${blockheight})"
cl_sync_height=$(echo "${ln_getInfo}" | jq .blockheight)
#echo "#cl_sync_height(${cl_sync_height})"
cl_sync_chain=""
cl_sync_progress=""
if [ "${blockheight}" != "" ]; then
cl_sync_progress=$(echo "scale=2; $cl_sync_height*100/$blockheight" | bc)
# needs to be at least "two blocks behind" to be considered not synced
blockheight=$(($blockheight - 1))
if [ ${blockheight} -gt ${cl_sync_height} ];then
cl_sync_chain=0
else
cl_sync_chain=1
fi
fi
# print data
echo "ln_cl_alias='${cl_alias}'"
echo "ln_cl_address='${cl_address}'"
echo "ln_cl_tor='${cl_tor}'"
echo "ln_cl_peers='${cl_peers}'"
echo "ln_cl_sync_chain='${cl_sync_chain}'"
echo "ln_cl_sync_progress='${cl_sync_progress}'"
echo "ln_cl_channels_pending='${cl_channels_pending}'"
echo "ln_cl_channels_active='${cl_channels_active}'"
echo "ln_cl_channels_inactive='${cl_channels_inactive}'"
echo "ln_cl_channels_total='${cl_channels_total}'"
echo "ln_cl_fees_total='${cl_fees_collected_msat//[^0-9.]/}'"
exit 0
fi
######################################################
# WALLETS (FUNDS)
######################################################
if [ "$2" = "wallet" ]; then
# raw data demo:
# /usr/local/bin/lightning-cli --lightning-dir=/home/bitcoin/.lightning --conf=/home/bitcoin/.lightning/config listfunds
# get data
cl_listfunds=$($lightningcli_alias listfunds 2>/dev/null)
if [ "${cl_listfunds}" == "" ]; then
echo "error='no data'"
exit 1
fi
ln_walletbalance=0
for i in $(echo "$cl_listfunds" | jq .outputs[] | jq 'select(.status=="confirmed")' | grep value | awk '{print $2}' | cut -d, -f1);do
ln_walletbalance=$((ln_walletbalance+i))
done
ln_walletbalance_wait=0
for i in $(echo "$cl_listfunds" | jq .outputs[] | jq 'select(.status=="unconfirmed")' | grep value | awk '{print $2}' | cut -d, -f1);do
ln_walletbalance_wait=$((ln_walletbalance_wait+i))
done
ln_closedchannelbalance=0
for i in $(echo "$cl_listfunds" | jq .channels[] | jq 'select(.state=="ONCHAIN")' | grep channel_sat | awk '{print $2}' | cut -d, -f1);do
ln_closedchannelbalance=$((ln_closedchannelbalance+i))
done
ln_pendingonchain=$((ln_walletbalance_wait+ln_closedchannelbalance))
if [ ${#ln_pendingonchain} -gt 0 ]; then ln_pendingonchain="(+${ln_pendingonchain})"; fi
ln_channelbalance=0
for i in $(echo "$cl_listfunds" |jq .channels[]|jq 'select(.state=="CHANNELD_NORMAL")'|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance=$((ln_channelbalance+i))
done
if [ ${#ln_channelbalance} -eq 0 ];then
ln_channelbalance=0
fi
ln_channelbalance_all=0
for i in $(echo "$cl_listfunds" |jq .channels[]|grep channel_sat|awk '{print $2}'|cut -d, -f1);do
ln_channelbalance_all=$((ln_channelbalance_all+i))
done
ln_channelbalance_pending=$((ln_channelbalance_all-ln_channelbalance-ln_closedchannelbalance))
if [ ${#ln_channelbalance_pending} -gt 0 ]; then ln_channelbalance_pending=" (+${ln_channelbalance_pending})"; fi
# print data
echo "ln_cl_wallet_onchain_balance='${ln_walletbalance//[^0-9.]/}'"
echo "ln_cl_wallet_onchain_pending='${ln_pendingonchain//[^0-9.]/}'"
echo "ln_cl_wallet_channels_balance='${ln_channelbalance//[^0-9.]/}'"
echo "ln_cl_wallet_channels_pending='${ln_channelbalance_pending//[^0-9.]/}'"
exit 0
fi
echo "FAIL - Unknown Parameter $2"
exit 1

View File

@ -26,7 +26,7 @@ if [ "$1" = connect ];then
sudo ufw allow "${portprefix}6100" comment "${netprefix}clrest" sudo ufw allow "${portprefix}6100" comment "${netprefix}clrest"
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
# hidden service to https://xx.onion # hidden service to https://xx.onion
/home/admin/config.scripts/internet.hiddenservice.sh ${netprefix}clrest 443 ${portprefix}6100 /home/admin/config.scripts/tor.onion-service.sh ${netprefix}clrest 443 ${portprefix}6100
toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}clrest/hostname) toraddress=$(sudo cat /mnt/hdd/tor/${netprefix}clrest/hostname)
hex_macaroon=$(xxd -plain /home/bitcoin/c-lightning-REST/certs/access.macaroon | tr -d '\n') hex_macaroon=$(xxd -plain /home/bitcoin/c-lightning-REST/certs/access.macaroon | tr -d '\n')
@ -135,7 +135,7 @@ WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/${netprefix}clrest.service " | sudo tee /etc/systemd/system/${netprefix}clrest.service
sudo systemctl enable ${netprefix}clrest sudo systemctl enable ${netprefix}clrest
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
echo "# OK - the clrest.service is enabled, system is ready so starting service" echo "# OK - the clrest.service is enabled, system is ready so starting service"
sudo systemctl start ${netprefix}clrest sudo systemctl start ${netprefix}clrest
@ -155,7 +155,7 @@ if [ $1 = off ];then
sudo rm -rf /home/bitcoin/c-lightning-REST/${CLNETWORK} sudo rm -rf /home/bitcoin/c-lightning-REST/${CLNETWORK}
echo "# Deny port ${portprefix}6100 through the firewall" echo "# Deny port ${portprefix}6100 through the firewall"
sudo ufw deny "${portprefix}6100" sudo ufw deny "${portprefix}6100"
/home/admin/config.scripts/internet.hiddenservice.sh off ${netprefix}clrest /home/admin/config.scripts/tor.onion-service.sh off ${netprefix}clrest
if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then
echo "# Removing the source code and binaries" echo "# Removing the source code and binaries"
sudo rm -rf /home/bitcoin/c-lightning-REST sudo rm -rf /home/bitcoin/c-lightning-REST

View File

@ -29,15 +29,6 @@ if [ ${#newName} -eq 0 ]; then
fi fi
fi fi
# config file
blitzConfig="/mnt/hdd/raspiblitz.conf"
# check if raspiblitz config file exists
if [ ! -f ${blitzConfig} ]; then
echo "FAIL - missing ${blitzConfig}"
exit 1
fi
# check if cl config file exists # check if cl config file exists
if ! sudo ls ${CLCONF}; then if ! sudo ls ${CLCONF}; then
echo "FAIL - missing ${CLCONF}" echo "FAIL - missing ${CLCONF}"
@ -57,7 +48,7 @@ sudo systemctl stop ${netprefix}lightningd 2>/dev/null
# config: change name # config: change name
sudo sed -i "s/^alias=.*/alias=${newName}/g" ${CLCONF} sudo sed -i "s/^alias=.*/alias=${newName}/g" ${CLCONF}
source /home/admin/raspiblitz.info source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd sudo systemctl start ${netprefix}lightningd
fi fi

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