raspiblitz/home.admin/00mainMenu.sh

206 lines
5.7 KiB
Bash
Raw Normal View History

2018-07-17 13:12:03 +02:00
#!/bin/bash
## default menu settings
HEIGHT=13
2018-07-17 13:12:03 +02:00
WIDTH=64
CHOICE_HEIGHT=6
2018-07-17 13:12:03 +02:00
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
2018-08-08 23:33:05 +02:00
# default config values (might get changed later)
2018-07-29 01:33:54 +02:00
if [ ! -f ./.network ]; then
echo "bitcoin" > /home/admin/.network
fi
network=`cat .network`
2018-07-17 13:12:03 +02:00
## get actual setup state
setupState=0;
if [ -f "/home/admin/.setup" ]; then
setupState=$( cat /home/admin/.setup )
fi
if [ ${setupState} -eq 0 ]; then
# start setup
2018-07-25 11:40:50 -04:00
BACKTITLE="RaspiBlitz - Setup"
2018-07-17 13:12:03 +02:00
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
2018-07-29 01:33:54 +02:00
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
2018-07-17 13:12:03 +02:00
elif [ ${setupState} -lt 100 ]; then
# continue setup
2018-07-25 11:40:50 -04:00
BACKTITLE="RaspiBlitz - Setup"
2018-07-17 13:12:03 +02:00
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
2018-07-29 01:33:54 +02:00
MENU="\nThe setup process in snot finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
2018-07-17 13:12:03 +02:00
HEIGHT=10
else
# make sure to have a init pause aufter fresh boot
uptimesecs=$(awk '{print $1}' /proc/uptime | awk '{print int($1)}')
waittimesecs=$(expr 150 - $uptimesecs)
if [ ${waittimesecs} -gt 0 ]; then
2018-07-29 01:33:54 +02:00
dialog --pause " Waiting for ${network} to startup and init ..." 8 58 ${waittimesecs}
2018-07-17 13:12:03 +02:00
fi
# MAIN MENU AFTER SETUP
2018-07-29 01:33:54 +02:00
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
2018-07-17 13:12:03 +02:00
if [ ${locked} -gt 0 ]; then
# LOCK SCREEN
MENU="!!! YOUR WALLET IS LOCKED !!!"
2018-08-08 17:36:04 +02:00
OPTIONS+=(U "Unlock your Lightning Wallet with 'lncli unlock'")
2018-07-17 13:12:03 +02:00
else
2018-08-08 17:36:04 +02:00
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
switchOption="to MAINNET"
2018-08-08 23:22:20 +02:00
if [ "${chain}" = "main" ]; then
2018-08-08 17:36:04 +02:00
switchOption="back to TESTNET"
fi
2018-08-09 13:04:23 +02:00
# Basic Options
2018-07-27 11:17:59 +02:00
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your Wallet" \
CONNECT "Connect to a Peer" \
2018-08-09 01:25:52 +02:00
CHANNEL "Open a Channel with Peer" \
2018-08-09 14:44:45 +02:00
SEND "Pay an Invoice/PaymentRequest" \
RECEIVE "Create Invoice/PaymentRequest" \
lnbalance "Detailed Wallet Balances" \
2018-08-09 13:04:23 +02:00
lnchannels "Lightning Channel List")
# Depending Options
2018-08-21 04:17:08 +02:00
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c)
2018-08-09 13:26:44 +02:00
if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
2018-08-09 13:04:23 +02:00
if [ "${network}" = "bitcoin" ]; then
OPTIONS+=(SWITCH "Switch ${switchOption}")
fi
2018-08-21 12:30:43 +02:00
torInstalled=$(sudo ls /mnt/hdd/tor/lnd9735/hostname 2>/dev/null | grep 'hostname' -c)
if [ ${torInstalled} -eq 0 ]; then
OPTIONS+=(TOR "Make reachable thru TOR")
else
OPTIONS+=(NYX "Monitor TOR")
fi
2018-08-09 13:04:23 +02:00
# final Options
OPTIONS+=(X "Console / Terminal")
2018-07-17 13:12:03 +02:00
fi
fi
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
CLOSE)
exit 1;
;;
2018-07-29 01:33:54 +02:00
BITCOIN)
echo "bitcoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
LITECOIN)
echo "litecoin" > /home/admin/.network
./10setupBlitz.sh
exit 1;
;;
CONTINUE)
2018-07-17 13:12:03 +02:00
./10setupBlitz.sh
exit 1;
;;
INFO)
./00infoBlitz.sh
echo "Screen is not updating ... press ENTER to continue."
2018-07-27 11:17:59 +02:00
read key
./00mainMenu.sh
;;
lnbalance)
lnbalance
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-21 12:30:43 +02:00
NYX)
sudo nyx
./00mainMenu.sh
;;
2018-07-27 11:17:59 +02:00
lnchannels)
lnchannels
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
2018-07-17 13:12:03 +02:00
;;
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
;;
2018-08-09 01:27:29 +02:00
CHANNEL)
2018-08-09 01:25:52 +02:00
./BBopenChannel.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-09 14:44:45 +02:00
SEND)
./BBpayInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
RECEIVE)
2018-08-09 14:58:44 +02:00
./BBcreateInvoice.sh
2018-08-09 14:44:45 +02:00
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-09 13:26:44 +02:00
CLOSEALL)
./BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-08 17:36:04 +02:00
SWITCH)
sudo ./95switchMainTest.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-21 12:30:43 +02:00
TOR)
sudo ./96addTorService.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2018-08-08 17:36:04 +02:00
X)
lncli -h
echo "SUCH WOW come back with ./00mainMenu.sh"
2018-08-08 17:36:04 +02:00
;;
U) # unlock
2018-07-17 13:12:03 +02:00
./AAunlockLND.sh
2018-07-27 11:17:59 +02:00
./00mainMenu.sh
2018-07-17 13:12:03 +02:00
;;
2018-08-21 12:30:43 +02:00
esac