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