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() {
40
40
unset " $fileVar "
41
41
}
42
42
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
+
43
61
_check_config () {
44
62
toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
45
63
if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -169,13 +187,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
169
187
170
188
echo
171
189
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[@]} "
179
191
done
180
192
181
193
if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
40
40
unset " $fileVar "
41
41
}
42
42
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
+
43
61
_check_config () {
44
62
toRun=( " $@ " --verbose --help --log-bin-index=" $( mktemp -u) " )
45
63
if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -169,13 +187,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
169
187
170
188
echo
171
189
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[@]} "
179
191
done
180
192
181
193
if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
40
40
unset " $fileVar "
41
41
}
42
42
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
+
43
61
_check_config () {
44
62
toRun=( " $@ " --verbose --help )
45
63
if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -174,13 +192,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
174
192
175
193
echo
176
194
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[@]} "
184
196
done
185
197
186
198
if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ file_env() {
40
40
unset " $fileVar "
41
41
}
42
42
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
+
43
61
_check_config () {
44
62
toRun=( " $@ " --verbose --help )
45
63
if ! errors=" $( " ${toRun[@]} " 2>&1 > /dev/null) " ; then
@@ -176,13 +194,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
176
194
177
195
echo
178
196
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[@]} "
186
198
done
187
199
188
200
if [ ! -z " $MYSQL_ONETIME_PASSWORD " ]; then
You can’t perform that action at this time.
0 commit comments