~james-page/ubuntu/precise/jenkins/954960-1.424.6

« back to all changes in this revision

Viewing changes to rpm/SOURCES/jenkins.init.in

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Damien Raude-Morvan
  • Date: 2012-01-14 18:41:37 UTC
  • mfrom: (1.1.3) (5.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120114184137-1pxuj76htdqukbia
Tags: 1.409.3+dfsg-2
[ James Page ]
* http://www.cloudbees.com/jenkins-advisory/jenkins-security-advisory-2012-01-10.cb
  - Rebuild to pickup new versions of jenkins-winstone (>= 0.9.10-jenkins-31)
    and jenkins-executable-war (>= 1.25) to fix Hash DoS vulnerability in
    jenkins when running standalone.

[ Damien Raude-Morvan ]
* Add DM-Upload-Allowed flag for James Page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
#     SUSE system statup script for Jenkins
4
 
#     Copyright (C) 2007  Pascal Bleser
5
 
#          
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.
10
 
#                             
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.
15
 
#      
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,
19
 
#     USA.
20
 
#
21
 
### BEGIN INIT INFO
22
 
# Provides:          jenkins
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
27
 
# Default-Start:     3 5
28
 
# Default-Stop:      0 1 2 6
29
 
# Short-Description: Jenkins continuous build server
30
 
# Description:       Start the Jenkins continuous build server
31
 
### END INIT INFO
32
 
 
33
 
# Check for missing binaries (stale symlinks should not happen)
34
 
JENKINS_WAR="@@WAR@@"
35
 
test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed"; 
36
 
        if [ "$1" = "stop" ]; then exit 0;
37
 
        else exit 5; fi; }
38
 
 
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;
43
 
        else exit 6; fi; }
44
 
test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?";
45
 
        if [ "$1" = "stop" ]; then exit 0;
46
 
        else exit 6; fi; }
47
 
 
48
 
JENKINS_PID_FILE="/var/run/jenkins.pid"
49
 
 
50
 
# Source function library.
51
 
. /etc/init.d/functions
52
 
 
53
 
# Read config   
54
 
[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG"
55
 
 
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;
59
 
        else exit 6; fi; }
60
 
[ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME";
61
 
        if [ "$1" = "stop" ]; then exit 0;
62
 
        else exit 1; fi; }
63
 
 
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
68
 
do
69
 
  [ -x "$JENKINS_JAVA_CMD" ] && break
70
 
  JENKINS_JAVA_CMD="$candidate"
71
 
done
72
 
 
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"
81
 
 
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"
84
 
fi
85
 
 
86
 
RETVAL=0
87
 
 
88
 
case "$1" in
89
 
    start)
90
 
        echo -n "Starting Jenkins "
91
 
        daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
92
 
        RETVAL=$?
93
 
        if [ $RETVAL = 0 ]; then
94
 
            success
95
 
            echo > "$JENKINS_PID_FILE"  # just in case we fail to find it
96
 
            MY_SESSION_ID=`/bin/ps h -o sess -p $$`
97
 
            # get PID
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
105
 
                # found a PID
106
 
                echo $pid > "$JENKINS_PID_FILE"
107
 
            done
108
 
        else
109
 
            failure
110
 
        fi
111
 
        echo
112
 
        ;;
113
 
    stop)
114
 
        echo -n "Shutting down Jenkins "
115
 
        killproc jenkins
116
 
        RETVAL=$?
117
 
        echo
118
 
        ;;
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}"
122
 
        fi
123
 
        $0 status
124
 
        if test $? = 0; then
125
 
                $0 restart
126
 
        else
127
 
                : # Not running is not a failure.
128
 
        fi
129
 
        ;;
130
 
    restart)
131
 
        $0 stop
132
 
        $0 start
133
 
        ;;
134
 
    force-reload)
135
 
        echo -n "Reload service Jenkins "
136
 
        $0 try-restart
137
 
        ;;
138
 
    reload)
139
 
        $0 restart
140
 
        ;;
141
 
    status)
142
 
        status jenkins
143
 
        RETVAL=$?
144
 
        ;;
145
 
    probe)
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)
149
 
 
150
 
        test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
151
 
        ;;
152
 
    *)
153
 
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
154
 
        exit 1
155
 
        ;;
156
 
esac
157
 
exit $RETVAL