[csw-devel] SF.net SVN: gar:[7847] csw/mgar/pkg/mysql5/branches/mysql-5.0.x

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 3 15:41:05 CET 2010


Revision: 7847
          http://gar.svn.sourceforge.net/gar/?rev=7847&view=rev
Author:   wahwah
Date:     2010-01-03 14:41:04 +0000 (Sun, 03 Jan 2010)

Log Message:
-----------
mysql-5.0.x: Configuring and starting the database during installation

Modified Paths:
--------------
    csw/mgar/pkg/mysql5/branches/mysql-5.0.x/checksums
    csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/CSWmysql5.postinstall
    csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/quick_start-csw

Property Changed:
----------------
    csw/mgar/pkg/mysql5/branches/mysql-5.0.x/


Property changes on: csw/mgar/pkg/mysql5/branches/mysql-5.0.x
___________________________________________________________________
Modified: svn:externals
   - gar https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/gar/v2-checkpkg

   + gar https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/gar/v2


Modified: csw/mgar/pkg/mysql5/branches/mysql-5.0.x/checksums
===================================================================
--- csw/mgar/pkg/mysql5/branches/mysql-5.0.x/checksums	2010-01-03 14:17:52 UTC (rev 7846)
+++ csw/mgar/pkg/mysql5/branches/mysql-5.0.x/checksums	2010-01-03 14:41:04 UTC (rev 7847)
@@ -2,11 +2,11 @@
 1414d06fab1530484a508927a0de4154  0002-cast-user_info-pw_gid-to-gid_t.patch
 5415f365f1b0f7a179d1efc25f45bbee  0003-OpenCSW-perl-for-tests.patch
 8ab232cd4d232b3cda3bbced93f80237  0004-basedir-and-datadir-in-the-cnf-files.patch
-747637bc4be42207974ae845d832ae65  CSWmysql5.postinstall
+8cfe94c6a9c0e43d17de20b551e15837  CSWmysql5.postinstall
 60162ea667507a6a487027e7c389ca55  CSWmysql5.preinstall
 e691b0cf00a3925ac55c1844045d6e30  ChangeLog
 e42afb5ec1b1ab02d2ec3b46d0922636  README.CSW
 aaca748fc044834e71ad544ab293c494  cswmysql5
 67228e1f096fe08a94f4267439a4ec36  cswusergroup
 65e6229cc98b6a8d4c5206d7fe16c7be  mysql-5.0.87.tar.gz
-90b7cfcd11ab56e021a195a6a085fa21  quick_start-csw
+4313c963657ac820a20eea2a50be27f3  quick_start-csw

Modified: csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/CSWmysql5.postinstall
===================================================================
--- csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/CSWmysql5.postinstall	2010-01-03 14:17:52 UTC (rev 7846)
+++ csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/CSWmysql5.postinstall	2010-01-03 14:41:04 UTC (rev 7847)
@@ -1,15 +1,95 @@
-#!/bin/sh
+#!/bin/ksh -p
 #
 # $Id$
 #
+# initial version for blastwave.org by Alex Moore 2006.02.25
+# Revised 2006.03.25 - see bug report 0001542
+#
+# This script creates a default database with the small-memory footprint.
+# Input may be provided for DATADIR and DEFAULTS_FILE
+#
+BASEDIR=/opt/csw/mysql5
+MYSQL_VAR=/var/opt/csw/mysql5
+DEFAULTS_FILE=$BASEDIR/my.cnf
+SAVE_DEFAULTS_FILE=$MYSQL_VAR/my.cnf
+MYSQLD_USER=mysql
+# Provide the default data directory
+MYSQLD_DATADIR=$MYSQL_VAR
 
-MYSQLDATADIR=/var/opt/csw/mysql5
-if [ ! -d "${MYSQLDATADIR}/mysql" ] ; then
-  echo "No database directory found in the default location:"
-  echo "${MYSQLDATADIR}/mysql"
-  echo "If you need to build the initial database directory,"
-  echo "  see /opt/csw/mysql5/share/mysql/quick_start-csw"
-  echo "If you are using a non-default database directory location,"
-  echo "  please start mysql manually."
-  exit 0
+# http://bugs.mysql.com/bug.php?id=31164
+# ERROR: 1004  Can't create file '/var/tmp//installRJaiQ3/#sql6fee_1_0.frm' (errno: 13)
+unset TMPDIR
+
+if [ ! -f "$DEFAULTS_FILE" ]; then
+    IN_DEFAULTS_FILE=$BASEDIR/share/mysql/my-small.cnf
+    echo "Using $IN_DEFAULTS_FILE to create the options file."
+else
+    IN_DEFAULTS_FILE=$DEFAULTS_FILE
+    echo "Using $DEFAULTS_FILE as the options file."
 fi
+
+if [ -d "$MYSQLD_DATADIR/mysql" ]; then
+    echo "mysql database already exists."
+    echo "Leaving script without initializing a database."
+    exit 0
+fi
+
+echo  "Setting up the database"
+# Create the database directory and set the permissions if needed
+if [ ! -d "$MYSQLD_DATADIR" ] ; then
+    mkdir -p $MYSQLD_DATADIR
+    chown -R mysql:mysql $MYSQLD_DATADIR
+    chmod 0700 $MYSQLD_DATADIR
+fi
+#
+# copy the configuration file if not exists.
+CNFCOPIED=no
+if [ ! -f "$DEFAULTS_FILE" ] ; then
+    cp -p $IN_DEFAULTS_FILE $DEFAULTS_FILE
+    CNFCOPIED=yes
+fi
+#
+# Run the mysql script to create the database
+echo "Creating MySQL core database in $MYSQLD_DATADIR"
+echo
+echo "###  The following messages are from mysql_install_db."
+$BASEDIR/bin/mysql_install_db \
+    --defaults-extra-file="$DEFAULTS_FILE" \
+    --user="$MYSQLD_USER" \
+    --basedir="$BASEDIR" \
+    --datadir="$MYSQLD_DATADIR"
+
+# Fix permissions on the data directory, since mysql_install_db was run as
+# root.
+chown -R mysql:mysql $MYSQLD_DATADIR
+
+# Update --datadir in the cnf file with the correct value if file was copied
+if [ x"$CNFCOPIED" = xyes ]; then
+    sed -e "s|/var/opt/csw/mysql5|$MYSQLD_DATADIR|g" $DEFAULTS_FILE >$DEFAULTS_FILE.new
+    mv $DEFAULTS_FILE.new $DEFAULTS_FILE
+fi
+
+# Ending message
+echo
+echo "###  The following messages are from $0."
+echo "See /opt/csw/mysql5/share/mysql/doc/README.CSW for packaging changes."
+echo "Please ignore references to starting mysqld_safe in the messages above."
+echo "  These messages are from mysql_install_db.  See the following"
+echo "  for starting CSWmysql5."
+smf=no
+if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ] ; then smf=yes ; fi
+if [ $smf = yes ]
+then
+	echo "Running \`svcadm enable cswmysql5\` start to start the database."
+  # First, we clear the status, since it's likely to be 'maintenance'.
+  svcadm disable cswmysql5
+  svcadm clear cswmysql5
+  svcadm enable cswmysql5
+else
+	echo "Running \`/etc/opt/csw/init.d/cswmysql\` start to start the database."
+	/etc/opt/csw/init.d/cswmysql start
+fi
+
+exit 0
+
+# vim:set ts=2 sw=2 sts=2 expandtab:

Modified: csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/quick_start-csw
===================================================================
--- csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/quick_start-csw	2010-01-03 14:17:52 UTC (rev 7846)
+++ csw/mgar/pkg/mysql5/branches/mysql-5.0.x/files/quick_start-csw	2010-01-03 14:41:04 UTC (rev 7847)
@@ -2,12 +2,14 @@
 #
 # $Id$
 #
-# initial version for blastwave.org by Alex Moore 2006.02.25
-# Revised 2006.03.25 - see bug report 0001542
+# initial version for blastwave.org by Alex Moore 2006.02.25 Revised 2006.03.25
+# - see bug report 0001542
 #
 # This script creates a default database with the small-memory footprint.
 # Input may be provided for DATADIR and DEFAULTS_FILE
 #
+# TODO: This file should be integrated with CSWmysql5.postinstall file.
+
 BASEDIR=/opt/csw/mysql5
 MYSQL_VAR=/var/opt/csw/mysql5
 DEFAULTS_FILE=$BASEDIR/my.cnf


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list