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 2009 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24# 25# Start/Stop method script for the Sun Solstice Enterprise Master Agent 26# 27# Command line arguments 28# $1 = start/stop string 29# $2 = The primary process contract ID, if any, that under which the 30# service instance is executing. 31# 32 33. /lib/svc/share/smf_include.sh 34 35SNMP_CONFDIR=/etc/snmp/conf 36 37SNMP_RSRC=${SNMP_CONFDIR}/snmpdx.rsrc 38SNMP_BIN=/usr/lib/snmp/snmpdx 39 40case "$1" in 41 start) 42 43 if [ ! -f $SNMP_RSRC ]; then 44 echo "Configuration file $SNMP_RSRC does not exist. "\ 45 "Not starting snmpdx" 46 exit $SMF_EXIT_ERR_CONFIG 47 fi 48 49 if [ ! -x $SNMP_BIN ]; then 50 echo "$SNMP_BIN not found. Not starting snmpdx" 51 exit $SMF_EXIT_ERR_CONFIG 52 fi 53 54 if /usr/bin/egrep -sv '^[ ]*(#|$)'\ 55 ${SNMP_RSRC} 2> /dev/null ; then 56 : 57 else 58 # Do not start snmpdx if snmpdx.rsrc contents are 59 # trivial. 60 echo "$SNMP_RSRC contains no definitions. Not starting snmpdx." 61 exit $SMF_EXIT_ERR_CONFIG 62 fi 63 64 # 65 # Since snmpdx isn't SMF_EXIT_*-aware, report any failures generically. 66 # 67 ${SNMP_BIN} -y -c ${SNMP_CONFDIR} || exit $SMF_EXIT_ERR_FATAL 68 ;; 69 stop) 70 # Kill any processes in the service contract 71 smf_kill_contract $2 TERM 1 5 72 ret=$? 73 [ $ret -eq 1 ] && exit $SMF_EXIT_ERR_FATAL 74 75 # 76 # Some processes in the contract may not handle SIGTERM. 77 # If the contract did not empty after TERM, move on to KILL. 78 # 79 if [ $ret -eq 2 ] ; then 80 smf_kill_contract $2 KILL 1 81 [ $? -ne 0 ] && exit $SMF_EXIT_ERR_FATAL 82 fi 83 ;; 84 *) 85 echo "Usage: $0 { start | stop }" 86 exit $SMF_EXIT_ERR_FATAL 87 ;; 88esac 89 90exit $SMF_EXIT_OK 91