openbsd-ports/databases/mysql/pkg/INSTALL
2000-08-15 18:23:19 +00:00

82 lines
1.9 KiB
Plaintext

#!/bin/sh
# $OpenBSD: INSTALL,v 1.7 2000/08/15 18:23:19 brad Exp $
#
# Pre/post-installation setup of MySQL
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
DB_DIR=${DB_DIR}
MYSQLGID=40
MYSQLUID=40
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
line=`egrep '^mysql:' /etc/group`
if [ "$line" != "" ]; then
MYSQLGID=`echo $line | cut -f3 -d:`
else
echo "===> Creating mysql group, gid $MYSQLGID"
group add -g $MYSQLGID mysql
fi
line=`egrep '^mysql:' /etc/passwd`
if [ "$line" != "" ]; then
MYSQLUID=`echo $line | cut -f3 -d:`
else
echo "===> Creating mysql user, uid $MYSQLUID"
user add -g $MYSQLGID -u $MYSQLUID -d /nonexistent -c 'MySQL Account' -s /sbin/nologin mysql
fi
echo "===> Using account mysql for MySQL, uid $MYSQLUID, gid $MYSQLGID"
}
do_post_install()
{
install -d -o mysql -g mysql -m 775 $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