dp-zp-agent/scripts/git_runner/runner.sh
2026-11-06 00:18:38 +01:00

55 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# Manage this runner without changing the API/Neo4j/MCP Compose project.
set -euo pipefail
runner_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
env_file="$runner_root/.env"
usage() {
echo "Pouzitie: bash scripts/git_runner/runner.sh {init|up|status|logs|stop}"
}
if [[ $# -ne 1 ]]; then
usage
exit 64
fi
if [[ "$1" == "init" ]]; then
umask 077
mkdir -p "$runner_root/data"
chmod 700 "$runner_root/data"
if [[ ! -e "$env_file" ]]; then
cp "$runner_root/runner.env.example" "$env_file"
fi
chmod 600 "$env_file"
echo "Vypln RUNNER_REGISTRATION_TOKEN v $env_file a potom spusti prikaz up."
exit 0
fi
case "$1" in
up|status|logs|stop) ;;
-h|--help) usage; exit 0 ;;
*) usage; exit 64 ;;
esac
if [[ ! -f "$env_file" ]]; then
echo "Najprv spusti: bash scripts/git_runner/runner.sh init" >&2
exit 1
fi
compose=(docker --context "${ZP_DOCKER_CONTEXT:-default}" compose
--project-name zp-git-runner --project-directory "$runner_root"
--env-file "$env_file" -f "$runner_root/compose.yml")
case "$1" in
up)
chmod 600 "$env_file"
"${compose[@]}" config --quiet
"${compose[@]}" up -d
"${compose[@]}" ps
;;
status) "${compose[@]}" ps ;;
logs) "${compose[@]}" logs --tail 50 runner ;;
stop) "${compose[@]}" stop runner ;;
esac