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