2019-12-17 18:33:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# command info
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
|
|
|
echo "config script to install or uninstall lndmanage"
|
2020-01-26 22:30:26 +01:00
|
|
|
echo "bonus.lndmanage.sh [on|off|menu]"
|
2019-12-17 18:33:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-19 00:40:37 +01:00
|
|
|
source /mnt/hdd/raspiblitz.conf
|
2020-01-11 09:38:17 +00:00
|
|
|
|
|
|
|
# add default value to raspi config if needed
|
|
|
|
if ! grep -Eq "^lndmanage=" /mnt/hdd/raspiblitz.conf; then
|
2019-12-17 18:33:18 +00:00
|
|
|
echo "lndmanage=off" >> /mnt/hdd/raspiblitz.conf
|
|
|
|
fi
|
|
|
|
|
2020-01-26 22:30:26 +01:00
|
|
|
# show info menu
|
|
|
|
if [ "$1" = "menu" ]; then
|
|
|
|
dialog --title " Info lndmanage " --msgbox "\n\
|
|
|
|
Usage: https://github.com/bitromortac/lndmanage/blob/master/README.md
|
|
|
|
Have at least one channel active to run it without error.\n
|
|
|
|
To start type: 'manage' in the command line.
|
|
|
|
" 9 75
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-12-17 18:33:18 +00:00
|
|
|
# install
|
|
|
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
2020-01-06 23:58:13 +01:00
|
|
|
|
2020-02-19 16:56:58 +01:00
|
|
|
if [ "${lndmanage}" == "on" ]; then
|
2020-02-19 17:03:03 +01:00
|
|
|
echo "# FAIL - LNDMANAGE already installed"
|
|
|
|
sleep 3
|
2020-01-06 23:58:13 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-17 18:33:18 +00:00
|
|
|
echo "*** INSTALL LNDMANAGE ***"
|
2020-02-19 17:06:47 +01:00
|
|
|
mkdir /home/admin/lndmanage 2>/dev/null
|
2020-01-20 23:12:55 +01:00
|
|
|
sudo chown admin:admin /home/admin/lndmanage
|
2020-01-06 23:58:13 +01:00
|
|
|
cd /home/admin/lndmanage
|
2020-02-19 16:56:58 +01:00
|
|
|
|
2019-12-17 18:33:18 +00:00
|
|
|
# activate virtual environment
|
2020-01-20 23:15:25 +01:00
|
|
|
python3 -m venv venv
|
2020-01-06 23:58:13 +01:00
|
|
|
source /home/admin/lndmanage/venv/bin/activate
|
2020-02-19 17:03:03 +01:00
|
|
|
|
2019-12-17 18:33:18 +00:00
|
|
|
# get dependencies
|
|
|
|
sudo apt install -y python3-dev libatlas-base-dev
|
2020-01-20 23:15:25 +01:00
|
|
|
python3 -m pip install wheel
|
2020-05-06 21:56:21 +02:00
|
|
|
python3 -m pip install lndmanage==0.10.0
|
2019-12-17 18:33:18 +00:00
|
|
|
|
2020-02-17 13:51:09 +01:00
|
|
|
# check if install was successfull
|
|
|
|
if [ $(python3 -m pip list | grep -c "lndmanage") -eq 0 ]; then
|
|
|
|
echo
|
2020-02-19 17:03:03 +01:00
|
|
|
echo "#!! FAIL --> Was not able to install LNDMANAGE"
|
|
|
|
echo "#!! Maybe because of internet network issues - try again later."
|
2020-02-17 13:51:09 +01:00
|
|
|
sleep 9
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-17 18:33:18 +00:00
|
|
|
# setting value in raspi blitz config
|
|
|
|
sudo sed -i "s/^lndmanage=.*/lndmanage=on/g" /mnt/hdd/raspiblitz.conf
|
|
|
|
|
2020-02-19 17:03:03 +01:00
|
|
|
echo "# usage: https://github.com/bitromortac/lndmanage/blob/master/README.md"
|
|
|
|
echo "# To start type: 'manage' in the command line."
|
|
|
|
echo "# Needs at least one channel to start without error."
|
|
|
|
echo "# To exit the venv - type 'deactivate' and press ENTER"
|
2019-12-17 18:33:18 +00:00
|
|
|
|
|
|
|
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
|
2020-02-19 17:03:03 +01:00
|
|
|
echo "# OK, lndmanage is removed."
|
2019-12-17 18:33:18 +00:00
|
|
|
exit 0
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "FAIL - Unknown Parameter $1"
|
2020-01-06 23:58:13 +01:00
|
|
|
exit 1
|