#!/usr/bin/env bash # Install rein-aharness claim-loop as a user systemd service (railiance01). # Run from a rein-aharness checkout ON the host: # ./deploy/scripts/install-claim-loop-user.sh set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" UNIT_DIR="${HOME}/.config/systemd/user" ENV_DIR="${HOME}/.config/rein-aharness" BIN_DIR="${HOME}/bin" mkdir -p "${UNIT_DIR}" "${ENV_DIR}" "${BIN_DIR}" # Refuse to install a service unit over accidental mutable sibling revisions. python3 "${ROOT}/scripts/verify_runtime_lock.py" cp -f "${ROOT}/deploy/systemd/rein-aharness-claim-loop.service" "${UNIT_DIR}/" # Durable env loader + k8s:// ClusterIP resolution (no port-forward) install -m 755 "${ROOT}/deploy/scripts/rein-aharness-claim" "${BIN_DIR}/rein-aharness-claim" if [[ ! -f "${ENV_DIR}/claim-loop.env" ]]; then cp "${ROOT}/deploy/systemd/claim-loop.env.example" "${ENV_DIR}/claim-loop.env" chmod 600 "${ENV_DIR}/claim-loop.env" echo "Created ${ENV_DIR}/claim-loop.env — set ACTIVITY_CORE_WORKER_TOKEN and REPO_MAP paths." else echo "Keeping existing ${ENV_DIR}/claim-loop.env" echo " Tip: migrate URLs with ${ROOT}/deploy/scripts/refresh-claim-loop-k8s-urls.sh" fi # Ensure package entrypoint exists if [[ ! -x "${ROOT}/.venv/bin/rein-aharness" ]]; then echo "error: ${ROOT}/.venv/bin/rein-aharness missing" >&2 echo "run ${ROOT}/deploy/scripts/install-pinned-runtime.sh first" >&2 exit 2 elif ! "${ROOT}/.venv/bin/python" -c 'import glas_harness, sandboxer' >/dev/null 2>&1; then echo "error: pinned profiled runtime packages are unavailable" >&2 echo "run ${ROOT}/deploy/scripts/install-pinned-runtime.sh first" >&2 exit 2 fi systemctl --user daemon-reload systemctl --user enable rein-aharness-claim-loop.service echo "Enabled. Start when env is filled:" echo " systemctl --user start rein-aharness-claim-loop.service" echo " journalctl --user -u rein-aharness-claim-loop -f" echo "llm-connect / actcore-api: use k8s:// URLs (see activity-core docs/llm-connect-host-access.md)." echo "Do not rely on kubectl port-forward for production claim-loop."