#!/bin/sh
#
#   REQDIR!  Quick bodge, this is one way to do it there are countless
#            better ways to do it.  Darryl L Miles G7LED.
#
#
TMP=/tmp/lbbs-reqdir.$$
TMP1=/tmp/lbbs-reqdir1.$$

cat - >/dev/null

if [ $# -ne 2 ] || [ "$2" = "" ]
then
   DIR=
else
   DIR=`echo "$2" | tr -d ' '`
fi

echo "`date` $1 $DIR" >>/tmp/lbbs/reqdir

# I did this little hack in the USHELL to stop people requesting something
#   like ../../usr/lib/aliases
if ls -l `echo /home/ftp/$DIR | tr -s '.' | tr '\' '/'` >$TMP 2>$TMP1
then
   (
      cat <<!EOF!
To: $1
From: g7led@g7led.ampr.org
Subject: REQDIR: $DIR

[ LBBS - script based 'REQDIR' version 1.0 by Darryl Miles 05/04/1994 ]

Directory: $DIR
     Date: `date`

!EOF!
      cat $TMP
      cat <<!EOF!


-- 
+=================================+
|  G7LED@G7LED.GB7MIP.#29.GBR.EU  |
+=================================+
!EOF!
   ) | /usr/lib/sendmail -f g7led@g7led.ampr.org $1
else
   (
      cat <<!EOF!
To: $1
From: g7led@g7led.ampr.org
Subject: REQDIR: $DIR

[ LBBS - script based 'REQDIR' version 1.0 by Darryl Miles 05/04/1994 ]

Directory: $DIR
     Date: `date`


An error occured while producing your requested listing:

!EOF!
      cat $TMP1
      cat <<!EOF!


-- 
+=================================+
|  G7LED@G7LED.GB7MIP.#29.GBR.EU  |
+=================================+
!EOF!
   ) | /usr/lib/sendmail -f g7led@g7led.ampr.org $1

fi

rm $TMP $TMP1

# Make it junk the copy, we've dealt with it...
exit 254
