set -eu
cd "$HOME"
backup="$HOME/halabi-f17-qa-20261029/staging-code-before.tar.gz"
staging="$HOME/staging"
held="$HOME/halabi-f17-qa-20261029/staging-post-test"
test "$(sha256sum "$backup" | cut -d' ' -f1)" = 070bd26d3d5cad7f640ef7add5159feb2f4e61fde145d06b76ab459d6f63132a
mkdir -p "$held"
for rel in wp-content/plugins/bookly-responsive-appointment-booking-tool wp-content/themes/halabi/includes/identity-resolution wp-content/themes/halabi/includes/notification-language.php wp-content/mu-plugins/halabi-temporary-open-intake.php; do
  if test -e "$staging/$rel"; then
    mkdir -p "$held/$(dirname "$rel")"
    mv "$staging/$rel" "$held/$rel"
  fi
done
tar -xzf "$backup" -C "$staging" \
  wp-content/plugins/bookly-responsive-appointment-booking-tool \
  wp-content/mu-plugins/avocat-halabi-resume-fix.php \
  wp-content/themes/halabi/components/appointment-form/appointment-form.js \
  wp-content/themes/halabi/includes/practice-panther-api.php \
  wp-content/themes/halabi/modules/form-submissions/class-completion-events.php \
  wp-content/themes/halabi/modules/form-submissions/class-submissions-storage.php \
  wp-content/themes/halabi/templates/page-reservation-template.php
cd "$staging"
wp option update halabi_temporary_open_intake_enabled 0 --skip-plugins --skip-themes >/dev/null
for rel in wp-content/mu-plugins/avocat-halabi-resume-fix.php wp-content/themes/halabi/components/appointment-form/appointment-form.js wp-content/themes/halabi/includes/practice-panther-api.php wp-content/themes/halabi/modules/form-submissions/class-completion-events.php wp-content/themes/halabi/modules/form-submissions/class-submissions-storage.php wp-content/themes/halabi/templates/page-reservation-template.php; do
  expected="$(tar -xOzf "$backup" "$rel" | sha256sum | cut -d' ' -f1)"
  actual="$(sha256sum "$rel" | cut -d' ' -f1)"
  test "$expected" = "$actual"
done
test ! -e wp-content/themes/halabi/includes/identity-resolution
test ! -e wp-content/themes/halabi/includes/notification-language.php
test ! -e wp-content/mu-plugins/halabi-temporary-open-intake.php
printf 'Staging code and switch restored; post-test copies held at %s\n' "$held"
