8 echo "Syntax: ./remove-user.sh <username>"
12 COUNT
=`grep -E -c "^$1:" "$ETC/passwd" || :`
13 if [ "$COUNT" -ne "1" ]; then
14 echo "fatal: user '$1' doesn't appear to exist (or exists multiple times, or contains regexpy characters)."
17 GRPS
=`(grep -E '^[^:]+:[^:]+:[^:]+.*(:|,)'"$1"'(,|$)' "$ETC/group" || :) | cut -d : -f 1`
19 echo "User '$1' is still part of these groups:" $GRPS
20 echo "fatal: this simplistic script cannot remove users from groups."
23 sed -i.$$
-e "/^$1:/ d" "$ETC/passwd"
24 rm -f "$ETC/passwd.$$" ||
:
25 rm -f "$ETC/sshkeys/$1" ||
:
26 rm -f "$ETC/sshcerts/$cfg_nickname"_
"$1"_user_
*.pem ||
:
27 rm -f "$ETC/sshactive/$1" ||
:
28 rm -f "$ETC/sshactive/$1",* ||
:
29 ! [ -e "$ETC/sshkeys/$1" ] ||
echo "Warning: unable to remove $ETC/sshkeys/$1" >&2
30 [ "$(echo "$ETC/sshcerts
/$cfg_nickname"_"$1"_user_*.pem)" = "$ETC/sshcerts/$cfg_nickname"_
"$1"_user_
"*".pem
] ||
31 echo "Warning: unable to remove $(echo "$ETC/sshcerts
/$cfg_nickname"_"$1"_user_*.pem)" >&2
32 if [ -n "$cfg_update_pwd_db" -a "$cfg_update_pwd_db" != "0" ]; then
33 "$cfg_basedir/bin/update-pwd-db" "$ETC/passwd" "$1"
35 echo "User (+SSH key/certs) removed."