1f06ca4afSHartmut Brandt#!/bin/sh 2f06ca4afSHartmut Brandt# 3f06ca4afSHartmut Brandt# Copyright (c) 2001-2003 4f06ca4afSHartmut Brandt# Fraunhofer Institute for Open Communication Systems (FhG Fokus). 5f06ca4afSHartmut Brandt# All rights reserved. 6f06ca4afSHartmut Brandt# 7f06ca4afSHartmut Brandt# Author: Harti Brandt <harti@freebsd.org> 8f06ca4afSHartmut Brandt# 9896052c1SHartmut Brandt# Redistribution and use in source and binary forms, with or without 10896052c1SHartmut Brandt# modification, are permitted provided that the following conditions 11896052c1SHartmut Brandt# are met: 12896052c1SHartmut Brandt# 1. Redistributions of source code must retain the above copyright 13896052c1SHartmut Brandt# notice, this list of conditions and the following disclaimer. 14f06ca4afSHartmut Brandt# 2. Redistributions in binary form must reproduce the above copyright 15f06ca4afSHartmut Brandt# notice, this list of conditions and the following disclaimer in the 16f06ca4afSHartmut Brandt# documentation and/or other materials provided with the distribution. 17f06ca4afSHartmut Brandt# 18896052c1SHartmut Brandt# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19896052c1SHartmut Brandt# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20896052c1SHartmut Brandt# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21896052c1SHartmut Brandt# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 22896052c1SHartmut Brandt# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23896052c1SHartmut Brandt# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24896052c1SHartmut Brandt# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25896052c1SHartmut Brandt# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26896052c1SHartmut Brandt# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27896052c1SHartmut Brandt# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28896052c1SHartmut Brandt# SUCH DAMAGE. 29f06ca4afSHartmut Brandt# 30896052c1SHartmut Brandt# $Begemot: bsnmp/snmpd/snmpd.sh,v 1.3 2004/08/06 08:47:13 brandt Exp $ 31f06ca4afSHartmut Brandt# 32f06ca4afSHartmut Brandt# SNMPd startup script 33f06ca4afSHartmut Brandt# 34f06ca4afSHartmut BrandtSNMPD=/usr/local/bin/bsnmpd 35f06ca4afSHartmut BrandtPID=/var/run/snmpd.pid 36f06ca4afSHartmut BrandtCONF=/etc/snmpd.conf 37f06ca4afSHartmut Brandt 38f06ca4afSHartmut Brandtcase "$1" in 39f06ca4afSHartmut Brandt 40f06ca4afSHartmut Brandtstart) 41f06ca4afSHartmut Brandt if [ -r ${PID} ] ; then 42f06ca4afSHartmut Brandt if kill -0 `cat ${PID}` ; then 43f06ca4afSHartmut Brandt echo "snmpd already running -- pid `cat ${PID}`" >/dev/stderr 44f06ca4afSHartmut Brandt exit 1 45f06ca4afSHartmut Brandt fi 46f06ca4afSHartmut Brandt rm -f ${PID} 47f06ca4afSHartmut Brandt fi 48f06ca4afSHartmut Brandt if ${SNMPD} -c ${CONF} -p ${PID} ; then 49f06ca4afSHartmut Brandt echo "snmpd started" 50f06ca4afSHartmut Brandt fi 51f06ca4afSHartmut Brandt ;; 52f06ca4afSHartmut Brandt 53f06ca4afSHartmut Brandtstop) 54f06ca4afSHartmut Brandt if [ -r ${PID} ] ; then 55f06ca4afSHartmut Brandt if kill -0 `cat ${PID}` ; then 56f06ca4afSHartmut Brandt if kill -15 `cat ${PID}` ; then 57f06ca4afSHartmut Brandt echo "snmpd stopped" 58f06ca4afSHartmut Brandt exit 0 59f06ca4afSHartmut Brandt fi 60f06ca4afSHartmut Brandt echo "cannot kill snmpd" >/dev/stderr 61f06ca4afSHartmut Brandt exit 1 62f06ca4afSHartmut Brandt fi 63f06ca4afSHartmut Brandt echo "stale pid file -- removing" >/dev/stderr 64f06ca4afSHartmut Brandt rm -f ${PID} 65f06ca4afSHartmut Brandt exit 1 66f06ca4afSHartmut Brandt fi 67f06ca4afSHartmut Brandt echo "snmpd not running" >/dev/stderr 68f06ca4afSHartmut Brandt ;; 69f06ca4afSHartmut Brandt 70f06ca4afSHartmut Brandtstatus) 71f06ca4afSHartmut Brandt if [ ! -r ${PID} ] ; then 72f06ca4afSHartmut Brandt echo "snmpd not running" 73f06ca4afSHartmut Brandt elif kill -0 `cat ${PID}` ; then 74f06ca4afSHartmut Brandt echo "snmpd pid `cat ${PID}`" 75f06ca4afSHartmut Brandt else 76f06ca4afSHartmut Brandt echo "stale pid file -- pid `cat ${PID}`" 77f06ca4afSHartmut Brandt fi 78f06ca4afSHartmut Brandt ;; 79f06ca4afSHartmut Brandt 80f06ca4afSHartmut Brandt*) 81f06ca4afSHartmut Brandt echo "usage: `basename $0` {start|stop|status}" 82f06ca4afSHartmut Brandt exit 1 83f06ca4afSHartmut Brandtesac 84f06ca4afSHartmut Brandt 85f06ca4afSHartmut Brandtexit 0 86