diff options
author | Aric Gardner <agardner@linuxfoundation.org> | 2016-11-29 12:31:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-11-29 12:31:13 +0000 |
commit | 27cda9f025a173b4f0f9e90a4aae9774f7f70026 (patch) | |
tree | 2681d555360859b2571614760c23e473220f482a | |
parent | aa11069e56842a36c24946753e13eb611613bb69 (diff) | |
parent | bbb4a9461e9ee5bf8f2e6ef52627565319cb0c96 (diff) |
Merge changes from topic 'fix-monit-script'
* changes:
utils: jenkins-jnlp-connect.sh: Make monit actions conditional
utils: jenkins-jnlp-connect.sh: Fix start up script
-rwxr-xr-x | utils/jenkins-jnlp-connect.sh | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh index 9ef4298ef..56ce61e17 100755 --- a/utils/jenkins-jnlp-connect.sh +++ b/utils/jenkins-jnlp-connect.sh @@ -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" @@ -60,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 @@ -94,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 $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 - } + } - 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 $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..." + echo "Updating monit config..." + makemonit $@ + fi + else makemonit $@ fi - else - makemonit $@ fi if [[ $started_monit == "true" ]]; then |