|
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) 2015, 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 |
|
45 if [ -z ${MYSQLCNF} ]; then |
|
46 echo "mysql/cnf property not set" |
|
47 exit $SMF_EXIT_ERR_CONFIG |
|
48 fi |
|
49 |
|
50 if [ -z ${MYSQLBIN} ]; then |
|
51 echo "mysql/bin property not set" |
|
52 exit $SMF_EXIT_ERR_CONFIG |
|
53 fi |
|
54 |
|
55 if [ -z ${MYSQLDATA} ]; then |
|
56 echo "mysql/data property not set" |
|
57 exit $SMF_EXIT_ERR_CONFIG |
|
58 fi |
|
59 |
|
60 if [ ! -d ${MYSQLDATA} ]; then |
|
61 echo "mysql/data directory ${MYSQLDATA} is not a valid MySQL data directory" |
|
62 exit $SMF_EXIT_ERR_CONFIG |
|
63 fi |
|
64 |
|
65 if [ ! -d ${MYSQLDATA}/mysql ]; then |
|
66 echo ${MYSQLBIN}/mysql_install_db --user=mysql --datadir=${MYSQLDATA} |
|
67 ${MYSQLBIN}/mysql_install_db --user=mysql --datadir=${MYSQLDATA} |
|
68 fi |
|
69 |
|
70 # refresh method for this service is not defined because mysqld by itself |
|
71 # cannot accept a HUP signal to reload the configuration file my.cnf |
|
72 |
|
73 mysql_start() { |
|
74 echo ${MYSQLBIN}/mysqld_safe --defaults-file=${MYSQLCNF} --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} |
|
75 ${MYSQLBIN}/mysqld_safe --defaults-file=${MYSQLCNF} --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null & |
|
76 |
|
77 } |
|
78 |
|
79 |
|
80 case "$1" in |
|
81 'start') |
|
82 mysql_start |
|
83 ;; |
|
84 |
|
85 *) |
|
86 echo "Usage: $0 start" |
|
87 exit 1 |
|
88 ;; |
|
89 |
|
90 esac |
|
91 exit $SMF_EXIT_OK |