raspiblitz/home.admin/00settingsMenuServices.sh

373 lines
13 KiB
Bash
Raw Normal View History

#!/bin/bash
# get raspiblitz config
2019-01-18 23:38:36 +01:00
echo "get raspiblitz config"
2019-02-02 23:49:04 +01:00
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
2019-02-02 23:49:04 +01:00
2019-01-18 23:38:36 +01:00
echo "services default values"
2019-12-14 01:26:10 +00:00
if [ ${#loop} -eq 0 ]; then loop="off"; fi
2018-12-02 23:08:20 +01:00
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi
if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi
2020-03-16 15:11:39 +01:00
if [ ${#specter} -eq 0 ]; then specter="off"; fi
2019-12-04 08:13:21 +00:00
if [ ${#BTCPayServer} -eq 0 ]; then BTCPayServer="off"; fi
if [ ${#ElectRS} -eq 0 ]; then ElectRS="off"; fi
2019-12-17 18:33:18 +00:00
if [ ${#lndmanage} -eq 0 ]; then lndmanage="off"; fi
2020-03-24 14:31:25 +00:00
if [ ${#joinmarket} -eq 0 ]; then joinmarket="off"; fi
2020-04-23 23:13:09 +02:00
if [ ${#LNBits} -eq 0 ]; then LNBits="off"; fi
2020-05-15 20:02:35 +02:00
if [ ${#faraday} -eq 0 ]; then faraday="off"; fi
2020-05-18 15:25:39 +01:00
if [ ${#bos} -eq 0 ]; then bos="off"; fi
2020-06-01 11:52:40 +01:00
if [ ${#thunderhub} -eq 0 ]; then thunderhub="off"; fi
2020-03-21 23:26:45 -07:00
# show select dialog
2019-01-18 23:38:36 +01:00
echo "run dialog ..."
2019-06-14 00:25:49 +02:00
2020-06-18 00:18:42 +02:00
OPTIONS=()
OPTIONS+=(l 'Lightning Loop' ${loop})
2020-06-18 00:43:39 +02:00
OPTIONS+=(r 'RTL Webinterface' ${rtlWebinterface})
2020-06-18 00:18:42 +02:00
OPTIONS+=(b 'BTC-RPC-Explorer' ${BTCRPCexplorer})
OPTIONS+=(s 'Cryptoadvance Specter' ${specter})
OPTIONS+=(e 'Electrum Rust Server' ${ElectRS})
OPTIONS+=(p 'BTCPayServer' ${BTCPayServer})
OPTIONS+=(m 'lndmanage' ${lndmanage})
OPTIONS+=(f 'Faraday' ${faraday})
OPTIONS+=(o 'Balance of Satoshis' ${bos})
OPTIONS+=(t 'ThunderHub' ${thunderhub})
OPTIONS+=(i 'LNbits' ${LNBits})
OPTIONS+=(j 'JoinMarket' ${joinmarket})
CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 20 45 12 "${OPTIONS[@]}" 2>&1 >/dev/tty)
2019-06-14 00:25:49 +02:00
2018-10-16 00:04:20 +02:00
dialogcancel=$?
2019-01-18 23:38:36 +01:00
echo "done dialog"
clear
# check if user canceled dialog
2019-01-18 23:38:36 +01:00
echo "dialogcancel(${dialogcancel})"
2018-10-16 00:04:20 +02:00
if [ ${dialogcancel} -eq 1 ]; then
echo "user canceled"
exit 1
elif [ ${dialogcancel} -eq 255 ]; then
echo "ESC pressed"
exit 1
fi
2018-12-01 20:25:33 +01:00
needsReboot=0
2019-02-11 19:59:09 +01:00
anychange=0
2018-12-01 20:25:33 +01:00
2020-01-23 11:15:46 +01:00
# LOOP process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "l")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${loop}" != "${choice}" ]; then
echo "Loop Setting changed .."
anychange=1
2020-03-22 19:52:31 -07:00
needsReboot=1 # always reboot so that RTL gets restarted to show/hide support loop
2020-01-23 11:15:46 +01:00
/home/admin/config.scripts/bonus.loop.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start loopd
2020-01-26 23:06:03 +01:00
/home/admin/config.scripts/bonus.loop.sh menu
2020-01-23 11:15:46 +01:00
else
l1="FAILED to install Lightning LOOP"
l2="Try manual install in the terminal with:"
l3="/home/admin/config.scripts/bonus.loop.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
2020-01-23 11:15:46 +01:00
echo "Loop Setting unchanged."
fi
2018-12-02 19:52:01 +01:00
# RTL process choice
2020-06-18 00:43:39 +02:00
choice="off"; check=$(echo "${CHOICES}" | grep -c "r")
2018-12-02 19:52:01 +01:00
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${rtlWebinterface}" != "${choice}" ]; then
echo "RTL Webinterface Setting changed .."
2019-02-18 11:32:27 +01:00
anychange=1
/home/admin/config.scripts/bonus.rtl.sh ${choice}
2019-03-13 18:13:49 +01:00
errorOnInstall=$?
2018-12-03 23:25:55 +01:00
if [ "${choice}" = "on" ]; then
2019-03-13 18:13:49 +01:00
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start RTL
2020-01-26 23:41:28 +01:00
echo "waiting 10 secs .."
sleep 10
2020-01-26 23:35:02 +01:00
/home/admin/config.scripts/bonus.rtl.sh menu
2019-03-13 18:13:49 +01:00
else
l1="!!! FAIL on RTL install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.rtl.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
2019-03-13 18:13:49 +01:00
fi
2018-12-02 19:52:01 +01:00
fi
2018-12-02 23:50:14 +01:00
else
2018-12-02 19:52:01 +01:00
echo "RTL Webinterface Setting unchanged."
2018-12-01 22:24:32 +01:00
fi
# BTC-RPC-Explorer process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "b")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${BTCRPCexplorer}" != "${choice}" ]; then
echo "RTL Webinterface Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.btc-rpc-explorer.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo sytemctl start btc-rpc-explorer
2020-01-27 02:26:45 +01:00
whiptail --title " Installed BTC-RPC-Explorer " --msgbox "\
The txindex may need to be created before BTC-RPC-Explorer can be active.\n
This can take ~7 hours on a RPi4 with SSD. Monitor the progress on the LCD.\n
When finished use the new 'EXPLORE' entry in Main Menu for more info.\n
" 14 50
2020-01-23 11:20:43 +01:00
needsReboot=1
else
l1="!!! FAIL on BTC-RPC-Explorer install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.btc-rpc-explorer.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "BTC-RPC-Explorer Setting unchanged."
fi
2020-03-16 15:11:39 +01:00
# cryptoadvance Specter process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "s")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${specter}" != "${choice}" ]; then
echo "Cryptoadvance Specter Setting changed .."
anychange=1
/home/admin/config.scripts/bonus.cryptoadvance-specter.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start cryptoadvance-specter
2020-03-16 15:11:39 +01:00
/home/admin/config.scripts/bonus.cryptoadvance-specter.sh menu
else
l1="!!! FAIL on Cryptoadvance Specter install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.cryptoadvance-specter.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
else
echo "Cryptoadvance Specter Setting unchanged."
fi
# ElectRS process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "e")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${ElectRS}" != "${choice}" ]; then
echo "ElectRS Setting changed .."
anychange=1
2020-01-27 23:55:12 +01:00
extraparameter=""
if [ "${choice}" = "on" ]; then
# check on HDD size
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${hddGigaBytes} -lt 800 ]; then
whiptail --title " HDD/SSD TOO SMALL " --msgbox "\
Since v1.5 we recommend at least a 1TB HDD/SSD if you want to run ElectRS.\n
This is due to the eletcrum index that will grow over time and needs space.\n
To migrate to a bigger HDD/SSD check RaspiBlitz README on 'migration'.\n
" 14 50
else
/home/admin/config.scripts/bonus.electrs.sh on ${extraparameter}
errorOnInstall=$?
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start electrs
whiptail --title " Installed ElectRS Server " --msgbox "\
The index database needs to be created before Electrum Server can be used.\n
This can take hours/days depending on your RaspiBlitz. Monitor the progress on the LCD.\n
When finished use the new 'ELECTRS' entry in Main Menu for more info.\n
" 14 50
else
l1="!!! FAIL on ElectRS install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.electrs.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
fi
2020-01-27 23:55:12 +01:00
if [ "${choice}" = "off" ]; then
whiptail --title "Delete Electrum Index?" \
--yes-button "Keep Index" \
--no-button "Delete Index" \
--yesno "ElectRS is getting uninstalled. Do you also want to delete the Electrum Index? It contains no important data, but can take multiple hours to rebuild if needed again." 10 60
if [ $? -eq 1 ]; then
extraparameter="deleteindex"
fi
/home/admin/config.scripts/bonus.electrs.sh off ${extraparameter}
fi
else
echo "ElectRS Setting unchanged."
fi
2019-12-04 08:13:21 +00:00
# BTCPayServer process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "p")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${BTCPayServer}" != "${choice}" ]; then
echo "BTCPayServer setting changed .."
2020-03-22 22:47:36 -07:00
# check if TOR is installed
source /mnt/hdd/raspiblitz.conf
2020-03-22 23:34:26 -07:00
if [ "${choice}" = "on" ] && [ "${runBehindTor}" = "off" ]; then
2020-03-22 22:47:36 -07:00
whiptail --title " BTCPayServer needs TOR " --msgbox "\
At the moment the BTCPayServer on the RaspiBlitz needs TOR.\n
2020-03-22 23:36:57 -07:00
Please activate TOR in SERVICES first.\n
2020-03-22 23:15:27 -07:00
Then try activating BTCPayServer again in SERVICES.\n
2020-03-22 23:36:57 -07:00
" 13 42
2020-03-22 22:47:36 -07:00
else
anychange=1
/home/admin/config.scripts/bonus.btcpayserver.sh ${choice} tor
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
source /home/btcpay/.btcpayserver/Main/settings.config
2020-03-22 23:34:26 -07:00
whiptail --title " Installed BTCPay Server " --msgbox "\
2020-01-27 06:44:10 +01:00
BTCPay server was installed.\n
Use the new 'BTCPay' entry in Main Menu for more info.\n
" 10 35
2020-03-22 22:47:36 -07:00
else
l1="BTCPayServer installation is cancelled"
l2="Try again from the menu or install from the terminal with:"
l3="/home/admin/config.scripts/bonus.btcpayserver.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
2019-12-04 08:13:21 +00:00
fi
fi
else
echo "BTCPayServer setting not changed."
fi
2019-12-17 18:33:18 +00:00
# LNDMANAGE process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "m")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${lndmanage}" != "${choice}" ]; then
echo "lndmanage Setting changed .."
anychange=1
2020-01-20 23:12:55 +01:00
sudo -u admin /home/admin/config.scripts/bonus.lndmanage.sh ${choice}
2020-02-19 17:05:07 +01:00
source /mnt/hdd/raspiblitz.conf
if [ "${lndmanage}" = "on" ]; then
2020-01-26 22:30:26 +01:00
sudo -u admin /home/admin/config.scripts/bonus.lndmanage.sh menu
fi
else
2019-12-17 18:33:18 +00:00
echo "lndmanage setting unchanged."
fi
2020-05-15 20:02:35 +02:00
# FARADAY process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "f")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${faraday}" != "${choice}" ]; then
echo "faraday Setting changed .."
anychange=1
sudo -u admin /home/admin/config.scripts/bonus.faraday.sh ${choice}
source /mnt/hdd/raspiblitz.conf
if [ "${faraday}" = "on" ]; then
sudo -u admin /home/admin/config.scripts/bonus.faraday.sh menu
fi
else
2020-05-15 20:02:35 +02:00
echo "faraday setting unchanged."
fi
2020-05-18 15:25:39 +01:00
# Balance of Satoshis process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "o")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${bos}" != "${choice}" ]; then
echo "Balance of Satoshis Setting changed .."
anychange=1
sudo -u admin /home/admin/config.scripts/bonus.bos.sh ${choice}
source /mnt/hdd/raspiblitz.conf
if [ "${bos}" = "on" ]; then
2020-06-01 11:52:40 +01:00
sudo -u admin /home/admin/config.scripts/bonus.bos.sh menu
2020-05-18 15:25:39 +01:00
fi
else
2020-05-18 15:25:39 +01:00
echo "Balance of Satoshis setting unchanged."
fi
2020-06-01 11:52:40 +01:00
# thunderhub process choice
2020-06-02 19:18:57 +02:00
choice="off"; check=$(echo "${CHOICES}" | grep -c "t")
2020-06-01 11:52:40 +01:00
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${thunderhub}" != "${choice}" ]; then
echo "ThunderHub Setting changed .."
2020-06-01 11:52:40 +01:00
anychange=1
/home/admin/config.scripts/bonus.thunderhub.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start thunderhub
echo "waiting 10 secs .."
sleep 10
/home/admin/config.scripts/bonus.thunderhub.sh menu
else
l1="!!! FAIL on ThunderHub install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.thunderhub.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
2020-06-01 11:52:40 +01:00
fi
2020-06-14 16:03:16 +02:00
else
2020-06-01 11:52:40 +01:00
echo "ThunderHub setting unchanged."
fi
# LNbits process choice
2020-02-10 20:46:23 +01:00
choice="off"; check=$(echo "${CHOICES}" | grep -c "i")
2020-02-10 20:44:41 +01:00
if [ ${check} -eq 1 ]; then choice="on"; fi
2020-04-23 23:10:30 +02:00
if [ "${LNBits}" != "${choice}" ]; then
echo "LNbits Setting changed .."
2020-02-10 20:44:41 +01:00
anychange=1
sudo -u admin /home/admin/config.scripts/bonus.lnbits.sh ${choice}
if [ "${choice}" = "on" ]; then
2020-02-10 21:43:35 +01:00
sudo systemctl start lnbits
2020-02-10 20:44:41 +01:00
sudo -u admin /home/admin/config.scripts/bonus.lnbits.sh menu
fi
else
2020-04-28 08:45:14 +01:00
echo "LNbits setting unchanged."
2020-02-10 20:44:41 +01:00
fi
2020-03-24 14:31:25 +00:00
# JoinMarket process choice
choice="off"; check=$(echo "${CHOICES}" | grep -c "j")
if [ ${check} -eq 1 ]; then choice="on"; fi
if [ "${joinmarket}" != "${choice}" ]; then
echo "JoinMarket setting changed .."
# check if TOR is installed
source /mnt/hdd/raspiblitz.conf
if [ "${choice}" = "on" ] && [ "${runBehindTor}" = "off" ]; then
whiptail --title " Use Tor with JoinMarket" --msgbox "\
It is highly recommended to use Tor with JoinMarket.\n
Please activate TOR in SERVICES first.\n
Then try activating JoinMarket again in SERVICES.\n
" 13 42
else
anychange=1
sudo /home/admin/config.scripts/bonus.joinmarket.sh ${choice}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo /home/admin/config.scripts/bonus.joinmarket.sh menu
else
2020-03-24 21:05:15 -07:00
whiptail --title 'FAIL' --msgbox "JoinMarket installation is cancelled\nTry again from the menu or install from the terminal with:\nsudo /home/admin/config.scripts/bonus.joinmarket.sh on" 9 65
2020-03-24 14:31:25 +00:00
fi
fi
fi
else
echo "JoinMarket not changed."
fi
2019-02-11 20:06:19 +01:00
if [ ${anychange} -eq 0 ]; then
2019-07-29 00:49:00 +02:00
dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58
2019-02-11 20:06:19 +01:00
exit 0
2019-02-11 19:59:09 +01:00
fi
2018-12-01 20:25:33 +01:00
if [ ${needsReboot} -eq 1 ]; then
2018-12-02 19:52:01 +01:00
sleep 2
2018-12-24 14:57:47 +01:00
dialog --pause "OK. System will reboot to activate changes." 8 58 8
2019-01-17 23:12:30 +01:00
clear
2018-12-24 14:57:47 +01:00
echo "rebooting .. (please wait)"
2019-01-28 16:55:51 +01:00
# stop bitcoind
sudo -u bitcoin ${network}-cli stop
sleep 4
2019-12-11 14:03:52 +01:00
sudo /home/admin/XXshutdown.sh reboot
2019-03-28 10:51:46 +08:00
fi