Skip to content

Commit d414024

Browse files
committed
catch errors when scraping datadir from help output
1 parent de740a4 commit d414024

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

5.5/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ for arg; do
1919
done
2020

2121
_datadir() {
22-
"$@" --verbose --help --log-bin-index=`mktemp -u` 2>/dev/null | awk '$1 == "datadir" { print $2; exit }'
22+
toRun=( "$@" --verbose --help --log-bin-index="$(mktemp -u)" )
23+
if ! "${toRun[@]}" 2>/tmp/mysql-config-error.log | awk '$1 == "datadir" { print $2; exit }'; then
24+
cat >&2 - /tmp/mysql-config-error.log <<-EOM
25+
26+
ERROR: mysqld failed while attempting to determine datadir
27+
command was: "${toRun[*]}"
28+
29+
EOM
30+
exit 1
31+
fi
32+
rm /tmp/mysql-config-error.log
2333
}
2434

2535
# allow the container to be started with `--user`

5.6/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ for arg; do
1919
done
2020

2121
_datadir() {
22-
"$@" --verbose --help --log-bin-index=`mktemp -u` 2>/dev/null | awk '$1 == "datadir" { print $2; exit }'
22+
toRun=( "$@" --verbose --help --log-bin-index="$(mktemp -u)" )
23+
if ! "${toRun[@]}" 2>/tmp/mysql-config-error.log | awk '$1 == "datadir" { print $2; exit }'; then
24+
cat >&2 - /tmp/mysql-config-error.log <<-EOM
25+
26+
ERROR: mysqld failed while attempting to determine datadir
27+
command was: "${toRun[*]}"
28+
29+
EOM
30+
exit 1
31+
fi
32+
rm /tmp/mysql-config-error.log
2333
}
2434

2535
# allow the container to be started with `--user`

5.7/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ for arg; do
1919
done
2020

2121
_datadir() {
22-
"$@" --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }'
22+
toRun=( "$@" --verbose --help )
23+
if ! "${toRun[@]}" 2>/tmp/mysql-config-error.log | awk '$1 == "datadir" { print $2; exit }'; then
24+
cat >&2 - /tmp/mysql-config-error.log <<-EOM
25+
26+
ERROR: mysqld failed while attempting to determine datadir
27+
command was: "${toRun[*]}"
28+
29+
EOM
30+
exit 1
31+
fi
32+
rm /tmp/mysql-config-error.log
2333
}
2434

2535
# allow the container to be started with `--user`

0 commit comments

Comments
 (0)