You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
7.1 KiB

7 years ago
#!/bin/bash
echo "Starting the main menu ..."
7 years ago
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# MAIN MENU AFTER SETUP
source ${infoFile}
source ${configFile}
# 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'/')
# BASIC MENU INFO
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=6
BACKTITLE="RaspiBlitz"
TITLE=""
MENU="Choose one of the following options:"
OPTIONS=()
plus=""
if [ "${runBehindTor}" = "on" ]; then
plus=" / TOR"
fi
if [ ${#dynDomain} -gt 0 ]; then
plus="${plus} / ${dynDomain}"
6 years ago
fi
BACKTITLE="${localip} / ${hostname} / ${network} / ${chain}${plus}"
6 years ago
if [ "${rtlWebinterface}" == "on" ]; then
TITLE="Webinterface: http://${localip}:3000"
6 years ago
fi
# 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"
)
# dont offer lnbalance/lnchannels on testnet
if [ "${chain}" = "main" ]; then
OPTIONS+=(lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List")
fi
# Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length')
6 years ago
if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels")
fi
6 years ago
if [ "${runBehindTor}" == "on" ]; then
OPTIONS+=(NYX "Monitor TOR")
7 years ago
fi
# final Options
OPTIONS+=(HARDWARE "Run Hardwaretest")
OPTIONS+=(SOFTWARE "Run Softwaretest (DebugReport)")
OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update")
OPTIONS+=(OFF "PowerOff RaspiBlitz")
OPTIONS+=(X "Console / Terminal")
7 years ago
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
6 years ago
#clear
7 years ago
case $CHOICE in
CLOSE)
6 years ago
exit 1;
;;
X)
6 years ago
clear
6 years ago
echo "***********************************"
echo "* RaspiBlitz Commandline"
echo "* Here be dragons .. have fun :)"
echo "***********************************"
echo "LND commandline options: lncli -h"
6 years ago
echo "Back to main menu use command: raspiblitz"
echo
7 years ago
exit 1;
;;
INFO)
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
6 years ago
./00raspiblitz.sh
;;
lnbalance)
lnbalance ${network}
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
6 years ago
NYX)
sudo nyx
./00mainMenu.sh
;;
lnchannels)
lnchannels ${network}
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
7 years ago
;;
CONNECT)
./BBconnectPeer.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
FUNDING)
./BBfundWallet.sh
./00mainMenu.sh
6 years ago
;;
6 years ago
CASHOUT)
./BBcashoutWallet.sh
./00mainMenu.sh
;;
6 years ago
CHANNEL)
./BBopenChannel.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
SEND)
./BBpayInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
RECEIVE)
./BBcreateInvoice.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
SERVICES)
./00settingsMenuServices.sh
./00mainMenu.sh
6 years ago
;;
CLOSEALL)
./BBcloseAllChannels.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
SWITCH)
sudo ./95switchMainTest.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
MOBILE)
6 years ago
./97addMobileWallet.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
6 years ago
;;
EXPORT)
sudo /home/admin/config.scripts/lnd.export.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
NAME)
sudo /home/admin/config.scripts/lnd.setname.sh
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
;;
HARDWARE)
sudo ./05hardwareTest.sh
./00mainMenu.sh
;;
SOFTWARE)
sudo ./XXdebugLogs.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
PASSWORD)
6 years ago
sudo /home/admin/config.scripts/blitz.setpassword.sh
noreboot=$?
if [ "${noreboot}" = "0" ]; then
sudo -u bitcoin ${network}-cli stop
6 years ago
echo "Press ENTER to Reboot .."
read key
sudo shutdown -r now
else
echo "Press ENTER to return to main menu .."
read key
6 years ago
./00mainMenu.sh
fi
;;
OFF)
echo ""
echo "LCD turns white when shutdown complete."
echo "Then wait 5 seconds and disconnect power."
echo "-----------------------------------------------"
echo "stop lnd - please wait .."
sudo systemctl stop lnd
echo "stop ${network}d (1) - please wait .."
sudo -u bitcoin ${network}-cli stop
sleep 10
echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d
sleep 3
sync
echo "starting shutdown ..."
sudo shutdown now
exit 0
6 years ago
;;
6 years ago
DELETE)
sudo ./XXcleanHDD.sh
sudo shutdown -r now
exit 0
;;
UPDATE)
/home/admin/99checkUpdate.sh
./00mainMenu.sh
exit 0
;;
esac