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=
lockfile=/var/lock/subsys/$prog
# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# Extract value of a MySQL option from config files
# Usage: get_mysql_option OPTION DEFAULT SECTION1 SECTION2 SECTIONN
# Result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
get_mysql_option () {
option=$1
default=$2
shift 2
result=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
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"
get_mysql_option mysqld socket "$datadir/mysql.sock"
get_mysql_option socket "$datadir/mysql.sock" mysqld
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"
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"
case $socketfile in
......
......@@ -38,23 +38,23 @@ PROG=/usr/bin/mysqld_safe
lockfile=/var/lock/subsys/mysql
get_option () {
local section=$1
local option=$2
local default=$3
ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
[ -z $ret ] && ret=$default
local option=$1
local default=$2
shift 2
ret=$(/usr/bin/my_print_defaults "$@" | sed -n "s/^--${option}=//p" | tail -n 1)
[ -z $ret ] && ret=${default}
echo $ret
}
datadir=$(get_option mysqld datadir "/var/lib/mysql")
socket=$(get_option mysqld socket "$datadir/mysql.sock")
pidfile=$(get_option mysqld_safe pid-file "/var/run/mysql/mysqld.pid")
datadir=$(get_option datadir "/var/lib/mysql" mysqld)
socket=$(get_option socket "$datadir/mysql.sock" mysqld)
pidfile=$(get_option pid-file "/var/run/mysql/mysqld.pid" mysqld mysqld_safe)
install_db () {
# Note: something different than datadir=/var/lib/mysql requires
# SELinux policy changes (in enforcing mode)
datadir=$(get_option mysqld datadir "/var/lib/mysql")
logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log")
datadir=$(get_option datadir "/var/lib/mysql" mysqld)
logfile=$(get_option log-error "/var/log/mysql/mysqld.log" mysqld mysqld_safe)
# Restore log, dir, perms and SELinux contexts
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