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