All pastes #908513 Raw Edit

Someone

public text v1 · immutable
·published 2008-02-18 15:15 UTC
rendered paste body
timf@haiiro[72] more /var/svc/manifest/network/http-apache22.xml 
<?xml version="1.0"?>
<!--
CDDL HEADER START

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]

CDDL HEADER END
-->

<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
    Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
    Use is subject to license terms.

    ident	"@(#)http-apache22.xml	1.8	07/12/12 SMI"
-->

<service_bundle type='manifest' name='SUNWapch22r: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='apache22' 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-apache22 start'
			timeout_seconds='60' />

		<exec_method
			type='method'
			name='stop'
			exec='/lib/svc/method/http-apache22 stop'
			timeout_seconds='60' />

		<exec_method
			type='method'
			name='refresh'
			exec='/lib/svc/method/http-apache22 refresh'
			timeout_seconds='60' />

		<property_group name='httpd' type='application'>
			<stability value='Evolving' />
			<propval name='startup_options' type='astring' value='' />
			<propval name='server_type' type='astring' value='prefork' />
			<propval name='enable_64bit' type='boolean' value='false' />
			<propval name='value_authorization' type='astring' value='solaris.smf.value.http/apache2
2' />
		</property_group>

		<property_group name='general' type='framework'>
			<propval name='action_authorization' type='astring' value='solaris.smf.manage.http/apach
e22' />
			<propval name='value_authorization' type='astring' value='solaris.smf.value.http/apache2
2' />
		</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>

		<template>
			<common_name>
				<loctext xml:lang='C'>
					Apache 2.2 HTTP server
				</loctext>
			</common_name>

			<documentation>
				<manpage title='httpd' section='8'
					manpath='/usr/apache2/2.2/man' />
				<doc_link name='apache.org'
					uri='http://httpd.apache.org' />
			</documentation>
		</template>

	</instance>

	<stability value='Evolving' />

</service>

</service_bundle>

timf@haiiro[71] more /lib/svc/method/http-apache22              
#!/sbin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)http-apache22	1.7	07/12/19 SMI"	
#

. /lib/svc/share/smf_include.sh

APACHE_VERSION=
APACHE_USR_ROOT=/usr/apache2
APACHE_ETC_ROOT=/etc/apache2

#if startup options contain multiple arguments separated by a blank,
#then they should be specified as below
#e.g., %> svccfg -s apache22 setprop 'httpd/startup_options=("-f" "/etc/apache2/2.2/new.conf")' 
#
STARTUP_OPTIONS=

SERVER_TYPE=prefork
PLATFORM_DIR=

getprop() {
    PROPVAL=""
    svcprop -q -p $1 ${SMF_FMRI}
    if [ $? -eq 0 ] ; then
        PROPVAL=`svcprop -p $1 ${SMF_FMRI}`
        if [ "${PROPVAL}" = "\"\"" ] ; then
            PROPVAL=""
        fi
        return
    fi
    return
}

APACHE_VERSION=`echo ${SMF_FMRI} | sed 's/[^0-9]//g;s/./\.&/g;s/^\.//'` 
if [ "x${APACHE_VERSION}" != "x" ]; then
    echo "Apache version is ${APACHE_VERSION}"
    APACHE_USR_ROOT=${APACHE_USR_ROOT}/${APACHE_VERSION}
    APACHE_ETC_ROOT=${APACHE_ETC_ROOT}/${APACHE_VERSION}
fi

getprop httpd/enable_64bit
if [ "${PROPVAL}" != "" ] ; then
    case ${PROPVAL} in
    true|1)
        # Check if the system architecture supports 64-bit applications
        PLATFORM=`isainfo -b`
        if [ "${PLATFORM}" != "64" ]; then
            echo "This system is not capable of supporting 64-bit applications."
            echo "Set \"enable_64bit\" property value to \"false\" to start the 32-bit server."
            exit $SMF_EXIT_ERR_CONFIG
        fi

	# 64 bit Apache
	PLATFORM_DIR=/amd64
	;;
    false|0) 
	# 32 bit Apache
	PLATFORM_DIR=
	;;
    *)
	# Invalid value for "bitness"
	echo "\"bitness\" property value is invalid. Starting the server in 32-bit mode"
	PLATFORM_DIR=
	;;
    esac
fi

APACHE_HOME=${APACHE_USR_ROOT}
APACHE_BIN=${APACHE_HOME}/bin${PLATFORM_DIR}

getprop httpd/startup_options
if [ "${PROPVAL}" != "" ] ; then
	echo startupoptions set
	echo val=${PROPVAL}
	STARTUP_OPTIONS="${PROPVAL} -k"
fi

getprop httpd/server_type
if [ "${PROPVAL}" != "" ] ; then
	SERVER_TYPE=${PROPVAL}
fi

case ${SERVER_TYPE} in
prefork)
	# If HTTPD value is set in
	# /etc/apache2/<version>/envvars file
	# delete the line so that it defaults to prefork 
	# type
	ALREADY_SET=`grep "HTTPD=" ${APACHE_ETC_ROOT}/envvars`
	if [ "${ALREADY_SET}" != "" ]; then
		sed -e '/^HTTPD=/ d' ${APACHE_ETC_ROOT}/envvars > ${APACHE_ETC_ROOT}/envvars.new
		cp ${APACHE_ETC_ROOT}/envvars.new ${APACHE_ETC_ROOT}/envvars
		rm ${APACHE_ETC_ROOT}/envvars.new
	fi
	;;
worker)
	# set HTTPD value to httpd.worker within 
	# /etc/apache2/<version>/envvars file
	ALREADY_SET=`grep "HTTPD=" ${APACHE_ETC_ROOT}/envvars`
	if [ "${ALREADY_SET}" != "" ]; then
		sed -e '/^HTTPD=/c\
HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_ETC_ROOT}/envvars > ${APACHE_ETC_ROOT}/envvars.new
	else
		sed -e '$a\
HTTPD='${APACHE_BIN}'/httpd.worker' ${APACHE_ETC_ROOT}/envvars > ${APACHE_ETC_ROOT}/envvars.new
	fi

	cp ${APACHE_ETC_ROOT}/envvars.new ${APACHE_ETC_ROOT}/envvars
	rm ${APACHE_ETC_ROOT}/envvars.new
	;;
*)
        if [ "x${APACHE_VERSION}" != "x" ]; then
            echo "Unknown server_type"
            exit $SMF_EXIT_ERR_CONFIG
        fi
	;;
esac
	


case "$1" in
start)
	cmd="start"
	;;
refresh)
	cmd="graceful"
	;;
stop)
	cmd="stop"
	;;
*)
	echo "Usage: $0 {start|stop|refresh}"
	exit $SMF_EXIT_ERR_CONFIG
	;;
esac

exec ${APACHE_BIN}/apachectl ${STARTUP_OPTIONS} ${cmd} 2>&1