X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Fjenkins-jnlp-connect.sh;h=c8a2b499d682121122984fd94a8fe8ff498901bf;hb=99f9acd56d6d06ba4766542a13e468ed1b7f32dd;hp=be9fe184d6c9e806fa4fc82403d70a946c25fc70;hpb=66748e90b09e7398e675285c10fc286b5c740f26;p=releng.git diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh index be9fe184d..c8a2b499d 100755 --- a/utils/jenkins-jnlp-connect.sh +++ b/utils/jenkins-jnlp-connect.sh @@ -52,7 +52,7 @@ main () { fi if [[ $(whoami) != "root" ]]; then - if sudo -l | grep "requiretty"; then + if sudo -l | grep "requiretty" | grep -v "\!requiretty"; then echo "please comment out Defaults requiretty from /etc/sudoers" exit 1 fi @@ -61,8 +61,8 @@ main () { #make pid dir pidfile="/var/run/$jenkinsuser/jenkins_jnlp_pid" if ! [ -d /var/run/$jenkinsuser/ ]; then - mkdir /var/run/$jenkinsuser/ - chown $jenkinsuser:$jenkinsuser /var/run/$jenkinsuser/ + sudo mkdir /var/run/$jenkinsuser/ + sudo chown $jenkinsuser:$jenkinsuser /var/run/$jenkinsuser/ fi if [[ $skip_monit != true ]]; then @@ -84,21 +84,30 @@ main () { if [ -d /etc/monit/conf.d ]; then monitconfdir="/etc/monit/conf.d/" + monitconfig="/etc/monit/monitrc" + #add start delay + sed -i '/^#.* delay /s/^#//' "$monitconfig" elif [ -d /etc/monit.d ]; then monitconfdir="/etc/monit.d" + monitconfig="/etc/monitrc" + #add start delay + sed -i '/^#.* delay /s/^#//' "$monitconfig" else echo "Could not determine the location of the monit configuration file." echo "Make sure monit is installed." exit 1 fi + chown=$(type -p chown) + mkdir=$(type -p mkdir) + makemonit () { echo "Writing the following as monit config:" cat << EOF | tee $monitconfdir/jenkins check directory jenkins_piddir path /var/run/$jenkinsuser -if does not exist then exec "/usr/bin/mkdir -p /var/run/$jenkinsuser" -if failed uid $jenkinsuser then exec "/usr/bin/chown $jenkinsuser /var/run/$jenkinsuser" -if failed gid $jenkinsuser then exec "/usr/bin/chown :$jenkinsuser /var/run/$jenkinsuser" +if does not exist then exec "$mkdir -p /var/run/$jenkinsuser" +if failed uid $jenkinsuser then exec "$chown $jenkinsuser /var/run/$jenkinsuser" +if failed gid $jenkinsuser then exec "$chown :$jenkinsuser /var/run/$jenkinsuser" 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" @@ -111,9 +120,9 @@ EOF #test for diff if [[ "$(diff $monitconfdir/jenkins <(echo "\ check directory jenkins_piddir path /var/run/$jenkinsuser -if does not exist then exec \"/usr/bin/mkdir -p /var/run/$jenkinsuser\" -if failed uid $jenkinsuser then exec \"/usr/bin/chown $jenkinsuser /var/run/$jenkinsuser\" -if failed gid $jenkinsuser then exec \"/usr/bin/chown :$jenkinsuser /var/run/$jenkinsuser\" +if does not exist then exec \"$mkdir -p /var/run/$jenkinsuser\" +if failed uid $jenkinsuser then exec \"$chown $jenkinsuser /var/run/$jenkinsuser\" +if failed gid $jenkinsuser then exec \"$chown :$jenkinsuser /var/run/$jenkinsuser\" 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\"