components/net-snmp/sun/masfd
changeset 252 ee0fb1eabcbf
equal deleted inserted replaced
251:f527656d334f 252:ee0fb1eabcbf
       
     1 #
       
     2 # Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
       
     3 #
       
     4 # ident  "@(#)masfd	1.5 03/06/25 SMI"
       
     5 
       
     6 SUNWMASF_PKGLIB=`pkgparam SUNWmasf BASEDIR`
       
     7 SNMPD=$SUNWMASF_PKGLIB/SUNWmasf/sbin/snmpd
       
     8 SUNWMASF_PKGLIB=$SUNWMASF_PKGLIB/SUNWmasf/lib
       
     9 CONF_FILE=/etc/opt/SUNWmasf/conf/snmpd.conf
       
    10 TIMEOUT=5
       
    11 
       
    12 if [ ! -f ${CONF_FILE} ]; then
       
    13 	exit 0
       
    14 fi
       
    15 
       
    16 export SUNWMASF_PKGLIB
       
    17 
       
    18 PATTERN=`echo $SNMPD | sed 's/\\//\\\\\\//g'` 
       
    19 
       
    20 is_running() {
       
    21         /usr/bin/pgrep -x -f "$PATTERN -X"> /dev/null 2>&1 
       
    22 }
       
    23 
       
    24 case "$1" in
       
    25 start)
       
    26         if is_running ; then
       
    27                 echo "Agent already running" >&2
       
    28                 exit 1
       
    29         else
       
    30 		{
       
    31                         # allow time for agentX master agent to open socket
       
    32 			sleep 30
       
    33 	        	$SNMPD -X > /dev/null 2>&1
       
    34 		} &
       
    35         fi
       
    36 	;;
       
    37 stop)
       
    38         TIME=0
       
    39 	/usr/bin/pkill -x -f "$PATTERN -X"
       
    40         # Allow time for final poll to complete, before relinquishing control
       
    41         # and allowing picld to be stopped
       
    42         while is_running && [ $TIME -lt $TIMEOUT ] ; do
       
    43                 sleep 1
       
    44                 TIME=`/usr/bin/expr $TIME + 1`
       
    45         done
       
    46 	;;
       
    47 *)
       
    48 	echo "Usage: $0 {start|stop}" >&2
       
    49 	exit 1
       
    50 	;;
       
    51 esac
       
    52 
       
    53 exit 0