Sysadmin > SolarIs > SolarisMySQL > MySQLStartupscript
getproparg() {
    val=`svcprop -p $1 $SMF_FMRI`
    [ -n "$val" ] && echo $val
}

MYSQLBIN=`getproparg mysql/bin`
MYSQLDATA=`getproparg mysql/data`
PIDFILE=${MYSQLDATA}/`/usr/bin/uname -n`.pid

if [ -z $SMF_FMRI ]; then
    echo "SMF framework variables are not initialized."
    exit $SMF_EXIT_ERR
fi

if [ -z ${MYSQLDATA} ]; then
    echo "mysql/data property not set"
    exit $SMF_EXIT_ERR_CONFIG
fi

                
                    if [ ! -d ${MYSQLDATA} ]; then
                        echo "mysql/data directory ${MYSQLDATA} is not a valid MySQL data directory"
                        exit $SMF_EXIT_ERR_CONFIG
                    fi
if [ ! -d ${MYSQLDATA}/mysql ]; then
    ${MYSQLBIN}/mysql_install_db --user=mysql --datadir=${MYSQLDATA}
fi
mysql_start() {

    echo ${MYSQLBIN}/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE}
    ${MYSQLBIN}/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &

}

mysql_stop() {

    if [ -f ${PIDFILE} ]; then
        pkill mysqld
    fi
}

case "$1" in

    'start')

        mysql_start
        ;;

    'stop')

        mysql_stop
        ;;

       \*)
        echo "Usage: $0 {start|stop}"
        exit 1

esac

exit $SMF_EXIT_OK