raspiblitz/home.admin/00mainMenu.sh

242 lines
6.9 KiB
Bash
Raw Normal View History

2018-07-17 13:12:03 +02:00
#!/bin/bash
2018-12-10 22:45:44 +01:00
echo "Starting the main menu ..."
2018-07-17 13:12:03 +02:00
2018-12-10 20:05:58 +01:00
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
2019-04-16 18:55:25 +01:00
# MAIN MENU AFTER SETUP
2018-12-10 20:05:58 +01:00
source ${infoFile}
2019-04-16 18:55:25 +01:00
source ${configFile}
2018-12-10 20:05:58 +01:00
2019-04-17 03:31:51 +01:00
# get the local network IP to be displayed on the lCD
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
2019-04-16 19:07:13 +01:00
# BASIC MENU INFO
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=6
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
2019-04-16 18:55:25 +01:00
plus=""
if [ "${runBehindTor}" = "on" ]; then
plus=" / TOR"
2018-12-10 20:05:58 +01:00
fi
2019-04-16 18:55:25 +01:00
if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
2019-04-15 22:37:03 +01:00
fi
2019-04-16 18:55:25 +01:00
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
2019-04-16 19:05:23 +01:00
if [ "${rtlWebinterface}" == "on" ]; then
2019-04-16 18:55:25 +01:00
TITLE="Webinterface: http://${localip}:3000"
2019-04-15 22:37:03 +01:00
fi
2019-01-30 09:48:25 +00:00
2019-04-16 18:55:25 +01:00
# Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your on-chain Wallet" \
CONNECT "Connect to a Peer" \
CHANNEL "Open a Channel with Peer" \
SEND "Pay an Invoice/PaymentRequest" \
RECEIVE "Create Invoice/PaymentRequest" \
SERVICES "Activate/Deactivate Services" \
MOBILE "Connect Mobile Wallet" \
EXPORT "Macaroons and TLS.cert" \
NAME "Change Name/Alias of Node" \
PASSWORD "Change Passwords" \
CASHOUT "Remove Funds from on-chain Wallet"
)
2019-12-04 08:13:21 +00:00
if [ "${runBehindTor}" == "on" ]; then
OPTIONS+=(TOR "Tor Service options")
fi
2019-04-16 18:55:25 +01:00
# dont offer lnbalance/lnchannels on testnet
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List")
2019-03-17 16:29:59 +01:00
fi
2019-04-16 18:55:25 +01:00
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
2019-04-16 19:05:23 +01:00
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
2019-04-16 18:55:25 +01:00
OPTIONS+=(CLOSEALL "Close all open Channels")
2018-12-10 20:05:58 +01:00
fi
2018-07-17 13:12:03 +02:00
2019-04-16 18:55:25 +01:00
# final Options
2019-06-19 00:13:03 +02:00
OPTIONS+=(REPAIR "Repair Options")
2019-04-16 18:55:25 +01:00
OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update")
OPTIONS+=(OFF "PowerOff RaspiBlitz")
OPTIONS+=(X "Console / Terminal")
2018-07-17 13:12:03 +02:00
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
2019-04-16 19:02:10 +01:00
#clear
2018-07-17 13:12:03 +02:00
case $CHOICE in
CLOSE)
2019-04-28 17:01:10 +02:00
exit 1;
;;
X)
2019-04-28 17:01:49 +02:00
clear
2019-04-28 17:04:08 +02:00
echo "***********************************"
echo "* RaspiBlitz Commandline"
echo "* Here be dragons .. have fun :)"
echo "***********************************"
2019-04-28 16:59:27 +02:00
echo "LND commandline options: lncli -h"
2019-04-28 17:06:18 +02:00
echo "Back to main menu use command: raspiblitz"
echo
2018-07-17 13:12:03 +02:00
exit 1;
;;
INFO)
2019-04-25 02:42:45 +02:00
walletLocked=$(lncli getinfo 2>&1 | grep -c "Wallet is encrypted")
if [ ${walletLocked} -eq 0 ]; then
./00infoBlitz.sh
echo "Screen is not refreshing itself ... press ENTER to continue."
read key
fi
2019-04-25 02:38:14 +02:00
./00raspiblitz.sh
2018-07-27 11:17:59 +02:00
;;
lnbalance)
lnbalance ${network}
2018-07-27 11:17:59 +02:00
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2019-12-04 08:13:21 +00:00
TOR)
./00torMenu.sh
2018-08-21 12:30:43 +02:00
./00mainMenu.sh
;;
2018-07-27 11:17:59 +02:00
lnchannels)
lnchannels ${network}
2018-07-27 11:17:59 +02:00
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
2018-12-03 18:43:19 +01:00
;;
FUNDING)
./BBfundWallet.sh
./00mainMenu.sh
2018-12-03 18:43:19 +01:00
;;
2018-08-23 17:59:35 +02:00
CASHOUT)
./BBcashoutWallet.sh
./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-12-03 18:43:19 +01:00
;;
2018-08-09 14:44:45 +02:00
SEND)
./BBpayInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
2018-12-03 18:43:19 +01:00
;;
2018-08-09 14:44:45 +02:00
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-12-03 18:43:19 +01:00
;;
2018-10-15 23:36:40 +02:00
SERVICES)
./00settingsMenuServices.sh
./00mainMenu.sh
2018-12-03 18:43:19 +01:00
;;
2018-08-09 13:26:44 +02:00
CLOSEALL)
./BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
2018-12-03 18:43:19 +01:00
;;
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-12-03 18:43:19 +01:00
;;
2018-08-23 03:51:40 +02:00
MOBILE)
2018-08-31 22:02:32 +02:00
./97addMobileWallet.sh
2018-08-23 03:51:40 +02:00
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
2018-12-03 18:43:19 +01:00
;;
EXPORT)
sudo /home/admin/config.scripts/lnd.export.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
2019-01-14 13:45:24 +01:00
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh
2019-01-30 09:48:25 +00:00
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop
echo "Press ENTER to Reboot."
read key
sudo shutdown -r now
else
./00mainMenu.sh
fi
2019-01-14 13:45:24 +01:00
;;
2019-06-19 00:13:03 +02:00
REPAIR)
./98repairMenu.sh
2019-04-10 14:58:47 +01:00
./00mainMenu.sh
;;
2019-01-14 17:59:18 +01:00
PASSWORD)
2019-01-14 18:19:48 +01:00
sudo /home/admin/config.scripts/blitz.setpassword.sh
noreboot=$?
if [ "${noreboot}" = "0" ]; then
2019-01-30 09:48:25 +00:00
sudo -u bitcoin ${network}-cli stop
2019-01-14 18:19:48 +01:00
echo "Press ENTER to Reboot .."
read key
sudo shutdown -r now
else
2019-01-14 18:34:21 +01:00
echo "Press ENTER to return to main menu .."
read key
2019-01-14 18:19:48 +01:00
./00mainMenu.sh
fi
2019-01-14 17:59:18 +01:00
;;
2018-10-18 23:38:44 +02:00
OFF)
2018-12-10 13:13:22 +01:00
echo ""
echo "LCD turns white when shutdown complete."
echo "Then wait 5 seconds and disconnect power."
echo "-----------------------------------------------"
2018-12-10 14:00:08 +01:00
echo "stop lnd - please wait .."
2018-12-10 13:13:22 +01:00
sudo systemctl stop lnd
2019-01-30 09:48:25 +00:00
echo "stop ${network}d (1) - please wait .."
sudo -u bitcoin ${network}-cli stop
2018-12-11 05:12:57 +01:00
sleep 10
2019-01-30 09:48:25 +00:00
echo "stop ${network}d (2) - please wait .."
2018-12-10 13:13:22 +01:00
sudo systemctl stop ${network}d
2019-02-24 17:20:35 +01:00
sleep 3
sync
echo "starting shutdown ..."
2018-10-18 23:38:44 +02:00
sudo shutdown now
exit 0
2018-12-03 18:43:19 +01:00
;;
2018-12-03 18:36:11 +01:00
DELETE)
sudo ./XXcleanHDD.sh
sudo shutdown -r now
exit 0
;;
2019-04-16 18:31:36 +01:00
UPDATE)
/home/admin/99checkUpdate.sh
./00mainMenu.sh
exit 0
;;
2019-01-21 21:26:26 +01:00
esac