diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index 49a8253ceef..88ff059ff22 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -4,8 +4,10 @@ mysql_datadir=%{mysqldatadir} mkdir -p $mysql_datadir/{mysql,test} # Make MySQL start/shutdown automatically when the machine does it. -if [ -x /sbin/chkconfig ] ; then - /sbin/chkconfig --add mysql +if [ $1 = 1 ] ; then + if [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --add mysql + fi fi # Create a MySQL user and group. Do not report any problems if it already @@ -65,13 +67,3 @@ if [ -x sbin/restorecon ] ; then sbin/restorecon -R var/lib/mysql fi -# Restart in the same way that mysqld will be started normally. -if [ -x %{_sysconfdir}/init.d/mysql ] ; then - %{_sysconfdir}/init.d/mysql start - echo "Giving mysqld 2 seconds to start" - sleep 2 -fi - -# Allow safe_mysqld to start mysqld and print a message before we exit -sleep 2 - diff --git a/support-files/rpm/server-postun.sh b/support-files/rpm/server-postun.sh new file mode 100644 index 00000000000..652d59154ae --- /dev/null +++ b/support-files/rpm/server-postun.sh @@ -0,0 +1,7 @@ +if [ $1 -ge 1 ]; then + if [ -x %{_sysconfdir}/init.d/mysql ] ; then + # only restart the server if it was alredy running + %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1 && \ + %{_sysconfdir}/init.d/mysql restart + fi +fi diff --git a/support-files/rpm/server-prein.sh b/support-files/rpm/server-prein.sh index 0a8ac0c5f97..9194f2b0656 100644 --- a/support-files/rpm/server-prein.sh +++ b/support-files/rpm/server-prein.sh @@ -64,10 +64,3 @@ HERE fi fi -# Shut down a previously installed server first -if [ -x %{_sysconfdir}/init.d/mysql ] ; then - %{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1 - echo "Giving mysqld 5 seconds to exit nicely" - sleep 5 -fi - diff --git a/support-files/rpm/server-preun.sh b/support-files/rpm/server-preun.sh index 182be27f1ec..7ef48f1c8d4 100644 --- a/support-files/rpm/server-preun.sh +++ b/support-files/rpm/server-preun.sh @@ -2,10 +2,10 @@ if [ $1 = 0 ] ; then # Stop MySQL before uninstalling it if [ -x %{_sysconfdir}/init.d/mysql ] ; then %{_sysconfdir}/init.d/mysql stop > /dev/null - # Don't start it automatically anymore - if [ -x /sbin/chkconfig ] ; then - /sbin/chkconfig --del mysql - fi + fi + # Don't start it automatically anymore + if [ -x /sbin/chkconfig ] ; then + /sbin/chkconfig --del mysql fi fi