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

remotes/origin/4.10
Thomas Eckert 7 years ago
parent 09870ece59
commit 409d736339
  1. 5
      cdist/conf/type/__user/gencode-remote

@ -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

Loading…
Cancel
Save