fix: centralize compose directory handling for Unraid and Fedora runners
This commit is contained in:
@@ -75,30 +75,36 @@ parse_runner_entry() {
|
|||||||
RUNNER_BOOT=$(ini_get "$RUNNERS_CONF" "$target_name" "boot" "false")
|
RUNNER_BOOT=$(ini_get "$RUNNERS_CONF" "$target_name" "boot" "false")
|
||||||
|
|
||||||
# --- Host resolution ---
|
# --- Host resolution ---
|
||||||
|
# Also resolves RUNNER_COMPOSE_DIR: centralized compose dir on unraid/fedora,
|
||||||
|
# falls back to data_path for custom/local hosts.
|
||||||
case "$RUNNER_HOST" in
|
case "$RUNNER_HOST" in
|
||||||
unraid)
|
unraid)
|
||||||
RUNNER_SSH_HOST="${UNRAID_IP:-}"
|
RUNNER_SSH_HOST="${UNRAID_IP:-}"
|
||||||
RUNNER_SSH_USER="${UNRAID_SSH_USER:-}"
|
RUNNER_SSH_USER="${UNRAID_SSH_USER:-}"
|
||||||
RUNNER_SSH_PORT="${UNRAID_SSH_PORT:-22}"
|
RUNNER_SSH_PORT="${UNRAID_SSH_PORT:-22}"
|
||||||
RUNNER_SSH_KEY="${UNRAID_SSH_KEY:-}"
|
RUNNER_SSH_KEY="${UNRAID_SSH_KEY:-}"
|
||||||
|
RUNNER_COMPOSE_DIR="${UNRAID_COMPOSE_DIR:-}/${RUNNER_NAME}"
|
||||||
;;
|
;;
|
||||||
fedora)
|
fedora)
|
||||||
RUNNER_SSH_HOST="${FEDORA_IP:-}"
|
RUNNER_SSH_HOST="${FEDORA_IP:-}"
|
||||||
RUNNER_SSH_USER="${FEDORA_SSH_USER:-}"
|
RUNNER_SSH_USER="${FEDORA_SSH_USER:-}"
|
||||||
RUNNER_SSH_PORT="${FEDORA_SSH_PORT:-22}"
|
RUNNER_SSH_PORT="${FEDORA_SSH_PORT:-22}"
|
||||||
RUNNER_SSH_KEY="${FEDORA_SSH_KEY:-}"
|
RUNNER_SSH_KEY="${FEDORA_SSH_KEY:-}"
|
||||||
|
RUNNER_COMPOSE_DIR="${FEDORA_COMPOSE_DIR:-}/${RUNNER_NAME}"
|
||||||
;;
|
;;
|
||||||
local)
|
local)
|
||||||
RUNNER_SSH_HOST="local"
|
RUNNER_SSH_HOST="local"
|
||||||
RUNNER_SSH_USER=""
|
RUNNER_SSH_USER=""
|
||||||
RUNNER_SSH_PORT=""
|
RUNNER_SSH_PORT=""
|
||||||
RUNNER_SSH_KEY=""
|
RUNNER_SSH_KEY=""
|
||||||
|
RUNNER_COMPOSE_DIR=""
|
||||||
;;
|
;;
|
||||||
custom)
|
custom)
|
||||||
RUNNER_SSH_HOST=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_host" "")
|
RUNNER_SSH_HOST=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_host" "")
|
||||||
RUNNER_SSH_USER=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_user" "")
|
RUNNER_SSH_USER=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_user" "")
|
||||||
RUNNER_SSH_PORT=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_port" "22")
|
RUNNER_SSH_PORT=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_port" "22")
|
||||||
RUNNER_SSH_KEY=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_key" "")
|
RUNNER_SSH_KEY=$(ini_get "$RUNNERS_CONF" "$target_name" "ssh_key" "")
|
||||||
|
RUNNER_COMPOSE_DIR="${RUNNER_DATA_PATH}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
log_error "Runner '$target_name': unknown host '$RUNNER_HOST' (must be unraid, fedora, local, or custom)"
|
log_error "Runner '$target_name': unknown host '$RUNNER_HOST' (must be unraid, fedora, local, or custom)"
|
||||||
@@ -331,19 +337,19 @@ add_docker_runner() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create data directory on remote host
|
# Create data + compose directories on remote host
|
||||||
runner_ssh "mkdir -p '${RUNNER_DATA_PATH}'"
|
runner_ssh "mkdir -p '${RUNNER_DATA_PATH}' '${RUNNER_COMPOSE_DIR}'"
|
||||||
|
|
||||||
# Render docker-compose template
|
# Render docker-compose template into the centralized compose dir
|
||||||
local tmpfile
|
local tmpfile
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
export RUNNER_NAME RUNNER_DATA_PATH RUNNER_LABELS_CSV RUNNER_REG_TOKEN RUNNER_DEPLOY_RESOURCES
|
export RUNNER_NAME RUNNER_DATA_PATH RUNNER_LABELS_CSV RUNNER_REG_TOKEN RUNNER_DEPLOY_RESOURCES
|
||||||
render_template "${SCRIPT_DIR}/templates/docker-compose-runner.yml.tpl" "$tmpfile" \
|
render_template "${SCRIPT_DIR}/templates/docker-compose-runner.yml.tpl" "$tmpfile" \
|
||||||
"\${ACT_RUNNER_VERSION} \${RUNNER_NAME} \${GITEA_INTERNAL_URL} \${RUNNER_REG_TOKEN} \${RUNNER_LABELS_CSV} \${RUNNER_DATA_PATH} \${RUNNER_DEPLOY_RESOURCES}"
|
"\${ACT_RUNNER_VERSION} \${RUNNER_NAME} \${GITEA_INTERNAL_URL} \${RUNNER_REG_TOKEN} \${RUNNER_LABELS_CSV} \${RUNNER_DATA_PATH} \${RUNNER_DEPLOY_RESOURCES}"
|
||||||
runner_scp "$tmpfile" "${RUNNER_DATA_PATH}/docker-compose.yml"
|
runner_scp "$tmpfile" "${RUNNER_COMPOSE_DIR}/docker-compose.yml"
|
||||||
rm -f "$tmpfile"
|
rm -f "$tmpfile"
|
||||||
|
|
||||||
# Render runner config
|
# Render runner config into the data dir (runner reads config from here)
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
# shellcheck disable=SC2090 # intentional — RUNNER_LABELS_YAML rendered via envsubst
|
# shellcheck disable=SC2090 # intentional — RUNNER_LABELS_YAML rendered via envsubst
|
||||||
export RUNNER_LABELS_YAML
|
export RUNNER_LABELS_YAML
|
||||||
@@ -353,8 +359,8 @@ add_docker_runner() {
|
|||||||
runner_scp "$tmpfile" "${RUNNER_DATA_PATH}/config.yaml"
|
runner_scp "$tmpfile" "${RUNNER_DATA_PATH}/config.yaml"
|
||||||
rm -f "$tmpfile"
|
rm -f "$tmpfile"
|
||||||
|
|
||||||
# Start the container
|
# Start the container from the compose dir
|
||||||
runner_ssh "cd '${RUNNER_DATA_PATH}' && docker compose up -d 2>/dev/null || docker-compose up -d"
|
runner_ssh "cd '${RUNNER_COMPOSE_DIR}' && docker compose up -d 2>/dev/null || docker-compose up -d"
|
||||||
log_success "Docker runner '${RUNNER_NAME}' started on ${RUNNER_HOST} (${RUNNER_SSH_HOST})"
|
log_success "Docker runner '${RUNNER_NAME}' started on ${RUNNER_HOST} (${RUNNER_SSH_HOST})"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,11 +495,11 @@ add_native_runner() {
|
|||||||
remove_docker_runner() {
|
remove_docker_runner() {
|
||||||
log_info "Removing Docker runner '${RUNNER_NAME}' from ${RUNNER_HOST} (${RUNNER_SSH_HOST})..."
|
log_info "Removing Docker runner '${RUNNER_NAME}' from ${RUNNER_HOST} (${RUNNER_SSH_HOST})..."
|
||||||
|
|
||||||
if runner_ssh "test -f '${RUNNER_DATA_PATH}/docker-compose.yml'" 2>/dev/null; then
|
if runner_ssh "test -f '${RUNNER_COMPOSE_DIR}/docker-compose.yml'" 2>/dev/null; then
|
||||||
if runner_ssh "cd '${RUNNER_DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"; then
|
if runner_ssh "cd '${RUNNER_COMPOSE_DIR}' && docker compose down 2>/dev/null || docker-compose down"; then
|
||||||
# Remove docker-compose.yml only after successful stop.
|
# Remove docker-compose.yml only after successful stop.
|
||||||
# It contains the registration token in plaintext.
|
# It contains the registration token in plaintext.
|
||||||
runner_ssh "rm -f '${RUNNER_DATA_PATH}/docker-compose.yml'" 2>/dev/null || true
|
runner_ssh "rm -f '${RUNNER_COMPOSE_DIR}/docker-compose.yml'" 2>/dev/null || true
|
||||||
log_success "Docker runner '${RUNNER_NAME}' stopped and compose file removed"
|
log_success "Docker runner '${RUNNER_NAME}' stopped and compose file removed"
|
||||||
else
|
else
|
||||||
log_error "Failed to stop Docker runner '${RUNNER_NAME}' — preserving compose file for retry"
|
log_error "Failed to stop Docker runner '${RUNNER_NAME}' — preserving compose file for retry"
|
||||||
|
|||||||
Reference in New Issue
Block a user