From 7bc0632ed511c515c54d516e136ef1a7e4a7e656 Mon Sep 17 00:00:00 2001 From: nxshock Date: Sat, 3 Apr 2021 21:30:51 +0500 Subject: [PATCH] Add user with useradd command based on https://unix.stackexchange.com/questions/28526/add-a-user-to-the-system-only-if-it-doesnt-exist --- contrib/deb/generate.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/deb/generate.sh b/contrib/deb/generate.sh index 866dba1..215ab02 100755 --- a/contrib/deb/generate.sh +++ b/contrib/deb/generate.sh @@ -39,11 +39,6 @@ mkdir -p /tmp/$PKGNAME/ mkdir -p /tmp/$PKGNAME/debian/ mkdir -p /tmp/$PKGNAME/usr/bin/ mkdir -p /tmp/$PKGNAME/etc/systemd/system/ -mkdir -p /tmp/$PKGNAME/usr/lib/sysusers.d/ - -cat > /tmp/$PKGNAME/usr/lib/sysusers.d/alfis.sysusers << EOF -u alfis - "alfis user" -EOF cat > /tmp/$PKGNAME/debian/changelog << EOF Please see https://github.com/Revertron/Alfis/ @@ -77,6 +72,8 @@ EOF cat > /tmp/$PKGNAME/debian/postinst << EOF #!/bin/sh +id -u somename &>/dev/null || useradd --system alfis || echo "Failed to create user 'alfis' - please create it manually and reinstall" + if ! getent group alfis 2>&1 > /dev/null; then groupadd --system --force alfis || echo "Failed to create group 'alfis' - please create it manually and reinstall" fi