Created
November 21, 2013 03:39
-
-
Save ashrithr/7575736 to your computer and use it in GitHub Desktop.
opscenter agent startup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /etc/init.d/opscenter-agent | |
# | |
# Startup script for opscenter-agent | |
# | |
# chkconfig: 2345 20 80 | |
# description: Starts and stops opscenter-agent | |
. /etc/init.d/functions | |
opsCenterAgentBin=/usr/share/opscenter/agent/bin/opscenter-agent | |
desc="Opscenter agent daemon" | |
outFile="/var/log/opscenter-agent/agent.out" | |
if ! [ -f $opsCenterAgentBin ]; then | |
echo "opscenter-agent binary not found." | |
exit 5 | |
fi | |
if [ -f /etc/sysconfig/opscenter-agent ]; then | |
. /etc/sysconfig/opscenter-agent | |
fi | |
start() { | |
echo "Starting $desc : " | |
#su -l $opscenterUser -c "nohup $opsCenterAgentBin >>$outFile 2>&1 &" | |
nohup $opsCenterAgentBin >> $outFile 2>&1 & | |
RETVAL=$? | |
return $RETVAL | |
} | |
stop() { | |
echo "Shutting down $desc: " | |
pkill -f opscenter-agent | |
} | |
restart() { | |
stop | |
start | |
} | |
status() { | |
pid=$(pgrep -f opscenter-agent) | |
if [ -z $pid ]; then | |
echo "opscenter-agent is NOT running." | |
else | |
echo "opscenter-agent is running (pid is $pid)." | |
fi | |
} | |
case "$1" in | |
start) start;; | |
stop) stop;; | |
restart) restart;; | |
status) status;; | |
*) echo "Usage: $0 {start|stop|restart}" | |
RETVAL=2;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment