#!/bin/bash
##############################################################################
#                                                                            #
#  This script deletes users using data stored in a file with the following  #
#  format:                                                                   #
#    - one username per line                                                 #
#                                                                            #
#    - Hint: you may also use the datafile you used with mkusers, since      #
#            additional datafields are ignored                               #
#                                                                            #
# !!!!ATTENTION!!!! Deleteting a user means also deleting its HOME-dir !!    #
#                                                                            #
#  Copyright: Released 1998 under the terms of the GNU GPL                   #
#  Written 1998 by Christian Ordig <chr.ordig@gmx.net>                       #
#                                                                            #
##############################################################################

echo "Written 1998 by Christian Ordig <chr.ordig@gmx.net>"
if [ "$LOGNAME" != "root" ]; then echo; echo "You must be root to delete users!"; exit; fi

if [ "$1" == "$NULL" ]; then echo; echo "Syntax: rmuser file_with_users_to_delete"; exit; fi

echo
echo "!!!!ATTENTION!!!! Deleteting a user means also deleting its HOME-dir !!"
echo -n "Do you really want to delete all the users in file '$1' (yes/n)? "
read q
if [ "$q" != "yes" ]; then exit; fi

echo "Deleting users ..."
eval `awk -F ':' '{printf ("userdel -r %s;\n",$1)};' $1`

