Skip to content

Repository files, collaboration, releases and project activity.

archforge-external-status / scripts/rollback.shmain
▤ scripts/rollback.sh769 bytes
16 lines · Select a line number for a permalink
1#!/usr/bin/env bash
2set -Eeuo pipefail
3[[ $EUID -eq 0 ]] || { echo 'Use sudo.' >&2;exit 1; }
4BASE=/opt/archforge-status
5[[ -f "$BASE/previous-release" ]] || { echo 'No previous release snapshot.' >&2;exit 1; }
6SNAP=$(cat "$BASE/previous-release")
7[[ "$SNAP" == "$BASE"/releases/release-* && -d "$SNAP" ]] || { echo 'Invalid rollback path.' >&2;exit 1; }
8read -rp 'Roll back application code (database remains unchanged)? Type ROLLBACK: ' ANSWER
9[[ "$ANSWER" == ROLLBACK ]] || exit 1
10systemctl stop archforge-status
11mv "$BASE/app" "$BASE/releases/undone-$(date -u +%Y%m%d-%H%M%S)"
12mv "$SNAP" "$BASE/app"
13rm -f "$BASE/previous-release"
14systemctl start archforge-status
15echo 'Rollback completed. If schema changes are incompatible, use restore.sh with a matching backup.'