Skip to content

Commit abf2047

Browse files
committed
Fix source detection for centos, call check_config first, explicit global for DATADIR SOCKET
1 parent 7a557cd commit abf2047

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.template.Debian/docker-entrypoint.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ file_env() {
3939
unset "$fileVar"
4040
}
4141

42+
# check to see if this file is being run or sourced from another script
43+
_is_sourced() {
44+
# https://unix.stackexchange.com/a/215279
45+
[ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" == 'source' ]
46+
}
47+
4248
# usage: docker_process_init_files [file [file [...]]]
4349
# ie: docker_process_init_files /always-initdb.d/*
4450
# process initializer files, based on file extensions
@@ -149,8 +155,10 @@ docker_init_database_dir() {
149155
}
150156

151157
# Loads various settings that are used elsewhere in the script
158+
# This should be called after mysql_check_config, but before any other functions
152159
docker_setup_env() {
153160
# Get config
161+
declare -g DATADIR SOCKET
154162
DATADIR="$(mysql_get_config 'datadir' "$@")"
155163
SOCKET="$(mysql_get_config 'socket' "$@")"
156164

@@ -282,9 +290,9 @@ _main() {
282290
if [ "$1" = 'mysqld' ] && ! _mysql_want_help "$@"; then
283291
mysql_note "Entrypoint script for MySQL Server ${MYSQL_VERSION} started."
284292

293+
mysql_check_config "$@"
285294
# Load various environment variables
286295
docker_setup_env "$@"
287-
mysql_check_config "$@"
288296
docker_create_db_directories
289297

290298
# If container is started as root user, restart as dedicated mysql user
@@ -319,9 +327,7 @@ _main() {
319327
exec "$@"
320328
}
321329

322-
# This checks if the script has been sourced from elsewhere.
323-
# If so we don't perform any further actions
324-
# https://unix.stackexchange.com/a/215279
325-
if [ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" != 'source' ]; then
330+
# If we are sourced from elsewhere, don't perform any further actions
331+
if ! _is_sourced; then
326332
_main "$@"
327333
fi

0 commit comments

Comments
 (0)