Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 d6f9ba9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rpm/build/SPECS/jenkins.spec
Expand Up @@ -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

Expand Down

0 comments on commit d6f9ba9

Please sign in to comment.