diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 05:55:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 05:55:27 +0000 |
commit | 32e0ba8ebdadc47ac1a0da8d9a9668ff21909e4f (patch) | |
tree | ebaa5eacafe874b431d69e52f0f73c013c3017ae /testsuite/cleanup.sh | |
parent | Initial commit. (diff) | |
download | adduser-32e0ba8ebdadc47ac1a0da8d9a9668ff21909e4f.tar.xz adduser-32e0ba8ebdadc47ac1a0da8d9a9668ff21909e4f.zip |
Adding upstream version 3.118+deb11u1.upstream/3.118+deb11u1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/cleanup.sh')
-rwxr-xr-x | testsuite/cleanup.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testsuite/cleanup.sh b/testsuite/cleanup.sh new file mode 100755 index 0000000..624ada9 --- /dev/null +++ b/testsuite/cleanup.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +#################################################################### +# ATTENTION!! DANGER!!! +# +# This script will unconditionally zap all accounts, grups, mail +# and home directory data (including home directory contents) for +# all accounts starting with $user_prefix. +#################################################################### + + +FAILED=0 + +if [ "$(id -u)" != "0" ]; then + echo "root needed" + exit 1 +fi + +. ./commons.sh + +if [ -z "$user_prefix" ]; then + echo "no $user_prefix set" + exit 1 +fi + +for acct in $(grep "^$user_prefix" /etc/passwd | awk '{print $1}' FS=":"); do + echo $acct + if [ -z "$acct" ]; then + echo "empty \$acct in for loop. this should not happen" + exit 1 + fi + userdel $acct + rm -rf /home/$acct + rm -rf /var/spool/$acct +done + +for grp in $(grep "^$user_prefix" /etc/group | awk '{print $1}' FS=":"); do + echo $grp + if [ -z "$grp" ]; then + echo "empty \$grp in for loop. this should not happen" + exit 1 + fi + group $grp +done + +rm -f $userid_file |