Skip to content

Commit

Permalink
Debian postinst: check for present user/group before adding them
Browse files Browse the repository at this point in the history
In git commit 7216aab0d the check for present user was removed
and therefore upgrading the Debian package on existing Jenkins
installations fails. Also the newly added code for adding a
configurable Jenkins group is missing a check for a possibly
already present Jenkins group.

Closes: JENKINS-22710

Originally-From: jenkins-ci.org/commit/core/1b706c194a44a4b49b6d8260fc8ded0a3f9fca06
  • Loading branch information
mika committed Apr 22, 2014
1 parent e7af395 commit a1dad64
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions debian/jenkins.postinst
Expand Up @@ -25,15 +25,19 @@ case "$1" in
: ${JENKINS_USER:=jenkins}
: ${JENKINS_GROUP:=jenkins}

# Create jenkins user if it doesn't exist.
# Create jenkins group and user if they don't exist.
# sometimes tools that users want Jenkins to run need a shell,
# so use /bin/bash. See JENKINS-4830
addgroup --system --quiet $JENKINS_GROUP
adduser --system --quiet --home /var/lib/jenkins --no-create-home \
--ingroup $JENKINS_GROUP --disabled-password --shell /bin/bash \
--gecos 'Jenkins' \
$JENKINS_USER

if ! getent group "$JENKINS_GROUP" > /dev/null; then
addgroup --system --quiet "$JENKINS_GROUP"
fi
if ! id "$JENKINS_USER" >/dev/null 2>&1 ; then
adduser --system --quiet --home /var/lib/jenkins --no-create-home \
--ingroup "$JENKINS_GROUP" --disabled-password --shell /bin/bash \
--gecos 'Jenkins' \
"$JENKINS_USER"
fi

# If we have an old hudson install, rename it to jenkins
if test -d /var/lib/hudson -a \! \( -e /var/lib/hudson/.for-jenkins \) ; then
# leave a marker to indicate this came from Hudson.
Expand Down

0 comments on commit a1dad64

Please sign in to comment.