#!/bin/sh
# $Id: delete-account.in,v 1.1 2004/03/18 17:59:49 gdt Exp $

system=`uname`

PATH=/usr/sbin:/sbin:$PATH; export PATH

HOME=/home; export PATH

case $system in
  FreeBSD)
	systype=bsd
	;;
  NetBSD)
	systype=bsd
	;;
  *)
	systype=unknown
	echo "Unknown system type $system"
	exit 1
	;;
esac

# assume bsd
	
if [ `id -u` != 0 ] ; then
  echo "Must be root."
  exit 2
fi

if [ $# -lt 1 ]; then 
  echo "Usage: delete-account uname [uname]*"
  exit 3
fi

while [ $# -ge 1 ]; do
  u=$1
  if egrep "^$u:" /etc/master.passwd > /dev/null 2>&1; then
    egrep -v "^$u:" /etc/master.passwd > /etc/TMP.delete-account.$$
    pwd_mkdb -p /etc/TMP.delete-account.$$
    echo "$u removed from passwd"
  else
    echo "$u is NOT in passwd file"
  fi

  shift
done
