snmpd.sh revision 122394
1#!/bin/sh 2# 3# Copyright (c) 2001-2003 4# Fraunhofer Institute for Open Communication Systems (FhG Fokus). 5# All rights reserved. 6# 7# Author: Harti Brandt <harti@freebsd.org> 8# 9# Redistribution of this software and documentation and use in source and 10# binary forms, with or without modification, are permitted provided that 11# the following conditions are met: 12# 13# 1. Redistributions of source code or documentation must retain the above 14# copyright notice, this list of conditions and the following disclaimer. 15# 2. Redistributions in binary form must reproduce the above copyright 16# notice, this list of conditions and the following disclaimer in the 17# documentation and/or other materials provided with the distribution. 18# 3. Neither the name of the Institute nor the names of its contributors 19# may be used to endorse or promote products derived from this software 20# without specific prior written permission. 21# 22# THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 23# AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 24# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 25# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 26# FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 29# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 32# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33# 34# $Begemot: bsnmp/snmpd/snmpd.sh,v 1.1 2002/12/04 11:15:23 hbb Exp $ 35# 36# SNMPd startup script 37# 38SNMPD=/usr/local/bin/bsnmpd 39PID=/var/run/snmpd.pid 40CONF=/etc/snmpd.conf 41 42case "$1" in 43 44start) 45 if [ -r ${PID} ] ; then 46 if kill -0 `cat ${PID}` ; then 47 echo "snmpd already running -- pid `cat ${PID}`" >/dev/stderr 48 exit 1 49 fi 50 rm -f ${PID} 51 fi 52 if ${SNMPD} -c ${CONF} -p ${PID} ; then 53 echo "snmpd started" 54 fi 55 ;; 56 57stop) 58 if [ -r ${PID} ] ; then 59 if kill -0 `cat ${PID}` ; then 60 if kill -15 `cat ${PID}` ; then 61 echo "snmpd stopped" 62 exit 0 63 fi 64 echo "cannot kill snmpd" >/dev/stderr 65 exit 1 66 fi 67 echo "stale pid file -- removing" >/dev/stderr 68 rm -f ${PID} 69 exit 1 70 fi 71 echo "snmpd not running" >/dev/stderr 72 ;; 73 74status) 75 if [ ! -r ${PID} ] ; then 76 echo "snmpd not running" 77 elif kill -0 `cat ${PID}` ; then 78 echo "snmpd pid `cat ${PID}`" 79 else 80 echo "stale pid file -- pid `cat ${PID}`" 81 fi 82 ;; 83 84*) 85 echo "usage: `basename $0` {start|stop|status}" 86 exit 1 87esac 88 89exit 0 90