Skip to content

Commit

Permalink
[JENKINS-5771] Use $JENKINS_USER in Debian postinst.
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored and kohsuke committed Nov 30, 2011
1 parent 9714917 commit 8d1cda0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -82,6 +82,9 @@
<li class=bug>
Jenkins takes up too much space in /var/run
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11366">issue 11366</a>)
<li class=bug>
Use $JENKINS_USER in Debian postinst script.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-5771">issue 5771</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
15 changes: 9 additions & 6 deletions debian/debian/jenkins.postinst
Expand Up @@ -21,13 +21,16 @@ set -e
case "$1" in
configure)

[ -r /etc/default/jenkins ] && . /etc/default/jenkins
: ${JENKINS_USER:=jenkins}

# Create jenkins user if it doesn't exist.
# sometimes tools that users want Jenkins to run need a shell,
# so use /bin/bash. See JENKINS-4830
if ! id jenkins > /dev/null 2>&1 ; then
if ! id $JENKINS_USER > /dev/null 2>&1 ; then
adduser --system --home /var/lib/jenkins --no-create-home \
--ingroup nogroup --disabled-password --shell /bin/bash \
jenkins
$JENKINS_USER
fi

# If we have an old hudson install, rename it to jenkins
Expand All @@ -38,20 +41,20 @@ case "$1" in
touch /var/lib/hudson/.from-hudson
mv -f /var/lib/hudson/* /var/lib/hudson/.??* /var/lib/jenkins
rmdir /var/lib/hudson
find /var/lib/jenkins -user hudson -exec chown jenkins {} + || true
find /var/lib/jenkins -user hudson -exec chown $JENKINS_USER {} + || true
fi

# directories needed for jenkins
# we don't do -R because it can take a long time on big installation
chown jenkins:adm /var/lib/jenkins /var/log/jenkins
chown $JENKINS_USER:adm /var/lib/jenkins /var/log/jenkins
# we don't do "chmod 750" so that the user can choose the pemission for g and o on their own
chmod u+rwx /var/lib/jenkins /var/log/jenkins

# make sure jenkins can delete everything in /var/cache/jenkins to
# re-explode war. older installations may use /var/run/jenkins
# so make sure that they can delete too.
chown -R jenkins:adm /var/cache/jenkins /var/run/jenkins
chmod -R 750 /var/cache/jenkins /var/run/jenkins
chown -R $JENKINS_USER:adm /var/cache/jenkins /var/run/jenkins
chmod -R 750 /var/cache/jenkins /var/run/jenkins
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down

0 comments on commit 8d1cda0

Please sign in to comment.