summaryrefslogtreecommitdiff
path: root/databases
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2004-07-21 17:45:13 +0000
committerjlam <jlam@pkgsrc.org>2004-07-21 17:45:13 +0000
commit2ce7564f6fa1f88f1ed9b41c58f5c24997d417d0 (patch)
tree0966574ba17a270792cb776dc2acbc8ec8c8bc51 /databases
parent0b8ae8d7c293a3322775709490a1c1c435b7cc2a (diff)
downloadpkgsrc-2ce7564f6fa1f88f1ed9b41c58f5c24997d417d0.tar.gz
Defer the creation of the initial MySQL database directories until we
actually try to run MySQL server. Beef up the rc.d script to work on systems that don't use NetBSD's rc.d script system, and to support an "initdb" command to initialize the MySQL database for first-time use.
Diffstat (limited to 'databases')
-rw-r--r--databases/mysql4-server/DEINSTALL16
-rw-r--r--databases/mysql4-server/INSTALL10
-rw-r--r--databases/mysql4-server/Makefile9
-rw-r--r--databases/mysql4-server/files/mysqld.sh96
4 files changed, 105 insertions, 26 deletions
diff --git a/databases/mysql4-server/DEINSTALL b/databases/mysql4-server/DEINSTALL
new file mode 100644
index 00000000000..e2259384523
--- /dev/null
+++ b/databases/mysql4-server/DEINSTALL
@@ -0,0 +1,16 @@
+# $NetBSD: DEINSTALL,v 1.1 2004/07/21 17:45:13 jlam Exp $
+
+case ${STAGE} in
+POST-DEINSTALL)
+ if [ -d @MYSQL_DATADIR@ ]; then
+ ${CAT} << EOF
+===========================================================================
+If you won't be using ${PKGNAME} any longer, you may want to remove
+
+ * the following directories:
+
+ @MYSQL_DATADIR@
+===========================================================================
+EOF
+ fi
+esac
diff --git a/databases/mysql4-server/INSTALL b/databases/mysql4-server/INSTALL
deleted file mode 100644
index 63e9e44163f..00000000000
--- a/databases/mysql4-server/INSTALL
+++ /dev/null
@@ -1,10 +0,0 @@
-# $NetBSD: INSTALL,v 1.1.1.1 2003/12/20 16:00:42 martti Exp $
-
-case ${STAGE} in
-POST-INSTALL)
- ${ECHO} "-------------------------------"
- ${ECHO} "Initializing MySQL databases..."
- ${ECHO} "-------------------------------"
- ${PKG_PREFIX}/bin/mysql_install_db --force
- ;;
-esac
diff --git a/databases/mysql4-server/Makefile b/databases/mysql4-server/Makefile
index b764e56de65..e432577e119 100644
--- a/databases/mysql4-server/Makefile
+++ b/databases/mysql4-server/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2004/07/20 17:28:37 jlam Exp $
+# $NetBSD: Makefile,v 1.9 2004/07/21 17:45:13 jlam Exp $
PKGNAME= ${DISTNAME:S/-/-server-/}
SVR4_PKGNAME= mysqs
@@ -20,14 +20,15 @@ PTHREAD_OPTS+= require
CONFIGURE_ARGS+= --with-pthreads
USE_PKGINSTALL= YES
-INSTALL_EXTRA_TMPL+= ${.CURDIR}/INSTALL
+DEINSTALL_EXTRA_TMPL= ${.CURDIR}/DEINSTALL
PKG_USERS= ${MYSQL_USER}:${MYSQL_GROUP}::MySQL\\ database\\ administrator:${MYSQL_DATADIR}:${SH}
PKG_GROUPS= ${MYSQL_GROUP}
RCD_SCRIPTS= mysqld
-MAKE_DIRS_PERMS+= ${MYSQL_DATADIR} ${MYSQL_USER} ${MYSQL_GROUP} 0700
-FILES_SUBST+= MYSQL_DATADIR=${MYSQL_DATADIR}
+FILES_SUBST+= HOSTNAME_CMD=${HOSTNAME_CMD} \
+ MYSQL_DATADIR=${MYSQL_DATADIR} \
+ MYSQL_USER=${MYSQL_USER} MYSQL_GROUP=${MYSQL_GROUP}
MESSAGE_SUBST+= MYSQL_DATADIR=${MYSQL_DATADIR} \
MYSQL_USER=${MYSQL_USER} MYSQL_GROUP=${MYSQL_GROUP}
BUILD_DEFS+= MYSQL_DATADIR
diff --git a/databases/mysql4-server/files/mysqld.sh b/databases/mysql4-server/files/mysqld.sh
index 7ae04dd072b..17b5d9e857a 100644
--- a/databases/mysql4-server/files/mysqld.sh
+++ b/databases/mysql4-server/files/mysqld.sh
@@ -1,31 +1,103 @@
#!@RCD_SCRIPTS_SHELL@
#
-# $NetBSD: mysqld.sh,v 1.1.1.1 2003/12/20 16:00:43 martti Exp $
+# $NetBSD: mysqld.sh,v 1.2 2004/07/21 17:45:13 jlam Exp $
#
-
# PROVIDE: mysqld
# REQUIRE: DAEMON LOGIN mountall
# KEYWORD: shutdown
-
-# Note: this needs NetBSD 1.6 or newer
+#
+# You will need to set some variables in /etc/rc.conf to start MySQL:
+#
+# mysqld=YES
+#
+# The following variables are optional:
+#
+# mysqld_user="mysql" # user to run mysqld as
+# mysqld_datadir="/path/to/home" # path to MySQL database directory
#
-. /etc/rc.subr
+if [ -f /etc/rc.subr ]; then
+ . /etc/rc.subr
+fi
name="mysqld"
-rcvar=$name
+rcvar=${name}
command="@PREFIX@/bin/mysqld_safe"
procname="@PREFIX@/libexec/${name}"
-pidfile="@MYSQL_DATADIR@/`hostname`.pid"
+mysqld_user="@MYSQL_USER@"
+mysqld_group="@MYSQL_GROUP@"
+mysqld_datadir="@MYSQL_DATADIR@"
+pidfile="${mysqld_datadir}/`@HOSTNAME_CMD@`.pid"
+
+extra_commands="initdb"
+initdb_cmd="mysqld_initdb"
+start_precmd="mysqld_precmd"
start_cmd="mysqld_start"
-required_files="@MYSQL_DATADIR@/mysql/host.frm"
+
+mysqld_precmd()
+{
+ if [ ! -d ${mysqld_datadir} ]; then
+ mysqld_initdb
+ fi
+}
+
+mysqld_initdb()
+{
+ initdb="@PREFIX@/bin/mysql_install_db"
+ if [ ! -x ${initdb} ]; then
+ return 1
+ fi
+ if [ -f ${mysqld_datadir}/mysql/host.frm ]; then
+ @ECHO@ "The MySQL database has already been initialized."
+ @ECHO@ "Skipping database initialization."
+ else
+ @ECHO@ "Initializing MySQL database system tables."
+ ${initdb} --force --user=${mysqld_user} \
+ --datadir=${mysqld_datadir} || return 1
+ if [ -d ${mysqld_datadir} ]; then
+ @CHOWN@ -R ${mysqld_user}:${mysqld_group} \
+ ${mysqld_datadir}
+ fi
+ fi
+}
mysqld_start()
{
- echo "Starting mysqld."
+ for f in $required_files; do
+ if [ ! -r "$f" ]; then
+ @ECHO@ 1>&2 "$0: WARNING: $f is not readable"
+ if [ -z $rc_force ]; then
+ return 1
+ fi
+ fi
+ done
+ @ECHO@ "Starting ${name}."
ulimit -n 4096
- ${command} ${mysqld_flags} &
+ cd @PREFIX@
+ ${command} --user=${mysqld_user} --datadir=${mysqld_datadir} \
+ --pid-file=${pidfile} ${mysqld_flags} &
}
-load_rc_config $name
-run_rc_command "$1"
+if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ load_rc_config $name
+ run_rc_command "$1"
+else
+ if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+ fi
+ case "$1" in
+ initdb)
+ eval ${initdb_cmd}
+ ;;
+ stop)
+ if [ -r "${pidfile}" ]; then
+ @ECHO@ "Stopping ${name}."
+ kill `@CAT@ ${pidfile}`
+ fi
+ ;;
+ *)
+ eval ${start_precmd}
+ eval ${start_cmd}
+ ;;
+ esac
+fi