2020-02-10 12:33:03 +01:00
#!/bin/bash
2020-05-02 19:56:30 +02:00
# https://github.com/lnbits/lnbits
2020-02-10 12:33:03 +01:00
# command info
if [ $# -eq 0 ] || [ " $1 " = "-h" ] || [ " $1 " = "-help" ] ; then
2020-04-22 20:57:32 +02:00
echo "small config script to switch LNbits on or off"
2020-10-14 23:25:39 +02:00
echo "bonus.lnbits.sh on [?GITHUBUSER] [?BRANCH]"
echo "bonus.lnbits.sh [off|status|menu|write-macaroons]"
echo "# DEVELOPMENT: TO SYNC WITH YOUR FORKED GITHUB-REPO"
echo "bonus.lnbits.sh github repo [GITHUBUSER] [?BRANCH]"
echo "bonus.lnbits.sh github sync"
2020-04-22 20:57:32 +02:00
exit 1
2020-02-10 12:33:03 +01:00
fi
2020-04-28 18:01:50 +02:00
source /mnt/hdd/raspiblitz.conf
2020-02-10 12:33:03 +01:00
# show info menu
if [ " $1 " = "menu" ] ; then
2020-07-14 21:04:14 +02:00
# get LNbits status info
2020-02-10 12:33:03 +01:00
echo "# collecting status info ... (please wait)"
source <( sudo /home/admin/config.scripts/bonus.lnbits.sh status)
2020-11-23 21:27:39 +01:00
# display possible problems with IP2TOR setup
2020-09-14 15:29:50 +02:00
if [ ${# ip2torWarn } -gt 0 ] ; then
2020-11-23 21:27:39 +01:00
whiptail --title " Warning " \
--yes-button "Back" \
--no-button "Continue Anyway" \
--yesno " Your IP2TOR+LetsEncrypt may have problems:\n ${ ip2torWarn } \n\nCheck if locally responding: https:// ${ localIP } : ${ httpsPort } \n\nCheck if service is reachable over Tor:\n ${ toraddress } " 14 72
if [ " $? " != "1" ] ; then
exit 0
fi
2020-09-14 15:29:50 +02:00
fi
2021-04-18 18:04:59 +02:00
text = " Local Webrowser: http:// ${ localIP } : ${ httpPort } "
2020-07-14 21:04:14 +02:00
if [ ${# publicDomain } -gt 0 ] ; then
text = " ${ text }
Public Domain: https://${ publicDomain } :${ httpsPort }
port forwarding on router needs to be active & may change port"
fi
2021-04-18 18:04:59 +02:00
text = " ${ text } \n
https://${ localIP } :${ httpsPort } with Fingerprint
${ sslFingerprintIP } "
2020-02-10 12:33:03 +01:00
2020-07-14 21:04:14 +02:00
if [ " ${ runBehindTor } " = "on" ] && [ ${# toraddress } -gt 0 ] ; then
2021-04-08 00:02:57 +02:00
/home/admin/config.scripts/blitz.display.sh qr " ${ toraddress } "
2020-07-14 21:04:14 +02:00
text = " ${ text } \n
2020-07-14 21:17:05 +02:00
TOR Browser Hidden Service address ( QR see LCD) :
2020-07-14 21:04:14 +02:00
${ toraddress } "
fi
if [ ${# ip2torDomain } -gt 0 ] ; then
2020-07-14 23:06:09 +02:00
text = " ${ text } \n
2020-07-14 21:04:14 +02:00
IP2TOR+LetsEncrypt: https://${ ip2torDomain } :${ ip2torPort }
2020-07-14 23:06:09 +02:00
SHA1 ${ sslFingerprintTOR } "
2020-07-14 21:04:14 +02:00
elif [ ${# ip2torIP } -gt 0 ] ; then
2020-07-14 22:56:20 +02:00
text = " ${ text } \n
2020-07-14 21:04:14 +02:00
IP2TOR: https://${ ip2torIP } :${ ip2torPort }
2020-07-14 21:11:59 +02:00
SHA1 ${ sslFingerprintTOR }
2020-07-14 21:04:14 +02:00
go MAINMENU > SUBSCRIBE and add LetsEncrypt HTTPS Domain"
elif [ ${# publicDomain } -eq 0 ] ; then
2020-07-14 21:10:19 +02:00
text = " ${ text } \n
2020-08-12 09:44:49 +02:00
To enable easy reachability with normal browser from the outside
2020-07-14 21:17:05 +02:00
consider adding a IP2TOR Bridge ( MAINMENU > SUBSCRIBE) ."
2020-02-10 12:33:03 +01:00
fi
2021-04-18 18:04:59 +02:00
whiptail --title " LNbits " --msgbox " ${ text } " 16 69
2020-07-14 21:04:14 +02:00
2021-04-08 00:02:57 +02:00
/home/admin/config.scripts/blitz.display.sh hide
2020-02-10 12:33:03 +01:00
echo "please wait ..."
exit 0
fi
# add default value to raspi config if needed
2020-04-23 23:21:32 +02:00
if ! grep -Eq "^LNBits=" /mnt/hdd/raspiblitz.conf; then
echo "LNBits=off" >> /mnt/hdd/raspiblitz.conf
2020-02-10 12:33:03 +01:00
fi
# status
if [ " $1 " = "status" ] ; then
2020-04-23 23:08:14 +02:00
if [ " ${ LNBits } " = "on" ] ; then
2020-02-10 12:33:03 +01:00
echo "installed=1"
2020-10-14 18:52:31 +02:00
localIP = $( ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/' )
2020-07-14 20:29:33 +02:00
echo " localIP=' ${ localIP } ' "
2021-04-18 18:04:59 +02:00
echo "httpPort='5000'"
2020-07-14 20:29:33 +02:00
echo "httpsPort='5001'"
echo " publicIP=' ${ publicIP } ' "
# check for LetsEnryptDomain for DynDns
error = ""
source <( sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $publicIP )
if [ ${# error } -eq 0 ] ; then
echo " publicDomain=' ${ domain } ' "
fi
2020-07-14 20:35:37 +02:00
sslFingerprintIP = $( openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
2020-07-14 20:29:33 +02:00
echo " sslFingerprintIP=' ${ sslFingerprintIP } ' "
toraddress = $( sudo cat /mnt/hdd/tor/lnbits/hostname 2>/dev/null)
echo " toraddress=' ${ toraddress } ' "
2020-07-14 20:35:37 +02:00
sslFingerprintTOR = $( openssl x509 -in /mnt/hdd/app-data/nginx/tor_tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
2020-07-14 20:29:33 +02:00
echo " sslFingerprintTOR=' ${ sslFingerprintTOR } ' "
# check for IP2TOR
error = ""
source <( sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $toraddress )
if [ ${# error } -eq 0 ] ; then
echo " ip2torType=' ${ ip2tor -v1 } ' "
2020-07-14 20:36:04 +02:00
echo " ip2torID=' ${ id } ' "
2020-07-14 20:29:33 +02:00
echo " ip2torIP=' ${ ip } ' "
echo " ip2torPort=' ${ port } ' "
# check for LetsEnryptDomain on IP2TOR
error = ""
source <( sudo /home/admin/config.scripts/blitz.subscriptions.letsencrypt.py domain-by-ip $ip )
if [ ${# error } -eq 0 ] ; then
echo " ip2torDomain=' ${ domain } ' "
2020-09-14 15:29:50 +02:00
domainWarning = $( sudo /home/admin/config.scripts/blitz.subscriptions.letsencrypt.py subscription-detail ${ domain } ${ port } | jq -r ".warning" )
if [ ${# domainWarning } -gt 0 ] ; then
echo " ip2torWarn=' ${ domainWarning } ' "
fi
2020-07-14 20:29:33 +02:00
fi
fi
2020-02-10 12:33:03 +01:00
# check for error
isDead = $( sudo systemctl status lnbits | grep -c 'inactive (dead)' )
if [ ${ isDead } -eq 1 ] ; then
echo "error='Service Failed'"
exit 1
fi
else
echo "installed=0"
fi
exit 0
fi
# status
if [ " $1 " = "write-macaroons" ] ; then
2020-04-22 20:57:32 +02:00
2020-02-10 12:33:03 +01:00
# make sure its run as user admin
adminUserId = $( id -u admin)
2020-02-10 12:47:33 +01:00
if [ " ${ EUID } " != " ${ adminUserId } " ] ; then
2020-02-10 12:33:03 +01:00
echo "error='please run as admin user'"
exit 1
fi
2020-05-01 11:15:32 +02:00
echo "make sure symlink to central app-data directory exists"
if ! [ [ -L "/home/lnbits/.lnd" ] ] ; then
sudo rm -rf "/home/lnbits/.lnd" # not a symlink.. delete it silently
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/lnbits/.lnd" # and create symlink
fi
# set tls.cert path (use | as separator to avoid escaping file path slashes)
2020-05-02 22:36:39 +02:00
sudo -u lnbits sed -i "s|^LND_REST_CERT=.*|LND_REST_CERT=/home/lnbits/.lnd/tls.cert|g" /home/lnbits/lnbits/.env
2020-05-01 11:15:32 +02:00
2020-05-04 14:53:58 +01:00
# set macaroon path info in .env - USING HEX IMPORT
sudo chmod 600 /home/lnbits/lnbits/.env
2020-05-04 15:32:18 +02:00
macaroonAdminHex = $( sudo xxd -ps -u -c 1000 /home/lnbits/.lnd/data/chain/${ network } /${ chain } net/admin.macaroon)
macaroonInvoiceHex = $( sudo xxd -ps -u -c 1000 /home/lnbits/.lnd/data/chain/${ network } /${ chain } net/invoice.macaroon)
macaroonReadHex = $( sudo xxd -ps -u -c 1000 /home/lnbits/.lnd/data/chain/${ network } /${ chain } net/readonly.macaroon)
sudo sed -i " s/^LND_REST_ADMIN_MACAROON=.*/LND_REST_ADMIN_MACAROON= ${ macaroonAdminHex } /g " /home/lnbits/lnbits/.env
sudo sed -i " s/^LND_REST_INVOICE_MACAROON=.*/LND_REST_INVOICE_MACAROON= ${ macaroonInvoiceHex } /g " /home/lnbits/lnbits/.env
sudo sed -i " s/^LND_REST_READ_MACAROON=.*/LND_REST_READ_MACAROON= ${ macaroonReadHex } /g " /home/lnbits/lnbits/.env
2020-05-04 14:53:58 +01:00
#echo "make sure lnbits is member of lndreadonly, lndinvoice, lndadmin"
#sudo /usr/sbin/usermod --append --groups lndinvoice lnbits
#sudo /usr/sbin/usermod --append --groups lndreadonly lnbits
#sudo /usr/sbin/usermod --append --groups lndadmin lnbits
2020-05-04 15:32:18 +02:00
# set macaroon path info in .env - USING PATH
#sudo sed -i "s|^LND_REST_ADMIN_MACAROON=.*|LND_REST_ADMIN_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/admin.macaroon|g" /home/lnbits/lnbits/.env
#sudo sed -i "s|^LND_REST_INVOICE_MACAROON=.*|LND_REST_INVOICE_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/invoice.macaroon|g" /home/lnbits/lnbits/.env
#sudo sed -i "s|^LND_REST_READ_MACAROON=.*|LND_REST_READ_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/read.macaroon|g" /home/lnbits/lnbits/.env
2020-05-02 19:39:45 +01:00
echo "# OK - macaroons written to /home/lnbits/lnbits/.env"
2020-02-10 12:33:03 +01:00
exit 0
fi
2020-10-14 23:25:39 +02:00
if [ " $1 " = "repo" ] ; then
# get github parameters
githubUser = " $2 "
if [ ${# githubUser } -eq 0 ] ; then
echo "echo='missing parameter'"
exit 1
fi
githubBranch = " $3 "
if [ ${# githubBranch } -eq 0 ] ; then
githubBranch = "master"
fi
# check if repo exists
githubRepo = " https://github.com/ ${ githubUser } /lnbits "
httpcode = $( curl -s -o /dev/null -w "%{http_code}" ${ githubRepo } )
if [ " ${ httpcode } " != "200" ] ; then
echo " # tested github repo: ${ githubRepo } "
echo "error='repo for user does not exist'"
exit 1
fi
# change origin repo of lnbits code
echo " # changing LNbits github repo( ${ githubUser } ) branch( ${ githubBranch } ) "
cd /home/lnbits/lnbits
sudo git remote remove origin
sudo git remote add origin ${ githubRepo }
sudo git fetch
sudo git checkout ${ githubBranch }
sudo git branch --set-upstream-to= origin/${ githubBranch } ${ githubBranch }
fi
if [ " $1 " = "sync" ] || [ " $1 " = "repo" ] ; then
echo "# pull all changes from github repo"
# output basic info
cd /home/lnbits/lnbits
sudo git remote -v
sudo git branch -v
# pull latest code
sudo git pull
# restart lnbits service
sudo systemctl restart lnbits
echo "# server is restarting ... maybe takes some seconds until available"
exit 0
fi
2020-02-10 12:33:03 +01:00
# stop service
echo "making sure services are not running"
sudo systemctl stop lnbits 2>/dev/null
# switch on
if [ " $1 " = "1" ] || [ " $1 " = "on" ] ; then
2020-04-22 20:57:32 +02:00
echo "*** INSTALL LNbits ***"
2020-02-10 12:33:03 +01:00
isInstalled = $( sudo ls /etc/systemd/system/lnbits.service 2>/dev/null | grep -c 'lnbits.service' )
if [ ${ isInstalled } -eq 0 ] ; then
2020-04-28 09:27:03 +01:00
echo "*** Add the 'lnbits' user ***"
sudo adduser --disabled-password --gecos "" lnbits
2020-02-10 12:33:03 +01:00
# make sure needed debian packages are installed
echo "# installing needed packages"
2020-10-14 23:25:39 +02:00
# get optional github parameter
githubUser = "lnbits"
if [ " $2 " != "" ] ; then
githubUser = " $2 "
fi
githubBranch = "tags/raspiblitz"
#githubBranch="f6bcff01f4b62ca26177f22bd2d479b01d371406"
if [ " $3 " != "" ] ; then
githubBranch = " $3 "
fi
2020-02-10 12:33:03 +01:00
2020-04-22 20:57:32 +02:00
# install from GitHub
2020-10-14 23:25:39 +02:00
echo " # get the github code user( ${ githubUser } ) branch( ${ githubBranch } ) "
2020-04-28 09:27:03 +01:00
sudo rm -r /home/lnbits/lnbits 2>/dev/null
cd /home/lnbits
2020-10-14 23:25:39 +02:00
sudo -u lnbits git clone https://github.com/${ githubUser } /lnbits.git
2020-04-28 09:27:03 +01:00
cd /home/lnbits/lnbits
2020-10-14 23:25:39 +02:00
sudo -u lnbits git checkout ${ githubBranch }
2020-04-22 20:57:32 +02:00
# prepare .env file
2020-02-10 12:33:03 +01:00
echo "# preparing env file"
2020-04-28 09:27:03 +01:00
sudo rm /home/lnbits/lnbits/.env 2>/dev/null
sudo -u lnbits touch /home/lnbits/lnbits/.env
2020-10-14 23:25:39 +02:00
sudo bash -c "echo 'QUART_APP=lnbits.app:create_app()' >> /home/lnbits/lnbits/.env"
sudo bash -c "echo 'LNBITS_FORCE_HTTPS=1' >> /home/lnbits/lnbits/.env"
2020-05-02 19:56:30 +02:00
sudo bash -c "echo 'LNBITS_BACKEND_WALLET_CLASS=LndRestWallet' >> /home/lnbits/lnbits/.env"
2020-05-02 19:54:57 +01:00
sudo bash -c "echo 'LND_REST_ENDPOINT=https://127.0.0.1:8080' >> /home/lnbits/lnbits/.env"
2020-05-02 19:56:30 +02:00
sudo bash -c "echo 'LND_REST_CERT=' >> /home/lnbits/lnbits/.env"
sudo bash -c "echo 'LND_REST_ADMIN_MACAROON=' >> /home/lnbits/lnbits/.env"
sudo bash -c "echo 'LND_REST_INVOICE_MACAROON=' >> /home/lnbits/lnbits/.env"
sudo bash -c "echo 'LND_REST_READ_MACAROON=' >> /home/lnbits/lnbits/.env"
2020-04-28 09:27:03 +01:00
/home/admin/config.scripts/bonus.lnbits.sh write-macaroons
2020-02-10 21:07:24 +01:00
# set database path to HDD data so that its survives updates and migrations
2020-04-23 08:07:49 +02:00
sudo mkdir /mnt/hdd/app-data/LNBits 2>/dev/null
2020-04-28 09:27:03 +01:00
sudo chown lnbits:lnbits -R /mnt/hdd/app-data/LNBits
2020-05-02 20:09:31 +01:00
sudo bash -c "echo 'LNBITS_DATA_FOLDER=/mnt/hdd/app-data/LNBits' >> /home/lnbits/lnbits/.env"
2020-02-10 12:33:03 +01:00
2020-02-10 14:29:28 +01:00
# to the install
2020-04-24 06:52:33 +02:00
echo "# installing application dependencies"
2020-04-28 09:27:03 +01:00
cd /home/lnbits/lnbits
2020-08-14 15:04:59 +02:00
# do install like this
2020-10-14 23:25:39 +02:00
sudo -u lnbits python3 -m venv venv
#sudo -u lnbits /home/lnbits/lnbits/venv/bin/pip install hypercorn
sudo -u lnbits ./venv/bin/pip install -r requirements.txt
# process assets
echo "# processing assets"
sudo -u lnbits ./venv/bin/quart assets
2020-07-22 21:20:34 +02:00
# update databases (if needed)
2020-04-24 06:52:33 +02:00
echo "# updating databases"
2020-10-14 23:25:39 +02:00
sudo -u lnbits ./venv/bin/quart migrate
2020-02-10 12:33:03 +01:00
# open firewall
2020-02-10 13:15:18 +01:00
echo
2020-02-10 12:33:03 +01:00
echo "*** Updating Firewall ***"
2021-04-18 18:04:59 +02:00
sudo ufw allow 5000 comment 'lnbits HTTP'
sudo ufw allow 5001 comment 'lnbits HTTPS'
2020-02-10 12:33:03 +01:00
echo ""
# install service
2020-02-10 14:29:28 +01:00
echo "*** Install systemd ***"
2020-05-23 22:17:00 +01:00
cat <<EOF | sudo tee /etc/systemd/system/lnbits.service >/dev/null
2020-02-10 18:16:55 +01:00
# systemd unit for lnbits
2020-02-10 12:33:03 +01:00
[ Unit]
Description = lnbits
Wants = lnd.service
After = lnd.service
[ Service]
2020-04-28 09:27:03 +01:00
WorkingDirectory = /home/lnbits/lnbits
2020-10-14 23:25:39 +02:00
ExecStart = /bin/sh -c 'cd /home/lnbits/lnbits && ./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 "lnbits.app:create_app()"'
2020-04-28 09:27:03 +01:00
User = lnbits
2020-02-10 12:33:03 +01:00
Restart = always
TimeoutSec = 120
RestartSec = 30
StandardOutput = null
StandardError = journal
2020-02-10 18:40:53 +01:00
[ Install]
WantedBy = multi-user.target
2020-02-10 12:33:03 +01:00
EOF
sudo systemctl enable lnbits
2020-07-19 17:56:00 +02:00
source /home/admin/raspiblitz.info
if [ " ${ state } " = = "ready" ] ; then
2020-07-19 17:56:39 +02:00
echo "# OK - lnbits service is enabled, system is on ready so starting lnbits service"
2020-07-19 17:56:00 +02:00
sudo systemctl start lnbits
else
echo "# OK - lnbits service is enabled, but needs reboot or manual starting: sudo systemctl start lnbits"
fi
2020-02-10 12:33:03 +01:00
2020-04-22 20:57:32 +02:00
else
echo "LNbits already installed."
2020-02-10 12:33:03 +01:00
fi
2020-05-23 22:34:03 +01:00
# setup nginx symlinks
2020-05-26 21:34:19 +02:00
if ! [ -f /etc/nginx/sites-available/lnbits_ssl.conf ] ; then
sudo cp /home/admin/assets/nginx/sites-available/lnbits_ssl.conf /etc/nginx/sites-available/lnbits_ssl.conf
fi
if ! [ -f /etc/nginx/sites-available/lnbits_tor.conf ] ; then
sudo cp /home/admin/assets/nginx/sites-available/lnbits_tor.conf /etc/nginx/sites-available/lnbits_tor.conf
fi
if ! [ -f /etc/nginx/sites-available/lnbits_tor_ssl.conf ] ; then
sudo cp /home/admin/assets/nginx/sites-available/lnbits_tor_ssl.conf /etc/nginx/sites-available/lnbits_tor_ssl.conf
fi
sudo ln -sf /etc/nginx/sites-available/lnbits_ssl.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/lnbits_tor.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/lnbits_tor_ssl.conf /etc/nginx/sites-enabled/
2020-05-23 22:34:03 +01:00
sudo nginx -t
sudo systemctl reload nginx
2020-02-10 12:33:03 +01:00
# setting value in raspi blitz config
2020-04-23 23:08:14 +02:00
sudo sed -i "s/^LNBits=.*/LNBits=on/g" /mnt/hdd/raspiblitz.conf
2020-04-22 20:57:32 +02:00
2020-02-10 14:29:28 +01:00
# Hidden Service if Tor is active
2020-02-10 12:33:03 +01:00
source /mnt/hdd/raspiblitz.conf
if [ " ${ runBehindTor } " = "on" ] ; then
2020-07-18 15:26:56 +02:00
# make sure to keep in sync with internet.tor.sh script
2020-05-24 17:55:48 +01:00
/home/admin/config.scripts/internet.hiddenservice.sh lnbits 80 5002 443 5003
2020-02-10 12:33:03 +01:00
fi
exit 0
fi
# switch off
if [ " $1 " = "0" ] || [ " $1 " = "off" ] ; then
2020-07-24 02:00:47 +02:00
# check for second parameter: should data be deleted?
deleteData = 0
if [ " $2 " = "--delete-data" ] ; then
deleteData = 1
elif [ " $2 " = "--keep-data" ] ; then
deleteData = 0
else
2020-10-14 23:25:39 +02:00
if ( whiptail --title " DELETE DATA? " --yesno "Do you want to delete\nthe LNbits Server Data?" 8 30) ; then
2020-07-24 02:00:47 +02:00
deleteData = 1
else
deleteData = 0
fi
fi
echo " # deleteData( ${ deleteData } ) "
2020-02-10 12:33:03 +01:00
# setting value in raspi blitz config
2020-04-23 23:08:14 +02:00
sudo sed -i "s/^LNBits=.*/LNBits=off/g" /mnt/hdd/raspiblitz.conf
2020-02-10 12:33:03 +01:00
2020-05-23 22:34:03 +01:00
# remove nginx symlinks
2020-06-11 16:29:30 +01:00
sudo rm -f /etc/nginx/sites-enabled/lnbits_ssl.conf
sudo rm -f /etc/nginx/sites-enabled/lnbits_tor.conf
sudo rm -f /etc/nginx/sites-enabled/lnbits_tor_ssl.conf
2020-06-26 22:57:12 +02:00
sudo rm -f /etc/nginx/sites-available/lnbits_ssl.conf
sudo rm -f /etc/nginx/sites-available/lnbits_tor.conf
sudo rm -f /etc/nginx/sites-available/lnbits_tor_ssl.conf
2020-05-23 22:34:03 +01:00
sudo nginx -t
sudo systemctl reload nginx
2020-07-12 20:05:41 +02:00
# Hidden Service if Tor is active
if [ " ${ runBehindTor } " = "on" ] ; then
/home/admin/config.scripts/internet.hiddenservice.sh off lnbits
fi
2020-02-10 12:33:03 +01:00
isInstalled = $( sudo ls /etc/systemd/system/lnbits.service 2>/dev/null | grep -c 'lnbits.service' )
2020-04-23 23:08:14 +02:00
if [ ${ isInstalled } -eq 1 ] || [ " ${ LNBits } " = = "on" ] ; then
2020-04-22 20:57:32 +02:00
echo "*** REMOVING LNbits ***"
2020-02-10 12:33:03 +01:00
sudo systemctl stop lnbits
sudo systemctl disable lnbits
sudo rm /etc/systemd/system/lnbits.service
2020-04-28 09:27:03 +01:00
sudo userdel -rf lnbits
2020-07-24 02:00:47 +02:00
if [ ${ deleteData } -eq 1 ] ; then
echo "# deleting data"
sudo rm -R /mnt/hdd/app-data/LNBits
else
echo "# keeping data"
fi
2020-04-22 20:57:32 +02:00
echo "OK LNbits removed."
else
echo "LNbits is not installed."
2020-02-10 12:33:03 +01:00
fi
exit 0
fi
echo " FAIL - Unknown Parameter $1 "
exit 1