Clean up safe_mysqld, mysql_install_db and mysql.server. They

should now work the way you expect them to (process command-line
arguments consistently).
parent 0c94c1de
...@@ -38966,6 +38966,11 @@ though, so Version 3.23 is not released as a stable version yet. ...@@ -38966,6 +38966,11 @@ though, so Version 3.23 is not released as a stable version yet.
@appendixsubsec Changes in release 3.23.29 @appendixsubsec Changes in release 3.23.29
@itemize @bullet @itemize @bullet
@item @item
safe_mysqld, mysql.server and mysql_install_db have been modified
to use mysql_print_defaults instead of various hacks to read the
my.cnf files. In addition, the handling of various paths has been
made more consistent with how mysqld handles them by default.
@item
Automatically remove Berkeley DB transaction logs that are no longer in Automatically remove Berkeley DB transaction logs that are no longer in
use. use.
@item @item
#!/bin/sh #!/bin/sh
# Copyright (C) 1997, 1998, 1999 TCX DataKonsult AB & Monty Program KB & Detron HB # Copyright (C) 1997, 1998, 1999 TCX DataKonsult AB & Monty Program KB & Detron HB
# For a more info consult the file COPYRIGHT distributed with this file # For a more info consult the file COPYRIGHT distributed with this file.
# This scripts creates the privilege tables db, host, user, tables_priv, # This scripts creates the privilege tables db, host, user, tables_priv,
# columns_priv in the mysql database, as well as the func table. # columns_priv in the mysql database, as well as the func table.
# #
# All arguments (exept -IN-RPM as a first argument) to this script are # All unrecognized arguments to this script are passed to mysqld.
# passed to mysqld
ldata=@localstatedir@
execdir=@libexecdir@
bindir=@bindir@
sbindir=@sbindir@
force=0
IN_RPM=0 IN_RPM=0
defaults= case "$1" in
-IN-RPM)
while [ "x$1" != x ] IN_RPM="$1"; shift
do
case "$1" in
-*) eqvalue="`echo $1 |sed 's/[-_a-zA-Z0-9]*=//'`"
case "$1" in
-IN-RPM) IN_RPM=1
;;
--force) force=1
;;
--no-defaults) defaults="$1"; CONFIG_FILES=/nonexistent
;;
--defaults-file=*) defaults="$1"; CONFIG_FILES="$eqvalue"
;;
--basedir=*) SETVARS="$SETVARS basedir=\"$eqvalue\"; bindir=\"$eqvalue/bin\"; execdir=\"$eqvalue/libexec\"; sbindir=\"$eqvalue/sbin\"; "
;;
--ldata=*|--datadir=*) SETVARS="$SETVARS ldata=\"$eqvalue\";"
;; ;;
--user=*) SETVARS="$SETVARS user=\"$eqvalue\";" esac
;; defaults=
esac case "$1" in
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$1"; shift
;; ;;
esac esac
parse_arguments() {
# We only need to pass arguments through to the server if we don't
# handle them here. So, we collect unrecognized options (passed on
# the command line) into the args variable.
pick_args=
if test "$1" = PICK-ARGS-FROM-ARGV
then
pick_args=1
shift shift
done fi
GetCNF () {
VARIABLES="basedir bindir datadir sbindir user pid-file log port socket"
# set it not already set
CONFIG_FILES=${CONFIG_FILES:-"/etc/my.cnf ./my.cnf $HOME/.my.cnf"}
for c in $CONFIG_FILES for arg do
do case "$arg" in
if [ -f $c ] --force) force=1 ;;
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
*)
if test -n "$pick_args"
then then
#echo "Processing $c..." # This sed command makes sure that any special chars are quoted,
for v in $VARIABLES # so the arg gets passed exactly to the server.
do args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'`
# This method assumes last of duplicate $variable entries will be the fi
# value set ([mysqld]) ;;
# This could easily be rewritten to gather [xxxxx]-specific entries,
# but for now it looks like only the mysqld ones are needed for
# server startup scripts
thevar=""
eval `sed -n -e '/^$/d' -e '/^#/d' -e 's,[ ],,g' -e '/=/p' $c |\
awk -F= -v v=$v '{if ($1 == v) printf ("thevar=\"%s\"\n", $2)}'`
# it would be easier if the my.cnf and variable values were
# all matched, but since they aren't we need to map them here.
case $v in
pid-file) v=pid_file ;;
log) v=log_file ;;
datadir) v=ldata ;;
esac esac
# As long as $thevar isn't blank, use it to set or override current
# value
[ "$thevar" != "" ] && eval $v=$thevar
done done
#else
# echo "No $c config file."
fi
done
} }
# run function to get config values # Get first arguments from the my.cfg file, groups [mysqld] and
GetCNF # [mysql_install_db], and then merge with the command line arguments
if test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x @bindir@/my_print_defaults
then
print_defaults="@bindir@/my_print_defaults"
elif test -x @bindir@/mysql_print_defaults
then
print_defaults="@bindir@/mysql_print_defaults"
else
print_defaults="my_print_defaults"
fi
# Override/set with command-line values args=
eval $SETVARS ldata=
execdir=
bindir=
basedir=
force=0
parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
parse_arguments PICK-ARGS-FROM-ARGV "$@"
test -z "$ldata" && ldata=@localstatedir@
if test -z "$basedir"
then
basedir=@prefix@
bindir=@bindir@
execdir=@libexecdir@
else
bindir="$basedir/bin"
execdir="$basedir/libexec"
fi
mdata=$ldata/mysql mdata=$ldata/mysql
...@@ -151,7 +146,7 @@ c_t="" c_c="" ...@@ -151,7 +146,7 @@ c_t="" c_c=""
# Check for old tables # Check for old tables
if test ! -f $mdata/db.frm if test ! -f $mdata/db.frm
then then
echo "Creating db table" echo "Preparing db table"
# mysqld --bootstrap wants one command/line # mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db (" c_d="$c_d CREATE TABLE db ("
...@@ -179,7 +174,7 @@ fi ...@@ -179,7 +174,7 @@ fi
if test ! -f $mdata/host.frm if test ! -f $mdata/host.frm
then then
echo "Creating host table" echo "Preparing host table"
c_h="$c_h CREATE TABLE host (" c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) DEFAULT '' NOT NULL," c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
...@@ -201,7 +196,7 @@ fi ...@@ -201,7 +196,7 @@ fi
if test ! -f $mdata/user.frm if test ! -f $mdata/user.frm
then then
echo "Creating user table" echo "Preparing user table"
c_u="$c_u CREATE TABLE user (" c_u="$c_u CREATE TABLE user ("
c_u="$c_u Host char(60) DEFAULT '' NOT NULL," c_u="$c_u Host char(60) DEFAULT '' NOT NULL,"
...@@ -237,7 +232,7 @@ fi ...@@ -237,7 +232,7 @@ fi
if test ! -f $mdata/func.frm if test ! -f $mdata/func.frm
then then
echo "Creating func table" echo "Preparing func table"
c_f="$c_f CREATE TABLE func (" c_f="$c_f CREATE TABLE func ("
c_f="$c_f name char(64) DEFAULT '' NOT NULL," c_f="$c_f name char(64) DEFAULT '' NOT NULL,"
...@@ -251,7 +246,7 @@ fi ...@@ -251,7 +246,7 @@ fi
if test ! -f $mdata/tables_priv.frm if test ! -f $mdata/tables_priv.frm
then then
echo "Creating tables_priv table" echo "Preparing tables_priv table"
c_t="$c_t CREATE TABLE tables_priv (" c_t="$c_t CREATE TABLE tables_priv ("
c_t="$c_t Host char(60) DEFAULT '' NOT NULL," c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
...@@ -270,7 +265,7 @@ fi ...@@ -270,7 +265,7 @@ fi
if test ! -f $mdata/columns_priv.frm if test ! -f $mdata/columns_priv.frm
then then
echo "Creating columns_priv table" echo "Preparing columns_priv table"
c_c="$c_c CREATE TABLE columns_priv (" c_c="$c_c CREATE TABLE columns_priv ("
c_c="$c_c Host char(60) DEFAULT '' NOT NULL," c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
...@@ -285,8 +280,9 @@ then ...@@ -285,8 +280,9 @@ then
c_c="$c_c comment='Column privileges';" c_c="$c_c comment='Column privileges';"
fi fi
if $execdir/mysqld $defaults --bootstrap --skip-grant-tables \ echo "Installing all prepared tables"
--basedir=@prefix@ --datadir=$ldata "$@" << END_OF_DATA if eval "$execdir/mysqld $defaults --bootstrap --skip-grant-tables \
--basedir=$basedir --datadir=$ldata $args" << END_OF_DATA
use mysql; use mysql;
$c_d $c_d
$i_d $i_d
......
...@@ -118,7 +118,15 @@ then ...@@ -118,7 +118,15 @@ then
exit 1 exit 1
fi fi
test -z "$pid_file" && pid_file=$DATADIR/`@HOSTNAME@`.pid if test -z "$pid_file"
then
pid_file=$DATADIR/`@HOSTNAME@`.pid
else
case "$pid_file" in
/* ) ;;
* ) pid_file="$DATADIR/$pid_file" ;;
esac
fi
test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err
export MYSQL_UNIX_PORT export MYSQL_UNIX_PORT
......
...@@ -4,71 +4,70 @@ ...@@ -4,71 +4,70 @@
# Mysql daemon start/stop script. # Mysql daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 # Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# based systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/S01mysql. # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/S01mysql.
# When this is done the mysql server will be started when the machine is started # When this is done the mysql server will be started when the machine is
# and shut down when the systems goes down. # started and shut down when the systems goes down.
# Comments to support chkconfig on RedHat Linux # Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90 # chkconfig: 2345 90 90
# description: A very fast and reliable SQL database engine. # description: A very fast and reliable SQL database engine.
# The following variables are only set for letting mysql.server find things # The following variables are only set for letting mysql.server find things.
# if you want to affect other MySQL variables, you should make your changes # If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf or other configuration files # in the /etc/my.cnf or other configuration files.
PATH=/sbin:/usr/sbin:/bin:/usr/bin PATH=/sbin:/usr/sbin:/bin:/usr/bin
basedir=@prefix@
bindir=@bindir@
sbindir=@sbindir@
datadir=@localstatedir@
pid_file=@localstatedir@/mysqld.pid
export PATH export PATH
mode=$1 mode=$1
GetCNF () { parse_arguments() {
for arg do
VARIABLES="basedir bindir sbindir datadir pid-file" case "$arg" in
CONFIG_FILES="/etc/my.cnf $basedir/my.cnf $HOME/.my.cnf" --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
for c in $CONFIG_FILES --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
do
if [ -f $c ]
then
#echo "Processing $c..."
for v in $VARIABLES
do
# This method assumes last of duplicate $variable entries will be the
# value set ([mysqld])
# This could easily be rewritten to gather [xxxxx]-specific entries,
# but for now it looks like only the mysqld ones are needed for
# server startup scripts
thevar=""
eval `sed -n -e '/^$/d' -e '/^#/d' -e 's,[ ],,g' -e '/=/p' $c |\
awk -F= -v v=$v '{if ($1 == v) printf ("thevar=\"%s\"\n", $2)}'`
# it would be easier if the my.cnf and variable values were
# all matched, but since they aren't we need to map them here.
case $v in
pid-file) v=pid_file ;;
log) v=log_file ;;
esac esac
# As long as $thevar isn't blank, use it to set or override current
# value
[ "$thevar" != "" ] && eval $v=$thevar
done done
#else
# echo "No $c config file."
fi
done
} }
# run function to get config values # Get arguments from the my.cfg file, group [mysqld]
GetCNF if test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x @bindir@/my_print_defaults
then
print_defaults="@bindir@/my_print_defaults"
elif test -x @bindir@/mysql_print_defaults
then
print_defaults="@bindir@/mysql_print_defaults"
else
print_defaults="my_print_defaults"
fi
datadir=@localstatedir@
basedir=
pid_file=
parse_arguments `$print_defaults $defaults mysqld mysql_server`
if test -z "$basedir"
then
basedir=@prefix@
bindir=@bindir@
else
bindir="$basedir/bin"
fi
if test -z "$pid_file"
then
pid_file=$datadir/mysqld.pid
else
case "$pid_file" in
/* ) ;;
* ) pid_file="$datadir/$pid_file" ;;
esac
fi
# Safeguard (relative paths, core dumps..) # Safeguard (relative paths, core dumps..)
cd $basedir cd $basedir
...@@ -81,8 +80,7 @@ case "$mode" in ...@@ -81,8 +80,7 @@ case "$mode" in
then then
# Give extra arguments to mysqld with the my.cnf file. This script may # Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade. # be overwritten at next upgrade.
$bindir/safe_mysqld \ $bindir/safe_mysqld --datadir=$datadir --pid-file=$pid_file &
--datadir=$datadir --pid-file=$pid_file &
# Make lock for RedHat / SuSE # Make lock for RedHat / SuSE
if test -d /var/lock/subsys if test -d /var/lock/subsys
then then
...@@ -115,7 +113,7 @@ case "$mode" in ...@@ -115,7 +113,7 @@ case "$mode" in
then echo " done" then echo " done"
fi fi
# delete lock for RedHat / SuSE # delete lock for RedHat / SuSE
if test -d /var/lock/subsys if test -e /var/lock/subsys/mysql
then then
rm /var/lock/subsys/mysql rm /var/lock/subsys/mysql
fi fi
......
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