@@ -34,26 +34,29 @@ lockfile=/var/lock/subsys/$prog
3434command=$1 && shift
3535extra_opts=" $@ "
3636
37- # extract value of a MySQL option from config files
38- # Usage: get_mysql_option SECTION VARNAME DEFAULT
39- # result is returned in $result
37+ # Extract value of a MySQL option from config files
38+ # Usage: get_mysql_option OPTION DEFAULT SECTION1 SECTION2 SECTIONN
39+ # Result is returned in $result
4040# We use my_print_defaults which prints all options from multiple files,
4141# with the more specific ones later; hence take the last match.
42- get_mysql_option (){
43- result=$( /usr/bin/my_print_defaults " $1 " | sed -n " s/^--$2 =//p" | tail -n 1)
44- if [ -z " $result " ]; then
45- # not found, use default
46- result=" $3 "
47- fi
42+ get_mysql_option () {
43+ option=$1
44+ default=$2
45+ shift 2
46+ result=$( /usr/bin/my_print_defaults " $@ " | sed -n " s/^--${option} =//p" | tail -n 1)
47+ if [ -z " $result " ]; then
48+ # not found, use default
49+ result=" ${default} "
50+ fi
4851}
4952
50- get_mysql_option mysqld datadir " /var/lib/mysql"
53+ get_mysql_option datadir " /var/lib/mysql" mysqld
5154datadir=" $result "
52- get_mysql_option mysqld socket " $datadir /mysql.sock"
55+ get_mysql_option socket " $datadir /mysql.sock" mysqld
5356socketfile=" $result "
54- get_mysql_option mysqld_safe log-error " /var/log/mysqld.log"
57+ get_mysql_option log-error " /var/log/mysqld.log" mysqld mysqld_safe
5558errlogfile=" $result "
56- get_mysql_option mysqld_safe pid-file " /var/run/mysqld/mysqld.pid"
59+ get_mysql_option pid-file " /var/run/mysqld/mysqld.pid" mysqld mysqld_safe
5760mypidfile=" $result "
5861
5962case $socketfile in
0 commit comments