From 32e0ba8ebdadc47ac1a0da8d9a9668ff21909e4f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 07:55:27 +0200 Subject: Adding upstream version 3.118+deb11u1. Signed-off-by: Daniel Baumann --- testsuite/cleanup.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 testsuite/cleanup.sh (limited to 'testsuite/cleanup.sh') 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 -- cgit v1.2.3