Apache SMF restarts apache automatically

Kartik Vashishta <[email protected]> Thu, 11 Jul 2013 11:12:56 -0500
Newsgroups gmane.os.solaris.managers
Message-ID <CAJFC5W2iSLzETuwZqFKdOb1QJ3HfJa-M+4sym2sW3DLGknaskg@mail.gmail.com>
Hi,

I do not want apache to be restarted, I have given user sudo access to
apachectl to stop and restart, however, when user stops it, it get's
restarted automatically. here are the files:

vi /usr/local/svc/method/apache7
"/usr/local/svc/method/apache7" 56 lines, 1209 characters
#!/sbin/sh
#
# apache2
#
# Chris Miles 20050624
#

. /lib/svc/share/smf_include.sh

PATH=${PATH}:/apps/apache7/prefork/bin
APACHECONF=/apps/apache7/prefork/conf/httpd.conf
PIDFILE=/apps/apache7/prefork/logs/httpd.pid

if [ -f $PIDFILE ] ; then
        pid=`cat $PIDFILE 2>/dev/null`
else
        pid=`pgrep httpd`
fi

logmsg()
{
        logger -p daemon.warning -t apache2 "$1"
        echo "$1" >&2
}

case "$1" in
        start)
                [ ! -f ${APACHECONF} ] && exit 0
                [ -n "$pid" ] && kill -TERM $pid 2>/dev/null
                /apps/apache7/prefork/bin/apachectl -k start
                if [ $? -ne 0 ]
                then
                        exit $SMF_EXIT_ERR_CONIG
                fi
                ;;

        stop)
                /apps/apache7/prefork/bin/apachectl -k stop
                ;;

        reload)
                /apps/apache7/prefork/bin/apachectl -k graceful
                ;;

        restart)
                /apps/apache7/prefork/bin/apachectl -k restart
                ;;

        *)
                echo "Usage: $0 \c" >&2
                echo "(start|stop|reload|restart)" >&2
                exit 1
                ;;

esac
exit $SMF_EXIT_OK


cat apache7.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
"/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
    Apache2 SMF Manifest
    Chris Miles 20050624
 -->
<service_bundle type="manifest" name="site:apache7">
<service name="site/apache7" type="service" version="1">
<create_default_instance enabled="false"/>
<single_instance/>
<dependency name="paths" grouping="require_all" restart_on="none"
type="path">
<service_fmri value="file://localhost/apps/apache7/prefork/bin/apachectl"/>
<service_fmri value="file://localhost/apps/apache7/prefork/bin/httpd"/>
<service_fmri
value="file://localhost/apps/apache7/prefork/conf/httpd.conf"/>
</dependency>
<dependency name="network" grouping="require_any" restart_on="none"
type="service">
<service_fmri value="svc:/network/service"/>
</dependency>
<dependent name="apache2_multi-user" grouping="optional_all"
restart_on="none">
<service_fmri value="svc:/milestone/multi-user"/>
</dependent>
<!--

                The timeout needs to be large enough to wait for startup.

-->
<exec_method type="method" name="start" exec="/usr/local/svc/method/apache7
start" timeout_seconds="60"/>
<exec_method type="method" name="stop" exec="/usr/local/svc/method/apache7
stop" timeout_seconds="60"/>
<stability value="Unstable"/>
<template>
<common_name>
<loctext xml:lang="C">Apache 2 (httpd)</loctext>
</common_name>
<documentation>
<manpage title="httpd" section="8"/>
</documentation>
</template>
</service>
</service_bundle>