[Git][java-team/tomcat9][master] extract system user (and group) creation into a separate script,
mirabilos
gitlab at salsa.debian.org
Tue Apr 2 15:44:15 BST 2019
mirabilos pushed to branch master at Debian Java Maintainers / tomcat9
Commits:
036902fe by mirabilos at 2019-04-02T14:43:40Z
extract system user (and group) creation into a separate script,
which I’ll gladly maintain, to reduce postinst complexity
- - - - -
4 changed files:
- debian/changelog
- + debian/libexec/create-sysuser.sh
- debian/tomcat9.install
- debian/tomcat9.postinst
Changes:
=====================================
debian/changelog
=====================================
@@ -13,8 +13,9 @@ tomcat9 (9.0.16-4) unstable; urgency=medium
a suitable GC automatically anyway (Closes: #925928)
* Correct the ownership and permissions on the log directory:
group adm and setgid (Closes: #925929)
+ * Reduce postinst complexity: extract user creation into separate script
- -- Thorsten Glaser <tg at mirbsd.de> Mon, 01 Apr 2019 17:16:06 +0200
+ -- Thorsten Glaser <tg at mirbsd.de> Tue, 02 Apr 2019 16:42:56 +0200
tomcat9 (9.0.16-3) unstable; urgency=medium
=====================================
debian/libexec/create-sysuser.sh
=====================================
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Create the tomcat system user
+#
+
+set -e
+
+if id tomcat >/dev/null 2>&1; then
+ # The user already exists
+ exit 0
+fi
+
+if which systemd-sysusers >/dev/null; then
+ # Use /usr/lib/sysusers.d/tomcat9.conf and systemd
+ systemd-sysusers
+else
+ # Use adduser instead, takes care of user and group both
+ adduser --system --home /var/lib/tomcat9 \
+ --shell /usr/sbin/nologin --no-create-home \
+ --group --disabled-password --disabled-login \
+ --gecos 'Apache Tomcat' tomcat
+fi
=====================================
debian/tomcat9.install
=====================================
@@ -8,6 +8,7 @@ debian/default.template /usr/share/tomcat9/
debian/logrotate.template /usr/share/tomcat9/
debian/sysusers/*.conf /usr/lib/sysusers.d/
+debian/libexec/create-sysuser.sh /usr/libexec/tomcat9/
debian/libexec/sysv-* /usr/libexec/tomcat9/
debian/libexec/tomcat-start.sh /usr/libexec/tomcat9/
debian/libexec/tomcat-update-policy.sh /usr/libexec/tomcat9/
=====================================
debian/tomcat9.postinst
=====================================
@@ -13,18 +13,8 @@ CONFFILES="tomcat-users.xml web.xml server.xml logging.properties context.xml ca
case "$1" in
configure)
- if which systemd-sysusers >/dev/null; then
- # Create the tomcat user as defined in /usr/lib/sysusers.d/tomcat9.conf
- systemd-sysusers
- elif id tomcat >/dev/null 2>&1; then
- : The tomcat user already exists
- else
- # Create the tomcat user without systemd
- adduser --system --home /var/lib/tomcat9 \
- --shell /usr/sbin/nologin --no-create-home \
- --group --disabled-password --disabled-login \
- --gecos 'Apache Tomcat' tomcat
- fi
+ # Create the tomcat user
+ /usr/libexec/tomcat9/create-sysuser.sh
# Install the configuration files
for conffile in $CONFFILES;
View it on GitLab: https://salsa.debian.org/java-team/tomcat9/commit/036902fe40f2f3b1fa4ff1c9457b2f3bc5193caa
--
View it on GitLab: https://salsa.debian.org/java-team/tomcat9/commit/036902fe40f2f3b1fa4ff1c9457b2f3bc5193caa
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190402/37cfd2cb/attachment.html>
More information about the pkg-java-commits
mailing list