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