fix #1617 (useradd: user 'audiobookshelf' already exists)

This change fixes the problem of failing upgrades on dpkg-based systems
by reworking the check for whether the `audiobookshelf` user/group already
exists.
This commit is contained in:
Frank de Lange 2025-10-10 22:30:38 +02:00
parent 2592467d09
commit 797dba2448

View File

@ -22,7 +22,7 @@ add_user() {
declare -r descr="${4:-No description}" declare -r descr="${4:-No description}"
declare -r shell="${5:-/bin/false}" declare -r shell="${5:-/bin/false}"
if ! getent passwd | grep -q "^$user:"; then if ! getent passwd "$user" 2>&1 >/dev/null; then
echo "Creating system user: $user in $group with $descr and shell $shell" echo "Creating system user: $user in $group with $descr and shell $shell"
useradd $uid_flags --gid $group --no-create-home --system --shell $shell -c "$descr" $user useradd $uid_flags --gid $group --no-create-home --system --shell $shell -c "$descr" $user
fi fi
@ -39,7 +39,7 @@ add_group() {
declare -r gid_flags="--gid $gid" declare -r gid_flags="--gid $gid"
fi fi
if ! getent group | grep -q "^$group:" ; then if ! getent group "$group" 2>&1 >/dev/null; then
echo "Creating system group: $group" echo "Creating system group: $group"
groupadd $gid_flags --system $group groupadd $gid_flags --system $group
fi fi