summaryrefslogtreecommitdiffstats
path: root/utils/jenkins-jnlp-connect.sh
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2016-11-24 14:42:13 +0000
committerMarkos Chandras <mchandras@suse.de>2016-11-29 12:04:10 +0000
commitbbb4a9461e9ee5bf8f2e6ef52627565319cb0c96 (patch)
tree7cb91326ecded64471caa5730c820af827b6c104 /utils/jenkins-jnlp-connect.sh
parent90dbe41e705c6247f0171380f49873ac40a54eb1 (diff)
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 <mchandras@suse.de>
Diffstat (limited to 'utils/jenkins-jnlp-connect.sh')
-rwxr-xr-xutils/jenkins-jnlp-connect.sh41
1 files changed, 20 insertions, 21 deletions
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