summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/deploy.sh b/deploy.sh
index 5517f94..a679cf2 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -5,7 +5,8 @@ cd "$(dirname "$0")"
SERVICE_NAME="slopbot"
SERVICE_FILE="${SERVICE_NAME}.service"
-SYSTEMD_SERVICE_PATH="/etc/systemd/system/${SERVICE_FILE}"
+SYSTEMD_USER_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
+SYSTEMD_SERVICE_PATH="${SYSTEMD_USER_DIR}/${SERVICE_FILE}"
NIX=(nix --extra-experimental-features 'nix-command flakes')
if [[ ! -f .zuliprc ]]; then
@@ -35,18 +36,20 @@ echo "locking local flake inputs..."
echo "building slopbot..."
"${NIX[@]}" build .#slopbot
-echo "installing systemd unit to ${SYSTEMD_SERVICE_PATH}..."
-sudo install -m 0644 "${SERVICE_FILE}" "${SYSTEMD_SERVICE_PATH}"
+echo "installing user systemd unit to ${SYSTEMD_SERVICE_PATH}..."
+mkdir -p "${SYSTEMD_USER_DIR}"
+install -m 0644 "${SERVICE_FILE}" "${SYSTEMD_SERVICE_PATH}"
-echo "reloading systemd..."
-sudo systemctl daemon-reload
+echo "reloading user systemd..."
+systemctl --user daemon-reload
echo "enabling and restarting ${SERVICE_NAME}..."
-sudo systemctl enable "${SERVICE_NAME}"
-sudo systemctl restart "${SERVICE_NAME}"
+systemctl --user enable "${SERVICE_NAME}"
+systemctl --user restart "${SERVICE_NAME}"
echo "${SERVICE_NAME} status:"
-sudo systemctl --no-pager --full status "${SERVICE_NAME}"
+systemctl --user --no-pager --full status "${SERVICE_NAME}"
echo
-echo "follow logs with: sudo journalctl -u ${SERVICE_NAME} -f"
+echo "follow logs with: journalctl --user -u ${SERVICE_NAME} -f"
+echo "to keep it running after logout, run once: sudo loginctl enable-linger $USER"