#!/bin/sh
# Offline verification of the restored physical bundle; does not start a server.
set -eu
[ "$#" = 3 ] || exit 2
[ ! -L "$1/.schipsave-postgresql" ] && [ "$(cat "$1/.schipsave-postgresql")" = 1 ] || exit 2
[ -d "$1/cluster" ] && [ ! -L "$1/cluster" ] || exit 2
major=$(cat "$1/cluster/PG_VERSION")
case "$major" in 11|13|14|15|16|17|18) ;; *) printf 'major PostgreSQL não suportado\n' >&2; exit 2 ;; esac
directory=${PG_BIN_DIR:-/usr/lib/postgresql/$major/bin}
case "$directory" in /*) ;; *) printf 'PG_BIN_DIR deve ser absoluto\n' >&2; exit 2 ;; esac
export PG_BIN_DIR="$directory"
exec python3 "$(dirname -- "$0")/schipsave-pg-physical" verify "$1"
