#!/sbin/openrc-run # rds-init — boot oneshot that bootstraps or attaches the MariaDB datadir before # the engine starts. # # `before mariadb` orders the two, and /etc/conf.d/mariadb makes the engine need # this oneshot: Alpine's packaged mariadb service only prints a warning when the # datadir is empty and starts anyway, so ordering alone would let mysqld_safe # launch against an unbootstrapped data volume. `after rds-agent`, not `need`, so # a failed fetch fails this oneshot visibly rather than skipping it. description="Spinifex RDS MariaDB bootstrap" AGENT_ENV="/etc/spinifex-rds/agent.env" depend() { need net after rds-agent rds-datadir before mariadb } 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 MariaDB 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 $? }