File jenkins.init of Package jenkins
#!/bin/sh
#
# SUSE system statup script for Jenkins
# Copyright (C) 2007 Pascal Bleser
# Copyright (C) 2013 SUSE Linux Products GmbH
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301,
# USA
#
### BEGIN INIT INFO
# Provides: jenkins
# Required-Start: $local_fs $remote_fs $network $named
# Should-Start: $time sendmail
# Required-Stop: $local_fs $remote_fs $network $named
# Should-Stop: $time sendmail
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Jenkins continuous build server
# Description: Start the Jenkins continuous build server
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of needed config file and read it
JENKINS_CONFIG=/etc/sysconfig/jenkins
test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
JENKINS_HOME="/var/lib/jenkins"
JENKINS_PID_FILE="/var/run/jenkins.pid"
JENKINS_USER="jenkins"
JENKINS_NICE="0"
JENKINS_LOG_DIR="/var/log/jenkins"
# Read config
. "$JENKINS_CONFIG"
. /etc/rc.status
rc_reset # Reset status of this service
[ -n "$JENKINS_ULIMIT" ] && ulimit -n "$JENKINS_ULIMIT"
JAVA_CMD="/usr/bin/java $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
PARAMS="--logfile=$JENKINS_LOG_DIR/jenkins.log"
[ -n "$JENKINS_HOST" ] && PARAMS="$PARAMS --httpListenAddress=$JENKINS_HOST"
[ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
[ -n "$JENKINS_HTTPS_HOST" ] && PARAMS="$PARAMS --httpsListenAddress=$JENKINS_HTTPS_HOST"
[ -n "$JENKINS_HTTPS_PORT" ] && PARAMS="$PARAMS --httpsPort=$JENKINS_HTTPS_PORT"
[ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
[ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
[ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
[ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
[ -n "$JENKINS_PREFIX" ] && PARAMS="$PARAMS --prefix=$JENKINS_PREFIX"
if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=$JENKINS_LOG_DIR/access.log"
fi
case "$1" in
start)
echo -n "Starting Jenkins "
/sbin/checkproc -k -p "$JENKINS_PID_FILE" "/usr/bin/java"
CHECK=$?
if [ $CHECK -eq 7 ]; then
HOME=$JENKINS_HOME startproc -n $JENKINS_NICE -s -e -u "$JENKINS_USER" -p "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS
JPROC=$( find /proc -maxdepth 2 -user $JENKINS_USER -name exe -lname "*/bin/java" )
if [ -n "$JPROC" ]; then
basename `dirname $JPROC` >"$JENKINS_PID_FILE"
rc_status -v
else
rc_failed
rc_status -v
fi
else
rc_failed $CHECK
rc_status -v
fi
;;
stop)
echo -n "Shutting down Jenkins "
/sbin/killproc -p "$JENKINS_PID_FILE" "/usr/bin/java"
rm -f "$JENKINS_PID_FILE"
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
echo -n "Reload service Jenkins "
$0 try-restart
rc_status
;;
reload)
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for service Jenkins "
/sbin/checkproc -p "$JENKINS_PID_FILE" "/usr/bin/java"
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.9)
test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit