From: Markos Chandras Date: Thu, 24 Nov 2016 14:42:13 +0000 (+0000) Subject: utils: jenkins-jnlp-connect.sh: Make monit actions conditional X-Git-Tag: danube.1.0~616^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=bbb4a9461e9ee5bf8f2e6ef52627565319cb0c96;p=releng.git utils: jenkins-jnlp-connect.sh: Make monit actions conditional When executing the connection testing command as indicated in [1], -t is added to the monit start-up script parameters. This prevents the jenkins service from running in the background and create the pid file. Because of that, monit is confused and reports the service as failed. We fix this by moving all the monit related actions inside the 'monit' conditional block. [1]: http://artifacts.opnfv.org/octopus/brahmaputra/docs/octopus_docs/opnfv-jenkins-slave-connection.html#connecting-slaves-from-community-labs-to-opnfv-jenkins Change-Id: I7371c4560311b84f56eff3461254264e1769ff7e Signed-off-by: Markos Chandras --- diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh index 33463e153..56ce61e17 100755 --- a/utils/jenkins-jnlp-connect.sh +++ b/utils/jenkins-jnlp-connect.sh @@ -58,17 +58,6 @@ main () { fi fi - - if [ -d /etc/monit/conf.d ]; then - monitconfdir="/etc/monit/conf.d/" - elif [ -d /etc/monit.d ]; then - monitconfdir="/etc/monit.d" - else - echo "Could not determine the location of the monit configuration file." - echo "Make sure monit is installed." - exit 1 - fi - #make pid dir pidfile="/var/run/$jenkinsuser/jenkins_jnlp_pid" if ! [ -d /var/run/$jenkinsuser/ ]; then @@ -92,29 +81,39 @@ main () { exit 1 fi fi - fi - makemonit () { - echo "Writing the following as monit config:" + if [ -d /etc/monit/conf.d ]; then + monitconfdir="/etc/monit/conf.d/" + elif [ -d /etc/monit.d ]; then + monitconfdir="/etc/monit.d" + else + echo "Could not determine the location of the monit configuration file." + echo "Make sure monit is installed." + exit 1 + fi + + makemonit () { + echo "Writing the following as monit config:" cat << EOF | tee $monitconfdir/jenkins check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds" stop program = "/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'" EOF - } + } - if [[ -f $monitconfdir/jenkins ]]; then - #test for diff - if [[ "$(diff $monitconfdir/jenkins <(echo "\ + if [[ -f $monitconfdir/jenkins ]]; then + #test for diff + if [[ "$(diff $monitconfdir/jenkins <(echo "\ check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $jenkinshome; export started_monit=true; $0 $@' with timeout 60 seconds\" stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"\ ") )" ]]; then - echo "Updating monit config..." + echo "Updating monit config..." + makemonit $@ + fi + else makemonit $@ fi - else - makemonit $@ fi if [[ $started_monit == "true" ]]; then