feat: add --yes support to teardown scripts
This commit is contained in:
@@ -89,17 +89,6 @@ else
|
|||||||
log_success "docker-compose.yml deployed"
|
log_success "docker-compose.yml deployed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Symlink into Unraid Compose Manager plugin so it appears on the dashboard.
|
|
||||||
# Idempotent: ln -sf overwrites existing symlink. Skipped if plugin not installed.
|
|
||||||
COMPOSE_PLUGIN_PROJECTS="/boot/config/plugins/compose.manager/projects"
|
|
||||||
if ssh_exec UNRAID "test -d '${COMPOSE_PLUGIN_PROJECTS}'"; then
|
|
||||||
ssh_exec UNRAID "mkdir -p '${COMPOSE_PLUGIN_PROJECTS}/gitea' && \
|
|
||||||
ln -sf '${DATA_PATH}/docker-compose.yml' '${COMPOSE_PLUGIN_PROJECTS}/gitea/docker-compose.yml'"
|
|
||||||
log_success "Registered with Unraid Compose Manager (dashboard symlink)"
|
|
||||||
else
|
|
||||||
log_info "Compose Manager plugin not found — skipping dashboard registration"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Step 4: Render + SCP app.ini
|
# Step 4: Render + SCP app.ini
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -11,6 +11,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars UNRAID_IP UNRAID_SSH_USER UNRAID_GITEA_DATA_PATH
|
require_vars UNRAID_IP UNRAID_SSH_USER UNRAID_GITEA_DATA_PATH
|
||||||
|
|
||||||
@@ -26,9 +59,7 @@ TEARDOWN_FAILED=false
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Check if docker-compose file exists (skip if already torn down)
|
# Check if docker-compose file exists (skip if already torn down)
|
||||||
if ssh_exec UNRAID "test -f '${DATA_PATH}/docker-compose.yml'" 2>/dev/null; then
|
if ssh_exec UNRAID "test -f '${DATA_PATH}/docker-compose.yml'" 2>/dev/null; then
|
||||||
printf 'This will stop Gitea on Unraid. Continue? [y/N] '
|
if confirm_action 'This will stop Gitea on Unraid. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
# Try modern "docker compose" first, fall back to standalone
|
# Try modern "docker compose" first, fall back to standalone
|
||||||
if ssh_exec UNRAID "cd '${DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"; then
|
if ssh_exec UNRAID "cd '${DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"; then
|
||||||
log_success "Gitea container stopped and removed"
|
log_success "Gitea container stopped and removed"
|
||||||
@@ -44,9 +75,7 @@ else
|
|||||||
existing_container=$(ssh_exec UNRAID "docker ps -a --filter 'name=^/gitea$' --format '{{.ID}}'" 2>/dev/null || true)
|
existing_container=$(ssh_exec UNRAID "docker ps -a --filter 'name=^/gitea$' --format '{{.ID}}'" 2>/dev/null || true)
|
||||||
if [[ -n "$existing_container" ]]; then
|
if [[ -n "$existing_container" ]]; then
|
||||||
log_warn "docker-compose.yml not found, but gitea container still exists."
|
log_warn "docker-compose.yml not found, but gitea container still exists."
|
||||||
printf 'Force-remove gitea container directly? [y/N] '
|
if confirm_action 'Force-remove gitea container directly? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
if ssh_exec UNRAID "docker rm -f gitea" >/dev/null 2>&1; then
|
if ssh_exec UNRAID "docker rm -f gitea" >/dev/null 2>&1; then
|
||||||
log_success "Gitea container force-removed"
|
log_success "Gitea container force-removed"
|
||||||
else
|
else
|
||||||
@@ -70,9 +99,7 @@ if [[ -n "$running_container" ]]; then
|
|||||||
log_warn "Gitea container is still running — refusing to remove data directory."
|
log_warn "Gitea container is still running — refusing to remove data directory."
|
||||||
log_warn "Stop the container first, then re-run teardown to remove data."
|
log_warn "Stop the container first, then re-run teardown to remove data."
|
||||||
elif ssh_exec UNRAID "test -d '${DATA_PATH}'" 2>/dev/null; then
|
elif ssh_exec UNRAID "test -d '${DATA_PATH}'" 2>/dev/null; then
|
||||||
printf 'Remove ALL Gitea data at %s? This is IRREVERSIBLE. [y/N] ' "$DATA_PATH"
|
if confirm_action "$(printf 'Remove ALL Gitea data at %s? This is IRREVERSIBLE. [y/N] ' "$DATA_PATH")"; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
if ssh_exec UNRAID "rm -rf '${DATA_PATH}'"; then
|
if ssh_exec UNRAID "rm -rf '${DATA_PATH}'"; then
|
||||||
log_success "All Gitea data removed from Unraid"
|
log_success "All Gitea data removed from Unraid"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -11,6 +11,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars FEDORA_IP FEDORA_SSH_USER FEDORA_GITEA_DATA_PATH
|
require_vars FEDORA_IP FEDORA_SSH_USER FEDORA_GITEA_DATA_PATH
|
||||||
|
|
||||||
@@ -26,9 +59,7 @@ TEARDOWN_FAILED=false
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Check if docker-compose file exists (skip if already torn down)
|
# Check if docker-compose file exists (skip if already torn down)
|
||||||
if ssh_exec FEDORA "test -f '${DATA_PATH}/docker-compose.yml'" 2>/dev/null; then
|
if ssh_exec FEDORA "test -f '${DATA_PATH}/docker-compose.yml'" 2>/dev/null; then
|
||||||
printf 'This will stop Gitea on Fedora. Continue? [y/N] '
|
if confirm_action 'This will stop Gitea on Fedora. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
# Try modern "docker compose" first, fall back to standalone
|
# Try modern "docker compose" first, fall back to standalone
|
||||||
if ssh_exec FEDORA "cd '${DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"; then
|
if ssh_exec FEDORA "cd '${DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"; then
|
||||||
log_success "Gitea container stopped and removed"
|
log_success "Gitea container stopped and removed"
|
||||||
@@ -44,9 +75,7 @@ else
|
|||||||
existing_container=$(ssh_exec FEDORA "docker ps -a --filter 'name=^/gitea$' --format '{{.ID}}'" 2>/dev/null || true)
|
existing_container=$(ssh_exec FEDORA "docker ps -a --filter 'name=^/gitea$' --format '{{.ID}}'" 2>/dev/null || true)
|
||||||
if [[ -n "$existing_container" ]]; then
|
if [[ -n "$existing_container" ]]; then
|
||||||
log_warn "docker-compose.yml not found, but gitea container still exists."
|
log_warn "docker-compose.yml not found, but gitea container still exists."
|
||||||
printf 'Force-remove gitea container directly? [y/N] '
|
if confirm_action 'Force-remove gitea container directly? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
if ssh_exec FEDORA "docker rm -f gitea" >/dev/null 2>&1; then
|
if ssh_exec FEDORA "docker rm -f gitea" >/dev/null 2>&1; then
|
||||||
log_success "Gitea container force-removed"
|
log_success "Gitea container force-removed"
|
||||||
else
|
else
|
||||||
@@ -66,9 +95,7 @@ fi
|
|||||||
# Only removed if no containers are still attached.
|
# Only removed if no containers are still attached.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
if ssh_exec FEDORA "docker network inspect gitea_net" &>/dev/null; then
|
if ssh_exec FEDORA "docker network inspect gitea_net" &>/dev/null; then
|
||||||
printf 'Remove macvlan network gitea_net on Fedora? [y/N] '
|
if confirm_action 'Remove macvlan network gitea_net on Fedora? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
if ssh_exec FEDORA "docker network rm gitea_net" >/dev/null 2>&1; then
|
if ssh_exec FEDORA "docker network rm gitea_net" >/dev/null 2>&1; then
|
||||||
log_success "macvlan network gitea_net removed"
|
log_success "macvlan network gitea_net removed"
|
||||||
else
|
else
|
||||||
@@ -91,9 +118,7 @@ if [[ -n "$running_container" ]]; then
|
|||||||
log_warn "Gitea container is still running — refusing to remove data directory."
|
log_warn "Gitea container is still running — refusing to remove data directory."
|
||||||
log_warn "Stop the container first, then re-run teardown to remove data."
|
log_warn "Stop the container first, then re-run teardown to remove data."
|
||||||
elif ssh_exec FEDORA "test -d '${DATA_PATH}'" 2>/dev/null; then
|
elif ssh_exec FEDORA "test -d '${DATA_PATH}'" 2>/dev/null; then
|
||||||
printf 'Remove ALL Gitea data at %s on Fedora? This is IRREVERSIBLE. [y/N] ' "$DATA_PATH"
|
if confirm_action "$(printf 'Remove ALL Gitea data at %s on Fedora? This is IRREVERSIBLE. [y/N] ' "$DATA_PATH")"; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
if ssh_exec FEDORA "rm -rf '${DATA_PATH}'"; then
|
if ssh_exec FEDORA "rm -rf '${DATA_PATH}'"; then
|
||||||
log_success "All Gitea data removed from Fedora"
|
log_success "All Gitea data removed from Fedora"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -12,6 +12,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
|
|
||||||
log_warn "=== Phase 3 Teardown: Runners ==="
|
log_warn "=== Phase 3 Teardown: Runners ==="
|
||||||
@@ -32,9 +65,7 @@ FAILED=0
|
|||||||
# Step 1: Remove each runner via manage_runner.sh
|
# Step 1: Remove each runner via manage_runner.sh
|
||||||
# manage_runner.sh handles its own safety (skips already-removed runners).
|
# manage_runner.sh handles its own safety (skips already-removed runners).
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
printf 'This will stop and remove all runners. Continue? [y/N] '
|
if confirm_action 'This will stop and remove all runners. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
while IFS= read -r name; do
|
while IFS= read -r name; do
|
||||||
[[ -z "$name" ]] && continue
|
[[ -z "$name" ]] && continue
|
||||||
log_info "Removing runner: ${name}"
|
log_info "Removing runner: ${name}"
|
||||||
|
|||||||
@@ -11,6 +11,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars GITEA_ADMIN_TOKEN GITEA_BACKUP_ADMIN_TOKEN \
|
require_vars GITEA_ADMIN_TOKEN GITEA_BACKUP_ADMIN_TOKEN \
|
||||||
GITEA_INTERNAL_URL GITEA_BACKUP_INTERNAL_URL \
|
GITEA_INTERNAL_URL GITEA_BACKUP_INTERNAL_URL \
|
||||||
@@ -21,9 +54,7 @@ log_warn "=== Phase 4 Teardown: Repos + Mirrors ==="
|
|||||||
|
|
||||||
read -ra REPOS <<< "$REPO_NAMES"
|
read -ra REPOS <<< "$REPO_NAMES"
|
||||||
|
|
||||||
printf 'This will DELETE all migrated repos and mirrors. Continue? [y/N] '
|
if ! confirm_action 'This will DELETE all migrated repos and mirrors. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log_info "Teardown cancelled"
|
log_info "Teardown cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -10,6 +10,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
||||||
GITEA_ADMIN_USER \
|
GITEA_ADMIN_USER \
|
||||||
@@ -51,9 +84,7 @@ git_with_auth() {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
printf 'This will remove .gitea/workflows/ from all repos. Continue? [y/N] '
|
if ! confirm_action 'This will remove .gitea/workflows/ from all repos. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log_info "Teardown cancelled"
|
log_info "Teardown cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -11,6 +11,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
||||||
GITHUB_USERNAME GITHUB_TOKEN \
|
GITHUB_USERNAME GITHUB_TOKEN \
|
||||||
@@ -20,9 +53,7 @@ log_warn "=== Phase 6 Teardown: Push Mirrors ==="
|
|||||||
|
|
||||||
read -ra REPOS <<< "$REPO_NAMES"
|
read -ra REPOS <<< "$REPO_NAMES"
|
||||||
|
|
||||||
printf 'This will remove all push mirror configurations. Continue? [y/N] '
|
if ! confirm_action 'This will remove all push mirror configurations. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log_info "Teardown cancelled"
|
log_info "Teardown cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -10,6 +10,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
||||||
REPO_NAMES PROTECTED_BRANCH
|
REPO_NAMES PROTECTED_BRANCH
|
||||||
@@ -18,9 +51,7 @@ log_warn "=== Phase 7 Teardown: Branch Protection ==="
|
|||||||
|
|
||||||
read -ra REPOS <<< "$REPO_NAMES"
|
read -ra REPOS <<< "$REPO_NAMES"
|
||||||
|
|
||||||
printf 'This will remove branch protection for "%s" on all repos. Continue? [y/N] ' "$PROTECTED_BRANCH"
|
if ! confirm_action "$(printf 'This will remove branch protection for \"%s\" on all repos. Continue? [y/N] ' "$PROTECTED_BRANCH")"; then
|
||||||
read -r confirm
|
|
||||||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log_info "Teardown cancelled"
|
log_info "Teardown cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -12,6 +12,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars UNRAID_IP UNRAID_SSH_USER \
|
require_vars UNRAID_IP UNRAID_SSH_USER \
|
||||||
GITEA_DOMAIN CADDY_DATA_PATH \
|
GITEA_DOMAIN CADDY_DATA_PATH \
|
||||||
@@ -36,9 +69,7 @@ github_pages_http_code() {
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
CONTAINER_STATUS=$(ssh_exec UNRAID "docker ps --filter name=caddy --format '{{.Status}}'" 2>/dev/null || true)
|
CONTAINER_STATUS=$(ssh_exec UNRAID "docker ps --filter name=caddy --format '{{.Status}}'" 2>/dev/null || true)
|
||||||
if [[ "$CONTAINER_STATUS" == *"Up"* ]]; then
|
if [[ "$CONTAINER_STATUS" == *"Up"* ]]; then
|
||||||
printf 'Stop and remove Caddy container? [y/N] '
|
if confirm_action 'Stop and remove Caddy container? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
ssh_exec UNRAID "cd '${CADDY_DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"
|
ssh_exec UNRAID "cd '${CADDY_DATA_PATH}' && docker compose down 2>/dev/null || docker-compose down"
|
||||||
log_success "Caddy container stopped and removed"
|
log_success "Caddy container stopped and removed"
|
||||||
else
|
else
|
||||||
@@ -60,9 +91,7 @@ fi
|
|||||||
# Step 2: Optionally remove Caddy data (certs, config)
|
# Step 2: Optionally remove Caddy data (certs, config)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
if ssh_exec UNRAID "test -d '${CADDY_DATA_PATH}/data'" 2>/dev/null; then
|
if ssh_exec UNRAID "test -d '${CADDY_DATA_PATH}/data'" 2>/dev/null; then
|
||||||
printf 'Remove Caddy TLS data (certificates) for %s? [y/N] ' "$GITEA_DOMAIN"
|
if confirm_action "$(printf 'Remove Caddy TLS data (certificates) for %s? [y/N] ' "$GITEA_DOMAIN")"; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
ssh_exec UNRAID "rm -rf '${CADDY_DATA_PATH}/data' '${CADDY_DATA_PATH}/config'"
|
ssh_exec UNRAID "rm -rf '${CADDY_DATA_PATH}/data' '${CADDY_DATA_PATH}/config'"
|
||||||
log_success "Caddy TLS data removed"
|
log_success "Caddy TLS data removed"
|
||||||
else
|
else
|
||||||
@@ -76,9 +105,7 @@ fi
|
|||||||
# Fallback path: if snapshot is missing, restore description from "— was: ..."
|
# Fallback path: if snapshot is missing, restore description from "— was: ..."
|
||||||
# and use legacy defaults for homepage/wiki/projects.
|
# and use legacy defaults for homepage/wiki/projects.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
printf 'Restore GitHub repo settings (description/homepage/wiki/projects/pages)? [y/N] '
|
if confirm_action 'Restore GitHub repo settings (description/homepage/wiki/projects/pages)? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
STATE_AVAILABLE=false
|
STATE_AVAILABLE=false
|
||||||
if [[ -f "$PHASE8_STATE_FILE" ]]; then
|
if [[ -f "$PHASE8_STATE_FILE" ]]; then
|
||||||
STATE_AVAILABLE=true
|
STATE_AVAILABLE=true
|
||||||
|
|||||||
@@ -10,6 +10,39 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/lib/common.sh"
|
source "${SCRIPT_DIR}/lib/common.sh"
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
AUTO_YES=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes|-y) AUTO_YES=true ;;
|
||||||
|
--help|-h)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--yes, -y Skip all confirmation prompts
|
||||||
|
--help, -h Show this help
|
||||||
|
EOF
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log_error "Unknown argument: $arg"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
confirm_action() {
|
||||||
|
local prompt="$1"
|
||||||
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
|
log_info "Auto-confirmed (--yes): ${prompt}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
printf '%s' "$prompt"
|
||||||
|
read -r confirm
|
||||||
|
[[ "$confirm" =~ ^[Yy]$ ]]
|
||||||
|
}
|
||||||
|
|
||||||
load_env
|
load_env
|
||||||
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
require_vars GITEA_ADMIN_TOKEN GITEA_INTERNAL_URL GITEA_ORG_NAME \
|
||||||
GITEA_ADMIN_USER \
|
GITEA_ADMIN_USER \
|
||||||
@@ -52,9 +85,7 @@ git_with_auth() {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
printf 'This will remove security-scan.yml from all repos. Continue? [y/N] '
|
if ! confirm_action 'This will remove security-scan.yml from all repos. Continue? [y/N] '; then
|
||||||
read -r confirm
|
|
||||||
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
|
|
||||||
log_info "Teardown cancelled"
|
log_info "Teardown cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -70,12 +70,6 @@ if [[ "$AUTO_YES" == "false" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Export YES=true so individual teardown scripts skip their own prompts
|
|
||||||
# when --yes is passed. Each teardown script checks for interactive input,
|
|
||||||
# but when called from here with --yes, we pipe 'y' to them instead.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Teardown scripts in reverse order (9 → 1)
|
# Teardown scripts in reverse order (9 → 1)
|
||||||
# Each entry: phase_num|script_path
|
# Each entry: phase_num|script_path
|
||||||
TEARDOWNS=(
|
TEARDOWNS=(
|
||||||
@@ -105,12 +99,8 @@ for entry in "${TEARDOWNS[@]}"; do
|
|||||||
log_info ">>> Tearing down Phase ${phase_num}..."
|
log_info ">>> Tearing down Phase ${phase_num}..."
|
||||||
|
|
||||||
if [[ "$AUTO_YES" == "true" ]]; then
|
if [[ "$AUTO_YES" == "true" ]]; then
|
||||||
# Feed unlimited 'y' responses via process substitution.
|
# Pass --yes through to each teardown script so prompts are skipped.
|
||||||
# A pipeline (yes | script) would break under pipefail: when the script
|
if "${SCRIPT_DIR}/${script}" --yes; then
|
||||||
# finishes and closes stdin, `yes` gets SIGPIPE (exit 141), making the
|
|
||||||
# pipeline report failure even though the teardown succeeded.
|
|
||||||
# Process substitution avoids this — only the script's exit code matters.
|
|
||||||
if "${SCRIPT_DIR}/${script}" < <(yes); then
|
|
||||||
PASS=$((PASS + 1))
|
PASS=$((PASS + 1))
|
||||||
else
|
else
|
||||||
log_warn "Phase ${phase_num} teardown had issues (continuing)"
|
log_warn "Phase ${phase_num} teardown had issues (continuing)"
|
||||||
|
|||||||
Reference in New Issue
Block a user