MySQL socket auth tries to be funny, so run init as root

This commit is contained in:
Disassembler 2020-03-18 22:54:40 +01:00
parent 719b4e04b6
commit dadda1c175
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
5 changed files with 20 additions and 10 deletions

@ -1 +1 @@
Subproject commit fc42131bb6acaa9d474930add14f9e7fdf055bf5
Subproject commit 44c1a8638d651a55e558ca9d97cd2222a367eeac

View File

@ -10,12 +10,12 @@ MIFOSX_CONF="${VOLUMES_DIR}/mifosx/mifosx_conf"
install -o 100000 -g 100000 -m 755 -d ${MARIADB_CONF}
install -o 103306 -g 103306 -m 750 -d ${MARIADB_DATA}
install -o 100000 -g 100000 -m 644 mariadb_conf/my.cnf ${MARIADB_CONF}/my.cnf
spoc-container exec -u 0 -g 0 mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
spoc-container exec mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
# Create databases
export MIFOSX_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
spoc-container start mifosx-mariadb
envsubst <createdb.sql | spoc-container exec mifosx-mariadb -- mysql -u mysql
envsubst <createdb.sql | spoc-container exec mifosx-mariadb -- mysql
# Configure Mifos X
install -o 100000 -g 100000 -m 755 -d ${MIFOSX_CONF}
@ -23,8 +23,8 @@ envsubst <mifosx_conf/context.xml | install -o 100000 -g 100000 -m 644 /dev/stdi
install -o 100000 -g 100000 -m 644 mifosx_conf/server.xml ${MIFOSX_CONF}/server.xml
# Populate database
spoc-container exec mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | spoc-container exec mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
envsubst <schemapwd.sql | spoc-container exec mifosx-mariadb -- mysql -u mysql mifosplatform-tenants
spoc-container exec mifosx -- cat /tmp/mifospltaform-tenants-first-time-install.sql | spoc-container exec mifosx-mariadb -- mysql mifosplatform-tenants
envsubst <schemapwd.sql | spoc-container exec mifosx-mariadb -- mysql mifosplatform-tenants
# Populate database
spoc-container start mifosx
@ -34,14 +34,14 @@ done
spoc-container stop mifosx
# Fix missing previous_run_status column
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | spoc-container exec mifosx-mariadb -- mysql -u mysql mifostenant-default
echo 'ALTER TABLE `scheduled_email_campaign` ADD `previous_run_status` VARCHAR(10) NULL;' | spoc-container exec mifosx-mariadb -- mysql mifostenant-default
# Update admin account
export MIFOSX_ADMIN_USER=admin
export MIFOSX_ADMIN_EMAIL=admin@example.com
export MIFOSX_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
export MIFOSX_ADMIN_HASH=$(echo -n "${MIFOSX_ADMIN_PWD}{1}" | sha256sum | awk '{print $1}')
envsubst <adminpwd.sql | spoc-container exec mifosx-mariadb -- mysql -u mysql mifostenant-default
envsubst <adminpwd.sql | spoc-container exec mifosx-mariadb -- mysql mifostenant-default
# Stop services required for setup
spoc-container stop mifosx-mariadb

View File

@ -14,7 +14,9 @@ RUN EOF
chown mysql:mysql /run/mysqld
EOF
USER mysql
CMD /usr/bin/mysqld
READY /usr/bin/test -e /run/mysqld/mysqld.sock
# Due to MySQL's socket authentication design the container init needs to be run as root
COPY image.d
CMD /bin/s6-svscan /etc/services.d
READY /bin/sh -c "echo 'SELECT version()'| mysql"
HALT SIGTERM

View File

@ -0,0 +1,3 @@
#!/bin/execlineb -P
foreground { s6-svwait -d -t 3000 mysqld }

View File

@ -0,0 +1,5 @@
#!/bin/execlineb -P
fdmove -c 2 1
s6-setuidgid mysql
/usr/bin/mysqld