mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-09 20:32:52 +02:00
bugfixes, bonus, screen session download
This commit is contained in:
@@ -8,7 +8,7 @@ if [ "$USER" = "pi" ]; then
|
|||||||
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||||
|
|
||||||
# check if bitcoin service is configured
|
# check if bitcoin service is configured
|
||||||
bitcoinInstalled=$(sudo -u bitcoin ls /mnt/hdd/${network}/ | grep -c ${network}.conf)
|
bitcoinInstalled=$(sudo -u bitcoin ls /mnt/hdd/${network}/ 2>/dev/null | grep -c ${network}.conf)
|
||||||
if [ ${bitcoinInstalled} -eq 1 ]; then
|
if [ ${bitcoinInstalled} -eq 1 ]; then
|
||||||
# wait enough secs to let bitcoind init
|
# wait enough secs to let bitcoind init
|
||||||
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 130
|
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 130
|
||||||
@@ -36,15 +36,15 @@ if [ "$USER" = "pi" ]; then
|
|||||||
l2="ssh admin@${localip}\n"
|
l2="ssh admin@${localip}\n"
|
||||||
l3="Use password: raspiblitz\n"
|
l3="Use password: raspiblitz\n"
|
||||||
boxwidth=$((${#localip} + 20))
|
boxwidth=$((${#localip} + 20))
|
||||||
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
elif [ ${setupStep} -lt 100 ]; then
|
elif [ ${setupStep} -lt 100 ]; then
|
||||||
|
|
||||||
# setup process init is done and not finished
|
# setup process init is done and not finished
|
||||||
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false)
|
lndSyncing=$(sudo -u bitcoin lncli getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c false)
|
||||||
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
|
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
|
||||||
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
|
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
|
||||||
|
|
||||||
if [ ${locked} -gt 0 ]; then
|
if [ ${locked} -gt 0 ]; then
|
||||||
|
|
||||||
@@ -69,7 +69,14 @@ if [ "$USER" = "pi" ]; then
|
|||||||
l2="ssh admin@${localip}\n"
|
l2="ssh admin@${localip}\n"
|
||||||
l3="Use your Password A\n"
|
l3="Use your Password A\n"
|
||||||
boxwidth=$((${#localip} + 20))
|
boxwidth=$((${#localip} + 20))
|
||||||
dialog --backtitle "RaspiBlitz - Welcome" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
|
||||||
|
if [ ${setupStep} -eq 50 ]; then
|
||||||
|
l1="Blockhain Setup - monitor progress:\n"
|
||||||
|
boxwidth=45
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
dialog --backtitle "RaspiBlitz - Welcome (${setupStep})" --infobox "$l1$l2$l3" 5 ${boxwidth}
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
## default menu settings
|
## default menu settings
|
||||||
HEIGHT=11
|
HEIGHT=13
|
||||||
WIDTH=64
|
WIDTH=64
|
||||||
CHOICE_HEIGHT=4
|
CHOICE_HEIGHT=6
|
||||||
BACKTITLE="RaspiBlitz"
|
BACKTITLE="RaspiBlitz"
|
||||||
TITLE=""
|
TITLE=""
|
||||||
MENU="Choose one of the following options:"
|
MENU="Choose one of the following options:"
|
||||||
@@ -62,8 +62,11 @@ else
|
|||||||
|
|
||||||
# REGULAR MENU
|
# REGULAR MENU
|
||||||
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
|
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
|
||||||
lnbalance "Detailed Wallet Balances" \
|
FUNDING "Fund your Wallet" \
|
||||||
lnchannels "Lightning Channel List")
|
CONNECT "Connect to a Peer" \
|
||||||
|
lnbalance "Detailed Wallet Balances" \
|
||||||
|
lnchannels "Lightning Channel List" \
|
||||||
|
RECKLES "Console / Terminal")
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -114,6 +117,22 @@ case $CHOICE in
|
|||||||
read key
|
read key
|
||||||
./00mainMenu.sh
|
./00mainMenu.sh
|
||||||
;;
|
;;
|
||||||
|
CONNECT)
|
||||||
|
./BBconnectPeer.sh
|
||||||
|
echo "Press ENTER to return to main menu."
|
||||||
|
read key
|
||||||
|
./00mainMenu.sh
|
||||||
|
;;
|
||||||
|
FUNDING)
|
||||||
|
./BBfundWallet.sh
|
||||||
|
echo "Press ENTER to return to main menu."
|
||||||
|
read key
|
||||||
|
./00mainMenu.sh
|
||||||
|
;;
|
||||||
|
RECKLES)
|
||||||
|
lncli -h
|
||||||
|
echo "SUCH WOW come back with ./00mainMenu.sh"
|
||||||
|
;;
|
||||||
X) # unlock
|
X) # unlock
|
||||||
./AAunlockLND.sh
|
./AAunlockLND.sh
|
||||||
./00mainMenu.sh
|
./00mainMenu.sh
|
||||||
|
@@ -13,9 +13,9 @@ network=`cat .network`
|
|||||||
lndRunning=$(systemctl status lnd.service | grep -c running)
|
lndRunning=$(systemctl status lnd.service | grep -c running)
|
||||||
if [ ${lndRunning} -eq 1 ]; then
|
if [ ${lndRunning} -eq 1 ]; then
|
||||||
|
|
||||||
chain=$(${network}-cli -datadir=/home/${network}/.${network} getblockchaininfo | jq -r '.chain')
|
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
|
||||||
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
|
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
|
||||||
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' | grep -c false)
|
lndSyncing=$(sudo -u bitcoin lncli getinfo | jq -r '.synced_to_chain' 2>/dev/null | grep -c false)
|
||||||
if [ ${locked} -gt 0 ]; then
|
if [ ${locked} -gt 0 ]; then
|
||||||
# LND wallet is locked
|
# LND wallet is locked
|
||||||
./AAunlockLND.sh
|
./AAunlockLND.sh
|
||||||
@@ -29,7 +29,7 @@ if [ ${lndRunning} -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check if bitcoin is running
|
# check if bitcoin is running
|
||||||
bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep -c blocks)
|
bitcoinRunning=$(sudo -u bitcoin ${network}-cli getblockchaininfo 2>/dev/null | grep -c blocks)
|
||||||
if [ ${bitcoinRunning} -eq 1 ]; then
|
if [ ${bitcoinRunning} -eq 1 ]; then
|
||||||
echo "OK - ${network}d is running"
|
echo "OK - ${network}d is running"
|
||||||
echo "Next step run Lightning"
|
echo "Next step run Lightning"
|
||||||
@@ -43,9 +43,18 @@ if [ ${mountOK} -eq 1 ]; then
|
|||||||
|
|
||||||
# are there any signs of blockchain data
|
# are there any signs of blockchain data
|
||||||
if [ -d "/mnt/hdd/${network}" ]; then
|
if [ -d "/mnt/hdd/${network}" ]; then
|
||||||
echo "UNKOWN STATE"
|
echo "UNKOWN STATE - there is blockain data folder, but blockchaind is not running"
|
||||||
echo "It seems that something went wrong during sync/download/copy of the blockchain."
|
echo "It seems that something went wrong during sync/download/copy of the blockchain."
|
||||||
echo "Maybe try --> ./60finishHDD.sh"
|
echo "Maybe try --> ./60finishHDD.sh"
|
||||||
|
echo "If this sill is not working reboot after running --> sudo rm -r /mnt/hdd/${network}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if there is a download to continue
|
||||||
|
downloadProgressExists=$(sudo ls /home/admin/.Download.progress 2>/dev/null | grep ".Download.progress" -c)
|
||||||
|
if [ ${downloadProgressExists} -eq 1 ]; then
|
||||||
|
echo "found download in progress .."
|
||||||
|
./50downloadHDD.sh
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -77,6 +86,9 @@ if [ ${mountOK} -eq 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# set SetupState
|
||||||
|
echo "50" > /home/admin/.setup
|
||||||
|
|
||||||
clear
|
clear
|
||||||
case $menuitem in
|
case $menuitem in
|
||||||
T)
|
T)
|
||||||
|
@@ -4,12 +4,12 @@ echo ""
|
|||||||
# *** BITCOIN ***
|
# *** BITCOIN ***
|
||||||
bitcoinList="" # url to list with other sources
|
bitcoinList="" # url to list with other sources
|
||||||
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16"
|
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16"
|
||||||
bitcoinSize=100
|
bitcoinSize=231000000 # 231235816-tolerance
|
||||||
|
|
||||||
# *** LITECOIN ***
|
# *** LITECOIN ***
|
||||||
litecoinList="" # url to list with other sources
|
litecoinList="" # url to list with other sources
|
||||||
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29"
|
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29"
|
||||||
litecoinSize=19000000
|
litecoinSize=19180000 # 19184960-tolerance
|
||||||
|
|
||||||
# load network
|
# load network
|
||||||
network=`cat .network`
|
network=`cat .network`
|
||||||
@@ -24,43 +24,149 @@ if [ "$network" = "litecoin" ]; then
|
|||||||
size=$litecoinSize
|
size=$litecoinSize
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# screen background monitoring settings
|
||||||
|
name="Download"
|
||||||
|
targetDir="/mnt/hdd/download/"
|
||||||
|
targetSize=$size
|
||||||
|
maxTimeoutLoops=500
|
||||||
|
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}"
|
||||||
|
|
||||||
|
# starting session if needed
|
||||||
|
echo "checking if ${name} has a running screen session"
|
||||||
|
screen -wipe 1>/dev/null
|
||||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
||||||
|
echo "isRunning(${isRunning})"
|
||||||
|
if [ ${isRunning} -eq 0 ]; then
|
||||||
|
echo "Starting screen session"
|
||||||
|
screen -S ${name} -dm ${command}
|
||||||
|
else
|
||||||
|
echo "Continue screen session"
|
||||||
|
fi
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
# monitor session
|
||||||
|
screenDump="... started ..."
|
||||||
|
actualSize=0
|
||||||
|
timeout=1
|
||||||
|
timeoutInfo="-"
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
|
||||||
|
# check if session is still running
|
||||||
|
screen -wipe 1>/dev/null
|
||||||
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
||||||
|
if [ ${isRunning} -eq 0 ]; then
|
||||||
|
timeout=0
|
||||||
|
echo "OK - session finished"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# calculate progress and write it to file for LCD to read
|
||||||
|
freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
|
||||||
|
if [ ${#actualSize} -eq 0 ]; then
|
||||||
|
freshSize=0
|
||||||
|
fi
|
||||||
|
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
|
||||||
|
echo $progress > '.${name}.progress'
|
||||||
|
|
||||||
|
# detect if since last loop any progress occured
|
||||||
|
if [ ${actualSize} -eq ${freshSize} ]; then
|
||||||
|
timeoutInfo="${timeout}/${maxTimeoutLoops}"
|
||||||
|
timeout=$(( $timeout + 1 ))
|
||||||
|
else
|
||||||
|
timeout=1
|
||||||
|
timeoutInfo="no timeout detected"
|
||||||
|
fi
|
||||||
|
actualSize=$freshSize
|
||||||
|
|
||||||
|
# detect if mx timeout loop limit is reached
|
||||||
|
if [ ${timeout} -gt ${maxTimeoutLoops} ]; then
|
||||||
|
echo "FAIL - download hit timeout"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# display info screen
|
||||||
|
clear
|
||||||
|
echo "****************************************************"
|
||||||
|
echo "Monitoring Screen Session: ${name}"
|
||||||
|
echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
|
||||||
|
echo "Timeout: ${timeoutInfo}"
|
||||||
|
echo "If needed press key x to stop ${name}"
|
||||||
|
echo "Its OK to close terminal now and SSH back in later."
|
||||||
|
echo "****************************************************"
|
||||||
|
screen -S ${name} -X hardcopy .${name}.out
|
||||||
|
newScreenDump=$(cat .Download.out | grep . | tail -10)
|
||||||
|
if [ ${#newScreenDump} -gt 0 ]; then
|
||||||
|
screenDump=$newScreenDump
|
||||||
|
fi
|
||||||
|
echo "$screenDump"
|
||||||
|
|
||||||
|
# wait 2 seconds for key input
|
||||||
|
read -n 1 -t 2 keyPressed
|
||||||
|
|
||||||
|
# check if user wants to abort session
|
||||||
|
if [ "${keyPressed}" = "x" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Aborting ${name}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
# clean up
|
||||||
|
rm -f .${name}.out
|
||||||
|
rm -f .${name}.progress
|
||||||
|
|
||||||
|
# quit session if still running
|
||||||
|
if [ ${isRunning} -eq 1 ]; then
|
||||||
|
# get the PID of screen session
|
||||||
|
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs)
|
||||||
|
echo "killing screen session PID(${sessionPID})"
|
||||||
|
# kill all child processes of screen sceesion
|
||||||
|
pkill -P ${sessionPID}
|
||||||
|
echo "proccesses klilled"
|
||||||
|
sleep 3
|
||||||
|
# tell the screen session to quit and wait a bit
|
||||||
|
screen -S ${name} -X quit 1>/dev/null
|
||||||
|
sleep 3
|
||||||
|
echo "cleaning screen"
|
||||||
|
screen -wipe 1>/dev/null
|
||||||
|
sleep 3
|
||||||
|
fi
|
||||||
|
|
||||||
# the path wget will download to
|
# the path wget will download to
|
||||||
targetPath=$(echo ${url} | cut -d '@' -f2)
|
targetPath=$(echo ${url} | cut -d '@' -f2)
|
||||||
|
echo "path to downloaded data is ${targetPath}"
|
||||||
|
|
||||||
echo "network($network)"
|
# calculate progress and write it to file for LCD to read
|
||||||
echo "list($list)"
|
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
|
||||||
echo "url($url)"
|
if [ ${#actualSize} -eq 0 ]; then
|
||||||
echo "size($size)"
|
finalSize=0
|
||||||
echo "targetPath($targetPath)"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "*** Downloading HDD / FTP ***"
|
|
||||||
sudo wget -r -P /mnt/hdd/ -q --show-progress ${url}
|
|
||||||
echo "OK"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
echo "*** Checking Download ***"
|
|
||||||
downloadsize=$(sudo du -s /mnt/hdd/${targetPath} | awk '{print $1}' | tr -dc '0-9')
|
|
||||||
if [ ${#downloadsize} -eq 0 ]; then
|
|
||||||
downloadsize=0
|
|
||||||
fi
|
fi
|
||||||
echo "download size is(${downloadsize}) needs to be minimum(${size}})"
|
echo "final size is ${finalSize} of targeted size ${targetSize}"
|
||||||
if [ ${downloadsize} -lt ${size} ]; then
|
|
||||||
|
# check result
|
||||||
|
if [ ${finalSize} -lt ${targetSize} ]; then
|
||||||
|
|
||||||
|
# Download failed
|
||||||
sleep 3
|
sleep 3
|
||||||
echo -ne '\007'
|
echo -ne '\007'
|
||||||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
|
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
|
||||||
response=$?
|
response=$?
|
||||||
case $response in
|
case $response in
|
||||||
1) sudo rm -rf /mnt/hdd/${targetPath} ;;
|
1) sudo rm -rf ${targetDir}${targetPath} ;;
|
||||||
esac
|
esac
|
||||||
./00mainMenu.sh
|
./00mainMenu.sh
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
|
||||||
echo ""
|
else
|
||||||
|
|
||||||
echo "*** Moving Files ***"
|
# Download worked
|
||||||
sudo mv /mnt/hdd/${targetPath} /mnt/hdd/${network}
|
echo "*** Moving Files ***"
|
||||||
echo "OK"
|
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network}
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
# continue setup
|
# continue setup
|
||||||
./60finishHDD.sh
|
./60finishHDD.sh
|
||||||
|
|
||||||
|
fi
|
@@ -1,6 +1,9 @@
|
|||||||
# load network
|
# load network
|
||||||
network=`sudo cat /home/admin/.network`
|
network=`sudo cat /home/admin/.network`
|
||||||
|
|
||||||
|
### USER PI AUTOSTART (LCD Display)
|
||||||
|
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||||
|
|
||||||
# parse the actual scanned height progress from LND logs
|
# parse the actual scanned height progress from LND logs
|
||||||
item=0
|
item=0
|
||||||
chain="$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
|
chain="$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
|
||||||
@@ -20,4 +23,4 @@ if [ ${percent} -e 100 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# display progress to user
|
# display progress to user
|
||||||
dialog --backtitle "RaspiBlitz (${network} / ${chain})" --infobox " Lightning Rescanning Blockchain ${percent}%\nplease wait - this can take some time" 4 42
|
dialog --backtitle "RaspiBlitz (${localip} / ${network} / ${chain})" --infobox " Lightning Rescanning Blockchain ${percent}%\nplease wait - this can take some time" 4 42
|
@@ -32,18 +32,13 @@ else
|
|||||||
sleep 60
|
sleep 60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# mark setup is done
|
|
||||||
echo "90" > /home/admin/.setup
|
|
||||||
|
|
||||||
# expand FS of SD
|
# expand FS of SD
|
||||||
echo "*** Expand RootFS ***"
|
echo "*** Expand RootFS ***"
|
||||||
sudo raspi-config --expand-rootfs
|
sudo raspi-config --expand-rootfs
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# set the hostname inputed on initDialog
|
# mark setup is done
|
||||||
hostname=`cat .hostname`
|
echo "90" > /home/admin/.setup
|
||||||
echo "Setting new network hostname '$hostname'"
|
|
||||||
sudo hostnamectl set-hostname ${hostname}
|
|
||||||
|
|
||||||
# show info to user
|
# show info to user
|
||||||
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
|
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
|
||||||
@@ -53,6 +48,11 @@ dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) "
|
|||||||
you need to unlock the LND wallet.
|
you need to unlock the LND wallet.
|
||||||
" 10 42
|
" 10 42
|
||||||
|
|
||||||
|
# set the hostname inputed on initDialog
|
||||||
|
hostname=`cat .hostname`
|
||||||
|
echo "Setting new network hostname '$hostname'"
|
||||||
|
sudo raspi-config nonint do_hostname ${hostname}
|
||||||
|
|
||||||
# mark setup is done (100%)
|
# mark setup is done (100%)
|
||||||
echo "100" > /home/admin/.setup
|
echo "100" > /home/admin/.setup
|
||||||
|
|
||||||
|
122
home.admin/BBconnectPeer.sh
Executable file
122
home.admin/BBconnectPeer.sh
Executable file
@@ -0,0 +1,122 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
_temp="./download/dialog.$$"
|
||||||
|
_error="./.error.out"
|
||||||
|
|
||||||
|
# load network and chain info
|
||||||
|
network=`cat .network`
|
||||||
|
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
|
||||||
|
|
||||||
|
# set ntwork map info
|
||||||
|
networkMap="https://lnmainnet.gaben.win"
|
||||||
|
if [ "$network" = "litecoin" ]; then
|
||||||
|
networkMap="https://lnexplorer.hcwong.me"
|
||||||
|
fi
|
||||||
|
if [ "$chain" = "test" ]; then
|
||||||
|
networkMap="https://explorer.acinq.co"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# let user enter a <pubkey>@host
|
||||||
|
l1="Enter the node pubkey address with host information:"
|
||||||
|
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735"
|
||||||
|
l3="network map -> ${networkMap}"
|
||||||
|
dialog --title "Open a Connection to a Peer" \
|
||||||
|
--backtitle "Lightning ( ${network} | ${chain} )" \
|
||||||
|
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp
|
||||||
|
_input=$(cat $_temp | xargs )
|
||||||
|
shred $_temp
|
||||||
|
if [ ${#_input} -eq 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build command
|
||||||
|
command="lncli connect ${_input}"
|
||||||
|
|
||||||
|
# info output
|
||||||
|
clear
|
||||||
|
echo "******************************"
|
||||||
|
echo "Connect to A Lightning Node"
|
||||||
|
echo "******************************"
|
||||||
|
echo ""
|
||||||
|
echo "COMMAND LINE: "
|
||||||
|
echo $command
|
||||||
|
echo ""
|
||||||
|
echo "RESULT:"
|
||||||
|
|
||||||
|
win=1
|
||||||
|
info=""
|
||||||
|
|
||||||
|
# check if input is available
|
||||||
|
if [ ${#_input} -lt 10 ]; then
|
||||||
|
win=0
|
||||||
|
info="node pubkey@host info is too short"
|
||||||
|
else
|
||||||
|
gotAt=$(echo $_input | grep '@' -c)
|
||||||
|
if [ ${gotAt} -eq 0 ]; then
|
||||||
|
win=0
|
||||||
|
info="format is not pubkey@host - @ is missing"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# execute command
|
||||||
|
sleep 2
|
||||||
|
result="$info"
|
||||||
|
if [ ${win} -eq 1 ]; then
|
||||||
|
result=$($command 2>$_error)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# on no result
|
||||||
|
if [ ${#result} -eq 0 ]; then
|
||||||
|
|
||||||
|
# basic error
|
||||||
|
win=0
|
||||||
|
info="No return value. Error not known."
|
||||||
|
|
||||||
|
# try to get error output
|
||||||
|
result=`cat ${_error}`
|
||||||
|
echo "$result"
|
||||||
|
|
||||||
|
# basic cli error
|
||||||
|
cliError=$(echo "${result}" | grep "[lncli]" -c )
|
||||||
|
if [ ${cliError} -gt 0 ]; then
|
||||||
|
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli."
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# when result is available
|
||||||
|
echo "$result"
|
||||||
|
|
||||||
|
# check if the node is now in peer list
|
||||||
|
pubkey=$(echo $_input | cut -d '@' -f1)
|
||||||
|
isPeer=$(lncli listpeers 2>/dev/null| grep "${pubkey}" -c)
|
||||||
|
if [ ${isPeer} -eq 0 ]; then
|
||||||
|
|
||||||
|
# basic error message
|
||||||
|
win=0
|
||||||
|
info="Was not able to establish connection to node."
|
||||||
|
|
||||||
|
# TODO: try to find out more details from cli output
|
||||||
|
|
||||||
|
else
|
||||||
|
info="Perfect - a connection to that node got established :)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# output info
|
||||||
|
echo ""
|
||||||
|
if [ ${win} -eq 1 ]; then
|
||||||
|
echo "******************************"
|
||||||
|
echo "WIN"
|
||||||
|
echo "******************************"
|
||||||
|
echo "${info}"
|
||||||
|
echo ""
|
||||||
|
echo "Whats next? --> Open a channel with that node."
|
||||||
|
else
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
echo "FAIL"
|
||||||
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
|
echo "${info}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
54
home.admin/BBfundWallet.sh
Executable file
54
home.admin/BBfundWallet.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# load network and chain info
|
||||||
|
network=`cat .network`
|
||||||
|
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
|
||||||
|
|
||||||
|
command="lncli newaddress np2wkh"
|
||||||
|
|
||||||
|
clear
|
||||||
|
echo "******************************"
|
||||||
|
echo "Fund your Blockchain Wallet"
|
||||||
|
echo "******************************"
|
||||||
|
echo ""
|
||||||
|
echo "COMMAND LINE: "
|
||||||
|
echo $command
|
||||||
|
echo ""
|
||||||
|
echo "RESULT:"
|
||||||
|
|
||||||
|
# execute command
|
||||||
|
result=$($command)
|
||||||
|
|
||||||
|
# on no result
|
||||||
|
if [ ${#result} -eq 0 ]; then
|
||||||
|
echo "Sorry something went wrong - thats unusual."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# when result is available
|
||||||
|
echo "$result"
|
||||||
|
|
||||||
|
# get address from result
|
||||||
|
address=$( echo "$result" | grep "address" | cut -d '"' -f4)
|
||||||
|
|
||||||
|
# prepare coin info
|
||||||
|
coininfo="REAL Bitcoin"
|
||||||
|
if [ "$network" = "litecoin" ]; then
|
||||||
|
coininfo="REAL Litecoin"
|
||||||
|
fi
|
||||||
|
if [ "$chain" = "test" ]; then
|
||||||
|
coininfo="TESTNET Bitcoin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# output info
|
||||||
|
echo ""
|
||||||
|
echo "******************************"
|
||||||
|
echo "TODO"
|
||||||
|
echo "******************************"
|
||||||
|
echo "Send ${coininfo} to address --> ${address}"
|
||||||
|
if [ "$chain" = "test" ]; then
|
||||||
|
echo "get some testnet coins from https://testnet.manu.backend.hamburg/faucet"
|
||||||
|
fi
|
||||||
|
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or info on LCD to check if funds have arrived."
|
||||||
|
echo ""
|
@@ -1,11 +1,35 @@
|
|||||||
# experimental script to let downloads run
|
#!/bin/sh
|
||||||
# in background with screen an monitor
|
echo ""
|
||||||
|
|
||||||
|
# *** BITCOIN ***
|
||||||
|
bitcoinList="" # url to list with other sources
|
||||||
|
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-bitcoin-2018-07-16"
|
||||||
|
bitcoinSize=100
|
||||||
|
|
||||||
|
# *** LITECOIN ***
|
||||||
|
litecoinList="" # url to list with other sources
|
||||||
|
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29"
|
||||||
|
litecoinSize=19000000
|
||||||
|
|
||||||
|
# load network
|
||||||
|
network=`cat .network`
|
||||||
|
|
||||||
|
# settings based on network
|
||||||
|
list=$bitcoinList
|
||||||
|
url=$bitcoinUrl
|
||||||
|
size=$bitcoinSize
|
||||||
|
if [ "$network" = "litecoin" ]; then
|
||||||
|
list=$litecoinList
|
||||||
|
url=$litecoinUrl
|
||||||
|
size=$litecoinSize
|
||||||
|
fi
|
||||||
|
|
||||||
|
# screen background monitoring settings
|
||||||
name="Download"
|
name="Download"
|
||||||
targetDir="./test/"
|
targetDir="/mnt/hdd/download/"
|
||||||
targetSize=2085832
|
targetSize=$size
|
||||||
maxTimeoutLoops=10
|
maxTimeoutLoops=100
|
||||||
command="wget -P ${targetDir} http://wiki.fulmo.org/downloads/raspiblitz-2018-07-29b.img.gz"
|
command="sudo wget -c -r -P ${targetDir} -q --show-progress ${url}"
|
||||||
|
|
||||||
# starting session if needed
|
# starting session if needed
|
||||||
echo "checking if ${name} has a running screen session"
|
echo "checking if ${name} has a running screen session"
|
||||||
@@ -32,6 +56,7 @@ while :
|
|||||||
screen -wipe 1>/dev/null
|
screen -wipe 1>/dev/null
|
||||||
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
||||||
if [ ${isRunning} -eq 0 ]; then
|
if [ ${isRunning} -eq 0 ]; then
|
||||||
|
timeout=0
|
||||||
echo "OK - session finished"
|
echo "OK - session finished"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -93,9 +118,54 @@ rm -f .${name}.progress
|
|||||||
|
|
||||||
# quit session if still running
|
# quit session if still running
|
||||||
if [ ${isRunning} -eq 1 ]; then
|
if [ ${isRunning} -eq 1 ]; then
|
||||||
echo "killing screen session TODO: KILL PROCESS"
|
# get the PID of screen session
|
||||||
screen -S ${name} -X quit
|
sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs)
|
||||||
|
echo "killing screen session PID(${sessionPID})"
|
||||||
|
# kill all child processes of screen sceesion
|
||||||
|
pkill -P ${sessionPID}
|
||||||
|
echo "proccesses klilled"
|
||||||
|
sleep 3
|
||||||
|
# tell the screen session to quit and wait a bit
|
||||||
|
screen -S ${name} -X quit 1>/dev/null
|
||||||
|
sleep 3
|
||||||
|
echo "cleaning screen"
|
||||||
|
screen -wipe 1>/dev/null
|
||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# decide on how to continue
|
# the path wget will download to
|
||||||
|
targetPath=$(echo ${url} | cut -d '@' -f2)
|
||||||
|
echo "path to downloaded data is ${targetPath}"
|
||||||
|
|
||||||
|
# calculate progress and write it to file for LCD to read
|
||||||
|
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
|
||||||
|
if [ ${#actualSize} -eq 0 ]; then
|
||||||
|
finalSize=0
|
||||||
|
fi
|
||||||
|
echo "final size is ${finalSize} of targeted size ${targetSize}"
|
||||||
|
|
||||||
|
# check result
|
||||||
|
if [ ${finalSize} -lt ${targetSize} ]; then
|
||||||
|
|
||||||
|
# Download failed
|
||||||
|
sleep 3
|
||||||
|
echo -ne '\007'
|
||||||
|
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
|
||||||
|
response=$?
|
||||||
|
case $response in
|
||||||
|
1) sudo rm -rf ${targetDir}${targetPath} ;;
|
||||||
|
esac
|
||||||
|
./00mainMenu.sh
|
||||||
|
exit 1;
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# Download worked
|
||||||
|
echo "*** Moving Files ***"
|
||||||
|
sudo mv ${targetDir}${targetPath} /mnt/hdd/${network}
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
# continue setup
|
||||||
|
./60finishHDD.sh
|
||||||
|
|
||||||
|
fi
|
Reference in New Issue
Block a user