Commit 0c03aea1 authored by monty@mishka.local's avatar monty@mishka.local

Set bindir, datadir & others if --basedir is given. This ensures that one only...

Set bindir, datadir & others if --basedir is given. This ensures that one only has to set basedir in [mysqld] group when moving a binary installation to a not default polace
Use for now safe_mysqld by default. (unless use-manager is set in the [mysql.server] option in my.cnf)
Search first for defaults files in basedir and then in datadir (like mysqld_safe)
parent de1b1fe5
...@@ -49,6 +49,7 @@ datadir= ...@@ -49,6 +49,7 @@ datadir=
# Set some defaults # Set some defaults
pid_file= pid_file=
server_pid_file= server_pid_file=
use_mysqld_safe=1
user=@MYSQLD_USER@ user=@MYSQLD_USER@
if test -z "$basedir" if test -z "$basedir"
then then
...@@ -59,6 +60,7 @@ then ...@@ -59,6 +60,7 @@ then
libexecdir=@libexecdir@ libexecdir=@libexecdir@
else else
bindir="$basedir/bin" bindir="$basedir/bin"
datadir="$basedir/data"
sbindir="$basedir/bin" sbindir="$basedir/bin"
libexecdir="$basedir/bin" libexecdir="$basedir/bin"
fi fi
...@@ -94,10 +96,17 @@ esac ...@@ -94,10 +96,17 @@ esac
parse_server_arguments() { parse_server_arguments() {
for arg do for arg do
case "$arg" in case "$arg" in
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
bindir="$basedir/bin"
datadir="$basedir/data"
sbindir="$basedir/bin"
libexecdir="$basedir/bin"
;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--use-mysqld_safe) use_mysqld_safe=1;;
--use-manager) use_mysqld_safe=0;;
esac esac
done done
} }
...@@ -178,14 +187,19 @@ else ...@@ -178,14 +187,19 @@ else
fi fi
# #
# Test if someone changed datadir; In this case we should also read the # Read defaults file from 'basedir'. If there is no defaults file there
# default arguments from this directory # check if it's in the old (depricated) place (datadir) and read it from there
# #
extra_args="" extra_args=""
if test "$datadir" != "@localstatedir@" if test -r "$basedir/my.cnf"
then then
extra_args="-e $datadir/my.cnf" extra_args="-e $basedir/my.cnf"
else
if test -r "$datadir/my.cnf"
then
extra_args="-e $datadir/my.cnf"
fi
fi fi
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
...@@ -231,11 +245,11 @@ case "$mode" in ...@@ -231,11 +245,11 @@ case "$mode" in
manager=$sbindir/mysqlmanager manager=$sbindir/mysqlmanager
fi fi
if test -x $manager echo $echo_n "Starting MySQL"
if test -x $manager -a "$use_mysqld_safe" = "0"
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.
echo $echo_n "Starting MySQL"
$manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 & $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 &
wait_for_pid created wait_for_pid created
...@@ -246,8 +260,8 @@ case "$mode" in ...@@ -246,8 +260,8 @@ case "$mode" in
fi fi
elif test -x $bindir/mysqld_safe elif test -x $bindir/mysqld_safe
then then
# Give extra arguments to mysqld with the my.cnf file. This script may be overwritten at next upgrade. # Give extra arguments to mysqld with the my.cnf file. This script
echo $echo_n "Starting MySQL" # may be overwritten at next upgrade.
pid_file=$server_pid_file pid_file=$server_pid_file
$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file >/dev/null 2>&1 & $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file >/dev/null 2>&1 &
wait_for_pid created wait_for_pid created
......
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