summaryrefslogtreecommitdiff
path: root/databases/mysql5-server/patches/patch-aj
blob: 37613199cefcf779ba6d490b9e55f575874ffa7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
$NetBSD: patch-aj,v 1.3 2007/03/11 18:42:50 adam Exp $

--- scripts/mysqld_safe.sh.orig	2007-03-05 20:21:13.000000000 +0100
+++ scripts/mysqld_safe.sh
@@ -331,6 +331,14 @@ then
   ulimit -c $core_file_size
 fi
 
+datemsg()
+{
+	echo -n $(date +'%y%M%d %H:%M:%S')"  "
+	echo "$*"
+}
+
+exec >>$err_log 2>&1
+
 #
 # If there exists an old pid file, check if the daemon is already running
 # Note: The switches to 'ps' may depend on your operating system
@@ -341,18 +349,16 @@ then
   then
     if @FIND_PROC@
     then    # The pid contains a mysqld process
-      echo "A mysqld process already exists"
-      echo "A mysqld process already exists at " `date` >> $err_log
+      datemsg "A mysqld process already exists"
       exit 1
     fi
   fi
   rm -f $pid_file
   if test -f $pid_file
   then
-    echo "Fatal error: Can't remove the pid file: $pid_file"
-    echo "Fatal error: Can't remove the pid file: $pid_file at " `date` >> $err_log
-    echo "Please remove it manually and start $0 again"
-    echo "mysqld daemon not started"
+    datemsg "Fatal error: Can't remove the pid file: $pid_file"
+    datemsg "Please remove it manually and start $0 again"
+    datemsg "mysqld daemon not started"
     exit 1
   fi
 fi
@@ -365,11 +371,11 @@ fi
 # Alternatively, you can start mysqld with the "myisam-recover" option. See
 # the manual for details.
 #
-# echo "Checking tables in $DATADIR"
+# datemsg "Checking tables in $DATADIR"
 # $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check $DATADIR/*/*.MYI
 # $MY_BASEDIR_VERSION/bin/isamchk --silent --force $DATADIR/*/*.ISM
 
-echo "Starting $MYSQLD daemon with databases from $DATADIR"
+datemsg "Starting $MYSQLD daemon with databases from $DATADIR"
 
 # Does this work on all systems?
 #if type ulimit | grep "shell builtin" > /dev/null
@@ -377,7 +383,7 @@ echo "Starting $MYSQLD daemon with datab
 #  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
+datemsg "mysqld started"
 while true
 do
   rm -f $safe_mysql_unix_port $pid_file	# Some extra safety
@@ -389,7 +395,7 @@ do
   fi
   if test ! -f $pid_file		# This is removed if normal shutdown
   then
-    echo "STOPPING server from pid file $pid_file"
+    datemsg "STOPPING server from pid file $pid_file"
     break
   fi
 
@@ -402,7 +408,7 @@ do
     # 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
+    datemsg -e "\nNumber of processes running now: $numofproces"
     I=1
     while test "$I" -le "$numofproces"
     do 
@@ -415,16 +421,14 @@ do
       #    echo "TEST $I - $T **"
       if kill -9 $T
       then
-        echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log
+        datemsg "$MYSQLD process hanging, pid $T - killed"
       else 
         break
       fi
       I=`expr $I + 1`
     done
   fi
-  echo "`date +'%y%m%d %H:%M:%S'`  mysqld restarted" | tee -a $err_log
+  datemsg "mysqld restarted"
 done
 
-echo "`date +'%y%m%d %H:%M:%S'`  mysqld ended" | tee -a $err_log
-echo "" | tee -a $err_log
-
+datemsg "mysqld ended"