summaryrefslogtreecommitdiff
path: root/system/jenkins/files/rc.jenkins
diff options
context:
space:
mode:
authorGiorgio Peron <giorgio.peron@gmail.com>2011-07-23 21:55:25 -0500
committerNiels Horn <niels.horn@slackbuilds.org>2011-08-11 20:28:36 -0300
commitc1ddce54cbe423d1d875b0e15356507c2ed72cdb (patch)
tree32a9564778ead706b9f5cf70dbbeae3f4b899635 /system/jenkins/files/rc.jenkins
parentcc71fc06d022150180e4b96148d9931c52054c59 (diff)
downloadslackbuilds-c1ddce54cbe423d1d875b0e15356507c2ed72cdb.tar.gz
system/jenkins: Added (automated job monitor)
Thanks to Vincent Batts for some configs :-) Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'system/jenkins/files/rc.jenkins')
-rw-r--r--system/jenkins/files/rc.jenkins82
1 files changed, 82 insertions, 0 deletions
diff --git a/system/jenkins/files/rc.jenkins b/system/jenkins/files/rc.jenkins
new file mode 100644
index 0000000000..d13e3912aa
--- /dev/null
+++ b/system/jenkins/files/rc.jenkins
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Copyright 2008,2009 Vincent Batts, Birmingham, AL, USA
+# Copyright 2010,2011 Vincent Batts, Vienna, VA, USA
+# vbatts@hashbangbash.com, http://hashbangbash.com/
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+function getPid() {
+ pgrep -f 'java.*jenkins.war'
+}
+pid_file="/var/run/jenkins/jenkins.pid"
+max_wait=8
+
+# Define start and stop functions
+jenkins_start() {
+ p=$(getPid)
+ if [ $p ]; then
+ echo "jenkins appears to already be running."
+ echo "on $p, check it first ..."
+ exit 1
+ else
+ echo "Starting jenkins daemon..."
+ jenkinsd 2>/dev/null 1>&2 || exit 1
+ fi
+}
+
+jenkins_stop() {
+ echo -ne "Stopping jenkins daemon... "
+ kill $(cat $pid_file) 2>/dev/null >/dev/null
+
+ p=$(getPid)
+ if [ ${p} -gt 1 ] 2>/dev/null ; then
+ echo "pid ${p}"
+ kill ${p}
+ else
+ echo "jenkins.war not found running"
+ fi
+}
+
+# See how we were called and take appropriate action
+case $1 in
+ start)
+ jenkins_start
+ ;;
+ stop)
+ jenkins_stop
+ ;;
+ restart)
+ jenkins_stop
+ i=0
+ while [ $i -lt $max_wait ] ; do
+ if [ $(getPid) ] >/dev/null ; then
+ sleep 1
+ else
+ break
+ fi
+ i=$[$i+1]
+ done
+ jenkins_start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+