$OpenBSD: patch-scripts_mysqld_safe_sh,v 1.12 2007/04/09 22:43:06 ckuethe Exp $
--- scripts/mysqld_safe.sh.orig	Mon Mar  5 20:21:13 2007
+++ scripts/mysqld_safe.sh	Sat Mar 31 19:02:39 2007
@@ -107,72 +107,12 @@ parse_arguments() {
 }
 
 
-#
-# First, try to find BASEDIR and ledir (where mysqld is)
-# 
+MY_BASEDIR_VERSION=@prefix@
+ledir=@libexecdir@
+DATADIR=@localstatedir@
 
-MY_PWD=`pwd`
-# Check for the directories we would expect from a binary release install
-if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld
-then
-  MY_BASEDIR_VERSION=$MY_PWD		# Where bin, share and data are
-  ledir=$MY_BASEDIR_VERSION/bin		# Where mysqld is
-# Check for the directories we would expect from a source install
-elif test -f ./share/mysql/english/errmsg.sys -a \
- -x ./libexec/mysqld
-then
-  MY_BASEDIR_VERSION=$MY_PWD		# Where libexec, share and var are
-  ledir=$MY_BASEDIR_VERSION/libexec	# Where mysqld is
-# Since we didn't find anything, used the compiled-in defaults
-else
-  MY_BASEDIR_VERSION=@prefix@
-  ledir=@libexecdir@
-fi
-
-#
-# Second, try to find the data directory
-#
-
-# Try where the binary installs put it
-if test -d $MY_BASEDIR_VERSION/data/mysql
-then
-  DATADIR=$MY_BASEDIR_VERSION/data
-  if test -z "$defaults" -a -r "$DATADIR/my.cnf"
-  then
-    defaults="--defaults-extra-file=$DATADIR/my.cnf"
-  fi
-# Next try where the source installs put it
-elif test -d $MY_BASEDIR_VERSION/var/mysql
-then
-  DATADIR=$MY_BASEDIR_VERSION/var
-# Or just give up and use our compiled-in default
-else
-  DATADIR=@localstatedir@
-fi
-
-if test -z "$MYSQL_HOME"
-then 
-  if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf"
-  then
-    echo "WARNING: Found two instances of my.cnf -"
-    echo "$MY_BASEDIR_VERSION/my.cnf and"
-    echo "$DATADIR/my.cnf"
-    echo "IGNORING $DATADIR/my.cnf"
-    echo
-    MYSQL_HOME=$MY_BASEDIR_VERSION
-  elif test -r "$DATADIR/my.cnf"
-  then
-    echo "WARNING: Found $DATADIR/my.cnf"
-    echo "Datadir is deprecated place for my.cnf, please move it to $MY_BASEDIR_VERSION"
-    echo
-    MYSQL_HOME=$DATADIR
-  else
-    MYSQL_HOME=$MY_BASEDIR_VERSION
-  fi
-fi
-export MYSQL_HOME
-
-user=@MYSQLD_USER@
+user=_mysql
+group=_mysql
 niceness=0
 
 # these rely on $DATADIR by default, so we'll set them later on
@@ -210,8 +150,8 @@ mysql_unix_port_dir=`dirname $safe_mysql_unix_port`
 if [ ! -d $mysql_unix_port_dir ]
 then
   mkdir $mysql_unix_port_dir
-  chown $user $mysql_unix_port_dir
-  chmod 755 $mysql_unix_port_dir
+  chown $user:$group $mysql_unix_port_dir
+  chmod 711 $mysql_unix_port_dir
 fi
 
 # Use the mysqld-max binary by default if the user doesn't specify a binary
@@ -371,12 +311,6 @@ fi
 
 echo "Starting $MYSQLD daemon with databases from $DATADIR"
 
-# Does this work on all systems?
-#if type ulimit | grep "shell builtin" > /dev/null
-#then
-#  ulimit -n 256 > /dev/null 2>&1		# Fix for BSD and FreeBSD systems
-#fi
-
 echo "`date +'%y%m%d %H:%M:%S  mysqld started'`" >> $err_log
 while true
 do
@@ -393,35 +327,6 @@ do
     break
   fi
 
-  if @TARGET_LINUX@ && test $KILL_MYSQLD -eq 1
-  then
-    # Test if one process was hanging.
-    # This is only a fix for Linux (running as base 3 mysqld processes)
-    # but should work for the rest of the servers.
-    # The only thing is ps x => redhat 5 gives warnings when using ps -x.
-    # kill -9 is used or the process won't react on the kill.
-    numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
-
-    echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log
-    I=1
-    while test "$I" -le "$numofproces"
-    do 
-      PROC=`ps xaww | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "pid-file=$pid_file" | sed -n '$p'` 
-
-      for T in $PROC
-      do
-        break
-      done
-      #    echo "TEST $I - $T **"
-      if kill -9 $T
-      then
-        echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
-      else 
-        break
-      fi
-      I=`expr $I + 1`
-    done
-  fi
   echo "`date +'%y%m%d %H:%M:%S'`  mysqld restarted" | tee -a $err_log
 done
 
