From 07ec866adc7d9d78cbc60b875f754b4bba66bceb Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Tue, 17 Dec 2019 18:33:18 +0000 Subject: [PATCH] services: add lndmanage (#915) --- home.admin/00settingsMenuServices.sh | 29 ++++++++++- home.admin/config.scripts/bonus.lndmanage.sh | 54 ++++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 home.admin/config.scripts/bonus.lndmanage.sh diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index 41e153aa..1dee292c 100644 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -19,6 +19,7 @@ if [ ${#touchscreen} -eq 0 ]; then touchscreen=0; fi if [ ${#lcdrotate} -eq 0 ]; then lcdrotate=0; fi if [ ${#BTCPayServer} -eq 0 ]; then BTCPayServer="off"; fi if [ ${#ElectRS} -eq 0 ]; then ElectRS="off"; fi +if [ ${#lndmanage} -eq 0 ]; then lndmanage="off"; fi echo "map chain to on/off" chainValue="off" @@ -56,7 +57,7 @@ fi echo "run dialog ..." if [ "${runBehindTor}" = "on" ]; then -CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 20 45 12 \ +CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 21 45 13 \ 1 'Channel Autopilot' ${autoPilot} \ l 'Lightning Loop' ${loop} \ 2 'Testnet' ${chainValue} \ @@ -69,9 +70,10 @@ b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ r 'LCD Rotate' ${lcdrotateMenu} \ e 'Electrum Rust Server' ${ElectRS} \ p 'BTCPayServer' ${BTCPayServer} \ +m 'lndmanage' ${lndmanage} \ 2>&1 >/dev/tty) else -CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 21 45 13 \ +CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 22 45 14 \ 1 'Channel Autopilot' ${autoPilot} \ l 'Lightning Loop' ${loop} \ 2 'Testnet' ${chainValue} \ @@ -86,6 +88,7 @@ b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ r 'LCD Rotate' ${lcdrotateMenu} \ e 'Electrum Rust Server' ${ElectRS} \ p 'BTCPayServer' ${BTCPayServer} \ +m 'lndmanage' ${lndmanage} \ 2>&1 >/dev/tty) fi @@ -122,6 +125,10 @@ if [ "${loop}" != "${choice}" ]; then echo "Loop Setting changed .." anychange=1 sudo /home/admin/config.scripts/bonus.loop.sh ${choice} + whiptail --title " Installed the Lightning Loop Service (loopd) " --msgbox "\ +Usage and examples: https://github.com/lightninglabs/loop#loop-out-swaps\n +Start from the command line by typing 'loop' to see the options. +" 10 75 needsReboot=0 else echo "Loop Setting unchanged." @@ -510,6 +517,24 @@ else echo "BTCPayServer setting not changed." fi +# 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 + sudo /home/admin/config.scripts/bonus.lndmanage.sh ${choice} + whiptail --title " Installed lndmanage " --msgbox "\ +Usage: https://github.com/bitromortac/lndmanage/blob/master/README.md\n +Start with the line: +'cd lndmanage & source venv/bin/activate & lndmanage'\n +To exit: type 'deactivate' and press ENTER +" 12 75 + needsReboot=0 +else + echo "lndmanage setting unchanged." +fi + if [ ${anychange} -eq 0 ]; then dialog --msgbox "NOTHING CHANGED!\nUse Spacebar to check/uncheck services." 8 58 exit 0 diff --git a/home.admin/config.scripts/bonus.lndmanage.sh b/home.admin/config.scripts/bonus.lndmanage.sh new file mode 100644 index 00000000..1b67f57d --- /dev/null +++ b/home.admin/config.scripts/bonus.lndmanage.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "config script to install or uninstall lndmanage" + echo "bonus.lndmanage.sh [on|off]" + exit 1 +fi + +# add default value to raspi config if needed +if [ ${#lndmanage} -eq 0 ]; then + echo "lndmanage=off" >> /mnt/hdd/raspiblitz.conf +fi + +# install +if [ "$1" = "1" ] || [ "$1" = "on" ]; then + echo "*** INSTALL LNDMANAGE ***" + mkdir lndmanage + cd lndmanage + # activate virtual environment + sudo apt install -y python3-venv + python3 -m venv venv + source venv/bin/activate + # get dependencies + sudo apt install -y python3-dev libatlas-base-dev + pip3 install wheel + pip3 install lndmanage==0.8.0.1 + + # setting value in raspi blitz config + sudo sed -i "s/^lndmanage=.*/lndmanage=on/g" /mnt/hdd/raspiblitz.conf + + echo "usage: https://github.com/bitromortac/lndmanage/blob/master/README.md" + echo "start with the line:" + echo "'cd lndmanage & source venv/bin/activate & lndmanage'" + echo "to exit type 'deactivate' and press ENTER" + + exit 0 +fi + +# switch off +if [ "$1" = "0" ] || [ "$1" = "off" ]; then + + # setting value in raspi blitz config + sudo sed -i "s/^lndmanage=.*/lndmanage=off/g" /mnt/hdd/raspiblitz.conf + + echo "*** REMOVING LNDMANAGE ***" + sudo rm -rf /home/admin/lndmanage + echo "OK, lndmanage is removed." + exit 0 + +fi + +echo "FAIL - Unknown Parameter $1" +exit 1 \ No newline at end of file