explicitly check for `absent` to handle state-typos gracefully

This commit is contained in:
tom 2018-10-11 15:58:30 +02:00
parent 09870ece59
commit 409d736339
1 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2013 Daniel Heule (hda at sfs.biz)
# 2018 Thomas Eckert (tom at it-eckert.de)
#
# This file is part of cdist.
#
@ -130,7 +131,7 @@ if [ "$state" = "present" ]; then
echo useradd "$@" "$name"
fi
fi
else
elif [ "$state" = "absent" ]; then
if grep -q "^${name}:" "$__object/explorer/passwd"; then
#user exists, but state != present, so delete it
if [ -f "$__object/parameter/remove-home" ]; then
@ -139,4 +140,6 @@ else
echo userdel "${name}"
fi
fi
else
echo "Invalid state $state" >&2
fi