diff --git a/hosts/jenkins/etc/init.d/jenkins b/hosts/jenkins/etc/init.d/jenkins index 076151e411d5e08f269c39329b76db825f7263f6..8bde1b5e79d12ce441fa75f9d3551481027b2532 100755 --- a/hosts/jenkins/etc/init.d/jenkins +++ b/hosts/jenkins/etc/init.d/jenkins @@ -24,10 +24,16 @@ SCRIPTNAME=/etc/init.d/$NAME #DAEMON=$JENKINS_SH DAEMON=/usr/bin/daemon DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE" +JAVA=`type -p java` + +JAVA_ALLOWED_VERSION="18" if [ -n "$UMASK" ]; then DAEMON_ARGS="$DAEMON_ARGS --umask=$UMASK" fi +if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then + DAEMON_ARGS="$DAEMON_ARGS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/$NAME/access_log" +fi SU=/bin/su @@ -43,6 +49,26 @@ if [ "$RUN_STANDALONE" = "false" ]; then exit 1 fi +# Make sure there exists a java executable, it may not be allways the case +if [ -z "$JAVA" ]; then + echo "ERROR: No Java executable found in current PATH: $PATH" >&2 + echo "If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path" >&2 + exit 1 +fi + +# Work out the JAVA version we are working with: +JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*"/\1\2/p;') + +if [ "$JAVA_VERSION" = "$JAVA_ALLOWED_VERSION" ]; then + echo "Correct java version found" >&2 +else + echo "Found an incorrect Java version" >&2 + echo "Java version found:" >&2 + echo $($JAVA -version) >&2 + echo "Aborting" >&2 + exit 1 +fi + # load environments if [ -r /etc/default/locale ]; then . /etc/default/locale