@@ -31,26 +31,29 @@ MYSQLD_OPTS=
3131lockfile=/var/lock/subsys/$prog
3232
3333
34- # extract value of a MySQL option from config files
35- # Usage: get_mysql_option SECTION VARNAME DEFAULT
36- # result is returned in $result
34+ # Extract value of a MySQL option from config files
35+ # Usage: get_mysql_option OPTION DEFAULT SECTION1 SECTION2 SECTIONN
36+ # Result is returned in $result
3737# We use my_print_defaults which prints all options from multiple files,
3838# with the more specific ones later; hence take the last match.
39- get_mysql_option (){
40- result=$( /usr/bin/my_print_defaults " $1 " | sed -n " s/^--$2 =//p" | tail -n 1)
41- if [ -z " $result " ]; then
42- # not found, use default
43- result=" $3 "
44- fi
39+ get_mysql_option () {
40+ option=$1
41+ default=$2
42+ shift 2
43+ result=$( /usr/bin/my_print_defaults " $@ " | sed -n " s/^--${option} =//p" | tail -n 1)
44+ if [ -z " $result " ]; then
45+ # not found, use default
46+ result=" ${default} "
47+ fi
4548}
4649
47- get_mysql_option mysqld datadir " /var/lib/mysql"
50+ get_mysql_option datadir " /var/lib/mysql" mysqld
4851datadir=" $result "
49- get_mysql_option mysqld socket " $datadir /mysql.sock"
52+ get_mysql_option socket " $datadir /mysql.sock" mysqld
5053socketfile=" $result "
51- get_mysql_option mysqld_safe log-error " /var/log/mysqld.log"
54+ get_mysql_option log-error " /var/log/mysqld.log" mysqld mysqld_safe
5255errlogfile=" $result "
53- get_mysql_option mysqld_safe pid-file " /var/run/mysqld/mysqld.pid"
56+ get_mysql_option pid-file " /var/run/mysqld/mysqld.pid" mysqld mysqld_safe
5457mypidfile=" $result "
5558
5659case $socketfile in
0 commit comments