Skip to content

Commit

Permalink
Merge pull request docker-library#109 from infosiftr/shell
Browse files Browse the repository at this point in the history
Fix some quotes, simplify update script
  • Loading branch information
yosifkit committed Oct 22, 2015
2 parents 3c6061b + 4797ba7 commit 0238018
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
15 changes: 9 additions & 6 deletions 5.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if [ "$1" = 'mysqld' ]; then
mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"

echo 'Running mysql_install_db'
echo 'Initializing database'
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --basedir=/usr/local/mysql
echo 'Finished mysql_install_db'
echo 'Database initialized'

mysqld --user=mysql --datadir="$DATADIR" --skip-networking --basedir=/usr/local/mysql &
"$@" --skip-networking --basedir=/usr/local/mysql &
pid="$!"

mysql=( mysql --protocol=socket -uroot )
Expand All @@ -41,7 +41,10 @@ if [ "$1" = 'mysqld' ]; then
exit 1
fi

mysql_tzinfo_to_sql /usr/share/zoneinfo | "${mysql[@]}" mysql
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
# sed is for https://bugs.mysql.com/bug.php?id=20545
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
fi

"${mysql[@]}" <<-EOSQL
-- What's done in this file shouldn't be replicated
Expand All @@ -65,10 +68,10 @@ if [ "$1" = 'mysqld' ]; then
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" | "${mysql[@]}"
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" | "${mysql[@]}"
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
fi

echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
Expand Down
16 changes: 9 additions & 7 deletions 5.6/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if [ "$1" = 'mysqld' ]; then
mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"

echo 'Running mysql_install_db'
echo 'Initializing database'
mysql_install_db --user=mysql --datadir="$DATADIR" --rpm --keep-my-cnf
echo 'Finished mysql_install_db'
echo 'Database initialized'

mysqld --user=mysql --datadir="$DATADIR" --skip-networking &
"$@" --skip-networking &
pid="$!"

mysql=( mysql --protocol=socket -uroot )
Expand All @@ -41,8 +41,10 @@ if [ "$1" = 'mysqld' ]; then
exit 1
fi

# sed is for https://bugs.mysql.com/bug.php?id=20545
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
# sed is for https://bugs.mysql.com/bug.php?id=20545
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
fi

"${mysql[@]}" <<-EOSQL
-- What's done in this file shouldn't be replicated
Expand All @@ -66,10 +68,10 @@ if [ "$1" = 'mysqld' ]; then
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" | "${mysql[@]}"
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" | "${mysql[@]}"
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
fi

echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
Expand Down
11 changes: 7 additions & 4 deletions 5.7/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ "$1" = 'mysqld' ]; then
mysqld --initialize-insecure=on --datadir="$DATADIR"
echo 'Database initialized'

mysqld --user=mysql --datadir="$DATADIR" --skip-networking &
"$@" --skip-networking &
pid="$!"

mysql=( mysql --protocol=socket -uroot )
Expand All @@ -41,7 +41,10 @@ if [ "$1" = 'mysqld' ]; then
exit 1
fi

mysql_tzinfo_to_sql /usr/share/zoneinfo | "${mysql[@]}" mysql
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
# sed is for https://bugs.mysql.com/bug.php?id=20545
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
fi

"${mysql[@]}" <<-EOSQL
-- What's done in this file shouldn't be replicated
Expand All @@ -65,10 +68,10 @@ if [ "$1" = 'mysqld' ]; then
fi

if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
echo "CREATE USER '"$MYSQL_USER"'@'%' IDENTIFIED BY '"$MYSQL_PASSWORD"' ;" | "${mysql[@]}"
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"

if [ "$MYSQL_DATABASE" ]; then
echo "GRANT ALL ON \`"$MYSQL_DATABASE"\`.* TO '"$MYSQL_USER"'@'%' ;" | "${mysql[@]}"
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
fi

echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
Expand Down

0 comments on commit 0238018

Please sign in to comment.