File tree Expand file tree Collapse file tree 3 files changed +53
-2
lines changed Expand file tree Collapse file tree 3 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
1818 esac
1919done
2020
21+ _check_config () {
22+ toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
23+ if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
24+ cat >&2 << -EOM
25+
26+ ERROR: mysqld failed while attempting to determine datadir
27+ command was: "${toRun[*]} "
28+
29+ $errors
30+ EOM
31+ exit 1
32+ fi
33+ }
34+
2135_datadir () {
22- " $@ " --verbose --help --log-bin-index=` mktemp -u` 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
36+ " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
2337}
2438
2539# allow the container to be started with `--user`
2640if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41+ _check_config " $@ "
2742 DATADIR=" $( _datadir " $@ " ) "
2843 mkdir -p " $DATADIR "
2944 chown -R mysql:mysql " $DATADIR "
3045 exec gosu mysql " $BASH_SOURCE " " $@ "
3146fi
3247
3348if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49+ # still need to check config, container may have started with --user
50+ _check_config " $@ "
3451 # Get config
3552 DATADIR=" $( _datadir " $@ " ) "
3653
Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
1818 esac
1919done
2020
21+ _check_config () {
22+ toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
23+ if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
24+ cat >&2 << -EOM
25+
26+ ERROR: mysqld failed while attempting to determine datadir
27+ command was: "${toRun[*]} "
28+
29+ $errors
30+ EOM
31+ exit 1
32+ fi
33+ }
34+
2135_datadir () {
22- " $@ " --verbose --help --log-bin-index=` mktemp -u` 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
36+ " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
2337}
2438
2539# allow the container to be started with `--user`
2640if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41+ _check_config " $@ "
2742 DATADIR=" $( _datadir " $@ " ) "
2843 mkdir -p " $DATADIR "
2944 chown -R mysql:mysql " $DATADIR "
3045 exec gosu mysql " $BASH_SOURCE " " $@ "
3146fi
3247
3348if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49+ # still need to check config, container may have started with --user
50+ _check_config " $@ "
3451 # Get config
3552 DATADIR=" $( _datadir " $@ " ) "
3653
Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
1818 esac
1919done
2020
21+ _check_config () {
22+ toRun=( " $@ " --verbose --help )
23+ if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
24+ cat >&2 << -EOM
25+
26+ ERROR: mysqld failed while attempting to determine datadir
27+ command was: "${toRun[*]} "
28+
29+ $errors
30+ EOM
31+ exit 1
32+ fi
33+ }
34+
2135_datadir () {
2236 " $@ " --verbose --help 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
2337}
2438
2539# allow the container to be started with `--user`
2640if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41+ _check_config " $@ "
2742 DATADIR=" $( _datadir " $@ " ) "
2843 mkdir -p " $DATADIR "
2944 chown -R mysql:mysql " $DATADIR "
3045 exec gosu mysql " $BASH_SOURCE " " $@ "
3146fi
3247
3348if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49+ # still need to check config, container may have started with --user
50+ _check_config " $@ "
3451 # Get config
3552 DATADIR=" $( _datadir " $@ " ) "
3653
You can’t perform that action at this time.
0 commit comments