utils: jenkins-jnlp-connect.sh: Fix start up script 57/24857/1
authorMarkos Chandras <mchandras@suse.de>
Thu, 24 Nov 2016 13:32:57 +0000 (13:32 +0000)
committerMarkos Chandras <mchandras@suse.de>
Thu, 24 Nov 2016 14:56:50 +0000 (14:56 +0000)
The jenkins-jnlp-connect.sh script is meant to be executed from the
$jenkinshome directory. The monit script was configured to enter a
different directory before starting the jenkins script which always
resulted in a broken start-up phase like this:

"This script needs to be run from the jenkins users home dir"

We fix this by entering the $jenkinshome directory before starting up
the jenkins script.

Change-Id: If0f65417f07a7fa9328f9adcd1ca1a1a3bc530ed
Signed-off-by: Markos Chandras <mchandras@suse.de>
utils/jenkins-jnlp-connect.sh

index 9ef4298..33463e1 100755 (executable)
@@ -30,8 +30,6 @@ EOF
 }
 
 main () {
-    dir=$(cd $(dirname $0); pwd)
-
     #tests
     if [[ -z $jenkinsuser || -z $jenkinshome ]]; then
         echo "jenkinsuser or home not defined, please edit this file to define it"
@@ -100,7 +98,7 @@ main () {
         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 $dir; export started_monit=true; $0 $@' with timeout 60 seconds"
+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
     }
@@ -109,7 +107,7 @@ EOF
         #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 $@' with timeout 60 seconds\"
+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..."