added linger

This commit is contained in:
Brad Stein 2025-06-01 21:59:43 -05:00
parent f5b2a4b813
commit 8ebb9a852b

View File

@ -1,21 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
USER=${SUDO_USER:-$(id -un)}
ORIG_USER=${SUDO_USER:-$(id -un)}
# 1. packages (Arch)
sudo pacman -Syq --needed --noconfirm git rustup protobuf gcc evtest
# 2. Rust tool-chain for both root & user
sudo rustup default stable
sudo -u "$USER" rustup default stable
sudo -u "$ORIG_USER" rustup default stable
# 3. clone / update into a user-writable dir
SRC="$HOME/.local/src/navka"
if [[ -d $SRC/.git ]]; then
sudo -u "$USER" git -C "$SRC" pull --ff-only
sudo -u "$ORIG_USER" git -C "$SRC" pull --ff-only
else
sudo -u "$USER" git clone "$PWD" "$SRC"
sudo -u "$ORIG_USER" git clone "$PWD" "$SRC"
fi
# 4. build
@ -44,8 +44,8 @@ WantedBy=default.target
EOF
# 8) (Optional) keep running when no session is active
loginctl enable-linger "$USER"
loginctl enable-linger "$ORIG_USER"
# 9) Enable + start as *you*, not root
sudo -u "$USER" systemctl --user daemon-reload
sudo -u "$USER" systemctl --user enable --now navka-client.service
sudo -u "$ORIG_USER" systemctl --user daemon-reload
sudo -u "$ORIG_USER" systemctl --user enable --now navka-client.service