Skip to content

Instantly share code, notes, and snippets.

@ahonor
Created December 2, 2010 02:27
Show Gist options
  • Save ahonor/724635 to your computer and use it in GitHub Desktop.
Save ahonor/724635 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# rundeckd Startup script for the RunDeck server
#
# description: rundeckd, providing rundeckd
# pidfile: $RDECK_BASE/var/run/rundeckd.pid
# Source installation profile
[ -z "$RDECK_BASE" -o ! -d "$RDECK_BASE" ] && {
echo "RDECK_BASE not set or does not exist" ;
exit 1 ;
}
[ ! -w $RDECK_BASE/var ] && {
echo "RDECK_BASE dir not writable: $RDECK_BASE"
exit 1 ;
}
. $RDECK_BASE/etc/profile
echo_success() {
echo "[OK]"
return 0
}
echo_failure() {
echo "[FAILED]"
return 1
}
PORT=9999
JAR=$RDECK_BASE/rundeck-launcher-1.0.0.jar
prog="rundeckd"
rundeckd="${JAVA_HOME}/bin/java ${RDECK_JVM} -Dserver.http.port=$PORT -jar $JAR"
RETVAL=0
PID_FILE=$RDECK_BASE/var/run/rundeckd.pid
mkdir -p $RDECK_BASE/var/run
mkdir -p $RDECK_BASE/var/log
mkdir -p $RDECK_BASE/var/lock/subsys
start() {
printf "%s" "Starting $prog: "
nohup $rundeckd 2>&1 >>$RDECK_BASE/var/log/service.log &
RETVAL=$?
PID=$!
echo $PID > $PID_FILE
if [ $RETVAL -eq 0 ]; then
touch $RDECK_BASE/var/lock/subsys/$prog
echo_success
else
echo_failure
fi
echo
return $RETVAL
}
stop() {
RETVAL=0
printf "%s" "Stopping $prog: "
PID=`cat $PID_FILE`
ps -p "$PID" >/dev/null
if [ $? -eq 0 ]; then
kill $PID
RETVAL=$?
[ $RETVAL -eq 0 ] && {
rm -f $RDECK_BASE/var/lock/subsys/$prog
} || {
echo_failure
return 1
}
fi
echo_success
return $RETVAL
}
status() {
printf "%s" "Status $prog: "
PID=`cat $PID_FILE`
ps -p "$PID" >/dev/null
RETVAL=$?
[ $RETVAL -eq 0 ] && { echo_success ; } || { echo "[DOWN]" ; }
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $RDECK_BASE/var/lock/subsys/$prog ]; then
stop
start
fi
;;
status)
status $rundeckd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment