#!/bin/sh # $OpenBSD: INSTALL-server,v 1.1 2001/06/02 20:18:45 brad Exp $ # # Pre/post-installation setup of MySQL PATH=/bin:/usr/bin:/sbin:/usr/sbin PREFIX=${PKG_PREFIX:-/usr/local} DB_DIR=${DB_DIR} do_notice_pre_install() { echo echo "+---------------" echo "| You appear to already have a MySQL database directory in $DB_DIR" echo "|" echo "| The database directory has been preserved. If you want to start" echo "| from the default database setup, you should perform these steps" echo "| as root:" echo "|" echo "| rm -rf $DB_DIR" echo "| $PREFIX/bin/mysql_install_db" echo "|" echo "+---------------" echo } 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() { $PREFIX/bin/mysql_install_db } # 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) if [ ! -d $DB_DIR ]; then do_post_install fi ;; *) echo "usage: $0 distname { PRE-INSTALL | POST-INSTALL }" >&2 exit 1 ;; esac exit 0