@@ -38,18 +38,33 @@ function main () {
3838 }
3939 export CONFIG
4040
41+ if [ " ${PREFER_MARIADB_CLIENT:- 1} " -eq 1 ] && command -v mariadb > /dev/null; then
42+ MYSQL=$( command -v mariadb)
43+ elif command -v mysql > /dev/null; then
44+ MYSQL=$( command -v mysql)
45+ else
46+ err " Could not find mysql or mariadb client in path."
47+ exit 1
48+ fi
49+
50+ if [ " ${PREFER_MARIADB_CLIENT:- 1} " -eq 1 ] && command -v mariadb-dump > /dev/null; then
51+ MYSQLDUMP=$( command -v mariadb-dump)
52+ elif command -v mysqldump > /dev/null; then
53+ MYSQLDUMP=$( command -v mysqldump)
54+ else
55+ err " Could not find mysqldump or mariadb-dump in path."
56+ exit 1
57+ fi
58+
4159 if [ -n " ${MY_DEFAULTS:- } " ]; then
4260 # Use a defaults file if one is specified
61+ # The default behaviour is to read options from ~/.my.cnf without having to specify it.
4362 if [ ! -f " ${MY_DEFAULTS} " ]; then
4463 err " MY_DEFAULTS is set to '${MY_DEFAULTS} ', but that file does not exist."
4564 exit 1
4665 fi
47- MYSQL=" $( command -v mysql) --defaults-file=${MY_DEFAULTS} "
48- MYSQLDUMP=" $( command -v mysqldump) --defaults-file=${MY_DEFAULTS} "
49- else
50- # The default behaviour is to read options from ~/.my.cnf without having to specify it.
51- MYSQL=" $( command -v mysql) "
52- MYSQLDUMP=" $( command -v mysqldump) "
66+ MYSQL=" $MYSQL --defaults-file=${MY_DEFAULTS} "
67+ MYSQLDUMP=" $MYSQLDUMP --defaults-file=${MY_DEFAULTS} "
5368 fi
5469
5570 # Touch the log file to make sure we can write to it.
0 commit comments