diff --git a/mysql.init b/mysql.init index 50363b4..31f4301 100644 --- a/mysql.init +++ b/mysql.init @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # mysqld This shell script takes care of starting and stopping # the MySQL subsystem (mysqld). @@ -16,7 +16,13 @@ . /etc/sysconfig/network -prog="MySQL" +exec="/usr/bin/mysqld_safe" +prog="mysqld" + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +lockfile=/var/lock/subsys/$prog + # extract value of a MySQL option from config files # Usage: get_mysql_option SECTION VARNAME DEFAULT @@ -40,7 +46,22 @@ errlogfile="$result" get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid" mypidfile="$result" + start(){ + [ -x $exec ] || exit 5 + # check to see if it's already running + RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` + if [ $? = 0 ]; then + # already running, do nothing + action $"Starting $prog: " /bin/true + ret=0 + elif echo "$RESPONSE" | grep -q "Access denied for user" + then + # already running, do nothing + action $"Starting $prog: " /bin/true + ret=0 + else + # prepare for start touch "$errlogfile" chown mysql:mysql "$errlogfile" chmod 0640 "$errlogfile" @@ -71,7 +92,7 @@ start(){ # and some users might prefer to configure logging to syslog.) # Note: set --basedir to prevent probes that might trigger SELinux # alarms, per bug #547485 - /usr/bin/mysqld_safe --datadir="$datadir" --socket="$socketfile" \ + $exec --datadir="$datadir" --socket="$socketfile" \ --pid-file="$mypidfile" \ --basedir=/usr --user=mysql >/dev/null 2>&1 & safe_pid=$! @@ -98,42 +119,49 @@ start(){ fi if [ $ret -eq 0 ]; then action $"Starting $prog: " /bin/true - touch /var/lock/subsys/mysqld + touch $lockfile else action $"Starting $prog: " /bin/false fi - return $ret + fi + return $ret } stop(){ - MYSQLPID=`cat "$mypidfile" 2>/dev/null ` - if [ -n "$MYSQLPID" ]; then - /bin/kill "$MYSQLPID" >/dev/null 2>&1 - ret=$? - if [ $ret -eq 0 ]; then - STOPTIMEOUT=60 - while [ $STOPTIMEOUT -gt 0 ]; do - /bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break - sleep 1 - let STOPTIMEOUT=${STOPTIMEOUT}-1 - done - if [ $STOPTIMEOUT -eq 0 ]; then - echo "Timeout error occurred trying to stop MySQL Daemon." - ret=1 - action $"Stopping $prog: " /bin/false - else - rm -f /var/lock/subsys/mysqld - rm -f "$socketfile" - action $"Stopping $prog: " /bin/true - fi - else - action $"Stopping $prog: " /bin/false - fi - else - ret=1 - action $"Stopping $prog: " /bin/false - fi - return $ret + if [ ! -f "$mypidfile" ]; then + # not running; per LSB standards this is "ok" + action $"Stopping $prog: " /bin/true + return 0 + fi + MYSQLPID=`cat "$mypidfile"` + if [ -n "$MYSQLPID" ]; then + /bin/kill "$MYSQLPID" >/dev/null 2>&1 + ret=$? + if [ $ret -eq 0 ]; then + STOPTIMEOUT=60 + while [ $STOPTIMEOUT -gt 0 ]; do + /bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break + sleep 1 + let STOPTIMEOUT=${STOPTIMEOUT}-1 + done + if [ $STOPTIMEOUT -eq 0 ]; then + echo "Timeout error occurred trying to stop MySQL Daemon." + ret=1 + action $"Stopping $prog: " /bin/false + else + rm -f $lockfile + rm -f "$socketfile" + action $"Stopping $prog: " /bin/true + fi + else + action $"Stopping $prog: " /bin/false + fi + else + # failed to read pidfile, probably insufficient permissions + action $"Stopping $prog: " /bin/false + ret=4 + fi + return $ret } restart(){ @@ -142,9 +170,10 @@ restart(){ } condrestart(){ - [ -e /var/lock/subsys/mysqld ] && restart || : + [ -e $lockfile ] && restart || : } + # See how we were called. case "$1" in start) @@ -154,17 +183,23 @@ case "$1" in stop ;; status) - status mysqld + status $prog ;; restart) restart ;; - condrestart) + condrestart|try-restart) condrestart ;; + reload) + exit 3 + ;; + force-reload) + restart + ;; *) - echo $"Usage: $0 {start|stop|status|condrestart|restart}" - exit 1 + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 esac exit $? diff --git a/mysql.spec b/mysql.spec index 8a24065..7cbdc91 100644 --- a/mysql.spec +++ b/mysql.spec @@ -1,6 +1,6 @@ Name: mysql Version: 5.1.44 -Release: 1%{?dist} +Release: 2%{?dist} Summary: MySQL client programs and shared libraries Group: Applications/Databases URL: http://www.mysql.com @@ -55,8 +55,11 @@ BuildRequires: perl(Socket) Requires: grep, fileutils Requires: %{name}-libs = %{version}-%{release} Requires: bash + +# MySQL (with caps) is upstream's spelling of their own RPMs for mysql Conflicts: MySQL -Obsoletes: mysql-client mysql-perl +# mysql-cluster used to be built from this SRPM, but no more +Obsoletes: mysql-cluster < 5.1.44 # Working around perl dependency checking bug in rpm FTTB. Remove later. %global __perl_requires %{SOURCE999} @@ -83,9 +86,14 @@ MySQL server. Summary: The MySQL server and related files Group: Applications/Databases -Requires: /sbin/chkconfig, /usr/sbin/useradd Requires: %{name} = %{version}-%{release} Requires: sh-utils +Requires(pre): /usr/sbin/useradd +Requires(post): chkconfig +Requires(preun): chkconfig +# This is for /sbin/service +Requires(preun): initscripts +Requires(postun): initscripts # mysqlhotcopy needs DBI/DBD support Requires: perl-DBI, perl-DBD-MySQL Conflicts: MySQL-server @@ -363,6 +371,7 @@ fi %preun server if [ $1 = 0 ]; then + /sbin/service mysqld stop >/dev/null 2>&1 /sbin/chkconfig --del mysqld fi @@ -371,7 +380,6 @@ if [ $1 = 0 ] ; then /sbin/ldconfig fi - %postun server if [ $1 -ge 1 ]; then /sbin/service mysqld condrestart >/dev/null 2>&1 || : @@ -560,6 +568,12 @@ fi %{_mandir}/man1/mysql_client_test.1* %changelog +* Sun Feb 21 2010 Tom Lane 5.1.44-2 +- Add "Obsoletes: mysql-cluster" to fix upgrade-in-place from F-12 +- Bring init script into some modicum of compliance with Fedora/LSB standards +Related: #557711 +Related: #562749 + * Sat Feb 20 2010 Tom Lane 5.1.44-1 - Update to MySQL 5.1.44, for various fixes described at http://dev.mysql.com/doc/refman/5.1/en/news-5-1-44.html