Add check for Requiretty add timeout 75/16175/3
authorAric Gardner <agardner@linuxfoundation.org>
Thu, 30 Jun 2016 14:08:12 +0000 (10:08 -0400)
committerAric Gardner <agardner@linuxfoundation.org>
Thu, 30 Jun 2016 14:41:11 +0000 (10:41 -0400)
if tty is requried monit fails, this will alert the user of this issue
if the wget takes to long monit panics and restart the process

Change-Id: Idf40a6150d1c87ec1b4b6652ace85680c6edb4fc
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
utils/jenkins-jnlp-connect.sh

index 8c41620..d268a28 100755 (executable)
@@ -48,6 +48,14 @@ main () {
         exit 1
     fi
 
+    if [[ $(whoami) != "root" ]]; then
+      if grep "^Defaults requiretty" /etc/sudoers
+        then echo "please comment out Defaults requiretty from /etc/sudoers"
+        exit 1
+      fi
+    fi
+
+
     if [ -d /etc/monit/conf.d ]; then
         monitconfdir="/etc/monit/conf.d/"
     elif [ -d /etc/monit.d ]; then
@@ -87,7 +95,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 $@'"
+start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $dir; 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
     }
@@ -96,7 +104,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 $@'\"
+start program = \"/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $dir; 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..."