From 8db40b4d8c89857b1f89cd6604ebc273a5b1ab8d Mon Sep 17 00:00:00 2001 From: Aric Gardner Date: Thu, 30 Jun 2016 10:08:12 -0400 Subject: Add check for Requiretty add timeout 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 --- utils/jenkins-jnlp-connect.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh index 8c41620d6..d268a28de 100755 --- a/utils/jenkins-jnlp-connect.sh +++ b/utils/jenkins-jnlp-connect.sh @@ -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..." -- cgit 1.2.3-korg