Files
spinifex/scripts/images/rds-postgres/rds-init.initd
T

35 lines
1.0 KiB
Plaintext

#!/sbin/openrc-run
# rds-init — boot oneshot that bootstraps or attaches the PostgreSQL cluster
# before the engine starts.
#
# `before postgresql` rather than a dependency of it: the engine runs with
# auto_setup="no", so a failure here leaves postgresql refusing to start rather
# than silently creating an empty cluster. `after rds-agent`, not `need`, so a
# failed fetch fails this oneshot visibly rather than skipping it.
description="Spinifex RDS PostgreSQL bootstrap"
AGENT_ENV="/etc/spinifex-rds/agent.env"
depend() {
need net
after rds-agent rds-datadir
before postgresql
}
start_pre() {
if [ -f "${AGENT_ENV}" ]; then
# shellcheck disable=SC1090
. "${AGENT_ENV}"
export RDS_HANDOFF_DIR RDS_DATA_MOUNT
fi
}
start() {
ebegin "Bootstrapping the RDS PostgreSQL instance"
# The VM has no operator login, so the host-side serial log is the only view
# of a bootstrap that failed before the engine came up.
/usr/local/sbin/rds-init > /dev/console 2>&1
eend $?
}