Skip to content

Commit 4a67e7b

Browse files
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents 7efac81 + b7f33d2 commit 4a67e7b

File tree

2 files changed

+69
-79
lines changed

2 files changed

+69
-79
lines changed

scripts/mysqld_safe.sh

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ esac
6565
usage () {
6666
cat <<EOF
6767
Usage: $0 [OPTIONS]
68+
The following options may be given as the first argument:
6869
--no-defaults Don't read the system defaults file
6970
--defaults-file=FILE Use the specified defaults file
7071
--defaults-extra-file=FILE Also use defaults from the specified file
72+
73+
Other options:
7174
--ledir=DIRECTORY Look for mysqld in the specified directory
7275
--open-files-limit=LIMIT Limit the number of open files
7376
--core-file-size=LIMIT Limit core files to the specified size
@@ -206,7 +209,12 @@ parse_arguments() {
206209
case "$arg" in
207210
# these get passed explicitly to mysqld
208211
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
209-
--datadir=*) DATADIR="$val" ;;
212+
--datadir=*)
213+
case $val in
214+
/) DATADIR=$val ;;
215+
*) DATADIR="`echo $val | sed 's;/*$;;'`" ;;
216+
esac
217+
;;
210218
--pid-file=*) pid_file="$val" ;;
211219
--plugin-dir=*) PLUGIN_DIR="$val" ;;
212220
--user=*) user="$val"; SET_USER=1 ;;
@@ -388,63 +396,70 @@ set_malloc_lib() {
388396
add_mysqld_ld_preload "$malloc_lib"
389397
}
390398

399+
find_basedir_from_cmdline () {
400+
for arg in "$@"; do
401+
case $arg in
402+
--basedir=*)
403+
MY_BASEDIR_VERSION="`echo "$arg" | sed -e 's;^--[^=]*=;;'`"
404+
# Convert to full path
405+
cd "$MY_BASEDIR_VERSION"
406+
if [ $? -ne 0 ] ; then
407+
log_error "--basedir set to '$MY_BASEDIR_VERSION', however could not access directory"
408+
exit 1
409+
fi
410+
MY_BASEDIR_VERSION="`pwd`"
411+
;;
412+
esac
413+
done
414+
}
391415

392416
#
393417
# First, try to find BASEDIR and ledir (where mysqld is)
394418
#
395419

396-
if echo '@pkgdatadir@' | grep '^@prefix@' > /dev/null
397-
then
398-
relpkgdata=`echo '@pkgdatadir@' | sed -e 's,^@prefix@,,' -e 's,^/,,' -e 's,^,./,'`
420+
oldpwd="`pwd`"
421+
422+
# Args not parsed yet, check if --basedir was given on command line
423+
find_basedir_from_cmdline "$@"
424+
425+
# --basedir is already overridden on command line
426+
if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" ; then
427+
# Search for mysqld and set ledir
428+
for dir in @INSTALL_SBINDIR@ libexec sbin bin ; do
429+
if test -x "$MY_BASEDIR_VERSION/$dir/mysqld" ; then
430+
ledir="$MY_BASEDIR_VERSION/$dir"
431+
break
432+
fi
433+
done
434+
399435
else
400-
# pkgdatadir is not relative to prefix
401-
relpkgdata='@pkgdatadir@'
402-
fi
436+
# Basedir should be parent dir of bindir, unless some non-standard
437+
# layout is used
403438

404-
case "$0" in
405-
/*)
406-
MY_PWD='@prefix@'
407-
;;
408-
*)
409-
MY_PWD=`dirname $0`
410-
MY_PWD=`dirname $MY_PWD`
411-
;;
412-
esac
413-
# Check for the directories we would expect from a binary release install
414-
if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"
415-
then
416-
# BASEDIR is already overridden on command line. Do not re-set.
439+
cd "`dirname $0`"
440+
if [ -h "$0" ] ; then
441+
realpath="`ls -l "$0" | awk '{print $NF}'`"
442+
cd "`dirname "$realpath"`"
443+
fi
444+
cd ..
445+
MY_PWD="`pwd`"
446+
447+
# Search for mysqld and set ledir and BASEDIR
448+
for dir in @INSTALL_SBINDIR@ libexec sbin bin ; do
449+
if test -x "$MY_PWD/$dir/mysqld" ; then
450+
MY_BASEDIR_VERSION="$MY_PWD"
451+
ledir="$MY_BASEDIR_VERSION/$dir"
452+
break
453+
fi
454+
done
417455

418-
# Use BASEDIR to discover le.
419-
if test -x "$MY_BASEDIR_VERSION/libexec/mysqld"
420-
then
421-
ledir="$MY_BASEDIR_VERSION/libexec"
422-
elif test -x "$MY_BASEDIR_VERSION/sbin/mysqld"
423-
then
424-
ledir="$MY_BASEDIR_VERSION/sbin"
425-
else
426-
ledir="$MY_BASEDIR_VERSION/bin"
456+
# If we still didn't find anything, use the compiled-in defaults
457+
if test -z "$MY_BASEDIR_VERSION" ; then
458+
MY_BASEDIR_VERSION='@prefix@'
459+
ledir='@libexecdir@'
427460
fi
428-
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld"
429-
then
430-
MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are
431-
ledir="$MY_PWD/bin" # Where mysqld is
432-
# Check for the directories we would expect from a source install
433-
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld"
434-
then
435-
MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are
436-
ledir="$MY_PWD/libexec" # Where mysqld is
437-
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/sbin/mysqld"
438-
then
439-
MY_BASEDIR_VERSION="$MY_PWD" # Where sbin, share and var are
440-
ledir="$MY_PWD/sbin" # Where mysqld is
441-
# Since we didn't find anything, used the compiled-in defaults
442-
else
443-
MY_BASEDIR_VERSION='@prefix@'
444-
ledir='@libexecdir@'
445461
fi
446462

447-
448463
#
449464
# Second, try to find the data directory
450465
#
@@ -457,10 +472,6 @@ then
457472
then
458473
defaults="--defaults-extra-file=$DATADIR/my.cnf"
459474
fi
460-
# Next try where the source installs put it
461-
elif test -d $MY_BASEDIR_VERSION/var/mysql
462-
then
463-
DATADIR=$MY_BASEDIR_VERSION/var
464475
# Or just give up and use our compiled-in default
465476
else
466477
DATADIR=@localstatedir@
@@ -491,21 +502,10 @@ export MYSQL_HOME
491502

492503
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
493504
# and then merge with the command line arguments
494-
if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults"
495-
then
505+
if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults" ; then
496506
print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults"
497-
elif test -x `dirname $0`/my_print_defaults
498-
then
499-
print_defaults="`dirname $0`/my_print_defaults"
500-
elif test -x ./bin/my_print_defaults
501-
then
502-
print_defaults="./bin/my_print_defaults"
503-
elif test -x @bindir@/my_print_defaults
504-
then
507+
elif test -x "@bindir@/my_print_defaults" ; then
505508
print_defaults="@bindir@/my_print_defaults"
506-
elif test -x @bindir@/mysql_print_defaults
507-
then
508-
print_defaults="@bindir@/mysql_print_defaults"
509509
else
510510
print_defaults="my_print_defaults"
511511
fi
@@ -516,6 +516,8 @@ append_arg_to_args () {
516516

517517
args=
518518

519+
cd "$oldpwd"
520+
519521
SET_USER=2
520522
parse_arguments `$print_defaults $defaults --loose-verbose mysqld server`
521523
if test $SET_USER -eq 2
@@ -613,7 +615,7 @@ fi
613615
logdir=`dirname "$err_log"`
614616
# Change the err log to the right user, if possible and it is in use
615617
if [ $logging = "file" -o $logging = "both" ]; then
616-
if [ ! -f "$err_log" -a ! -h "$err_log" ]; then
618+
if [ ! -e "$err_log" -a ! -h "$err_log" ]; then
617619
if test -w / -o "$USER" = "root"; then
618620
case $logdir in
619621
/var/log)
@@ -633,7 +635,7 @@ if [ $logging = "file" -o $logging = "both" ]; then
633635
fi
634636
fi
635637

636-
if [ -f "$err_log" ]; then # Log to err_log file
638+
if [ -f "$err_log" -o -p "$err_log" ]; then # Log to err_log file
637639
log_notice "Logging to '$err_log'."
638640
elif [ "x$user" = "xroot" ]; then # running as root, mysqld can create log file; continue
639641
echo "Logging to '$err_log'." >&2

support-files/mysql.server.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,8 @@ wait_for_pid () {
200200

201201
# Get arguments from the my.cnf file,
202202
# the only group, which is read from now on is [mysqld]
203-
if test -x ./bin/my_print_defaults
204-
then
205-
print_defaults="./bin/my_print_defaults"
206-
elif test -x $bindir/my_print_defaults
207-
then
203+
if test -x "$bindir/my_print_defaults"; then
208204
print_defaults="$bindir/my_print_defaults"
209-
elif test -x $bindir/mysql_print_defaults
210-
then
211-
print_defaults="$bindir/mysql_print_defaults"
212205
else
213206
# Try to find basedir in /etc/my.cnf
214207
conf=/etc/my.cnf
@@ -225,11 +218,6 @@ else
225218
print_defaults="$d/bin/my_print_defaults"
226219
break
227220
fi
228-
if test -x "$d/bin/mysql_print_defaults"
229-
then
230-
print_defaults="$d/bin/mysql_print_defaults"
231-
break
232-
fi
233221
done
234222
fi
235223

0 commit comments

Comments
 (0)