Cool Tools - Any interest in SMF included?

I'd like to be able to manage the MySQL and Apache instances included with Cool Stack with SMF.

If we wrote up a good SMF manifest, would there be any chance of getting it included with future versions of Cool Stack? I'd hate to think of how many of us have reinvented the wheel writing our own. It would be nice to have standardized service names and use reduced privileges (one of the nicest features of SMF) for running these services.

Anybody know of any really nice ones already written before I go writing my own (again)?

What does the community think?

[585 byte] By [john.tracya] at [2007-11-26 23:13:57]
# 1
I'm working on this as we speak.I will post them soon.Shanti
shantiSa at 2007-7-10 14:12:23 > top of Java-index,Open Source Technologies,OpenSPARC...
# 2

Will these be helpful for Apache and Mysql?

__

cat /lib/svc/method/http-apache2

#!/sbin/sh

#

# Copyright 2004 Sun Microsystems, Inc. All rights reserved.

# Use is subject to license terms.

#

# ident "@(#)http-apache21.204/11/11 SMI"

#

. /lib/svc/share/smf_include.sh

APACHE_HOME=/opt/coolstack/apache2/

CONF_FILE=/opt/coolstack/apache2/conf/httpd.conf

PIDFILE=/var/run/apache2/httpd.pid

[ ! -f ${CONF_FILE} ] && exit $SMF_EXIT_ERR_CONFIG

case "$1" in

start)

/bin/rm -f ${PIDFILE}

/bin/mkdir -p /var/run/apache2

ssl=`svcprop -p httpd/ssl svc:/network/http:apache2`

if [ "$ssl" = false ]; then

cmd="start"

else

cmd="startssl"

fi

;;

refresh)

cmd="graceful"

;;

stop)

cmd="stop"

;;

*)

echo "Usage: $0 {start|stop|refresh}"

exit 1

;;

esac

exec ${APACHE_HOME}/bin/apachectl $cmd 2>&1

__

cat /var/svc/manifest/network/http-apache2.xml

<?xml version="1.0"?>

<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<!--

Copyright 2006 Sun Microsystems, Inc. All rights reserved.

Use is subject to license terms.

ident"@(#)http-apache2.xml1.306/03/27 SMI"

-->

<service_bundle type='manifest' name='SUNWapch2r:apache'>

<service

name='network/http'

type='service'

version='1'>

<!--

Because we may have multiple instances of network/http

provided by different implementations, we keep dependencies

and methods within the instance.

-->

<instance name='apache2' enabled='false'>

<!--

Wait for network interfaces to be initialized.

-->

<dependency name='network'

grouping='require_all'

restart_on='error'

type='service'>

<service_fmri value='svc:/milestone/network:default'/>

</dependency>

<!--

Wait for all local filesystems to be mounted.

-->

<dependency name='filesystem-local'

grouping='require_all'

restart_on='none'

type='service'>

<service_fmri

value='svc:/system/filesystem/local:default'/>

</dependency>

<!--

Wait for automounting to be available, as we may be

serving data from home directories or other remote

filesystems.

-->

<dependency name='autofs'

grouping='optional_all'

restart_on='error'

type='service'>

<service_fmri

value='svc:/system/filesystem/autofs:default'/>

</dependency>

<exec_method

type='method'

name='start'

exec='/lib/svc/method/http-apache2 start'

timeout_seconds='60' />

<exec_method

type='method'

name='stop'

exec='/lib/svc/method/http-apache2 stop'

timeout_seconds='60' />

<exec_method

type='method'

name='refresh'

exec='/lib/svc/method/http-apache2 refresh'

timeout_seconds='60' />

<property_group name='httpd' type='application'>

<stability value='Evolving' />

<propval name='ssl' type='boolean' value='false' />

</property_group>

<property_group name='startd' type='framework'>

<!-- sub-process core dumps shouldn't restart

session -->

<propval name='ignore_error' type='astring'

value='core,signal' />

</property_group>

</instance>

<stability value='Evolving' />

<template>

<common_name>

<loctext xml:lang='C'>

Apache 2 HTTP server

</loctext>

</common_name>

<documentation>

<manpage title='httpd' section='8'

manpath='/usr/apache2/man' />

<doc_link name='apache.org'

uri='http://httpd.apache.org' />

</documentation>

</template>

</service>

</service_bundle>

__

And for Mysql (this will use the mysql.server script in /opt/coolstack/mysql/share/mysql

cat /var/svc/manifest/network/mysql.xml

<?xml version="1.0"?>

<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<!--

This manifest can be used to manage a binary distro install

of Mysql using Solaris SMF system.

To use:

Set "basedir" in /opt/local/mysql/support-files/mysql.server

Import this manifest: svccfg -v import mysql_manifest.xml

Activate service: svcadm enable mysql

Copyright (C) 2005 Keith Lawson <keith.lawson@sjhc.london.on.ca>

This program is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

-->

<service_bundle type='manifest' name='mysql'>

<service

name='network/mysql'

type='service'

version='1'>

<create_default_instance enabled='false' />

<single_instance />

<dependency name='milestone'

grouping='require_all'

restart_on='error'

type='service'>

<service_fmri value='svc:/milestone/multi-user:default' />

</dependency>

<dependency name='filesystem'

grouping='require_all'

restart_on='error'

type='service'>

<service_fmri value='svc:/system/filesystem/root:default' />

</dependency>

<exec_method

type='method'

name='start'

exec='/opt/coolstack/mysql/share/mysql/mysql.server start'

timeout_seconds='60' />

<exec_method

type='method'

name='stop'

exec='/opt/coolstack/mysql/share/mysql/mysql.server stop'

timeout_seconds='60' />

<template>

<common_name>

<loctext xml:lang='C'>

Mysql database server

</loctext>

</common_name>

<documentation>

</documentation>

</template>

</service>

</service_bundle>

__

I'm using these now without issue. I'd like to have the drop privileges, but I don't have time to handle that yet.

-John

john.tracya at 2007-7-10 14:12:23 > top of Java-index,Open Source Technologies,OpenSPARC...