#! /bin/sh
: &&O='cd .' || exec /bin/sh "$0" $argv:q # we're in a csh, feed myself to sh
$O || exec /bin/sh "$0" "$@"		  # we're in a buggy zsh
#########################################################################
#	removelist	To remove mailinglists				#
#									#
#	Created by S.R. van den Berg, The Netherlands			#
#########################################################################
#$Id$

defaults=.etc

test=test		# /bin/test
rm=rm			# /bin/rm
ls=ls			# /bin/ls
pwd=pwd			# /bin/pwd
echo=echo		# /bin/echo
sleep=sleep		# /bin/sleep

EX_USAGE=64

if $test ! -d $defaults
then
  if $test -d list
  then cd ./list
  else cd ..
     $test -d $defaults || cd ..
  fi
fi
if $test ! -d $defaults
then
  $echo "removelist: You should be near the main list directory to do this" \
   1>&2
  exit $EX_USAGE
fi

if $test $# != 1
then $echo "Usage: removelist listname" 1>&2; exit $EX_USAGE
fi

list="$1"

case "$list" in
  ../*|*/..|*/../*|*/*) $echo "removelist: Suspicious listname specified" 1>&2
     exit $EX_USAGE;;
  *[@!]*) $echo "removelist: Specify listname without domain name appended" \
     1>&2; exit $EX_USAGE;;
esac

if test ! -d "$list"
then $echo "removelist: \"$list\" doesn't exist" 1>&2
  $echo 1>&2
  $echo "Existing mailinglists:" 1>&2
  $echo 1>&2
  $ls 1>&2
  $echo 1>&2
  exit $EX_USAGE
fi

$echo "Expunging `$pwd`/$list, countdown initiated:" 1>&2
$sleep 1
$echo "						     3"
$sleep 1
$echo "						       2"
$sleep 1
$echo "							 1"
$sleep 1
$echo "							   zero"

$rm -rf $list

$echo "Don't forget to remove the corresponding entries from" 1>&2
$echo "the /usr/lib/aliases file:" 1>&2
$echo \########################################################################
$echo "$list:"
$echo "$list-request:"
$echo "$list-dist:"
$echo \########################################################################
