summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..6dfe14c
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+cd "$(dirname "$0")"
+
+SERVICE_NAME="slopbot"
+SERVICE_FILE="${SERVICE_NAME}.service"
+SYSTEMD_SERVICE_PATH="/etc/systemd/system/${SERVICE_FILE}"
+NIX=(nix --extra-experimental-features 'nix-command flakes')
+
+if [[ ! -f .zuliprc ]]; then
+ echo "error: .zuliprc is missing. Copy .zuliprc.example and fill in bot credentials." >&2
+ exit 1
+fi
+
+if [[ ! -f .env ]]; then
+ cat > .env <<'EOF'
+SLOPBOT_AGENT_MODEL=parasail/kimi-k26
+SLOPBOT_WORKERS=4
+SLOPBOT_AGENT_WORKERS=1
+SLOPBOT_AGENT_TIMEOUT=120
+EOF
+ echo "created .env with slopbot defaults"
+ echo "edit .env if agent needs provider keys or config before restarting again"
+fi
+
+echo "locking local flake inputs..."
+"${NIX[@]}" flake lock
+
+echo "building slopbot..."
+"${NIX[@]}" build .#slopbot
+
+echo "installing systemd unit to ${SYSTEMD_SERVICE_PATH}..."
+sudo install -m 0644 "${SERVICE_FILE}" "${SYSTEMD_SERVICE_PATH}"
+
+echo "reloading systemd..."
+sudo systemctl daemon-reload
+
+echo "enabling and restarting ${SERVICE_NAME}..."
+sudo systemctl enable "${SERVICE_NAME}"
+sudo systemctl restart "${SERVICE_NAME}"
+
+echo "${SERVICE_NAME} status:"
+sudo systemctl --no-pager --full status "${SERVICE_NAME}"
+
+echo
+echo "follow logs with: sudo journalctl -u ${SERVICE_NAME} -f"