Add user with useradd command
based on https://unix.stackexchange.com/questions/28526/add-a-user-to-the-system-only-if-it-doesnt-exist
This commit is contained in:
@@ -39,11 +39,6 @@ mkdir -p /tmp/$PKGNAME/
|
|||||||
mkdir -p /tmp/$PKGNAME/debian/
|
mkdir -p /tmp/$PKGNAME/debian/
|
||||||
mkdir -p /tmp/$PKGNAME/usr/bin/
|
mkdir -p /tmp/$PKGNAME/usr/bin/
|
||||||
mkdir -p /tmp/$PKGNAME/etc/systemd/system/
|
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
|
cat > /tmp/$PKGNAME/debian/changelog << EOF
|
||||||
Please see https://github.com/Revertron/Alfis/
|
Please see https://github.com/Revertron/Alfis/
|
||||||
@@ -77,6 +72,8 @@ EOF
|
|||||||
cat > /tmp/$PKGNAME/debian/postinst << EOF
|
cat > /tmp/$PKGNAME/debian/postinst << EOF
|
||||||
#!/bin/sh
|
#!/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
|
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"
|
groupadd --system --force alfis || echo "Failed to create group 'alfis' - please create it manually and reinstall"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user