openbsd-ports/databases/mysql/pkg/INSTALL

78 lines
1.7 KiB
Plaintext
Raw Normal View History

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