Run on the core host, on Claude Sonnet 5.5 via the Anthropic API; no Ollama
The daemon moves from WSL on the workstation to the core host, where it runs commands directly (core is the only host). One model profile, claude, with a 200k context and the existing cost caps. install.sh runs on the core host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
974abbec1d
commit
12e6fef51c
9 files changed
+263
-271
No files matched your search
+17
-20
@@ -1,15 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# install.sh — install & enable the semprini-maintainer systemd service.
|
||||
#
|
||||
# Run on the operator's workstation, in WSL (Ubuntu, systemd enabled), from
|
||||
# this checkout, as the user the service runs as (not root; sudo is used for
|
||||
# the systemd parts). Idempotent.
|
||||
# Run on the core host (ubuntu@3.107.254.151), from this checkout, as the
|
||||
# user the service runs as (ubuntu, not root; sudo is used for the systemd
|
||||
# parts). Idempotent.
|
||||
#
|
||||
# It also takes over from the daemon on the core host: the two share one
|
||||
# Matrix bot, so they must never run at once. Just before the local service
|
||||
# starts, the host's service is stopped and disabled. The host keeps its
|
||||
# checkout and its git credentials: sync-to-host.sh's `--hold` and the host's
|
||||
# own pushes still use them.
|
||||
# One Matrix bot means one daemon. If config.json's repo host is reached over
|
||||
# SSH (the daemon runs elsewhere), the service on that host is stopped and
|
||||
# disabled before this one starts. A daemon on any other machine (the
|
||||
# workstation's WSL, until 2026-11-26) must be stopped by hand first.
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -20,17 +19,15 @@ die() { echo "ERROR: $*" >&2; exit 1; }
|
||||
[ "$USER_NAME" != root ] || die "run as the service user, not root"
|
||||
|
||||
echo "→ Pre-flight checks"
|
||||
grep -qi microsoft /proc/version || echo "WARN: this does not look like WSL; carrying on"
|
||||
[ "$(ps -p 1 -o comm=)" = systemd ] ||
|
||||
die "systemd is not running: add [boot] systemd=true to /etc/wsl.conf, then wsl --shutdown"
|
||||
[ "$(ps -p 1 -o comm=)" = systemd ] || die "systemd is not running"
|
||||
for bin in python3 git ssh curl; do
|
||||
command -v "$bin" >/dev/null || die "$bin not found"
|
||||
done
|
||||
case "$DIR" in /mnt/*) echo "WARN: $DIR is on the Windows filesystem; clone into ~ for speed and file modes";; esac
|
||||
|
||||
if [ ! -f "$DIR/config.json" ]; then
|
||||
die "config.json missing. Copy config.example.json to config.json, bring the tokens
|
||||
over from the host's config.json (matrix, gitea), and adjust the paths."
|
||||
over from the previous daemon's config.json (matrix, gitea), then set the
|
||||
model's key: .venv/bin/python maintainer.py --set-api-key claude"
|
||||
fi
|
||||
chmod 600 "$DIR/config.json"
|
||||
|
||||
@@ -54,13 +51,14 @@ if sys.argv[2] == "git-credential":
|
||||
if env:
|
||||
print(cfg["gitea"]["web_base"].rstrip("/"), env["GIT_CONFIG_VALUE_2"])
|
||||
elif sys.argv[2] == "core-ssh":
|
||||
print(cfg["hosts"][cfg["repo_host"]]["ssh"])
|
||||
print(cfg["hosts"][cfg["repo_host"]].get("ssh", ""))
|
||||
else:
|
||||
print(cfg[sys.argv[2]])
|
||||
PY
|
||||
}
|
||||
|
||||
CORE="$(cfg_get core-ssh)"
|
||||
if [ -n "$CORE" ]; then
|
||||
echo "→ SSH to the core host ($CORE)"
|
||||
if ! ssh -o BatchMode=yes -o ConnectTimeout=15 "$CORE" true 2>/dev/null; then
|
||||
cat >&2 <<EOF
|
||||
@@ -73,12 +71,13 @@ Then run install.sh again.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "→ Checking maintainer.py, the config, the hosts and the models"
|
||||
"$PY" "$DIR/maintainer.py" --config "$DIR/config.json" --check
|
||||
|
||||
# The daemon's own checkout fetches from Gitea as claude-code (self-update).
|
||||
# Scoped to this repository: WSL is also the operator's shell.
|
||||
# Scoped to this repository.
|
||||
read -r WEB HELPER <<<"$(cfg_get git-credential)" || true
|
||||
if [ -n "${WEB:-}" ]; then
|
||||
echo "→ Git credential helper for $WEB, in this checkout only"
|
||||
@@ -93,6 +92,7 @@ sed -e "s|@USER@|$USER_NAME|g" -e "s|@HOME@|$HOME|g" -e "s|@DIR@|$DIR|g" \
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$UNIT"
|
||||
|
||||
if [ -n "$CORE" ]; then
|
||||
echo "→ Retiring the daemon on $CORE (one Matrix bot, one daemon)"
|
||||
ssh -o BatchMode=yes "$CORE" '
|
||||
if systemctl is-enabled --quiet semprini-maintainer 2>/dev/null ||
|
||||
@@ -102,6 +102,7 @@ ssh -o BatchMode=yes "$CORE" '
|
||||
echo " not running there"
|
||||
fi' || die "could not stop the host's daemon; stop it by hand before starting this one:
|
||||
ssh $CORE sudo systemctl disable --now semprini-maintainer"
|
||||
fi
|
||||
|
||||
sudo systemctl restart "$UNIT"
|
||||
|
||||
@@ -111,9 +112,5 @@ cat <<EOF
|
||||
Logs: journalctl -u $UNIT -f
|
||||
Status: systemctl status $UNIT (or send 'status' in Matrix)
|
||||
Stop: sudo systemctl stop $UNIT
|
||||
Model: $PY $DIR/maintainer.py --try-model local
|
||||
|
||||
WSL stops when nothing runs in it. Keep it up with a Windows scheduled task
|
||||
that starts at logon (PowerShell or cmd, one line):
|
||||
schtasks /Create /TN "WSL keep-alive" /SC ONLOGON /RL LIMITED /F /TR "wsl.exe -d Ubuntu --exec sleep infinity"
|
||||
Model: $PY $DIR/maintainer.py --try-model claude
|
||||
EOF
|
||||
Reference in new issue
Block a user