File tree Expand file tree Collapse file tree 4 files changed +76
-28
lines changed Expand file tree Collapse file tree 4 files changed +76
-28
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
4040 unset " $fileVar "
4141}
4242
43+ # usage: process_init_file FILENAME MYSQLCOMMAND...
44+ # ie: process_init_file foo.sh mysql -uroot
45+ # (process a single initializer file, based on its extension. we define this
46+ # function here, so that initializer scripts (*.sh) can use the same logic,
47+ # potentially recursively, or override the logic used in subsequent calls)
48+ process_init_file () {
49+ local f=" $1 " ; shift
50+ local mysql=( " $@ " )
51+
52+ case " $f " in
53+ * .sh) echo " $0 : running $f " ; . " $f " ;;
54+ * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
55+ * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
56+ * ) echo " $0 : ignoring $f " ;;
57+ esac
58+ echo
59+ }
60+
4361_check_config () {
4462 toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
4563 if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -169,13 +187,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
169187
170188 echo
171189 for f in /docker-entrypoint-initdb.d/* ; do
172- case " $f " in
173- * .sh) echo " $0 : running $f " ; . " $f " ;;
174- * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
175- * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
176- * ) echo " $0 : ignoring $f " ;;
177- esac
178- echo
190+ process_init_file " $f " " ${mysql[@]} "
179191 done
180192
181193 if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
4040 unset " $fileVar "
4141}
4242
43+ # usage: process_init_file FILENAME MYSQLCOMMAND...
44+ # ie: process_init_file foo.sh mysql -uroot
45+ # (process a single initializer file, based on its extension. we define this
46+ # function here, so that initializer scripts (*.sh) can use the same logic,
47+ # potentially recursively, or override the logic used in subsequent calls)
48+ process_init_file () {
49+ local f=" $1 " ; shift
50+ local mysql=( " $@ " )
51+
52+ case " $f " in
53+ * .sh) echo " $0 : running $f " ; . " $f " ;;
54+ * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
55+ * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
56+ * ) echo " $0 : ignoring $f " ;;
57+ esac
58+ echo
59+ }
60+
4361_check_config () {
4462 toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
4563 if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -169,13 +187,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
169187
170188 echo
171189 for f in /docker-entrypoint-initdb.d/* ; do
172- case " $f " in
173- * .sh) echo " $0 : running $f " ; . " $f " ;;
174- * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
175- * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
176- * ) echo " $0 : ignoring $f " ;;
177- esac
178- echo
190+ process_init_file " $f " " ${mysql[@]} "
179191 done
180192
181193 if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
4040 unset " $fileVar "
4141}
4242
43+ # usage: process_init_file FILENAME MYSQLCOMMAND...
44+ # ie: process_init_file foo.sh mysql -uroot
45+ # (process a single initializer file, based on its extension. we define this
46+ # function here, so that initializer scripts (*.sh) can use the same logic,
47+ # potentially recursively, or override the logic used in subsequent calls)
48+ process_init_file () {
49+ local f=" $1 " ; shift
50+ local mysql=( " $@ " )
51+
52+ case " $f " in
53+ * .sh) echo " $0 : running $f " ; . " $f " ;;
54+ * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
55+ * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
56+ * ) echo " $0 : ignoring $f " ;;
57+ esac
58+ echo
59+ }
60+
4361_check_config () {
4462 toRun=( " $@ " --verbose --help )
4563 if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -174,13 +192,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
174192
175193 echo
176194 for f in /docker-entrypoint-initdb.d/* ; do
177- case " $f " in
178- * .sh) echo " $0 : running $f " ; . " $f " ;;
179- * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
180- * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
181- * ) echo " $0 : ignoring $f " ;;
182- esac
183- echo
195+ process_init_file " $f " " ${mysql[@]} "
184196 done
185197
186198 if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
4040 unset " $fileVar "
4141}
4242
43+ # usage: process_init_file FILENAME MYSQLCOMMAND...
44+ # ie: process_init_file foo.sh mysql -uroot
45+ # (process a single initializer file, based on its extension. we define this
46+ # function here, so that initializer scripts (*.sh) can use the same logic,
47+ # potentially recursively, or override the logic used in subsequent calls)
48+ process_init_file () {
49+ local f=" $1 " ; shift
50+ local mysql=( " $@ " )
51+
52+ case " $f " in
53+ * .sh) echo " $0 : running $f " ; . " $f " ;;
54+ * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
55+ * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
56+ * ) echo " $0 : ignoring $f " ;;
57+ esac
58+ echo
59+ }
60+
4361_check_config () {
4462 toRun=( " $@ " --verbose --help )
4563 if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -176,13 +194,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
176194
177195 echo
178196 for f in /docker-entrypoint-initdb.d/* ; do
179- case " $f " in
180- * .sh) echo " $0 : running $f " ; . " $f " ;;
181- * .sql) echo " $0 : running $f " ; " ${mysql[@]} " < " $f " ; echo ;;
182- * .sql.gz) echo " $0 : running $f " ; gunzip -c " $f " | " ${mysql[@]} " ; echo ;;
183- * ) echo " $0 : ignoring $f " ;;
184- esac
185- echo
197+ process_init_file " $f " " ${mysql[@]} "
186198 done
187199
188200 if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
You can’t perform that action at this time.
0 commit comments