Add PostgreSQL HA OCF agent modular baseline

This commit is contained in:
Lyncoln
2026-09-12 01:28:33 -04:00
commit 4a358ae0f6
30 changed files with 7119 additions and 0 deletions
@@ -0,0 +1,55 @@
# Sourced by managed-container; uses the shared OCF and parameter environment.
service_uid()
{
id -u "${SERVICE_USER}"
}
service_home()
{
getent passwd "${SERVICE_USER}" | cut -d: -f6
}
as_service_user()
{
local uid home
uid="$(id -u "$SERVICE_USER")" || return 1
home="$(getent passwd "$SERVICE_USER" | cut -d: -f6)" || return 1
runuser -u "$SERVICE_USER" -- \
sh -c '
home="$1"
runtime="$2"
shift 2
cd "$home" || exit 1
export HOME="$home"
export XDG_RUNTIME_DIR="$runtime"
exec "$@"
' sh \
"$home" \
"/run/user/$uid" \
"$@"
}
service_running()
{
as_service_user \
systemctl --user is-active --quiet "${SERVICE_NAME}"
}
container_running()
{
local state
state="$(
as_service_user podman inspect \
--format '{{.State.Running}}' \
"${CONTAINER_NAME}" 2>/dev/null
)" || return 1
[ "${state}" = "true" ]
}