Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Poweralert 12.0 Unix Shell Script to start and stop the engine
- # only. Modified by MJL 23 June, 2006
- #
- #---------------------------------------
- # Usage:
- # pa start|stop|restart|status
- #
- #---------------------------------------
- #
- # Added status checks
- . /etc/rc.status
- rc_reset
- ### BEGIN INIT INFO
- # Provides: PowerAlert Engine
- # Required-Start: $ALL
- # Should-Start: $ALL
- # Required-Stop: $ALL
- # Should-Stop: $ALL
- # Default-Start: 2 3 5
- # Default-Stop: 0 2 3 5
- # Short-Description: PowerAlert engine daemon
- # Description: PowerAlert engine daemon modifed by MJL to start/stop and status of engine only
- ### END INIT INFO
- TRIPPLITE_PA_HOME=/opt/TrippLite/PowerAlert
- SRV_PATH=$TRIPPLITE_PA_HOME/engine
- #CNS_PATH=$TRIPPLITE_PA_HOME/console
- #UNINSTALL_PATH=$TRIPPLITE_PA_HOME/_uninst
- cd $TRIPPLITE_PA_HOME
- #paramNum=$#
- #param2="engine"
- #Copy the process table
- ps -efw > tempFile
- case "$1" in
- start)
- if `cat tempFile | grep engine/pa > /dev/null`
- then
- echo -n "PowerAlert Engine is already running... "
- else
- echo -n "Starting PowerAlert Engine... "
- $SRV_PATH/pa
- sleep 3
- fi
- rc_status -v
- ;;
- stop)
- if `cat tempFile | grep engine/pa > /dev/null`
- then
- echo -n "Stopping PowerAlert Engine... "
- kill `pidof engine/pa`
- sleep 3
- rc_status -v
- else
- echo -n "PowerAlert Engine is already stopped... "
- rc_status -v
- fi
- ;;
- restart)
- ## Stop the service and regardless of whether it was
- ## running or not, start it again.
- $0 stop
- $0 start
- # Remember status and be quiet
- rc_status
- ;;
- status)
- if `cat tempFile | grep engine/pa > /dev/null`
- then
- echo "PowerAlert Engine is running "
- else
- echo "PowerAlert Engine is stopped "
- fi
- ## Check status with checkproc(8), if process is running
- ## checkproc will return with exit status 0.
- # Return value is slightly different for the status command:
- # 0 - service up and running
- # 1 - service dead, but /var/run/ pid file exists
- # 2 - service dead, but /var/lock/ lock file exists
- # 3 - service not running (unused)
- # 4 - service status unknown :-(
- # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- exit 1
- ;;
- esac
- rc_exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement