summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2017-01-10 15:48:51 +0000
committerMarkos Chandras <mchandras@suse.de>2017-01-11 10:56:47 +0000
commit309d7e37065bea52e31f0cb6573dc8d19a41fc0b (patch)
treeff8105e2cb030006586623c1309edecdc17efcfb /utils
parent3f8ff074cbdc4f6d882345ac2cacf2acc26efc5b (diff)
utils/jenkins-jnlp-connect.sh: Make sure the pid directory exists
/var/run/ is only writable by root so Monit will fail to create the necessary subdirectory for the jenkins pid file since we run it as the 'jenkin' user. We add another entry to the monit configuration file to check the presence and the permissions of that directory before we try to start the jenkins slave. Change-Id: Ica7153c3e90900f60e4f65708c8f08abf5af9201 Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/jenkins-jnlp-connect.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh
index 9751a90de..be9fe184d 100755
--- a/utils/jenkins-jnlp-connect.sh
+++ b/utils/jenkins-jnlp-connect.sh
@@ -95,18 +95,30 @@ main () {
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"
+
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"
stop program = "/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'"
+depends on jenkins_piddir
EOF
}
if [[ -f $monitconfdir/jenkins ]]; then
#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\"
+
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\"
-stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"\
+stop program = \"/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"
+depends on jenkins_piddir\
") )" ]]; then
echo "Updating monit config..."
makemonit $@