File tree 3 files changed +53
-2
lines changed
3 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
18
18
esac
19
19
done
20
20
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 check config
27
+ command was: "${toRun[*]} "
28
+
29
+ $errors
30
+ EOM
31
+ exit 1
32
+ fi
33
+ }
34
+
21
35
_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 }'
23
37
}
24
38
25
39
# allow the container to be started with `--user`
26
40
if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41
+ _check_config " $@ "
27
42
DATADIR=" $( _datadir " $@ " ) "
28
43
mkdir -p " $DATADIR "
29
44
chown -R mysql:mysql " $DATADIR "
30
45
exec gosu mysql " $BASH_SOURCE " " $@ "
31
46
fi
32
47
33
48
if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49
+ # still need to check config, container may have started with --user
50
+ _check_config " $@ "
34
51
# Get config
35
52
DATADIR=" $( _datadir " $@ " ) "
36
53
Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
18
18
esac
19
19
done
20
20
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 check config
27
+ command was: "${toRun[*]} "
28
+
29
+ $errors
30
+ EOM
31
+ exit 1
32
+ fi
33
+ }
34
+
21
35
_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 }'
23
37
}
24
38
25
39
# allow the container to be started with `--user`
26
40
if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41
+ _check_config " $@ "
27
42
DATADIR=" $( _datadir " $@ " ) "
28
43
mkdir -p " $DATADIR "
29
44
chown -R mysql:mysql " $DATADIR "
30
45
exec gosu mysql " $BASH_SOURCE " " $@ "
31
46
fi
32
47
33
48
if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49
+ # still need to check config, container may have started with --user
50
+ _check_config " $@ "
34
51
# Get config
35
52
DATADIR=" $( _datadir " $@ " ) "
36
53
Original file line number Diff line number Diff line change @@ -18,19 +18,36 @@ for arg; do
18
18
esac
19
19
done
20
20
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 check config
27
+ command was: "${toRun[*]} "
28
+
29
+ $errors
30
+ EOM
31
+ exit 1
32
+ fi
33
+ }
34
+
21
35
_datadir () {
22
36
" $@ " --verbose --help 2> /dev/null | awk ' $1 == "datadir" { print $2; exit }'
23
37
}
24
38
25
39
# allow the container to be started with `--user`
26
40
if [ " $1 " = ' mysqld' -a -z " $wantHelp " -a " $( id -u) " = ' 0' ]; then
41
+ _check_config " $@ "
27
42
DATADIR=" $( _datadir " $@ " ) "
28
43
mkdir -p " $DATADIR "
29
44
chown -R mysql:mysql " $DATADIR "
30
45
exec gosu mysql " $BASH_SOURCE " " $@ "
31
46
fi
32
47
33
48
if [ " $1 " = ' mysqld' -a -z " $wantHelp " ]; then
49
+ # still need to check config, container may have started with --user
50
+ _check_config " $@ "
34
51
# Get config
35
52
DATADIR=" $( _datadir " $@ " ) "
36
53
You can’t perform that action at this time.
0 commit comments