@@ -31,26 +31,29 @@ MYSQLD_OPTS=
31
31
lockfile=/var/lock/subsys/$prog
32
32
33
33
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
37
37
# We use my_print_defaults which prints all options from multiple files,
38
38
# 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
45
48
}
46
49
47
- get_mysql_option mysqld datadir " /var/lib/mysql"
50
+ get_mysql_option datadir " /var/lib/mysql" mysqld
48
51
datadir=" $result "
49
- get_mysql_option mysqld socket " $datadir /mysql.sock"
52
+ get_mysql_option socket " $datadir /mysql.sock" mysqld
50
53
socketfile=" $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
52
55
errlogfile=" $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
54
57
mypidfile=" $result "
55
58
56
59
case $socketfile in
0 commit comments