1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/bin/bash
# based off of https://salsa.debian.org/perl-team/modules/packages/libdbd-mariadb-perl/-/blob/3f83abd55844ec22ba9b6d8f5a2a3ebdcd0ec3b6/debian/tests/pkg-perl/smoke-setup
# and https://github.com/mariadb-corporation/connector-test-machine/blob/d0ac910e69cab92e3d485d4e3709acf358e766d2/launch.sh#L82
set -ex
/usr/bin/mariadb-install-db --no-defaults --datadir=${MARIADB_DIR} --force --skip-name-resolve --explicit_defaults_for_timestamp 2>&1
/usr/sbin/mysqld --no-defaults --user=${MARIADB_USER} --socket=${MARIADB_UNIX_PORT} -P10010 --datadir=${MARIADB_DIR} --pid-file=${MARIADB_PIDFILE} --explicit_defaults_for_timestamp 2>&1 &
attempts=0
while ! /usr/bin/mariadb-admin --user=${MARIADB_USER} --socket=${MARIADB_UNIX_PORT} ping 2>&1 ; do
sleep 3
attempts=$((attempts+1))
if [ ${attempts} -gt 10 ] ; then
echo "skipping test, the mariadb server could not be contacted after 30 seconds"
exit 1
fi
done
/usr/bin/mariadb --user=${MARIADB_USER} --socket=${MARIADB_UNIX_PORT} -e "create DATABASE IF NOT EXISTS ${TEST_DB_DATABASE}"
/usr/bin/mariadb --user=${MARIADB_USER} --socket=${MARIADB_UNIX_PORT} ${TEST_DB_DATABSE} <<EOT
CREATE USER IF NOT EXISTS '${TEST_DB_USERNAME}'@'%' identified by '${TEST_DB_PASSWORD}';
GRANT ALL ON *.* TO '${TEST_DB_USERNAME}'@'%' /*M!100401 identified by 'heyPassword'*/ with grant option;
CREATE USER IF NOT EXISTS '${TEST_DB_USERNAME}'@'localhost' identified by '${TEST_DB_PASSWORD}';
GRANT ALL ON *.* TO '${TEST_DB_USERNAME}'@'localhost' /*M!100401 identified by 'heyPassword'*/ with grant option;
EOT
|