Files
spinifex/scripts/images/rds-postgres/rds-datadir.initd
T
2026-08-13 10:38:18 +10:00

36 lines
1.2 KiB
Plaintext

#!/sbin/openrc-run
# rds-datadir — boot oneshot that discovers the hot-plugged data volume, formats
# it if authorized, and mounts it at the datadir mount point. It runs after the
# agent has written the authenticated handoff and before anything can use the
# PostgreSQL datadir. Soft ordering keeps a failed boot visible on the console.
description="Spinifex RDS data volume mount"
AGENT_ENV="/etc/spinifex-rds/agent.env"
depend() {
after localmount rds-agent
before rds-init postgresql
}
start_pre() {
# This image's layout, stated here because the mount script is shared by
# every engine preset. A delivered RDS_DATA_MOUNT still wins, so the control
# plane can move the mount point without rebuilding the image.
RDS_DATA_MOUNT="/var/lib/postgresql"
RDS_ENGINE_USER="postgres"
if [ -f "${AGENT_ENV}" ]; then
# shellcheck disable=SC1090
. "${AGENT_ENV}"
fi
export RDS_HANDOFF_DIR RDS_DATA_MOUNT RDS_ENGINE_USER
}
start() {
ebegin "Mounting the RDS data volume"
# To the console for the same reason rds-init's is: the serial log is the
# only view of a boot that failed before the engine came up.
/usr/local/sbin/rds-datadir > /dev/console 2>&1
eend $?
}