2000-01-01 00:54:12 -05:00
|
|
|
#!/bin/sh
|
2000-11-02 19:54:09 -05:00
|
|
|
# $OpenBSD: INSTALL,v 1.12 2000/11/03 00:54:09 espie Exp $
|
2000-01-01 00:54:12 -05:00
|
|
|
#
|
|
|
|
# Pre/post-installation setup of MySQL
|
|
|
|
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
|
|
|
PREFIX=${PKG_PREFIX:-/usr/local}
|
2000-08-15 09:24:00 -04:00
|
|
|
DB_DIR=${DB_DIR}
|
2000-04-08 02:06:25 -04:00
|
|
|
|
2000-04-07 15:07:20 -04:00
|
|
|
do_notice_pre_install()
|
|
|
|
{
|
|
|
|
echo
|
|
|
|
echo "+---------------"
|
2000-08-15 09:24:00 -04:00
|
|
|
echo "| You appear to already have a MySQL database directory in $DB_DIR"
|
2000-04-07 15:07:20 -04:00
|
|
|
echo "|"
|
|
|
|
echo "| In order to preserve your existing data, you should:"
|
|
|
|
echo "| - dump all your databases"
|
|
|
|
echo "| - kill MySQL if it's running"
|
2000-08-15 09:24:00 -04:00
|
|
|
echo "| - delete the $DB_DIR directory"
|
2000-04-07 15:07:20 -04:00
|
|
|
echo "| - install MySQL"
|
|
|
|
echo "| - start up MySQL"
|
|
|
|
echo "| - re-create all of your database"
|
|
|
|
echo "| - re-load your data"
|
|
|
|
echo "+---------------"
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2000-01-01 00:54:12 -05:00
|
|
|
do_pre_install()
|
|
|
|
{
|
2000-08-15 09:24:00 -04:00
|
|
|
# Create mysql user and group
|
2000-09-06 17:09:16 -04:00
|
|
|
groupinfo -e mysql
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "===> Using mysql group for MySQL"
|
2000-08-15 09:24:00 -04:00
|
|
|
else
|
2000-09-06 17:09:16 -04:00
|
|
|
echo "===> Creating mysql group"
|
|
|
|
groupadd mysql
|
2000-08-15 09:24:00 -04:00
|
|
|
fi
|
2000-09-06 17:09:16 -04:00
|
|
|
userinfo -e mysql
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "===> Using mysql user for MySQL"
|
2000-08-15 09:24:00 -04:00
|
|
|
else
|
2000-09-06 17:09:16 -04:00
|
|
|
echo "===> Creating mysql user"
|
|
|
|
useradd -g mysql -d /nonexistent -c 'MySQL Account' -s /sbin/nologin mysql
|
2000-08-15 09:24:00 -04:00
|
|
|
fi
|
2000-01-01 00:54:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
do_post_install()
|
|
|
|
{
|
2000-11-02 19:54:09 -05:00
|
|
|
install -d -o mysql -g mysql -m 711 $DB_DIR
|
2000-04-07 15:07:20 -04:00
|
|
|
|
|
|
|
# The shell is switched back to /bin/sh to ensure that the database
|
|
|
|
# creation can proceed successfully
|
|
|
|
chpass -s /bin/sh mysql
|
2000-08-15 09:24:00 -04:00
|
|
|
su mysql -c $PREFIX/bin/mysql_install_db
|
2000-04-07 15:07:20 -04:00
|
|
|
chpass -s /sbin/nologin mysql
|
2000-01-01 00:54:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify/process the command
|
|
|
|
#
|
|
|
|
case $2 in
|
|
|
|
PRE-INSTALL)
|
2000-04-07 15:07:20 -04:00
|
|
|
if [ -d $DB_DIR ]; then
|
|
|
|
do_notice_pre_install $1
|
|
|
|
fi
|
|
|
|
do_pre_install
|
2000-01-01 00:54:12 -05:00
|
|
|
;;
|
|
|
|
POST-INSTALL)
|
2000-04-07 15:07:20 -04:00
|
|
|
do_post_install
|
2000-01-01 00:54:12 -05:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|