3
# SUSE system statup script for Jenkins
4
# Copyright (C) 2007 Pascal Bleser
6
# This library is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU Lesser General Public License as published by
8
# the Free Software Foundation; either version 2.1 of the License, or (at
9
# your option) any later version.
11
# This library is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Lesser General Public License for more details.
16
# You should have received a copy of the GNU Lesser General Public
17
# License along with this library; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
23
# Required-Start: $local_fs $remote_fs $network $time $named
24
# Should-Start: $time sendmail
25
# Required-Stop: $local_fs $remote_fs $network $time $named
26
# Should-Stop: $time sendmail
28
# Default-Stop: 0 1 2 6
29
# Short-Description: Jenkins continuous build server
30
# Description: Start the Jenkins continuous build server
33
# Check for missing binaries (stale symlinks should not happen)
35
test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed";
36
if [ "$1" = "stop" ]; then exit 0;
39
# Check for existence of needed config file and read it
40
JENKINS_CONFIG=/etc/sysconfig/jenkins
41
test -e "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not existing";
42
if [ "$1" = "stop" ]; then exit 0;
44
test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?";
45
if [ "$1" = "stop" ]; then exit 0;
48
JENKINS_PID_FILE="/var/run/jenkins.pid"
50
# Source function library.
51
. /etc/init.d/functions
54
[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG"
56
# Set up environment accordingly to the configuration settings
57
[ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG";
58
if [ "$1" = "stop" ]; then exit 0;
60
[ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME";
61
if [ "$1" = "stop" ]; then exit 0;
64
# Search usable Java. We do this because various reports indicated
65
# that /usr/bin/java may not always point to Java 1.5
66
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
67
for candidate in /usr/lib/jvm/java-1.6.0/bin/java /usr/lib/jvm/jre-1.6.0/bin/java /usr/lib/jvm/java-1.5.0/bin/java /usr/lib/jvm/jre-1.5.0/bin/java /usr/bin/java
69
[ -x "$JENKINS_JAVA_CMD" ] && break
70
JENKINS_JAVA_CMD="$candidate"
73
JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
74
PARAMS="--logfile=/var/log/jenkins/jenkins.log --daemon"
75
[ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
76
[ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
77
[ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
78
[ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
79
[ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
80
[ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS"
82
if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
83
PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access_log"
90
echo -n "Starting Jenkins "
91
daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
93
if [ $RETVAL = 0 ]; then
95
echo > "$JENKINS_PID_FILE" # just in case we fail to find it
96
MY_SESSION_ID=`/bin/ps h -o sess -p $$`
98
/bin/ps hww -u "$JENKINS_USER" -o sess,ppid,pid,cmd | \
99
while read sess ppid pid cmd; do
100
[ "$ppid" = 1 ] || continue
101
# this test doesn't work because Jenkins sets a new Session ID
102
# [ "$sess" = "$MY_SESSION_ID" ] || continue
103
echo "$cmd" | grep $JENKINS_WAR > /dev/null
104
[ $? = 0 ] || continue
106
echo $pid > "$JENKINS_PID_FILE"
114
echo -n "Shutting down Jenkins "
119
try-restart|condrestart)
120
if test "$1" = "condrestart"; then
121
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
127
: # Not running is not a failure.
135
echo -n "Reload service Jenkins "
146
## Optional: Probe for the necessity of a reload, print out the
147
## argument to this init script which is required for a reload.
148
## Note: probe is not (yet) part of LSB (as of 1.9)
150
test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
153
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"