Add Obsoletes: mysql-cluster, and improve init script's LSB compliance

This commit is contained in:
Tom Lane 2010-02-22 02:10:00 +00:00 committed by Michal Schorm
parent ce2db75c8b
commit 0f10670319
2 changed files with 91 additions and 42 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# mysqld This shell script takes care of starting and stopping # mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld). # the MySQL subsystem (mysqld).
@ -16,7 +16,13 @@
. /etc/sysconfig/network . /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 # extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT # 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" get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
mypidfile="$result" mypidfile="$result"
start(){ 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" touch "$errlogfile"
chown mysql:mysql "$errlogfile" chown mysql:mysql "$errlogfile"
chmod 0640 "$errlogfile" chmod 0640 "$errlogfile"
@ -71,7 +92,7 @@ start(){
# and some users might prefer to configure logging to syslog.) # and some users might prefer to configure logging to syslog.)
# Note: set --basedir to prevent probes that might trigger SELinux # Note: set --basedir to prevent probes that might trigger SELinux
# alarms, per bug #547485 # alarms, per bug #547485
/usr/bin/mysqld_safe --datadir="$datadir" --socket="$socketfile" \ $exec --datadir="$datadir" --socket="$socketfile" \
--pid-file="$mypidfile" \ --pid-file="$mypidfile" \
--basedir=/usr --user=mysql >/dev/null 2>&1 & --basedir=/usr --user=mysql >/dev/null 2>&1 &
safe_pid=$! safe_pid=$!
@ -98,42 +119,49 @@ start(){
fi fi
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true action $"Starting $prog: " /bin/true
touch /var/lock/subsys/mysqld touch $lockfile
else else
action $"Starting $prog: " /bin/false action $"Starting $prog: " /bin/false
fi fi
return $ret fi
return $ret
} }
stop(){ stop(){
MYSQLPID=`cat "$mypidfile" 2>/dev/null ` if [ ! -f "$mypidfile" ]; then
if [ -n "$MYSQLPID" ]; then # not running; per LSB standards this is "ok"
/bin/kill "$MYSQLPID" >/dev/null 2>&1 action $"Stopping $prog: " /bin/true
ret=$? return 0
if [ $ret -eq 0 ]; then fi
STOPTIMEOUT=60 MYSQLPID=`cat "$mypidfile"`
while [ $STOPTIMEOUT -gt 0 ]; do if [ -n "$MYSQLPID" ]; then
/bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break /bin/kill "$MYSQLPID" >/dev/null 2>&1
sleep 1 ret=$?
let STOPTIMEOUT=${STOPTIMEOUT}-1 if [ $ret -eq 0 ]; then
done STOPTIMEOUT=60
if [ $STOPTIMEOUT -eq 0 ]; then while [ $STOPTIMEOUT -gt 0 ]; do
echo "Timeout error occurred trying to stop MySQL Daemon." /bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
ret=1 sleep 1
action $"Stopping $prog: " /bin/false let STOPTIMEOUT=${STOPTIMEOUT}-1
else done
rm -f /var/lock/subsys/mysqld if [ $STOPTIMEOUT -eq 0 ]; then
rm -f "$socketfile" echo "Timeout error occurred trying to stop MySQL Daemon."
action $"Stopping $prog: " /bin/true ret=1
fi action $"Stopping $prog: " /bin/false
else else
action $"Stopping $prog: " /bin/false rm -f $lockfile
fi rm -f "$socketfile"
else action $"Stopping $prog: " /bin/true
ret=1 fi
action $"Stopping $prog: " /bin/false else
fi action $"Stopping $prog: " /bin/false
return $ret fi
else
# failed to read pidfile, probably insufficient permissions
action $"Stopping $prog: " /bin/false
ret=4
fi
return $ret
} }
restart(){ restart(){
@ -142,9 +170,10 @@ restart(){
} }
condrestart(){ condrestart(){
[ -e /var/lock/subsys/mysqld ] && restart || : [ -e $lockfile ] && restart || :
} }
# See how we were called. # See how we were called.
case "$1" in case "$1" in
start) start)
@ -154,17 +183,23 @@ case "$1" in
stop stop
;; ;;
status) status)
status mysqld status $prog
;; ;;
restart) restart)
restart restart
;; ;;
condrestart) condrestart|try-restart)
condrestart condrestart
;; ;;
reload)
exit 3
;;
force-reload)
restart
;;
*) *)
echo $"Usage: $0 {start|stop|status|condrestart|restart}" echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 1 exit 2
esac esac
exit $? exit $?

View File

@ -1,6 +1,6 @@
Name: mysql Name: mysql
Version: 5.1.44 Version: 5.1.44
Release: 1%{?dist} Release: 2%{?dist}
Summary: MySQL client programs and shared libraries Summary: MySQL client programs and shared libraries
Group: Applications/Databases Group: Applications/Databases
URL: http://www.mysql.com URL: http://www.mysql.com
@ -55,8 +55,11 @@ BuildRequires: perl(Socket)
Requires: grep, fileutils Requires: grep, fileutils
Requires: %{name}-libs = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release}
Requires: bash Requires: bash
# MySQL (with caps) is upstream's spelling of their own RPMs for mysql
Conflicts: 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. # Working around perl dependency checking bug in rpm FTTB. Remove later.
%global __perl_requires %{SOURCE999} %global __perl_requires %{SOURCE999}
@ -83,9 +86,14 @@ MySQL server.
Summary: The MySQL server and related files Summary: The MySQL server and related files
Group: Applications/Databases Group: Applications/Databases
Requires: /sbin/chkconfig, /usr/sbin/useradd
Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version}-%{release}
Requires: sh-utils 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 # mysqlhotcopy needs DBI/DBD support
Requires: perl-DBI, perl-DBD-MySQL Requires: perl-DBI, perl-DBD-MySQL
Conflicts: MySQL-server Conflicts: MySQL-server
@ -363,6 +371,7 @@ fi
%preun server %preun server
if [ $1 = 0 ]; then if [ $1 = 0 ]; then
/sbin/service mysqld stop >/dev/null 2>&1
/sbin/chkconfig --del mysqld /sbin/chkconfig --del mysqld
fi fi
@ -371,7 +380,6 @@ if [ $1 = 0 ] ; then
/sbin/ldconfig /sbin/ldconfig
fi fi
%postun server %postun server
if [ $1 -ge 1 ]; then if [ $1 -ge 1 ]; then
/sbin/service mysqld condrestart >/dev/null 2>&1 || : /sbin/service mysqld condrestart >/dev/null 2>&1 || :
@ -560,6 +568,12 @@ fi
%{_mandir}/man1/mysql_client_test.1* %{_mandir}/man1/mysql_client_test.1*
%changelog %changelog
* Sun Feb 21 2010 Tom Lane <tgl@redhat.com> 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 <tgl@redhat.com> 5.1.44-1 * Sat Feb 20 2010 Tom Lane <tgl@redhat.com> 5.1.44-1
- Update to MySQL 5.1.44, for various fixes described at - 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 http://dev.mysql.com/doc/refman/5.1/en/news-5-1-44.html