diff options
author | Giorgio Peron <giorgio.peron@gmail.com> | 2011-07-23 21:55:25 -0500 |
---|---|---|
committer | Niels Horn <niels.horn@slackbuilds.org> | 2011-08-11 20:28:36 -0300 |
commit | c1ddce54cbe423d1d875b0e15356507c2ed72cdb (patch) | |
tree | 32a9564778ead706b9f5cf70dbbeae3f4b899635 /system/jenkins/files | |
parent | cc71fc06d022150180e4b96148d9931c52054c59 (diff) |
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')
-rw-r--r-- | system/jenkins/files/jenkins.bin.sh | 2 | ||||
-rw-r--r-- | system/jenkins/files/jenkins.conf | 68 | ||||
-rw-r--r-- | system/jenkins/files/jenkinsd.sh | 119 | ||||
-rw-r--r-- | system/jenkins/files/logrotate.jenkins | 13 | ||||
-rw-r--r-- | system/jenkins/files/rc.jenkins | 82 |
5 files changed, 284 insertions, 0 deletions
diff --git a/system/jenkins/files/jenkins.bin.sh b/system/jenkins/files/jenkins.bin.sh new file mode 100644 index 0000000000000..270ce32d65c21 --- /dev/null +++ b/system/jenkins/files/jenkins.bin.sh @@ -0,0 +1,2 @@ +#!/bin/sh +java -jar /usr/share/jenkins/jenkins.war ${1+"$@"} diff --git a/system/jenkins/files/jenkins.conf b/system/jenkins/files/jenkins.conf new file mode 100644 index 0000000000000..fbdbcb875b9ed --- /dev/null +++ b/system/jenkins/files/jenkins.conf @@ -0,0 +1,68 @@ +## jenkins configuration setup file +# +## 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. + +## Java defaults to `which java` +#JAVA=/usr/lib/java/bin/java + +## system user for jenkins daemon (default to 'jenkins') +JENKINS_USER="jenkins" + +## set the http route prefix. Must include the preceding '/'. default is just '/' +#JENKINS_PREFIX=/ + +## set the http listening port. -1 to disable, Default is 8080 +#JENKINS_HTTP_PORT=8080 + +## set the http listening address. Default is all interfaces +#JENKINS_HTTP_LISTENING_ADDRESS="localhost" + +## set the https listening port. -1 to disable, Default is disabled +#JENKINS_HTTPS_PORT=8080 + +## set the https listening address. Default is all interfaces +#JENKINS_HTTPS_LISTENING_ADDRESS="localhost" + +## the location of the SSL KeyStore file. Default is ./winstone.ks +#JENKINS_HTTPS_KEYSTORE="" + +## the password for the SSL KeyStore file. Default is null +#JENKINS_HTTPS_KEYSTORE_PASSWORD="" + +## the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509 +#JENKINS_HTTPS_KEY_MANAGER="SunX509" + +## Default home of jenkins stuffs +#JENKINS_HOME=/var/lib/jenkins + +## Default location to log +#JENKINS_LOG_DIR=/var/log/jenkins.log + +## set directory for multiple webapps to be deployed from +#JENKINS_WEBAPPSDIR=/var/lib/jenkins/apps/ + +## set document root folder +#JENKINS_WEBROOT=/var/lib/jenkins/webroot + +## any additionally flags available, see `jenkins --help` +#OPT_ARGS="" diff --git a/system/jenkins/files/jenkinsd.sh b/system/jenkins/files/jenkinsd.sh new file mode 100644 index 0000000000000..f10ed4f9abaf1 --- /dev/null +++ b/system/jenkins/files/jenkinsd.sh @@ -0,0 +1,119 @@ +#!/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. + +JAVA=$(which java) +JENKINS="/usr/share/jenkins/jenkins.war" +JENKINS_USER="jenkins" +JENKINS_HTTP_PORT="8080" +JENKINS_LOG_FILE="/var/log/jenkins/jenkins.log" +JENKINS_CONSOLELOG_FILE="/var/log/jenkins/jenkins_console.log" +JENKINS_PID_DIR="/var/run/jenkins/" +JENKINS_PID_FILE="$JENKINS_PID_DIR/jenkins.pid" +JENKINS_WEBAPPSDIR="/var/lib/jenkins/apps/" +JENKINS_WEBROOT="/var/lib/jenkins/webroot/" +JENKINS_HOME="/var/lib/jenkins" +OPT_ARGS="" + +# Override some of the above settings, if defined in jenkins.conf +if [ -f /etc/jenkins/jenkins.conf ] ; then + . /etc/jenkins/jenkins.conf +fi + +export JENKINS_HOME + +PREV_PID=$( pgrep -f "$JENKINS" ) +if [ ! "$PREV_PID" = "" ] ; then + echo $PREV_PID still running + exit 1 +fi + +if [ "$JENKINS_PREFIX" != "" ] ; then + JENKINS_PREFIX_ARG="--prefix=$JENKINS_PREFIX" +fi + +if [ "$JENKINS_HTTP_PORT" != "" ] ; then + JENKINS_HTTP_PORT_ARG="--httpPort=$JENKINS_HTTP_PORT" +fi + +if [ "$JENKINS_HTTP_LISTENING_ADDRESS" != "" ] ; then + JENKINS_HTTP_LISTENING_ADDRESS_ARG="--httpListenAddress=$JENKINS_HTTP_LISTENING_ADDRESS" +fi + +if [ "$JENKINS_HTTPS_PORT" != "" ] ; then + JENKINS_HTTPS_PORT_ARG="--httpsPort=$JENKINS_HTTPS_PORT" +fi + +if [ "$JENKINS_HTTPS_LISTENING_ADDRESS" != "" ] ; then + JENKINS_HTTPS_LISTENING_ADDRESS_ARG="--httpsListenAddress=$JENKINS_HTTPS_LISTENING_ADDRESS" +fi + +if [ "$JENKINS_HTTPS_KEYSTORE" != "" ] ; then + JENKINS_HTTPS_KEYSTORE_ARG="--httpsKeyStore=$JENKINS_HTTPS_KEYSTORE" +fi + +if [ "$JENKINS_HTTPS_KEYSTORE_PASSWORD" != "" ] ; then + JENKINS_HTTPS_KEYSTORE_PASSWORD_ARG="--httpsKeyStorePassword=$JENKINS_HTTPS_KEYSTORE_PASSWORD" +fi + +if [ "$JENKINS_HTTPS_KEY_MANAGER" != "" ] ; then + JENKINS_HTTPS_KEY_MANAGER_ARG="--httpsKeyManagerType=$JENKINS_HTTPS_KEY_MANAGER" +fi + +if [ "$JENKINS_LOG_FILE" != "" ] ; then + JENKINS_LOG_FILE_ARG="--logfile=$JENKINS_LOG_FILE" +fi + +if [ "$JENKINS_WEBAPPSDIR" != "" ] ; then + JENKINS_WEBAPPSDIR_ARG="--webapssDir=$JENKINS_WEBAPPSDIR" +fi + +if [ "$JENKINS_WEBROOT" != "" ] ; then + JENKINS_WEBROOT_ARG="--webroot=$JENKINS_WEBROOT" +fi + +mkdir -p $JENKINS_PID_DIR +chown $JENKINS_USER $JENKINS_PID_DIR + +su - $JENKINS_USER -c " \ + JENKINS_HOME=$JENKINS_HOME \ + exec setsid \ + $JAVA -jar $JENKINS \ + $JENKINS_HTTP_PORT_ARG \ + $JENKINS_HTTP_LISTENING_ADDRESS_ARG \ + $JENKINS_HTTPS_PORT_ARG \ + $JENKINS_PREFIX_ARG \ + $JENKINS_HTTPS_LISTENING_ADDRESS_ARG \ + $JENKINS_HTTPS_KEYSTORE_ARG \ + $JENKINS_HTTPS_KEYSTORE_PASSWORD_ARG \ + $JENKINS_HTTPS_KEY_MANAGER_ARG \ + $JENKINS_LOG_FILE_ARG \ + $JENKINS_WEBAPPSDIR_ARG \ + $JENKINS_WEBROOT_ARG \ + $OPT_ARGS \ + </dev/null >> $JENKINS_CONSOLELOG_FILE 2>&1 & + + echo \$! > $JENKINS_PID_FILE + disown \$! + + " + diff --git a/system/jenkins/files/logrotate.jenkins b/system/jenkins/files/logrotate.jenkins new file mode 100644 index 0000000000000..f6b40db07baf2 --- /dev/null +++ b/system/jenkins/files/logrotate.jenkins @@ -0,0 +1,13 @@ +/var/log/jenkins/jenkins.log /var/log/jenkins/jenkins_console.log { + compress + dateext + maxage 365 + rotate 99 + size=+4096k + notifempty + missingok + create 644 + postrotate + kill -s SIGALRM `cat /var/run/jenkins.pid` + endscript +} diff --git a/system/jenkins/files/rc.jenkins b/system/jenkins/files/rc.jenkins new file mode 100644 index 0000000000000..d13e3912aa205 --- /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 + |