PREIN
/bin/sh
if [ `uname` = "Linux" ]; then
if test -x /etc/rc.d/init.d/mysql
then
/etc/rc.d/init.d/mysql stop > /dev/null 2>&1
echo "Giving mysqld a couple of seconds to exit nicely"
sleep 5
fi
fi
if [ `uname` = "SunOS" ]; then
if test -x /etc/init.d/mysql
then
/etc/init.d/mysql stop > /dev/null 2>&1
echo "Giving mysqld a couple of seconds to exit nicely"
sleep 5
fi
fi
PREUN
/bin/sh
if [ `uname` = "Linux" ]; then
if test -x /etc/rc.d/init.d/mysql
then
/etc/rc.d/init.d/mysql stop > /dev/null
fi
fi
if [ `uname` = "SunOS" ]; then
if test -x /etc/init.d/mysql
then
/etc/init.d/mysql stop > /dev/null
fi
fi
# Remove autostart of mysql
if [ `uname` = "Linux" ]; then
if test $1 = 0
then
/sbin/chkconfig --del mysql
fi
fi
# We do not remove the mysql user since it may still own a lot of
# database files.
POSTIN
/bin/sh
mysql_datadir=/var/lib/mysql
# Create data directory if needed
if test ! -d $mysql_datadir; then mkdir $mysql_datadir; fi
if test ! -d $mysql_datadir/mysql; then mkdir $mysql_datadir/mysql; fi
if test ! -d $mysql_datadir/test; then mkdir $mysql_datadir/test; fi
# Make MySQL start/shutdown automatically when the machine does it.
if [ `uname` = "Linux" ]; then
/sbin/chkconfig --add mysql
fi
# Create a MySQL user. Do not report any problems if it already
# exists.
if [ `uname` = "Linux" ]; then
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" mysql 2> /dev/null || true
fi
if [ `uname` = "SunOS" ]; then
useradd -d $mysql_datadir -s /bin/sh -c "MySQL server" mysql 2> /dev/null || true
fi
# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
chown -R mysql $mysql_datadir
# Initiate databases
mysql_install_db -IN-RPM
# Change permissions again to fix any new files.
chown -R mysql $mysql_datadir
# Restart in the same way that mysqld will be started normally.
if [ "$DURING_INSTALL" = "" ]; then
if [ `uname` = "Linux" ]; then
/etc/rc.d/init.d/mysql start
fi
if [ `uname` = "SunOS" ]; then
/etc/init.d/mysql start
fi
# Allow safe_mysqld to start mysqld and print a message before we exit
sleep 2
fi
# Allow safe_mysqld to start mysqld and print a message before we exit
sleep 2