Add overage and junit report for verify
[releng.git] / utils / jenkins-jnlp-connect.sh
index 00c1997..10ac50b 100755 (executable)
@@ -1,4 +1,13 @@
 #!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 Linux Foundation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
 #Monit setup script for opnfv jnlp slave connections
 
 test_firewall() {
@@ -39,10 +48,14 @@ if [[ $(whoami) != "root" && $(whoami) != "$jenkinsuser"  ]]; then
   exit 1
 fi
 
-if [[ $distro == Debian || $distro == Ubuntu ]]; then
+if [ -d /etc/monit/conf.d ]; then
   monitconfdir="/etc/monit/conf.d/"
-elif [[ $distro == Fedora || $distro == CentOS || $distro == Redhat ]]; then
+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
@@ -87,8 +100,8 @@ 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 $dir; export started_monit=true; $0 $@'\"
-stop program = \" /bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"\
+start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $dir; export started_monit=true; $0 $@'\"
+stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"\
 ") )" ]]; then
     echo "Updating monit config..."
     makemonit $@
@@ -114,7 +127,7 @@ then echo "pid file found"
         fi
 fi
 
-if [[ run_in_foreground == true ]]; then
+if [[ $run_in_foreground == true ]]; then
   $connectionstring
 else
   exec $connectionstring &
@@ -177,6 +190,5 @@ do
 done
 
 connectionstring="java -jar slave.jar -jnlpUrl https://build.opnfv.org/ci/computer/"$slave_name"/slave-agent.jnlp -secret "$slave_secret" -noCertificateCheck "
-distro="$(tr -s ' \011' '\012' < /etc/issue | head -n 1)"
 
 main "$@"