From ac0bedf80f329a767c18c2044a09d9aa2ed3f5ca Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Sat, 5 Dec 2020 21:10:26 +0100 Subject: [PATCH] jenkins: update to init script from latest package Signed-off-by: Holger Levsen --- hosts/jenkins/etc/init.d/jenkins | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hosts/jenkins/etc/init.d/jenkins b/hosts/jenkins/etc/init.d/jenkins index 562f84106..c40ee6142 100755 --- a/hosts/jenkins/etc/init.d/jenkins +++ b/hosts/jenkins/etc/init.d/jenkins @@ -47,7 +47,7 @@ if [ "$RUN_STANDALONE" = "false" ]; then exit 1 fi -# Make sure there exists a java executable, it may not be allways the case +# Make sure there exists a java executable, it may not be always 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 @@ -55,9 +55,9 @@ if [ -z "$JAVA" ]; then fi # Which Java versions can be used to run Jenkins -JAVA_ALLOWED_VERSIONS=( "18" "110" ) +JAVA_ALLOWED_VERSIONS=( "1.8" "11" ) # Work out the JAVA version we are working with: -JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*".*/\1\2/p;') +JAVA_VERSION=$($JAVA -version 2>&1 | sed -n ';s/.* version "\([0-9]\{2,\}\|[0-9]\.[0-9]\)\..*".*/\1/p;') if [[ ${JAVA_ALLOWED_VERSIONS[*]} =~ "$JAVA_VERSION" ]]; then echo "Correct java version found" >&2 @@ -140,6 +140,9 @@ do_start() # 2 if daemon could not be started $DAEMON $DAEMON_ARGS --running && return 1 + # Verify if there is a jenkins process already running without a daemon + get_running || return 2 + # Verify that the jenkins port is not already in use, winstone does not exit # even for BindException check_tcp_port "http" "$HTTP_PORT" "8080" "$HTTP_HOST" "0.0.0.0" || return 2 @@ -164,18 +167,26 @@ do_start() # # Verify that all jenkins processes have been shutdown -# and if not, then do killall for them # get_running() { return `ps -U $JENKINS_USER --no-headers -f | egrep -e '(java)' | grep -v defunct | grep -c . ` } +# +# killall jenkins processes that have not been shutdown +# force_stop() { get_running if [ $? -ne 0 ]; then killall -u $JENKINS_USER java daemon || return 3 + # wait for the process to really terminate + for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + sleep 1 + get_running && return 0 + done + return 2 fi } @@ -206,11 +217,11 @@ do_stop() $DAEMON $DAEMON_ARGS --running || break done if get_daemon_status; then - force_stop || return 3 + force_stop || return "$?" fi ;; *) - force_stop || return 3 + force_stop || return "$?" ;; esac @@ -247,7 +258,7 @@ case "$1" in do_stop case "$?" in 0|1) log_end_msg 0 ;; - 2) log_end_msg 1 ; exit 100 ;; + 2|3) log_end_msg 1 ; exit 100 ;; esac ;; restart|force-reload) -- GitLab