Skip to content
Permalink
Browse files

[JENKINS-23273] Do a recursive chown only when needed

* When the owner of files and configured JENKINS_USER are not the same we
need a recursive chown
* If the owner and the configured JENKINS_USER are the same but not the
default chown only the folders
* In the default case (owner, JENKINS_USER and %name being the same) do
nothing
  • Loading branch information
raul-arabaolaza committed Jan 29, 2017
1 parent bd92f0a commit d6f9ba991306e1b5f5e87315debd7dc0c66fc5b1
Showing with 10 additions and 3 deletions.
  1. +10 −3 rpm/build/SPECS/jenkins.spec
@@ -103,22 +103,29 @@ if test x"$JENKINS_INSTALL_SKIP_CHOWN" != "xtrue"; then
cacheOwner=$(cat /tmp/cacheowner)
rm -f /tmp/cacheowner
fi
if [ "${JENKINS_USER:-%{name}}" != "%{name}" ] || [ "${cacheOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
if [ "${cacheOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
chown -R ${JENKINS_USER:-%{name}} /var/cache/%{name}
elif [ "${JENKINS_USER:-%{name}}" != "%{name}" ] ; then
# User has changed ownership of files and JENKINS_USER, chown only the folder
chown ${JENKINS_USER:-%{name}} /var/cache/%{name}
fi
if [ -f "/tmp/logowner" ]; then
logOwner=$(cat /tmp/logowner)
rm -f /tmp/logowner
fi
if [ "${JENKINS_USER:-%{name}}" != "%{name}" ] || [ "${logOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
if [ "${logOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
chown -R ${JENKINS_USER:-%{name}} /var/log/%{name}
elif [ "${JENKINS_USER:-%{name}}" != "%{name}" ] ; then
chown ${JENKINS_USER:-%{name}} /var/log/%{name}
fi
if [ -f "/tmp/workdirowner" ]; then
workdirOwner=$(cat /tmp/workdirowner)
rm -f /tmp/workdirowner
fi
if [ "${JENKINS_USER:-%{name}}" != "%{name}" ] || [ "${workdirOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
if [ "${workdirOwner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then
chown -R ${JENKINS_USER:-%{name}} ${JENKINS_HOME:-%{workdir}}
elif [ "${JENKINS_USER:-%{name}}" != "%{name}" ] ; then
chown ${JENKINS_USER:-%{name}} ${JENKINS_HOME:-%{workdir}}
fi
fi

0 comments on commit d6f9ba9

Please sign in to comment.
You can’t perform that action at this time.