Files
watermaps/deploy/scripts/remote-rollback.sh
T
BuTzZ c9a20aacd7
Test and publish container images / test (push) Successful in 2m50s
Test and publish container images / publish (push) Failing after 54s
Reorganised deployment scripts and added rollback functionality. Updated documentation and workflow for container image builds.
2026-07-25 12:36:35 +02:00

62 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
WM_DEPLOY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=remote-common.sh
source "$WM_DEPLOY_DIR/scripts/remote-common.sh"
server_ipv4=""
identity_file=""
revision="previous"
usage() {
printf 'Verwendung: %s [--revision SHA|previous] [--host IPV4] [--identity DATEI] [--user BENUTZER]\n' "$0"
}
while [[ "$#" -gt 0 ]]; do
case "$1" in
--revision)
[[ "$#" -ge 2 ]] || wm_local_die "Wert für --revision fehlt."
revision="$2"
shift 2
;;
--host)
[[ "$#" -ge 2 ]] || wm_local_die "Wert für --host fehlt."
server_ipv4="$2"
shift 2
;;
--identity)
[[ "$#" -ge 2 ]] || wm_local_die "Wert für --identity fehlt."
identity_file="$2"
shift 2
;;
--user)
[[ "$#" -ge 2 ]] || wm_local_die "Wert für --user fehlt."
WATERMAPS_SSH_USER="$2"
export WATERMAPS_SSH_USER
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
wm_local_die "Unbekannte Option: $1"
;;
esac
done
[[ "$revision" == "previous" || "$revision" =~ ^[0-9a-f]{40}$ ]] ||
wm_local_die "--revision muss 'previous' oder eine vollständige Git-Commit-SHA sein."
wm_local_resolve_ssh "$server_ipv4" "$identity_file"
wm_local_wait_for_ssh
remote_prefix=""
if [[ -n "$WM_REMOTE_SUDO" ]]; then
remote_prefix="$WM_REMOTE_SUDO "
fi
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" \
"${remote_prefix}/opt/watermaps/deploy/scripts/rollback.sh '$revision'"