summaryrefslogtreecommitdiff
path: root/support-files/mysql.server.sh
diff options
context:
space:
mode:
authorunknown <tim@threads.polyesthetic.msg>2000-11-29 15:21:48 -0500
committerunknown <tim@threads.polyesthetic.msg>2000-11-29 15:21:48 -0500
commitd3cce712223312cd1f3341e462918162f4261246 (patch)
tree9ddfe8fb21a1b1a4814dba13d7ab541c56165b38 /support-files/mysql.server.sh
parentef2356d653cc40096b45a7d5bb9fb82f379dca66 (diff)
downloadmariadb-git-d3cce712223312cd1f3341e462918162f4261246.tar.gz
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). scripts/mysql_install_db.sh: - use mysql_print_defaults instead of awk hack - actually pass unrecognized options to mysqld, instead of ignoring them - recognize a [mysql_install_db] section of my.cnf - general cleanup scripts/safe_mysqld.sh: - handle a relative pid-file the same way mysqld does support-files/mysql.server.sh: - use mysql_print_defaults instead of awk hack - recognize a [mysql_server] section of my.cnf - handle a relative pid-file the same way mysqld does - general cleanup Docs/manual.texi: - News item: safe_mysqld, mysql.server and mysql_install_db have been modified
Diffstat (limited to 'support-files/mysql.server.sh')
-rw-r--r--support-files/mysql.server.sh116
1 files changed, 57 insertions, 59 deletions
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index b28cff66b24..9d66fb8d13e 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -4,71 +4,70 @@
# Mysql daemon start/stop script.
-# Usually this is put in /etc/init.d (at least on machines SYSV R4
-# based 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
-# and shut down when the systems goes down.
+# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
+# 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 and shut down when the systems goes down.
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description: A very fast and reliable SQL database engine.
-# 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
-# in the /etc/my.cnf or other configuration files
+# 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
+# in the /etc/my.cnf or other configuration files.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
-basedir=@prefix@
-bindir=@bindir@
-sbindir=@sbindir@
-datadir=@localstatedir@
-pid_file=@localstatedir@/mysqld.pid
export PATH
mode=$1
-GetCNF () {
-
-VARIABLES="basedir bindir sbindir datadir pid-file"
-CONFIG_FILES="/etc/my.cnf $basedir/my.cnf $HOME/.my.cnf"
-
-for c in $CONFIG_FILES
-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
-
- # As long as $thevar isn't blank, use it to set or override current
- # value
- [ "$thevar" != "" ] && eval $v=$thevar
-
- done
- #else
- # echo "No $c config file."
- fi
-done
+parse_arguments() {
+ for arg do
+ case "$arg" in
+ --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
+ esac
+ done
}
-# run function to get config values
-GetCNF
+# Get arguments from the my.cfg file, group [mysqld]
+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..)
cd $basedir
@@ -81,13 +80,12 @@ case "$mode" in
then
# Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade.
- $bindir/safe_mysqld \
- --datadir=$datadir --pid-file=$pid_file &
- # Make lock for RedHat / SuSE
- if test -d /var/lock/subsys
- then
- touch /var/lock/subsys/mysql
- fi
+ $bindir/safe_mysqld --datadir=$datadir --pid-file=$pid_file &
+ # Make lock for RedHat / SuSE
+ if test -d /var/lock/subsys
+ then
+ touch /var/lock/subsys/mysql
+ fi
else
echo "Can't execute $bindir/safe_mysqld"
fi
@@ -115,7 +113,7 @@ case "$mode" in
then echo " done"
fi
# delete lock for RedHat / SuSE
- if test -d /var/lock/subsys
+ if test -e /var/lock/subsys/mysql
then
rm /var/lock/subsys/mysql
fi