raspiblitz/home.admin/config.scripts/blitz.shutdown.sh
/rootzoll 9d23c63c38
#3313 & #3230 lndg final (#3506)
* Integrate LNDg to Raspiblitz (#3313)

* cl.hsmtool: fix password display

* add clearnet fallback for tor keys

* fix CLN wallet reset (#3296)

* cln: unify and improve the resetWallet function
previously the old config and channel database could have been left
behind when using SEEDRESTORE and FILERESTORE
* prompt to save the wallet password for backup

* change default branch to v1.8 (#3306)

* Adds install script for LNDg (https://github.com/cryptosharks131/lndg)

Install script creates user lndg and installs LNDg in /home/lndg/lndg,
uses systemd for the backend, and uses nginx and uwsgi for the gui.

Install script will check for tor and enable tor
if "run behind tor" is on.

Updates menu settings for easy access to the script settings

* Creates bonus.lndg.sh script for installing LNDg
Adds LNDg to list of apps in "SERVICES"
Adds LNDg to UPDATES when installed
Adds LNDg to menu when installed

Fixed typos/errors, tested and works!

* LNDg menu install. Added ssl, ssl over tor, and standardized nginx files. Tests Good.

* FAQ.cln: poncho, CLN cheatsheet, extract privkey

* #3286 fix loca IP

* fix #3312

* fix lnbits update options (#3307)

* Integrates LNDg to Raspiblitz
Fixes issues with python and python3 (see comments on PR).
Adds option to keep or delete database on both uninstall and install with existing database.

Fixes issues with python and python3 (see comments on PR).
Adds option to keep or delete database on both uninstall and install with existing database.

Update 00settingsMenuServices.sh

Update info menu for LNDg

Adds username and instructions on how to change username

* Update bonus.lndg.sh

* Install LNDg script
Forces yes on install question

* Update blitz.shutdown.sh

* Update bonus.lndg.sh

* Update bonus.lndg.sh

* Update bonus.lndg.sh

* Update bonus.lndg.sh

Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: Dipun Mistry <dipunm@gmail.com>
Co-authored-by: rootzoll <christian@geektank.de>

* added documentation

* #3230 change password B

* #3230 fix to version 1.4.0

Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: Dipun Mistry <dipunm@gmail.com>
2022-12-09 21:49:44 +01:00

93 lines
2.9 KiB
Bash
Executable file

#!/bin/bash
# for reboot call: sudo /home/admin/config.scripts/blitz.shutdown.sh reboot
# use this script instead of direct shutdown command to:
# 1) give UI the info that a reboot/shutdown is now happening
# 2) shutdown/reboot in a safe way to prevent data corruption
source <(/home/admin/_cache.sh get network)
# display info
echo ""
echo "Green activity light stays dark and LCD turns white when shutdown complete."
if [ "$1" = "reboot" ]; then
shutdownParams="-h -r now"
echo "It will then reboot again automatically."
/home/admin/_cache.sh set state "reboot"
/home/admin/_cache.sh set message "$2"
else
shutdownParams="-h now"
echo "Then wait 5 seconds and disconnect power."
/home/admin/_cache.sh set state "shutdown"
/home/admin/_cache.sh set message ""
fi
# do shutdown/reboot
echo "-----------------------------------------------"
sleep 3
# stopping electRS (if installed)
echo "stop electrs - please wait .."
sudo systemctl stop electrs 2>/dev/null
# stopping LNDg (if installed)
isInstalled=$(sudo ls /etc/systemd/system/jobs-lndg.service 2>/dev/null | grep -c 'jobs-lndg.service')
if ! [ ${isInstalled} -eq 0 ]; then
echo "stop LNDg - please wait .."
sudo systemctl stop gunicorn.service 2>/dev/null
sudo systemctl stop jobs-lndg.timer 2>/dev/null
sudo systemctl stop jobs-lndg.service 2>/dev/null
sudo systemctl stop rebalancer-lndg.timer 2>/dev/null
sudo systemctl stop rebalancer-lndg.service 2>/dev/null
sudo systemctl stop htlc-stream-lndg.service 2>/dev/null
fi
# stopping lightning
echo "stop lightning - please wait .."
sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop lightningd 2>/dev/null
sudo systemctl stop tlnd 2>/dev/null
sudo systemctl stop tlightningd 2>/dev/null
sudo systemctl stop slnd 2>/dev/null
sudo systemctl stop slightningd 2>/dev/null
if [ "${network}" != "" ]; then
# stopping bitcoin (thru cli)
echo "stop ${network}d (1) - please wait .."
timeout 10 sudo -u bitcoin ${network}-cli stop 2>/dev/null
# stopping bitcoind (thru systemd)
echo "stop ${network}d (2) - please wait .."
sudo systemctl stop ${network}d 2>/dev/null
sudo systemctl stop t${network}d 2>/dev/null
sudo systemctl stop s${network}d 2>/dev/null
sleep 3
else
echo "skipping stopping layer1 (network=='' in cache)"
fi
# make sure drives are synced before shutdown
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${isBTRFS}" == "1" ] && [ "${isMounted}" == "1" ]; then
echo "STARTING BTRFS RAID DATA CHECK ..."
sudo btrfs scrub start /mnt/hdd/
fi
sync
echo "starting shutdown ..."
sudo shutdown ${shutdownParams}
# detect missing DBUS
if [ "${DBUS_SESSION_BUS_ADDRESS}" == "" ]; then
echo "WARN: Missing \$DBUS_SESSION_BUS_ADDRESS .. "
if [ "$1" = "reboot" ]; then
echo "RUNNING FALLBACK REBOOT .. "
sudo systemctl --force --force reboot
else
echo "RUNNING FALLBACK SHUTDOWN .. "
sudo systemctl --force --force poweroff
fi
fi
exit 0