|
|
80384c |
#!/bin/sh
|
|
|
80384c |
|
|
|
80384c |
# Some useful functions used in other MySQL helper scripts
|
|
|
80384c |
# This scripts defines variables datadir, errlogfile, socketfile
|
|
|
80384c |
|
|
|
80384c |
export LC_ALL=C
|
|
|
80384c |
|
|
|
80384c |
# extract value of a MySQL option from config files
|
|
|
80384c |
# Usage: get_mysql_option VARNAME DEFAULT SECTION [ SECTION, ... ]
|
|
|
80384c |
# result is returned in $result
|
|
|
80384c |
# We use my_print_defaults which prints all options from multiple files,
|
|
|
80384c |
# with the more specific ones later; hence take the last match.
|
|
|
80384c |
get_mysql_option(){
|
|
|
80384c |
if [ $# -ne 3 ] ; then
|
|
|
80384c |
echo "get_mysql_option requires 3 arguments: section option default_value"
|
|
|
80384c |
return
|
|
|
80384c |
fi
|
|
|
80384c |
sections="$1"
|
|
|
80384c |
option_name="$2"
|
|
|
80384c |
default_value="$3"
|
|
|
80384c |
result=`@bindir@/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1`
|
|
|
80384c |
if [ -z "$result" ]; then
|
|
|
80384c |
# not found, use default
|
|
|
80384c |
result="${default_value}"
|
|
|
80384c |
fi
|
|
|
80384c |
}
|
|
|
80384c |
|
|
|
80384c |
# Defaults here had better match what mysqld_safe will default to
|
|
|
80384c |
# The option values are generally defined on three important places
|
|
|
80384c |
# on the default installation:
|
|
|
80384c |
# 1) default values are hardcoded in the code of mysqld daemon or
|
|
|
80384c |
# mysqld_safe script
|
|
|
80384c |
# 2) configurable values are defined in @sysconfdir@/my.cnf
|
|
|
80384c |
# 3) default values for helper scripts are specified bellow
|
|
|
80384c |
# So, in case values are defined in my.cnf, we need to get that value.
|
|
|
80384c |
# In case they are not defined in my.cnf, we need to get the same value
|
|
|
80384c |
# in the daemon, as in the helper scripts. Thus, default values here
|
|
|
80384c |
# must correspond with values defined in mysqld_safe script and source
|
|
|
80384c |
# code itself.
|
|
|
80384c |
|
|
|
80384c |
server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ client-server"
|
|
|
80384c |
|
|
|
80384c |
get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@"
|
|
|
80384c |
datadir="$result"
|
|
|
80384c |
|
|
|
80384c |
# if there is log_error in the my.cnf, my_print_defaults still
|
|
|
80384c |
# returns log-error
|
|
|
80384c |
# log-error might be defined in mysqld_safe and mysqld sections,
|
|
|
80384c |
# the former has bigger priority
|
|
|
80384c |
get_mysql_option "$server_sections" log-error "$datadir/`hostname`.err"
|
|
|
80384c |
errlogfile="$result"
|
|
|
80384c |
|
|
|
80384c |
get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@"
|
|
|
80384c |
socketfile="$result"
|
|
|
80384c |
|
|
|
80384c |
get_mysql_option "$server_sections" pid-file "$datadir/`hostname`.pid"
|
|
|
80384c |
pidfile="$result"
|
|
|
80384c |
|