#!/usr/bin/env bash # Manage this runner without changing the API/Neo4j/MCP Compose project. set -euo pipefail project_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" runner_root="$project_root/tools/git_runner" env_file="$project_root/.env" usage() { echo "Pouzitie: bash scripts/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 touch "$env_file" fi chmod 600 "$env_file" if ! grep -Eq '^[[:space:]]*(export[[:space:]]+)?RUNNER_REGISTRATION_TOKEN[[:space:]]*=' "$env_file"; then printf '\n# Gitea Actions runner\nRUNNER_REGISTRATION_TOKEN=\n' >> "$env_file" fi 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/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