components/mysql-5-7/Solaris/mysql_57
changeset 5884 ef644c2bdc65
child 6277 073d7b623ddf
equal deleted inserted replaced
5881:a24bda958288 5884:ef644c2bdc65
       
     1 #!/sbin/sh
       
     2 #
       
     3 # CDDL HEADER START
       
     4 #
       
     5 # The contents of this file are subject to the terms of the
       
     6 # Common Development and Distribution License (the "License").
       
     7 # You may not use this file except in compliance with the License.
       
     8 #
       
     9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    10 # or http://www.opensolaris.org/os/licensing.
       
    11 # See the License for the specific language governing permissions
       
    12 # and limitations under the License.
       
    13 #
       
    14 # When distributing Covered Code, include this CDDL HEADER in each
       
    15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    16 # If applicable, add the following below this CDDL HEADER, with the
       
    17 # fields enclosed by brackets "[]" replaced with your own identifying
       
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 # Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
       
    23 #
       
    24 
       
    25 . /lib/svc/share/smf_include.sh
       
    26 
       
    27 # SMF_FMRI is the name of the target service. This allows multiple instances 
       
    28 # to use the same script.
       
    29 
       
    30 if [ -z $SMF_FMRI ]; then
       
    31         echo "SMF framework variables are not initialized."
       
    32         exit $SMF_EXIT_ERR
       
    33 fi
       
    34 
       
    35 getproparg() {
       
    36 	val=`svcprop -p $1 $SMF_FMRI`
       
    37 	[ -n "$val" ] && echo $val
       
    38 }
       
    39 
       
    40 MYSQLCNF=`getproparg mysql/cnf`
       
    41 MYSQLBIN=`getproparg mysql/bin`
       
    42 MYSQLDATA=`getproparg mysql/data`
       
    43 PIDFILE=${MYSQLDATA}/`/usr/bin/uname -n`.pid
       
    44 LOG_ERROR=${MYSQLDATA}/`/usr/bin/uname -n`.err
       
    45 
       
    46 if [ -z "${MYSQLCNF}" ]; then
       
    47         echo "mysql/cnf property not set"
       
    48         exit $SMF_EXIT_ERR_CONFIG
       
    49 fi
       
    50 
       
    51 if [ -z "${MYSQLBIN}" ]; then
       
    52         echo "mysql/bin property not set"
       
    53         exit $SMF_EXIT_ERR_CONFIG
       
    54 fi
       
    55 
       
    56 if [ -z "${MYSQLDATA}" ]; then
       
    57 	echo "mysql/data property not set"
       
    58 	exit $SMF_EXIT_ERR_CONFIG
       
    59 fi
       
    60 
       
    61 if [ ! -d "${MYSQLDATA}" ]; then
       
    62 	echo "mysql/data directory ${MYSQLDATA} is not a valid MySQL data directory"
       
    63 	exit $SMF_EXIT_ERR_CONFIG
       
    64 fi
       
    65 
       
    66 if [ ! -d "${MYSQLDATA}"/mysql ]; then
       
    67 	(
       
    68 	exec 2>&1
       
    69 	set -x
       
    70 	"${MYSQLBIN}"/mysqld --initialize --user=mysql --datadir="${MYSQLDATA}" --log-error="${LOG_ERROR}"
       
    71 	)
       
    72 fi
       
    73 
       
    74 # refresh method for this service is not defined because mysqld by itself
       
    75 # cannot accept a HUP signal to reload the configuration file my.cnf
       
    76 
       
    77 mysql_start() 	{
       
    78 	(
       
    79 	exec 2>&1
       
    80 	set -x
       
    81 	"${MYSQLBIN}"/mysqld_safe --defaults-file="${MYSQLCNF}" --user=mysql --datadir="${MYSQLDATA}" --pid-file="${PIDFILE}" > /dev/null &
       
    82 	)
       
    83 }
       
    84 
       
    85 case "$1" in
       
    86 'start')
       
    87 	mysql_start 
       
    88 	;;
       
    89 
       
    90 *)
       
    91 	echo "Usage: $0 start"
       
    92 	exit 1
       
    93 	;;
       
    94 
       
    95 esac
       
    96 exit $SMF_EXIT_OK