summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-21 21:26:15 +0900
committerAdam Malczewski <[email protected]>2026-06-21 21:26:15 +0900
commit1049c38af2466eaa4dbb698af3cf56a4826c26c6 (patch)
tree98628f8ad9b650d7f57ca5c17e646f5579f9208b
parentc58d811e719da91e195b1fc3c29c2554c1d9b0ad (diff)
downloaddispatch-1049c38af2466eaa4dbb698af3cf56a4826c26c6.tar.gz
dispatch-1049c38af2466eaa4dbb698af3cf56a4826c26c6.zip
fix(install): write service file directly instead of sed (slashes broke it)
The sed substitution failed because the comment line contained '/' chars. Now writes the service file via heredoc with User=/Group= patched in. Also removes any previous masked service file first.
-rwxr-xr-xbin/install29
1 files changed, 26 insertions, 3 deletions
diff --git a/bin/install b/bin/install
index 99421f1..2bf6ff3 100755
--- a/bin/install
+++ b/bin/install
@@ -82,11 +82,34 @@ fi
# ─── Install systemd service ─────────────────────────────────────────────────
echo "[install] systemd service → /etc/systemd/system/"
-# Patch User=/Group= with the real user (so it doesn't run as root)
+# Detect the real user to run the service as (not root)
REAL_USER="${SUDO_USER:-$USER}"
REAL_GROUP=$(id -gn "$REAL_USER" 2>/dev/null || echo "$REAL_USER")
-sed "s/# User\/Group are set by bin/install (patched from SUDO_USER)/User=$REAL_USER\nGroup=$REAL_GROUP/" \
- "$ROOT/systemd/dispatch.service" > /etc/systemd/system/dispatch.service
+
+# Unmask if previously masked
+rm -f /etc/systemd/system/dispatch.service 2>/dev/null || true
+
+# Write the service file directly with the user patched in
+cat > /etc/systemd/system/dispatch.service << EOF
+[Unit]
+Description=Dispatch AI Agent Server
+After=network.target
+
+[Service]
+Type=simple
+User=$REAL_USER
+Group=$REAL_GROUP
+ExecStart=/usr/bin/dispatch-server
+EnvironmentFile=/etc/dispatch/env
+WorkingDirectory=/var/lib/dispatch
+Restart=on-failure
+RestartSec=5
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=multi-user.target
+EOF
chmod 644 /etc/systemd/system/dispatch.service
# ─── Config (don't overwrite if it exists) ───────────────────────────────────