#!/usr/bin/env bash # Install/manage the Gitea-push webhook receiver as a systemd service. # ./deploy-webhook.sh install -> generate secret, write unit, enable+start # ./deploy-webhook.sh status -> show service + last logs # ./deploy-webhook.sh secret -> print the current webhook secret (to paste into Gitea) # ./deploy-webhook.sh uninstall -> disable+remove the service # # After install: in Gitea (admin/modelTesting) → Settings → Webhooks → Add webhook: # Target URL: http://10.0.0.22:41798/hook # HTTP method: POST # Content type: application/json # Secret: (output of `./deploy-webhook.sh secret`) # Trigger on: Push events (branch: main) set -euo pipefail cd "$(dirname "$0")" UNIT=/etc/systemd/system/llm-bench-webhook.service SECRET_FILE=.webhook.secret PORT="${WEBHOOK_PORT:-41798}" case "${1:-status}" in install) # generate a fresh secret if none yet if [[ ! -f "$SECRET_FILE" ]]; then openssl rand -hex 32 > "$SECRET_FILE" chmod 600 "$SECRET_FILE" echo "generated new secret -> $SECRET_FILE" fi SECRET=$(cat "$SECRET_FILE") sudo tee "$UNIT" >/dev/null </dev/null | head -15 || echo "not installed" echo "--- recent log ---" journalctl -u llm-bench-webhook -n 10 --no-pager 2>/dev/null || true ;; secret) cat "$SECRET_FILE" ;; uninstall) sudo systemctl disable --now llm-bench-webhook 2>/dev/null || true sudo rm -f "$UNIT"; sudo systemctl daemon-reload echo "removed webhook service" ;; *) echo "usage: $0 [install|status|secret|uninstall]"; exit 1 ;; esac