1*c18ec02fSPetter Reinholdtsen#!/bin/bash 2*c18ec02fSPetter Reinholdtsen# 3*c18ec02fSPetter Reinholdtsen# /etc/rc.d/init.d/ipmievd 4*c18ec02fSPetter Reinholdtsen# 5*c18ec02fSPetter Reinholdtsen# Based on example sysvinitfiles script 6*c18ec02fSPetter Reinholdtsen# Copyright (c) 2000 Red Hat Software, Inc. 7*c18ec02fSPetter Reinholdtsen# 8*c18ec02fSPetter Reinholdtsen# chkconfig: 345 99 00 9*c18ec02fSPetter Reinholdtsen# description: ipmievd daemon to send events to syslog 10*c18ec02fSPetter Reinholdtsen# processname: ipmievd 11*c18ec02fSPetter Reinholdtsen# config: /etc/sysconfig/ipmievd 12*c18ec02fSPetter Reinholdtsen# 13*c18ec02fSPetter Reinholdtsen### BEGIN INIT INFO 14*c18ec02fSPetter Reinholdtsen# Provides: ipmievd 15*c18ec02fSPetter Reinholdtsen# Required-Start: $syslog ipmi 16*c18ec02fSPetter Reinholdtsen# Should-Start: $time 17*c18ec02fSPetter Reinholdtsen# Required-Stop: $syslog ipmi 18*c18ec02fSPetter Reinholdtsen# Should-Stop: $time 19*c18ec02fSPetter Reinholdtsen# Default-Start: 3 4 5 20*c18ec02fSPetter Reinholdtsen# Default-Stop: 0 1 2 6 21*c18ec02fSPetter Reinholdtsen# Short-Description: ipmievd daemon to send events to syslog 22*c18ec02fSPetter Reinholdtsen# Description: Start ipmievd to read events from BMC and 23*c18ec02fSPetter Reinholdtsen# log them to syslog. Events correspond to hardware faults, 24*c18ec02fSPetter Reinholdtsen# state transitions such as power on and off, and sensor 25*c18ec02fSPetter Reinholdtsen# readings such as temperature, voltage and fan speed that 26*c18ec02fSPetter Reinholdtsen# are abnormal. 27*c18ec02fSPetter Reinholdtsen### END INIT INFO 28*c18ec02fSPetter Reinholdtsen 29*c18ec02fSPetter ReinholdtsenIPMIEVD_BIN=/usr/sbin/ipmievd 30*c18ec02fSPetter Reinholdtsentest -x $IPMIEVD_BIN || { echo "$IPMIEVD_BIN not installed"; 31*c18ec02fSPetter Reinholdtsen if [ "$1" = "stop" ]; then exit 0; 32*c18ec02fSPetter Reinholdtsen else exit 5; fi; } 33*c18ec02fSPetter Reinholdtsen 34*c18ec02fSPetter Reinholdtsen# Check for existence of needed config file 35*c18ec02fSPetter ReinholdtsenIPMIEVD_CONFIG=/etc/sysconfig/ipmievd 36*c18ec02fSPetter Reinholdtsentest -r $IPMIEVD_CONFIG || { echo "$IPMIEVD_CONFIG does not exist"; 37*c18ec02fSPetter Reinholdtsen if [ "$1" = "stop" ]; then exit 0; 38*c18ec02fSPetter Reinholdtsen else exit 6; fi; } 39*c18ec02fSPetter Reinholdtsen 40*c18ec02fSPetter Reinholdtsen# Read config file 41*c18ec02fSPetter Reinholdtsen. $IPMIEVD_CONFIG 42*c18ec02fSPetter Reinholdtsen 43*c18ec02fSPetter Reinholdtsen# Source function library. 44*c18ec02fSPetter Reinholdtsen. /etc/init.d/functions 45*c18ec02fSPetter Reinholdtsen 46*c18ec02fSPetter Reinholdtsenstart() { 47*c18ec02fSPetter Reinholdtsen echo "Starting ipmievd:" 48*c18ec02fSPetter Reinholdtsen if [ -f /var/lock/subsys/ipmievd ]; then 49*c18ec02fSPetter Reinholdtsen return 0 50*c18ec02fSPetter Reinholdtsen fi 51*c18ec02fSPetter Reinholdtsen daemon $IPMIEVD_BIN $IPMIEVD_OPTIONS 52*c18ec02fSPetter Reinholdtsen ret=$? 53*c18ec02fSPetter Reinholdtsen [ $ret -eq 0 ] && touch /var/lock/subsys/ipmievd 54*c18ec02fSPetter Reinholdtsen return $ret 55*c18ec02fSPetter Reinholdtsen} 56*c18ec02fSPetter Reinholdtsen 57*c18ec02fSPetter Reinholdtsenstop() { 58*c18ec02fSPetter Reinholdtsen echo "Shutting down ipmievd:" 59*c18ec02fSPetter Reinholdtsen killproc $IPMIEVD_BIN 60*c18ec02fSPetter Reinholdtsen ret=$? 61*c18ec02fSPetter Reinholdtsen [ $ret -eq 0 ] && rm -f /var/lock/subsys/ipmievd 62*c18ec02fSPetter Reinholdtsen return $ret 63*c18ec02fSPetter Reinholdtsen} 64*c18ec02fSPetter Reinholdtsen 65*c18ec02fSPetter Reinholdtsencase "$1" in 66*c18ec02fSPetter Reinholdtsen start) 67*c18ec02fSPetter Reinholdtsen start 68*c18ec02fSPetter Reinholdtsen ;; 69*c18ec02fSPetter Reinholdtsen stop) 70*c18ec02fSPetter Reinholdtsen stop 71*c18ec02fSPetter Reinholdtsen ;; 72*c18ec02fSPetter Reinholdtsen status) 73*c18ec02fSPetter Reinholdtsen status $IPMIEVD_BIN 74*c18ec02fSPetter Reinholdtsen ;; 75*c18ec02fSPetter Reinholdtsen restart|reload) 76*c18ec02fSPetter Reinholdtsen stop 77*c18ec02fSPetter Reinholdtsen start 78*c18ec02fSPetter Reinholdtsen ;; 79*c18ec02fSPetter Reinholdtsen condrestart) 80*c18ec02fSPetter Reinholdtsen [ -f /var/lock/subsys/ipmievd ] && restart || : 81*c18ec02fSPetter Reinholdtsen ;; 82*c18ec02fSPetter Reinholdtsen *) 83*c18ec02fSPetter Reinholdtsen echo "Usage: ipmievd {start|stop|status|reload|restart|condrestart}" 84*c18ec02fSPetter Reinholdtsen exit 1 85*c18ec02fSPetter Reinholdtsen ;; 86*c18ec02fSPetter Reinholdtsenesac 87*c18ec02fSPetter Reinholdtsenexit $? 88