mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-20 03:11:46 +00:00
2ad9d64c48
Adds scripts/images/rds-mariadb/: the manifest with every mariadb package pinned =~11.8, setup.sh, the rds-datadir and rds-agent services, and the static include drop-in that points MariaDB at the generated configuration on the data volume. The AMI carries engine=mariadb, engine-version=11.8 and the data-volume contract tag, so resolveEngineAMI can select it. The include is named zz- rather than 00-: MariaDB walks an include directory in byte order and takes the last occurrence of a setting, so a digit prefix would sort ahead of Alpine's packaged mariadb-server.cnf and let a distribution default beat a platform-owned one. setup.sh asserts the resulting order against the real directory at build time. The include target is baked empty as well, because MariaDB treats an includedir it cannot open as a fatal defaults-parsing error and a boot with no data volume would otherwise lose the client alongside the server. The packaged drop-in also sets skip-networking, which would leave the endpoint resolving and the health probe passing while nothing on the customer ENI could connect. setup.sh disables it at the source and asserts no configuration file still does. The mariadb service is deliberately not enabled: the packaged service only warns about an empty datadir rather than refusing, so an engine enabled before the bootstrap exists would launch mysqld_safe against an unbootstrapped volume. rds-datadir moves to scripts/images/common/ rather than being copied. Volume selection, format authorization and mount are already engine-neutral; the mount point and owning user are the only per-engine facts and now come from each preset's own service. The script fails closed when either is unset, so no image can inherit another engine's layout by omission.
36 lines
1.2 KiB
Plaintext
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 $?
|
|
}
|