Commit 6fce90e5 authored by Terje Rosten's avatar Terje Rosten

Bug#25287707 THE PID-FILE VALUE IS IGNORED IN THE /ETC/MY.CNF OPTION FILE

In SysV initscripts for RPMS [mysqld] section was ignored for some options.
parent b7f33d22
...@@ -31,26 +31,29 @@ MYSQLD_OPTS= ...@@ -31,26 +31,29 @@ MYSQLD_OPTS=
lockfile=/var/lock/subsys/$prog lockfile=/var/lock/subsys/$prog
# extract value of a MySQL option from config files # Extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT # Usage: get_mysql_option OPTION DEFAULT SECTION1 SECTION2 SECTIONN
# result is returned in $result # Result is returned in $result
# We use my_print_defaults which prints all options from multiple files, # We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match. # with the more specific ones later; hence take the last match.
get_mysql_option(){ get_mysql_option () {
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1` option=$1
if [ -z "$result" ]; then default=$2
# not found, use default shift 2
result="$3" result=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
fi if [ -z "$result" ]; then
# not found, use default
result="${default}"
fi
} }
get_mysql_option mysqld datadir "/var/lib/mysql" get_mysql_option datadir "/var/lib/mysql" mysqld
datadir="$result" datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock" get_mysql_option socket "$datadir/mysql.sock" mysqld
socketfile="$result" socketfile="$result"
get_mysql_option mysqld_safe log-error "/var/log/mysqld.log" get_mysql_option log-error "/var/log/mysqld.log" mysqld mysqld_safe
errlogfile="$result" errlogfile="$result"
get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" get_mysql_option pid-file "/var/run/mysqld/mysqld.pid" mysqld mysqld_safe
mypidfile="$result" mypidfile="$result"
case $socketfile in case $socketfile in
......
...@@ -38,23 +38,23 @@ PROG=/usr/bin/mysqld_safe ...@@ -38,23 +38,23 @@ PROG=/usr/bin/mysqld_safe
lockfile=/var/lock/subsys/mysql lockfile=/var/lock/subsys/mysql
get_option () { get_option () {
local section=$1 local option=$1
local option=$2 local default=$2
local default=$3 shift 2
ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-) ret=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
[ -z $ret ] && ret=$default [ -z $ret ] && ret=${default}
echo $ret echo $ret
} }
datadir=$(get_option mysqld datadir "/var/lib/mysql") datadir=$(get_option datadir "/var/lib/mysql" mysqld)
socket=$(get_option mysqld socket "$datadir/mysql.sock") socket=$(get_option socket "$datadir/mysql.sock" mysqld)
pidfile=$(get_option mysqld_safe pid-file "/var/run/mysql/mysqld.pid") pidfile=$(get_option pid-file "/var/run/mysql/mysqld.pid" mysqld mysqld_safe)
install_db () { install_db () {
# Note: something different than datadir=/var/lib/mysql requires # Note: something different than datadir=/var/lib/mysql requires
# SELinux policy changes (in enforcing mode) # SELinux policy changes (in enforcing mode)
datadir=$(get_option mysqld datadir "/var/lib/mysql") datadir=$(get_option datadir "/var/lib/mysql" mysqld)
logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") logfile=$(get_option log-error "/var/log/mysql/mysqld.log" mysqld mysqld_safe)
# Restore log, dir, perms and SELinux contexts # Restore log, dir, perms and SELinux contexts
if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment