Skip to content

Commit 032647e

Browse files
committed
Merge pull request #37 from infosiftr/sync-entrypoint
Resync entrypoint with MySQL
2 parents 3aa5bda + 5d17b85 commit 032647e

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

10.0/docker-entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -eo pipefail
33

44
# if command starts with an option, prepend mysqld
55
if [ "${1:0:1}" = '-' ]; then
@@ -11,9 +11,9 @@ if [ "$1" = 'mysqld' ]; then
1111
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
1212

1313
if [ ! -d "$DATADIR/mysql" ]; then
14-
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
15-
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
16-
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
14+
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
15+
echo >&2 'error: database is uninitialized and password option is not specified '
16+
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
1717
exit 1
1818
fi
1919

@@ -46,6 +46,10 @@ if [ "$1" = 'mysqld' ]; then
4646
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
4747
fi
4848

49+
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
50+
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
51+
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
52+
fi
4953
"${mysql[@]}" <<-EOSQL
5054
-- What's done in this file shouldn't be replicated
5155
-- or products like mysql-fabric won't work
@@ -81,8 +85,8 @@ if [ "$1" = 'mysqld' ]; then
8185
for f in /docker-entrypoint-initdb.d/*; do
8286
case "$f" in
8387
*.sh) echo "$0: running $f"; . "$f" ;;
84-
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f" && echo ;;
85-
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}" && echo ;;
88+
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
89+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
8690
*) echo "$0: ignoring $f" ;;
8791
esac
8892
echo

10.1/docker-entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -eo pipefail
33

44
# if command starts with an option, prepend mysqld
55
if [ "${1:0:1}" = '-' ]; then
@@ -11,9 +11,9 @@ if [ "$1" = 'mysqld' ]; then
1111
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
1212

1313
if [ ! -d "$DATADIR/mysql" ]; then
14-
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
15-
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
16-
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
14+
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
15+
echo >&2 'error: database is uninitialized and password option is not specified '
16+
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
1717
exit 1
1818
fi
1919

@@ -46,6 +46,10 @@ if [ "$1" = 'mysqld' ]; then
4646
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
4747
fi
4848

49+
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
50+
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
51+
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
52+
fi
4953
"${mysql[@]}" <<-EOSQL
5054
-- What's done in this file shouldn't be replicated
5155
-- or products like mysql-fabric won't work
@@ -81,8 +85,8 @@ if [ "$1" = 'mysqld' ]; then
8185
for f in /docker-entrypoint-initdb.d/*; do
8286
case "$f" in
8387
*.sh) echo "$0: running $f"; . "$f" ;;
84-
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f" && echo ;;
85-
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}" && echo ;;
88+
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
89+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
8690
*) echo "$0: ignoring $f" ;;
8791
esac
8892
echo

5.5/docker-entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -eo pipefail
33

44
# if command starts with an option, prepend mysqld
55
if [ "${1:0:1}" = '-' ]; then
@@ -11,9 +11,9 @@ if [ "$1" = 'mysqld' ]; then
1111
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
1212

1313
if [ ! -d "$DATADIR/mysql" ]; then
14-
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
15-
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
16-
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
14+
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
15+
echo >&2 'error: database is uninitialized and password option is not specified '
16+
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
1717
exit 1
1818
fi
1919

@@ -46,6 +46,10 @@ if [ "$1" = 'mysqld' ]; then
4646
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
4747
fi
4848

49+
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
50+
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
51+
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
52+
fi
4953
"${mysql[@]}" <<-EOSQL
5054
-- What's done in this file shouldn't be replicated
5155
-- or products like mysql-fabric won't work
@@ -81,8 +85,8 @@ if [ "$1" = 'mysqld' ]; then
8185
for f in /docker-entrypoint-initdb.d/*; do
8286
case "$f" in
8387
*.sh) echo "$0: running $f"; . "$f" ;;
84-
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f" && echo ;;
85-
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}" && echo ;;
88+
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
89+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
8690
*) echo "$0: ignoring $f" ;;
8791
esac
8892
echo

docker-entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -e
2+
set -eo pipefail
33

44
# if command starts with an option, prepend mysqld
55
if [ "${1:0:1}" = '-' ]; then
@@ -11,9 +11,9 @@ if [ "$1" = 'mysqld' ]; then
1111
DATADIR="$("$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
1212

1313
if [ ! -d "$DATADIR/mysql" ]; then
14-
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then
15-
echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
16-
echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
14+
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
15+
echo >&2 'error: database is uninitialized and password option is not specified '
16+
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
1717
exit 1
1818
fi
1919

@@ -46,6 +46,10 @@ if [ "$1" = 'mysqld' ]; then
4646
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
4747
fi
4848

49+
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
50+
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
51+
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
52+
fi
4953
"${mysql[@]}" <<-EOSQL
5054
-- What's done in this file shouldn't be replicated
5155
-- or products like mysql-fabric won't work
@@ -81,8 +85,8 @@ if [ "$1" = 'mysqld' ]; then
8185
for f in /docker-entrypoint-initdb.d/*; do
8286
case "$f" in
8387
*.sh) echo "$0: running $f"; . "$f" ;;
84-
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f" && echo ;;
85-
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}" && echo ;;
88+
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
89+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
8690
*) echo "$0: ignoring $f" ;;
8791
esac
8892
echo

0 commit comments

Comments
 (0)