mysql_51 revision 444
444N/A#!/sbin/sh
444N/A#
444N/A# CDDL HEADER START
444N/A#
444N/A# The contents of this file are subject to the terms of the
444N/A# Common Development and Distribution License (the "License").
444N/A# You may not use this file except in compliance with the License.
444N/A#
444N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
444N/A# or http://www.opensolaris.org/os/licensing.
444N/A# See the License for the specific language governing permissions
444N/A# and limitations under the License.
444N/A#
444N/A# When distributing Covered Code, include this CDDL HEADER in each
444N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
444N/A# If applicable, add the following below this CDDL HEADER, with the
444N/A# fields enclosed by brackets "[]" replaced with your own identifying
444N/A# information: Portions Copyright [yyyy] [name of copyright owner]
444N/A#
444N/A# CDDL HEADER END
444N/A#
444N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
444N/A#
444N/A
444N/A. /lib/svc/share/smf_include.sh
444N/A
444N/A# SMF_FMRI is the name of the target service. This allows multiple instances
444N/A# to use the same script.
444N/A
444N/Agetproparg() {
444N/A val=`svcprop -p $1 $SMF_FMRI`
444N/A [ -n "$val" ] && echo $val
444N/A}
444N/A
444N/AMYSQLBIN=`getproparg mysql/bin`
444N/AMYSQLDATA=`getproparg mysql/data`
444N/APIDFILE=${MYSQLDATA}/`/usr/bin/uname -n`.pid
444N/A
444N/A
444N/Aif [ -z $SMF_FMRI ]; then
444N/A echo "SMF framework variables are not initialized."
444N/A exit $SMF_EXIT_ERR
444N/Afi
444N/A
444N/Aif [ -z ${MYSQLDATA} ]; then
444N/A echo "mysql/data property not set"
444N/A exit $SMF_EXIT_ERR_CONFIG
444N/Afi
444N/A
444N/Aif [ ! -d ${MYSQLDATA} ]; then
444N/A echo "mysql/data directory ${MYSQLDATA} is not a valid MySQL data directory"
444N/A exit $SMF_EXIT_ERR_CONFIG
444N/Afi
444N/A
444N/Aif [ ! -d ${MYSQLDATA}/mysql ]; then
444N/A ${MYSQLBIN}/mysql_install_db --user=mysql --datadir=${MYSQLDATA}
444N/Afi
444N/A
444N/A
444N/Amysql_start() {
444N/A MYSQLDVAL=`getproparg mysql/enable_64bit mysql:version_51`
444N/A if [ "$MYSQLDVAL" != "" ] ; then
444N/A case "$MYSQLDVAL" in
444N/A true|1)
444N/A #Check if the system architecture supports 64-bit applications
444N/A PLATFORM=`isainfo -b`
444N/A if [ "${PLATFORM}" != "64" ]; then
444N/A echo "This system is not capable of supporting 64-bit applications."
444N/A echo "Set the \"enable_64bit\" property value to \"false\" to start the 32-bit server."
444N/A exit $SMF_EXIT_ERR_CONFIG
444N/A else
444N/A echo ${MYSQLBIN}/64/mysqld_safe --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE}
444N/A ${MYSQLBIN}/64/mysqld_safe --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &
444N/A fi
444N/A ;;
444N/A false|0)
444N/A echo ${MYSQLBIN}/mysqld_safe --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE}
444N/A ${MYSQLBIN}/mysqld_safe --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &
444N/A
444N/A ;;
444N/A esac
444N/A fi
444N/A
444N/A}
444N/A
444N/A
444N/Amysql_stop() {
444N/A if [ -f ${PIDFILE} ]; then
444N/A pkill mysqld
444N/A fi
444N/A}
444N/A
444N/Acase "$1" in
444N/A'start')
444N/A mysql_start
444N/A ;;
444N/A
444N/A'stop')
444N/A mysql_stop
444N/A ;;
444N/A
444N/A
444N/A*)
444N/A echo "Usage: $0 {start|stop}"
444N/A exit 1
444N/A ;;
444N/A
444N/Aesac
444N/Aexit $SMF_EXIT_OK