Sam Yaple 13062e23e8 Restructure builds to allow more flexibility
As a restructure, nothing is changed from the original behaviour and
naming despite the file structure changing. The symlinks to build had
to be updated generating lots of "deleted" and "new_file".

The new structure is:

docker/${base_distro}/${type}/${container}

base_distro == centos, ubuntu, fedora, etc
type == source, binary, rdo

type rdo is a symlink to binary for backwards compatibility

Two new flags are added to the build-all script to support the ability
to support different base distros and a flag to support binary or source
containers.

There are several added folders that are empty to hold the directory
structure for future containers of these types.

To use a prefix other than centos-rdo- you can set PREFIX in the toplevel
directory .buildconf file

Change-Id: Ifc7bac0d827470f506c8b5c004a833da9ce13b90
2015-05-15 01:32:22 -05:00

50 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
# Configure MySQL settings
. /opt/kolla/config-mysql.sh
if [ -z "$(ls -A /var/lib/mysql)" -a "${1%_safe}" = 'mysqld' ]; then
PATH=/usr/libexec:$PATH
export PATH
if [ -z "$MARIADB_ROOT_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and MARIADB_ROOT_PASSWORD not set'
echo >&2 ' Did you forget to add -e MARIADB_ROOT_PASSWORD=... ?'
exit 1
fi
mysql_install_db --user=mysql --datadir="$DATADIR"
# These statements _must_ be on individual lines, and _must_ end with
# semicolons (no line breaks or comments are permitted).
# TODO proper SQL escaping on ALL the things D:
TEMP_FILE='/tmp/mysql-first-time.sql'
cat > "$TEMP_FILE" <<-EOSQL
DELETE FROM mysql.user ;
CREATE USER 'root'@'%' IDENTIFIED BY '${MARIADB_ROOT_PASSWORD}' ;
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
DROP DATABASE IF EXISTS test ;
EOSQL
if [ "$MARIADB_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS $MARIADB_DATABASE ;" >> "$TEMP_FILE"
fi
if [ "$MARIADB_USER" -a "$MARIADB_PASSWORD" ]; then
echo "CREATE USER '$MARIADB_USER'@'%' IDENTIFIED BY '$MARIADB_PASSWORD' ;" >> "$TEMP_FILE"
if [ "$MARIADB_DATABASE" ]; then
echo "GRANT ALL ON $MARIADB_DATABASE.* TO '$MARIADB_USER'@'%' ;" >> "$TEMP_FILE"
fi
fi
echo 'FLUSH PRIVILEGES ;' >> "$TEMP_FILE"
set -- "$@" --init-file="$TEMP_FILE"
fi
chown -R mysql:mysql "$DATADIR"
exec "$@"