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 bash2
set -Eeuo pipefail3
[[ $EUID -eq 0 ]] || { echo 'Use sudo.' >&2;exit 1; }4
BASE=/opt/archforge-status5
[[ -f "$BASE/previous-release" ]] || { echo 'No previous release snapshot.' >&2;exit 1; }6
SNAP=$(cat "$BASE/previous-release")7
[[ "$SNAP" == "$BASE"/releases/release-* && -d "$SNAP" ]] || { echo 'Invalid rollback path.' >&2;exit 1; }8
read -rp 'Roll back application code (database remains unchanged)? Type ROLLBACK: ' ANSWER9
[[ "$ANSWER" == ROLLBACK ]] || exit 110
systemctl stop archforge-status11
mv "$BASE/app" "$BASE/releases/undone-$(date -u +%Y%m%d-%H%M%S)"12
mv "$SNAP" "$BASE/app"13
rm -f "$BASE/previous-release"14
systemctl start archforge-status15
echo 'Rollback completed. If schema changes are incompatible, use restore.sh with a matching backup.'