From b93d73fb83f978814ee99b9c501b8c4fffd70fe7 Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Wed, 7 Apr 2021 23:24:55 +0100 Subject: [PATCH] SSH menu refactoring + CONNECT, LIGHTNING and SYSTEM menus added (#2119) --- home.admin/00mainMenu.sh | 163 ++++------- home.admin/00settingsMenuBasics.sh | 12 +- home.admin/00settingsMenuServices.sh | 4 +- home.admin/99connectMenu.sh | 281 +++++++++++++++++++ home.admin/99lightningMenu.sh | 119 ++++++++ home.admin/99systemMenu.sh | 154 ++++++++++ home.admin/99updateMenu.sh | 31 +- home.admin/config.scripts/blitz.setconf.sh | 47 ++++ home.admin/config.scripts/internet.tor.sh | 7 - home.admin/config.scripts/lnd.credentials.sh | 34 --- 10 files changed, 701 insertions(+), 151 deletions(-) create mode 100644 home.admin/99connectMenu.sh create mode 100644 home.admin/99lightningMenu.sh create mode 100644 home.admin/99systemMenu.sh create mode 100644 home.admin/config.scripts/blitz.setconf.sh diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 0dbc1588b..248f74c7a 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -41,9 +41,9 @@ confirmation() source <(/home/admin/config.scripts/internet.sh status local) # BASIC MENU INFO -HEIGHT=17 +HEIGHT=19 WIDTH=64 -CHOICE_HEIGHT=10 +CHOICE_HEIGHT=12 BACKTITLE="RaspiBlitz" TITLE="" MENU="Choose one of the following options:" @@ -64,100 +64,119 @@ fi # Put Activated Apps on top if [ "${rtlWebinterface}" == "on" ]; then OPTIONS+=(RTL "RTL Web Node Manager") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${BTCPayServer}" == "on" ]; then OPTIONS+=(BTCPAY "BTCPay Server Info") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${lit}" == "on" ]; then OPTIONS+=(LIT "LIT (loop, pool, faraday)") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${ElectRS}" == "on" ]; then OPTIONS+=(ELECTRS "Electrum Rust Server") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${BTCRPCexplorer}" == "on" ]; then OPTIONS+=(EXPLORE "BTC RPC Explorer") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${LNBits}" == "on" ]; then OPTIONS+=(LNBITS "LNbits Server") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${lndmanage}" == "on" ]; then OPTIONS+=(LNDMANAGE "LND Manage Script") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${loop}" == "on" ]; then OPTIONS+=(LOOP "Loop In/Out Service") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${mempoolExplorer}" == "on" ]; then OPTIONS+=(MEMPOOL "Mempool Space") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${specter}" == "on" ]; then OPTIONS+=(SPECTER "Cryptoadvance Specter") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${joinmarket}" == "on" ]; then OPTIONS+=(JMARKET "JoinMarket") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${faraday}" == "on" ]; then OPTIONS+=(FARADAY "Faraday Channel Management") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${bos}" == "on" ]; then OPTIONS+=(BOS "Balance of Satoshis") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${pyblock}" == "on" ]; then OPTIONS+=(PYBLOCK "PyBlock") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${thunderhub}" == "on" ]; then OPTIONS+=(THUB "ThunderHub") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${zerotier}" == "on" ]; then OPTIONS+=(ZEROTIER "ZeroTier") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${pool}" == "on" ]; then OPTIONS+=(POOL "Lightning Pool") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${sphinxrelay}" == "on" ]; then OPTIONS+=(SPHINX "Sphinx Chat Relay") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${chantools}" == "on" ]; then OPTIONS+=(CHANTOOLS "ChannelTools (Fund Rescue)") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${circuitbreaker}" == "on" ]; then OPTIONS+=(CIRCUIT "Circuitbreaker (LND firewall)") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi # Basic Options OPTIONS+=(INFO "RaspiBlitz Status Screen") -OPTIONS+=(FUNDING "Fund your LND Wallet") -OPTIONS+=(CONNECT "Connect to a Peer") -OPTIONS+=(CHANNEL "Open a Channel with Peer") -OPTIONS+=(SEND "Pay an Invoice/PaymentRequest") -OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest") - -openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') -if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then - OPTIONS+=(CLOSEALL "Close all open Channels") -fi - -OPTIONS+=(CASHOUT "Remove Funds from LND") - -if [ "${chain}" = "main" ]; then - OPTIONS+=(lnbalance "Detailed Wallet Balances") - OPTIONS+=(lnchannels "Lightning Channel List") - OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report") -fi - +OPTIONS+=(LIGHTNING "LND Wallet Options") OPTIONS+=(SETTINGS "Node Settings & Options") OPTIONS+=(SERVICES "Additional Apps & Services") +OPTIONS+=(SYSTEM "Monitoring & Configuration") +OPTIONS+=(CONNECT "Connect Apps & Show Credentials") OPTIONS+=(SUBSCRIBE "Manage Subscriptions") -OPTIONS+=(MOBILE "Connect Mobile Wallet") -OPTIONS+=(LNDCREDS "Manage LND Credentials") -OPTIONS+=(NAME "Change Name/Alias of Node") OPTIONS+=(PASSWORD "Change Passwords") -if [ "${runBehindTor}" == "on" ]; then - OPTIONS+=(TOR "Monitor TOR Service") -fi - if [ "${touchscreen}" == "1" ]; then OPTIONS+=(SCREEN "Touchscreen Calibration") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi # final Options @@ -165,11 +184,12 @@ OPTIONS+=(REPAIR "Repair Options") OPTIONS+=(UPDATE "Check/Prepare RaspiBlitz Update") OPTIONS+=(REBOOT "Reboot RaspiBlitz") OPTIONS+=(OFF "PowerOff RaspiBlitz") -OPTIONS+=(X "Console / Terminal") CHOICE=$(dialog --clear \ --backtitle "$BACKTITLE" \ --title "$TITLE" \ + --ok-label "Select" \ + --cancel-label "Exit" \ --menu "$MENU" \ $HEIGHT $WIDTH $CHOICE_HEIGHT \ "${OPTIONS[@]}" \ @@ -206,8 +226,14 @@ case $CHOICE in exit 0 fi ;; - TOR) - sudo -u debian-tor nyx + LIGHTNING) + /home/admin/99lightningMenu.sh + ;; + CONNECT) + /home/admin/99connectMenu.sh + ;; + SYSTEM) + /home/admin/99systemMenu.sh ;; SCREEN) dialog --title 'Touchscreen Calibration' --msgbox 'Choose OK and then follow the instructions on touchscreen for calibration.\n\nBest is to use a stylus for accurate touchscreen interaction.' 9 48 @@ -276,78 +302,12 @@ case $CHOICE in SUBSCRIBE) /home/admin/config.scripts/blitz.subscriptions.py ;; - lnbalance) - clear - echo "*** YOUR SATOSHI BALANCES ***" - /home/admin/config.scripts/lnd.balance.sh ${network} - echo "Press ENTER to return to main menu." - read key - ;; - lnchannels) - clear - echo "*** YOUR LIGHTNING CHANNELS ***" - echo "" - echo "Capacity -> total sats in the channel (their side + your side)" - echo "Commit-Fee -> the fee that's charged if either side of the channel closes" - echo "Balance-Local -> sats on your side of the channel (outbound liquidity)" - echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)" - echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel" - echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding" - /home/admin/config.scripts/lnd.channels.sh ${network} - echo "Press ENTER to return to main menu." - read key - ;; - lnfwdreport) - /home/admin/config.scripts/lnd.fwdreport.sh -menu - echo "Press ENTER to return to main menu." - read key - ;; - CONNECT) - /home/admin/BBconnectPeer.sh - ;; - FUNDING) - /home/admin/BBfundWallet.sh - ;; - CASHOUT) - /home/admin/BBcashoutWallet.sh - ;; - CHANNEL) - /home/admin/BBopenChannel.sh - ;; - SEND) - /home/admin/BBpayInvoice.sh - ;; - RECEIVE) - /home/admin/BBcreateInvoice.sh - ;; SERVICES) /home/admin/00settingsMenuServices.sh ;; SETTINGS) /home/admin/00settingsMenuBasics.sh ;; - CLOSEALL) - /home/admin/BBcloseAllChannels.sh - echo "Press ENTER to return to main menu." - read key - ;; - MOBILE) - /home/admin/97addMobileWallet.sh - ;; - LNDCREDS) - sudo /home/admin/config.scripts/lnd.credentials.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 /home/admin/XXshutdown.sh reboot - exit 0 - fi - ;; REPAIR) /home/admin/98repairMenu.sh if [ $? -eq 99 ]; then @@ -394,22 +354,17 @@ case $CHOICE in sudo /home/admin/XXshutdown.sh reboot exit 0 ;; - X) + *) clear echo "***********************************" echo "* RaspiBlitz Commandline" echo "* Here be dragons .. have fun :)" echo "***********************************" - echo "Bitcoin command line options: bitcoin-cli help" + echo "Bitcoin command line options: bitcoin-cli help" echo "LND command line options: lncli -h" echo "Back to main menu use command: raspiblitz" echo exit 0 - ;; - *) - clear - echo "To return to main menu use command: raspiblitz" - exit 0 esac # go into loop - start script from beginning to load config/sate fresh diff --git a/home.admin/00settingsMenuBasics.sh b/home.admin/00settingsMenuBasics.sh index a952a579e..2767295ff 100755 --- a/home.admin/00settingsMenuBasics.sh +++ b/home.admin/00settingsMenuBasics.sh @@ -71,7 +71,13 @@ fi # show select dialog echo "run dialog ..." + +# BASIC MENU INFO +HEIGHT=19 # add 6 to CHOICE_HEIGHT + MENU lines +WIDTH=45 +CHOICE_HEIGHT=11 # 1 line / OPTIONS OPTIONS=() + OPTIONS+=(t 'Run behind TOR' ${runBehindTor}) OPTIONS+=(s 'Touchscreen' ${touchscreenMenu}) OPTIONS+=(r 'LCD Rotate' ${lcdrotateMenu}) @@ -90,7 +96,11 @@ if [ ${#runBehindTor} -eq 0 ] || [ "${runBehindTor}" = "off" ]; then OPTIONS+=(l 'LND UPnP (AutoNAT)' ${autoNatDiscovery}) fi -CHOICES=$(dialog --title ' Node Settings & Options ' --checklist ' use spacebar to activate/de-activate ' 19 45 11 "${OPTIONS[@]}" 2>&1 >/dev/tty) +CHOICES=$(dialog \ + --title ' Node Settings & Options ' \ + --checklist ' use spacebar to activate/de-activate ' \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" 2>&1 >/dev/tty) dialogcancel=$? echo "done dialog" diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index 7bf638196..fa4df1dc6 100755 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -43,7 +43,9 @@ OPTIONS+=(y 'PyBLOCK' ${pyblock}) OPTIONS+=(c 'ChannelTools (Fund Rescue)' ${chantools}) OPTIONS+=(w 'Download Bitcoin Whitepaper' ${whitepaper}) -CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 20 45 12 "${OPTIONS[@]}" 2>&1 >/dev/tty) +CHOICES=$(dialog --title ' Additional Services ' \ + --checklist ' use spacebar to activate/de-activate ' \ + 22 45 15 "${OPTIONS[@]}" 2>&1 >/dev/tty) dialogcancel=$? echo "done dialog" diff --git a/home.admin/99connectMenu.sh b/home.admin/99connectMenu.sh new file mode 100644 index 000000000..64f1dd8de --- /dev/null +++ b/home.admin/99connectMenu.sh @@ -0,0 +1,281 @@ +#!/bin/bash + +# get raspiblitz config +echo "get raspiblitz config" +source /home/admin/raspiblitz.info +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 +HEIGHT=12 +WIDTH=64 +CHOICE_HEIGHT=6 +BACKTITLE="RaspiBlitz" +TITLE="Connect Options" +MENU="" +OPTIONS=() + +OPTIONS+=(MOBILE "Connect Mobile Wallet") +if [ "${ElectRS}" == "on" ]; then + OPTIONS+=(ELECTRS "Electrum Rust Server") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) +fi +if [ "${BTCPayServer}" == "on" ]; then + OPTIONS+=(BTCPAY "Show LND connection string") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) +fi +OPTIONS+=(${network}RPC "Connect Specter Desktop or JoinMarket") +OPTIONS+=(BISQ "Connect Bisq to this node") +OPTIONS+=(EXPORT "Get Macaroons and TLS.cert") +OPTIONS+=(RESET "Recreate LND Macaroons & tls.cert") +OPTIONS+=(SYNC "Sync Macaroons & tls.cert with Apps/Users") + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --ok-label "Select" \ + --cancel-label "Main menu" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +case $CHOICE in + + MOBILE) + /home/admin/97addMobileWallet.sh;; + ELECTRS) + /home/admin/config.scripts/bonus.electrs.sh menu;; + BTCPAY) + /home/admin/config.scripts/lnd.export.sh btcpay;; + RESET) + sudo /home/admin/config.scripts/lnd.credentials.sh reset + echo "Press ENTER to return to main menu." + read key + exit 0;; + SYNC) + sudo /home/admin/config.scripts/lnd.credentials.sh sync + echo "Press ENTER to return to main menu." + read key + exit 0;; + EXPORT) + sudo /home/admin/config.scripts/lnd.export.sh + exit 0;; + + BISQ) + OPTIONS=() + if [ $(grep -c "peerbloomfilters=1" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ]||\ + [ $(grep -c Bisq < /etc/tor/torrc) -eq 0 ];then + OPTIONS+=(ADDBISQ "Add a Hidden Service for Bisq") + fi + if [ $(grep -c "peerbloomfilters=1" < /mnt/hdd/bitcoin/bitcoin.conf) -gt 0 ]&&\ + [ $(grep -c Bisq < /etc/tor/torrc) -gt 0 ];then + OPTIONS+=(SHOWBISQ "Show the Hidden Service to connect Bisq") + OPTIONS+=(REMOVEBISQ "Remove the Hidden Service for bisq") + fi + CHOICE=$(dialog --clear \ + --backtitle "" \ + --title "Connect Bisq" \ + --ok-label "Select" \ + --cancel-label "Cancel" \ + --menu "" \ + 8 64 2 \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + + case $CHOICE in + ADDBISQ) + clear + if [ $(grep -c "peerbloomfilters=1" < /mnt/hdd/bitcoin/bitcoin.conf) -eq 0 ] + then + echo "peerbloomfilters=1" | sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf + echo "# Restarting bitcoind" + sudo systemctl restart bitcoind + else + echo "# bitcoind is already configured with peerbloomfilters=1" + fi + + if [ $(grep -c Bisq < /etc/tor/torrc) -eq 0 ];then + echo "# Creating the Hidden Service for Bisq" + echo " +# Hidden Service for Bisq (bitcoin RPC v2) +HiddenServiceDir /mnt/hdd/tor/bisq +HiddenServiceVersion 2 +HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc + echo "# Restarting Tor" + sudo systemctl restart tor + sleep 10 + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/bisq/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo "Waiting for the Hidden Service" + sleep 10 + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/bisq/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo "# FAIL - The Hidden Service address could not be found - Tor error?" + exit 1 + fi + fi + else + echo "# The Hidden Service for Bisq is already configured" + fi + echo + echo "Install from https://bisq.network/downloads/" + echo "Go to Bisq Settings -> Network Info -> 'Custom Bitcoin Node'." + echo + echo "Enter: ${TOR_ADDRESS}:8333 to connect to this node." + echo + echo "Press ENTER to return to the menu." + read key + exit 0;; + REMOVEBISQ) + sudo sed -i '/Bisq/{N;N;N;d}' /etc/tor/torrc + echo "# Restarting Tor" + sudo systemctl restart tor;; + SHOWBISQ) + clear + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/bisq/hostname) + echo + echo "Install from https://bisq.network/downloads/" + echo "Go to Bisq Settings -> Network Info -> 'Custom Bitcoin Node'." + echo + echo "Enter: ${TOR_ADDRESS}:8333 to connect to this node." + echo + echo "Press ENTER to return to the menu." + read key;; + esac + ;; + ${network}RPC) + # vars + localIPrange=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\ + grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' |\ + awk -F. '{print $1"."$2"."$3".0/24"}') + localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\ + grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf) + bindIP=$(grep -c "rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf) + rpcTorService=$(grep -c "HiddenServicePort 8332 127.0.0.1:8332" < /etc/tor/torrc) + TorRPCaddress=$(sudo cat /mnt/hdd/tor/bitcoin8332/hostname) + + # menu + OPTIONS=() + if [ $allowIPrange -eq 0 ]&&\ + [ $bindIP -eq 0 ]&&\ + [ $rpcTorService -eq 0 ];then + OPTIONS+=(ADDRPCLAN "Accept local connections to ${network} RPC") + OPTIONS+=(ADDRPCTOR "Add a Hidden Service to connect to ${network} RPC") + else + OPTIONS+=(CREDENTIALS "Show how to connect to ${network} RPC") + OPTIONS+=(REMOVERPC "Close all connections to ${network} RPC") + if [ $allowIPrange -eq 0 ]||[ $bindIP -eq 0 ];then + OPTIONS+=(ADDRPCLAN "Accept local connections to ${network} RPC") + fi + if [ $rpcTorService -eq 0 ];then + OPTIONS+=(ADDRPCTOR "Add a Hidden Service to connect to ${network} RPC") + fi + fi + CHOICE=$(dialog --clear \ + --backtitle "" \ + --title "${network} RPC" \ + --ok-label "Select" \ + --cancel-label "Cancel" \ + --menu "" 9 64 3 \ + "${OPTIONS[@]}" 2>&1 >/dev/tty) + + case $CHOICE in + ADDRPCLAN) + echo "# Make sure the bitcoind wallet is on" + /home/admin/config.scripts/network.wallet.sh on + + restartCore=0 + if [ $allowIPrange -eq 0 ]; then + echo "rpcallowip=$localIPrange" | sudo tee -a /mnt/hdd/${network}/${network}.conf + restartCore=1 + fi + if [ $bindIP -eq 0 ]; then + echo "rpcbind=$localIP" | sudo tee -a /mnt/hdd/${network}/${network}.conf + restartCore=1 + fi + if [ $restartCore = 1 ];then + echo "# Restarting ${network}d" + sudo systemctl restart ${network}d + fi + echo "# ufw allow from $localIPrange to any port 8332" + sudo ufw allow from $localIPrange to any port 8332 + ;; + ADDRPCTOR) + echo "# Make sure the bitcoind wallet is on" + /home/admin/config.scripts/network.wallet.sh on + + /home/admin/config.scripts/internet.hiddenservice.sh bitcoin8332 8332 8332 + echo + echo "The address of the local node is: $TorRPCaddress" + ;; + + CREDENTIALS) + clear + RPCUSER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-) + RPCPSW=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-) + + if [ $allowIPrange -gt 0 ]&&[ $bindIP -gt 0 ];then + echo $localIP + fi + if [ $rpcTorService -gt 0 ];then + echo $TorRPCaddress + fi + + echo "RPC username:" + echo "$RPCUSER" + echo + echo "RPC password:" + echo "$RPCPSW" + echo + if [ $allowIPrange -gt 0 ]&&[ $bindIP -gt 0 ];then + echo "Host on the local network (make sure to connect from the same network):" + echo $localIP + fi + if [ $rpcTorService -gt 0 ];then + echo "Host via Tor (make sure to connect over Tor):" + echo $TorRPCaddress + fi + echo + echo "Port:" + echo "8332" + echo + echo "More documentation at:" + echo "https://github.com/openoms/joininbox/blob/master/prepare_remote_node.md" + echo + echo + echo "Press ENTER to return to the menu." + read key + ;; + REMOVERPC) + # remove old entrysudo 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 + /home/admin/config.scripts/internet.hiddenservice.sh off bitcoin8332 + sudo sed -i "/# Hidden Service for BITCOIN RPC (mainnet, testnet, signet)/,/^\s*$/{d}" /etc/tor/torrc + + sudo ufw deny from $localIPrange to any port 8332 + restartCore=0 + if [ $allowIPrange -gt 0 ]; then + sed '/rrpcallowip=$localIPrange/d' /mnt/hdd/${network}/${network}.conf + restartCore=1 + fi + if [ $bindIP -eq 0 ]; then + sed '/rpcbind=$localIP/d' /mnt/hdd/${network}/${network}.conf + restartCore=1 + fi + if [ $restartCore = 1 ];then + echo "# Restarting ${network}d" + sudo systemctl restart ${network}d + fi + ;; + esac + ;; +esac + +# go into loop - start script from beginning to load config/start fresh +/home/admin/00mainMenu.sh diff --git a/home.admin/99lightningMenu.sh b/home.admin/99lightningMenu.sh new file mode 100644 index 000000000..37cd1a43b --- /dev/null +++ b/home.admin/99lightningMenu.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +# get raspiblitz config +echo "get raspiblitz config" +source /home/admin/raspiblitz.info +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 +HEIGHT=13 +WIDTH=64 +CHOICE_HEIGHT=7 +BACKTITLE="RaspiBlitz" +TITLE="Lightning Options" +MENU="" +OPTIONS=() + +OPTIONS+=(FUNDING "Fund your LND Wallet") +OPTIONS+=(PEERING "Connect to a Peer") +OPTIONS+=(CHANNEL "Open a Channel with Peer") +OPTIONS+=(SEND "Pay an Invoice/PaymentRequest") +OPTIONS+=(RECEIVE "Create Invoice/PaymentRequest") + +if [ "${chain}" = "main" ]; then + OPTIONS+=(lnbalance "Detailed Wallet Balances") + OPTIONS+=(lnchannels "Lightning Channel List") + OPTIONS+=(lnfwdreport "Lightning Forwarding Events Report") + HEIGHT=$((HEIGHT+3)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+3)) +fi + +OPTIONS+=(NAME "Change Name/Alias of Node") + +openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | jq '.[] | length') +if [ ${#openChannels} -gt 0 ] && [ ${openChannels} -gt 0 ]; then + OPTIONS+=(CLOSEALL "Close all open Channels") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) +fi + +OPTIONS+=(CASHOUT "Remove Funds from LND") + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --ok-label "Select" \ + --cancel-label "Main menu" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +case $CHOICE in + lnbalance) + clear + echo "*** YOUR SATOSHI BALANCES ***" + /home/admin/config.scripts/lnd.balance.sh ${network} + echo "Press ENTER to return to main menu." + read key + ;; + lnchannels) + clear + echo "*** YOUR LIGHTNING CHANNELS ***" + echo "" + echo "Capacity -> total sats in the channel (their side + your side)" + echo "Commit-Fee -> the fee that's charged if either side of the channel closes" + echo "Balance-Local -> sats on your side of the channel (outbound liquidity)" + echo "Balance-Remote -> sats on their side of the channel (inbound liquidity)" + echo "Fee-Base -> fixed fee (in millisatoshis) per forwarding on channel" + echo "Fee-PerMil -> amount based fee (millisatoshis per 1 satoshi) on forwarding" + /home/admin/config.scripts/lnd.channels.sh ${network} + echo "Press ENTER to return to main menu." + read key + ;; + lnfwdreport) + /home/admin/config.scripts/lnd.fwdreport.sh -menu + echo "Press ENTER to return to main menu." + read key + ;; + PEERING) + /home/admin/BBconnectPeer.sh + ;; + FUNDING) + /home/admin/BBfundWallet.sh + ;; + CASHOUT) + /home/admin/BBcashoutWallet.sh + ;; + CHANNEL) + /home/admin/BBopenChannel.sh + ;; + SEND) + /home/admin/BBpayInvoice.sh + ;; + RECEIVE) + /home/admin/BBcreateInvoice.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 /home/admin/XXshutdown.sh reboot + exit 0 + fi + ;; + CLOSEALL) + /home/admin/BBcloseAllChannels.sh + echo "Press ENTER to return to main menu." + read key + ;; +esac + +# go into loop - start script from beginning to load config/sate fresh +/home/admin/00mainMenu.sh \ No newline at end of file diff --git a/home.admin/99systemMenu.sh b/home.admin/99systemMenu.sh new file mode 100644 index 000000000..51e52d7fd --- /dev/null +++ b/home.admin/99systemMenu.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# get raspiblitz config +echo "get raspiblitz config" +source /home/admin/raspiblitz.info +source /mnt/hdd/raspiblitz.conf + +# BASIC MENU INFO +HEIGHT=12 # add 6 to CHOICE_HEIGHT + MENU lines +WIDTH=64 +CHOICE_HEIGHT=6 # 1 line / OPTIONS +BACKTITLE="RaspiBlitz" +TITLE="System Options" +MENU="" # adds lines to HEIGHT +OPTIONS=() # adds lines to HEIGHt + CHOICE_HEIGHT + +OPTIONS+=(${network}LOG "Monitor the debug.log") +OPTIONS+=(${network}CONF "Edit the bitcoin.conf") +OPTIONS+=(LNDLOG "Monitor the lnd.log") +OPTIONS+=(LNDCONF "Edit the lnd.conf") + +if [ "${runBehindTor}" == "on" ]; then + OPTIONS+=(TORLOG "Monitor the Tor Service with Nyx") + OPTIONS+=(TORRC "Edit the Tor Configuration") + HEIGHT=$((HEIGHT+2)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+2)) +fi +OPTIONS+=(CUSTOMLOG "Monitor a custom service") +OPTIONS+=(CUSTOMRESTART "Restart a custom service") +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --ok-label "Select" \ + --cancel-label "Main menu" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +case $CHOICE in + ${network}LOG) + clear + echo + echo "Will follow the /mnt/hdd/${network}/debug.log" + echo "running: 'sudo tail -n 30 -f /mnt/hdd/${network}/debug.log'" + echo + echo "Press ENTER to continue" + echo "use CTRL+C any time to abort" + read key + sudo tail -n 30 -f /mnt/hdd/${network}/debug.log;; + ${network}CONF) + if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/${network}/${network}.conf" "root" + then + whiptail \ + --title "Restart" --yes-button "Restart" --no-button "Not now" \ + --yesno "To apply the new settings ${network}d needs to restart. + Do you want to restart ${network}d now?" 10 55 + if [ $? -eq 0 ]; then + echo "# Restarting ${network}d" + sudo systemctl restart ${network}d + else + echo "# Continue without restarting." + fi + else + echo "# No change made" + fi;; + LNDLOG) + clear + echo + echo "Will follow the /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log" + echo "running 'sudo tail -n 30 -f /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log'" + echo + echo "Press ENTER to continue" + echo "use CTRL+C any time to abort" + read key + sudo tail -n 30 -f /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log;; + LNDCONF) + if /home/admin/config.scripts/blitz.setconf.sh "/mnt/hdd/lnd/lnd.conf" "root" + then + whiptail \ + --title "Restart" --yes-button "Restart" --no-button "Not now" \ + --yesno "To apply the new settings LND needs to restart. + Do you want to restart LND now?" 10 55 + if [ $? -eq 0 ]; then + echo "# Restarting LND" + sudo systemctl restart ${network}d + else + echo "# Continue without restarting." + fi + else + echo "# No change made" + fi;; + TORLOG) + sudo -u debian-tor nyx;; + TORRC) + if /home/admin/config.scripts/blitz.setconf.sh "/etc/tor/torrc" "debian-tor" + then + whiptail \ + --title "Restart" --yes-button "Restart" --no-button "Not now" \ + --yesno "To apply the new settings Tor needs to restart. + Do you want to restart Tor now?" 10 55 + if [ $? -eq 0 ]; then + echo "# Restarting tor" + sudo systemctl restart tor@default + else + echo "# Continue without restarting." + fi + else + echo "# No change made" + fi;; + CUSTOMLOG) + clear + echo + echo "Example list: +btc-rpc-explorer, btcpayserver, circuitbreaker, +cryptoadvance-specter, getty@tty1, electrs, lit, +lnbits, mempool, nbxlorer, nginx, RTL, telegraf, +thunderhub, tor@default, tor@lnd, tor +" + echo "Type the name of the service you would like to monitor:" + read SERVICE + echo + echo "Will use the command 'sudo journalctl -n 100 -fu $SERVICE'" + echo + echo "Press ENTER to continue" + echo "use CTRL+C any time to abort" + sudo journalctl -n 100 -fu $SERVICE;; + CUSTOMRESTART) + clear + echo + echo "Example list: +btc-rpc-explorer, btcpayserver, circuitbreaker, +cryptoadvance-specter, getty@tty1, electrs, lit, +lnbits, mempool, nbxlorer, nginx, RTL, telegraf, +thunderhub, tor@default, tor@lnd, tor +" + echo "Type the name of the service you would like to restart:" + read SERVICE + echo + echo "Will run: 'sudo systemctl restart $SERVICE'" + echo + echo "Press ENTER to restart $SERVICE or use CTRL+C to abort" + read key + sudo systemctl restart $SERVICE + echo + echo "Will show the logs with: 'sudo journalctl -n 100 -fu $SERVICE'" + echo + echo "Press ENTER to continue" + echo "use CTRL+C any time to abort" + sudo journalctl -n 100 -fu $SERVICE;; +esac + +# go into loop - start script from beginning to load config/start fresh +/home/admin/00mainMenu.sh \ No newline at end of file diff --git a/home.admin/99updateMenu.sh b/home.admin/99updateMenu.sh index a00bce7ac..84cd6368b 100755 --- a/home.admin/99updateMenu.sh +++ b/home.admin/99updateMenu.sh @@ -276,37 +276,60 @@ if [ "$1" == "github" ]; then fi # Basic Options Menu +HEIGHT=9 # add 6 to CHOICE_HEIGHT + MENU lines +WIDTH=55 +CHOICE_HEIGHT=3 # 1 line / OPTIONS OPTIONS=( -RELEASE "RaspiBlitz Release Update/Recovery" \ -LND "Interim LND Update Options" \ +RELEASE "RaspiBlitz Release Update/Recovery" +LND "Interim LND Update Options" PATCH "Patch RaspiBlitz v${codeVersion}" ) if [ "${bos}" == "on" ]; then OPTIONS+=(BOS "Update Balance of Satoshis") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${thunderhub}" == "on" ]; then OPTIONS+=(THUB "Update ThunderHub") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${specter}" == "on" ]; then OPTIONS+=(SPECTER "Update Cryptoadvance Specter") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${rtlWebinterface}" == "on" ]; then OPTIONS+=(RTL "Update RTL") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${sphinxrelay}" == "on" ]; then OPTIONS+=(SPHINX "Update Sphinx Server Relay") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${pyblock}" == "on" ]; then OPTIONS+=(PYBLOCK "Update PyBLOCK") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi if [ "${runBehindTor}" == "on" ]; then OPTIONS+=(TOR "Update Tor from the source code") + HEIGHT=$((HEIGHT+1)) + CHOICE_HEIGHT=$((CHOICE_HEIGHT+1)) fi -CHOICE=$(whiptail --clear --title "Update Options" --menu "" 16 55 8 "${OPTIONS[@]}" 2>&1 >/dev/tty) +CHOICE=$(dialog --clear \ + --backtitle "" \ + --title "Update Options" \ + --ok-label "Select" \ + --cancel-label "Main menu" \ + --menu "" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" 2>&1 >/dev/tty) -clear case $CHOICE in RELEASE) release diff --git a/home.admin/config.scripts/blitz.setconf.sh b/home.admin/config.scripts/blitz.setconf.sh new file mode 100644 index 000000000..03ef823f7 --- /dev/null +++ b/home.admin/config.scripts/blitz.setconf.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +EDITFILE="$1" +USER="$2" +if [ ${#USER} -eq 0 ];then + USER="admin" +fi +if [ ${#EDITFILE} -eq 0 ]; then + echo "# Please specify a file to edit" +else + echo "Opening $EDITFILE" +fi + +# temp conf +conf=$(mktemp -p /dev/shm/) + +# trap it +trap 'rm -f $conf' 0 1 2 5 15 + +dialog \ +--title "Editing the $EDITFILE" \ +--editbox "$EDITFILE" 200 200 2> "$conf" + +# make decison +pressed=$? +case $pressed in + 0) + dialog --title "Finished editing" \ + --msgbox " +Saving to: +$EDITFILE" 7 56 + sudo -u $USER tee "$EDITFILE" 1>/dev/null < "$conf" + shred "$conf" + exit 0;; + 1) + shred "$conf" + dialog --title "Finished editing" \ + --msgbox " +Cancelled editing: +$EDITFILE" 7 56 + echo "# Cancelled" + exit 1;; + 255) + shred "$conf" + [ -s "$conf" ] && cat "$conf" || echo "ESC pressed." + exit 1;; +esac \ No newline at end of file diff --git a/home.admin/config.scripts/internet.tor.sh b/home.admin/config.scripts/internet.tor.sh index 83b357b8a..8efc72af6 100755 --- a/home.admin/config.scripts/internet.tor.sh +++ b/home.admin/config.scripts/internet.tor.sh @@ -256,13 +256,6 @@ HiddenServiceDir /mnt/hdd/tor/web80/ HiddenServiceVersion 3 HiddenServicePort 80 127.0.0.1:80 -# Hidden Service for BITCOIN RPC (mainnet, testnet, signet) -HiddenServiceDir /mnt/hdd/tor/bitcoin8332/ -HiddenServiceVersion 3 -HiddenServicePort 8332 127.0.0.1:8332 -HiddenServicePort 18332 127.0.0.1:18332 -HiddenServicePort 38332 127.0.0.1:38332 - # NOTE: since Bitcoin Core v0.21.0 sets up a v3 Tor service automatically # see /mnt/hdd/bitcoin for the onion private key - delete and restart bitcoind to reset diff --git a/home.admin/config.scripts/lnd.credentials.sh b/home.admin/config.scripts/lnd.credentials.sh index e2d59a65c..49027cd73 100755 --- a/home.admin/config.scripts/lnd.credentials.sh +++ b/home.admin/config.scripts/lnd.credentials.sh @@ -7,40 +7,6 @@ if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then exit 1 fi -# interactive choose type of action -if [ "$1" = "" ] || [ $# -eq 0 ]; then - OPTIONS=() - OPTIONS+=(RESET "Recreate Macaroons + TLS") - OPTIONS+=(SYNC "Sync with RaspiBlitz Apps/Users") - OPTIONS+=(EXPORT "Get Macaroons and TLS.cert") - CHOICE=$(dialog --clear \ - --backtitle "RaspiBlitz" \ - --title "Manage LND credentials" \ - --menu "Choose action" \ - 11 50 7 \ - "${OPTIONS[@]}" \ - 2>&1 >/dev/tty) - clear - case $CHOICE in - RESET) - sudo /home/admin/config.scripts/lnd.credentials.sh reset - echo "Press ENTER to return to main menu." - read key - exit 0 - ;; - SYNC) - sudo /home/admin/config.scripts/lnd.credentials.sh sync - echo "Press ENTER to return to main menu." - read key - exit 0 - ;; - EXPORT) - sudo /home/admin/config.scripts/lnd.export.sh - exit 0 - ;; - esac -fi - # load data from config source /mnt/hdd/raspiblitz.conf