Skip to content

Commit

Permalink
[JENKINS-45287] Modify deb init script to check if configured java is…
Browse files Browse the repository at this point in the history
… suitable
  • Loading branch information
raul-arabaolaza committed Jul 7, 2017
1 parent 35a903a commit d076d29
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions deb/build/debian/jenkins.init
Expand Up @@ -25,6 +25,8 @@ SCRIPTNAME=/etc/init.d/$NAME
DAEMON=/usr/bin/daemon
DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE"

JAVA_ALLOWED_VERSION="18"

if [ -n "$UMASK" ]; then
DAEMON_ARGS="$DAEMON_ARGS --umask=$UMASK"
fi
Expand All @@ -43,6 +45,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 the system" >&2
echo "If you actually have java installed on the system make sure 'which 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
Expand Down

0 comments on commit d076d29

Please sign in to comment.