summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rwxr-xr-xdeploy.sh21
-rw-r--r--slopbot.service2
3 files changed, 26 insertions, 10 deletions
diff --git a/README.md b/README.md
index 20a0bb4..020c310 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,19 @@ cp .env.example .env
python main.py
```
+Deploy as a user-level systemd service:
+
+```bash
+./deploy.sh
+journalctl --user -u slopbot -f
+```
+
+To keep the user service running after logout, run once:
+
+```bash
+sudo loginctl enable-linger $USER
+```
+
Get your `.zuliprc` from Zulip: Settings → Bots → your bot → download config.
## Architecture
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"
diff --git a/slopbot.service b/slopbot.service
index 7b582e0..0be6208 100644
--- a/slopbot.service
+++ b/slopbot.service
@@ -29,4 +29,4 @@ RestrictRealtime=true
SystemCallArchitectures=native
[Install]
-WantedBy=multi-user.target
+WantedBy=default.target