enable linger in script

This commit is contained in:
shocknet-justin 2025-12-15 13:18:24 -05:00
parent 9b2c71cf16
commit 8d2d2beddc
2 changed files with 9 additions and 3 deletions

View file

@ -12,7 +12,7 @@ log() {
echo "$message" | sed 's/\\e\[[0-9;]*m//g' >> "$TMP_LOG_FILE"
}
SCRIPT_VERSION="0.3.0"
SCRIPT_VERSION="0.3.1"
REPO="shocknet/Lightning.Pub"
BRANCH="master"
@ -181,14 +181,14 @@ detect_os_arch
# Define installation paths based on user
if [ "$(id -u)" -eq 0 ]; then
IS_ROOT=true
export IS_ROOT=true
# For root, install under /opt for system-wide access
export INSTALL_DIR="/opt/lightning_pub"
export UNIT_DIR="/etc/systemd/system"
export SYSTEMCTL_CMD="systemctl"
log "Running as root: App will be installed in $INSTALL_DIR"
else
IS_ROOT=false
export IS_ROOT=false
export INSTALL_DIR="$HOME/lightning_pub"
export UNIT_DIR="$HOME/.config/systemd/user"
export SYSTEMCTL_CMD="systemctl --user"

View file

@ -15,6 +15,12 @@ start_services() {
if [ "$OS" = "Linux" ]; then
if [ "$SYSTEMCTL_AVAILABLE" = true ]; then
# Enable linger for user services so they persist after logout
if [ "$IS_ROOT" = false ] && command -v loginctl &> /dev/null; then
log "Enabling linger for user services to persist after logout..."
loginctl enable-linger || log "Warning: Failed to enable linger. Services may stop after logout."
fi
mkdir -p "$UNIT_DIR"
# Check and create lnd.service if needed (only if it doesn't exist)