From 6fc17e3f42dfa8df5256a1edbd1f04fb047e7852 Mon Sep 17 00:00:00 2001 From: brad Date: Tue, 15 Aug 2000 13:24:00 +0000 Subject: [PATCH] - re-introduce DB_DIR option - make sure MySQL is started as user mysql from safe_mysqld.sh script instead of the example startup.sh - hard coded /usr/local -> ${PREFIX} in MESSAGE - use user/group commands instead of cat/adduser in INSTALL script - ${FOO} -> $FOO in INSTALL/DEINSTALL --- databases/mysql/Makefile | 11 +++--- databases/mysql/files/startup.sh | 2 +- databases/mysql/patches/patch-af | 14 ++++++-- databases/mysql/pkg/DEINSTALL | 34 +++++++++---------- databases/mysql/pkg/INSTALL | 57 ++++++++++++-------------------- databases/mysql/pkg/MESSAGE | 2 +- 6 files changed, 58 insertions(+), 62 deletions(-) diff --git a/databases/mysql/Makefile b/databases/mysql/Makefile index becc02e9da6..b60faa5300f 100644 --- a/databases/mysql/Makefile +++ b/databases/mysql/Makefile @@ -1,8 +1,6 @@ -# $OpenBSD: Makefile,v 1.26 2000/07/28 22:04:25 brad Exp $ +# $OpenBSD: Makefile,v 1.27 2000/08/15 13:24:00 brad Exp $ # $FreeBSD: Makefile,v 1.44 1999/03/04 21:27:58 dirk Exp $ -#BROKEN= installs files automatically in /etc - DISTNAME= mysql-3.22.32 CATEGORIES= databases NEED_VERSION= 1.310 @@ -24,16 +22,19 @@ PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes +DB_DIR?= /var/mysql +SUBST_VARS= DB_DIR + CONFIGURE_STYLE= gnu CONFIGURE_ARGS+= ${CONFIGURE_SHARED} CONFIGURE_ARGS+= --enable-static \ - --localstatedir="/var/mysql" \ + --localstatedir="${DB_DIR}" \ --without-perl \ --without-debug \ --without-readline \ --without-bench \ --without-mit-threads \ - --with-unix-socket-path="/var/mysql/mysql.sock" + --with-unix-socket-path="${DB_DIR}/mysql.sock" FLAVORS= pth FLAVOR?= diff --git a/databases/mysql/files/startup.sh b/databases/mysql/files/startup.sh index e3fc048af87..ee457105d80 100644 --- a/databases/mysql/files/startup.sh +++ b/databases/mysql/files/startup.sh @@ -7,5 +7,5 @@ if [ -x /sbin/ldconfig ]; then fi if [ -x ${PREFIX}/bin/safe_mysqld ]; then - ${PREFIX}/bin/safe_mysqld --user="mysql" > /dev/null & echo -n ' mysql' + ${PREFIX}/bin/safe_mysqld > /dev/null & echo -n ' mysql' fi diff --git a/databases/mysql/patches/patch-af b/databases/mysql/patches/patch-af index 5a664454513..8d9370fb4ae 100644 --- a/databases/mysql/patches/patch-af +++ b/databases/mysql/patches/patch-af @@ -1,5 +1,5 @@ --- scripts/safe_mysqld.sh.orig Mon Jan 10 16:49:29 2000 -+++ scripts/safe_mysqld.sh Wed Aug 2 00:06:21 2000 ++++ scripts/safe_mysqld.sh Mon Aug 14 05:01:01 2000 @@ -12,33 +12,9 @@ trap '' 1 2 3 15 # we shouldn't let anyone kill us @@ -52,7 +52,17 @@ echo "mysqld started on " `date` >> $err_log while true -@@ -124,33 +100,6 @@ +@@ -116,41 +92,14 @@ + if test "$#" -eq 0 + then + nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \ +- @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 ++ @MYSQLD_DEFAULT_SWITCHES@ --user=mysql >> $err_log 2>&1 + else + nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \ +- @MYSQLD_DEFAULT_SWITCHES@ "$@" >> $err_log 2>&1 ++ @MYSQLD_DEFAULT_SWITCHES@ --user=mysql "$@" >> $err_log 2>&1 + fi if test ! -f $pid_file # This is removed if normal shutdown then break; diff --git a/databases/mysql/pkg/DEINSTALL b/databases/mysql/pkg/DEINSTALL index 895259806a7..ec6845de83d 100644 --- a/databases/mysql/pkg/DEINSTALL +++ b/databases/mysql/pkg/DEINSTALL @@ -1,25 +1,23 @@ -# $OpenBSD: DEINSTALL,v 1.2 2000/04/08 05:41:34 brad Exp $ +# $OpenBSD: DEINSTALL,v 1.3 2000/08/15 13:24:01 brad Exp $ # # MySQL de-installation -set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin PREFIX=${PKG_PREFIX:-/usr/local} -DB_DIR=${PKG_DB_DIR:-/var/mysql} +DB_DIR=${DB_DIR} + +echo +echo "+---------------" +echo "| To completely deinstall the $1 package you need to perform" +echo "| these steps as root:" +echo "|" +echo "| user del mysql" +echo "| group del mysql" +echo "| rm -rf $DB_DIR" +echo "|" +echo "| Do not do this if you plan on re-installing $1" +echo "| at some future time." +echo "+---------------" +echo -if [ -d ${DB_DIR} ]; then - echo - echo "+---------------" - echo "| To completely deinstall the $1 package you need to perform" - echo "| these steps as root:" - echo "|" - echo "| rmuser mysql" - echo "| rmgroup mysql" - echo "| rm -rf ${DB_DIR}" - echo "|" - echo "| Do not do this if you plan on re-installing $1" - echo "| at some future time." - echo "+---------------" - echo -fi exit 0 diff --git a/databases/mysql/pkg/INSTALL b/databases/mysql/pkg/INSTALL index 7c9fc6115b2..66a8eca4ea8 100644 --- a/databases/mysql/pkg/INSTALL +++ b/databases/mysql/pkg/INSTALL @@ -1,30 +1,25 @@ #!/bin/sh -# $OpenBSD: INSTALL,v 1.5 2000/04/08 06:06:25 brad Exp $ +# $OpenBSD: INSTALL,v 1.6 2000/08/15 13:24:01 brad Exp $ # # Pre/post-installation setup of MySQL -# exit on errors, use a sane path and install prefix -# -set -e PATH=/bin:/usr/bin:/sbin:/usr/sbin PREFIX=${PKG_PREFIX:-/usr/local} -DB_DIR=${PKG_DB_DIR:-/var/mysql} +DB_DIR=${DB_DIR} MYSQLGID=40 MYSQLUID=40 -# Function: tell the user that an existing database directory was -# found on their system do_notice_pre_install() { echo echo "+---------------" - echo "| You appear to already have a MySQL database directory in ${DB_DIR}" + 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 "| - delete the $DB_DIR directory" echo "| - install MySQL" echo "| - start up MySQL" echo "| - re-create all of your database" @@ -34,42 +29,34 @@ do_notice_pre_install() exit 1 } -# Function: install the MySQL user account and group -# do_pre_install() { -# Add group 'mysql' to /etc/group -if [ "`egrep '^mysql:' /etc/group`" = "" ]; then - echo "===> Creating mysql group, gid $MYSQLGID" - echo "mysql:*:${MYSQLGID}:" 2>/dev/null >> /etc/group || { - echo "===> Problem creating group mysql" >&2 - exit 1 - } -fi - -# Add user 'mysql' in /etc/passwd -if [ "`egrep '^mysql:' /etc/passwd`" = "" ]; then - echo "===> Creating mysql user, uid $MYSQLUID" - adduser -batch mysql mysql "MySQL Account" "" -uid_start ${MYSQLUID} > /dev/null 2>&1 /dev/null - if [ $? -eq 0 ]; then - echo "===> Using account mysql for MySQL, uid $MYSQLUID, gid $MYSQLGID" - else - echo "===> Problem creating account mysql" - exit 1 - fi -fi + # 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 -c 'MySQL Account' -s /sbin/nologin mysql + fi + echo "===> Using account mysql for MySQL, uid $MYSQLUID, gid $MYSQLGID" } -# Function: create database directory and the initial database -# do_post_install() { -install -d -o mysql -g mysql -m 775 ${DB_DIR} +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 +su mysql -c $PREFIX/bin/mysql_install_db chpass -s /sbin/nologin mysql } diff --git a/databases/mysql/pkg/MESSAGE b/databases/mysql/pkg/MESSAGE index cda01d724ad..9cafcd0b984 100644 --- a/databases/mysql/pkg/MESSAGE +++ b/databases/mysql/pkg/MESSAGE @@ -1,3 +1,3 @@ -*** See startup.sh in /usr/local/lib/mysql for a sample startup script +*** See startup.sh in ${PREFIX}/lib/mysql for a sample startup script