
Here are the latest copies of the XBBS Sysop's utilities purge & mvfile.sh.
You should find that they will run without modification with the exception of
purge which will require you to correct the path to allign.


===================  B E G I N N I N G    O F   P U R G E   ====================
:
# trap " put clean-up code here" 1 2 3 15
#purge
#	This script will assist the XBBS system operator in maintaining
#	the users lists.
#
#	Copyright Dighera Data Services  July 20, 1987
#

# This command should assure that the user.bbs file has been 'alligned',
# then prompt the sysop for a date, range of dates, name, or other search
# criteria, present matching users names individually and ask if they should be
# purged, if yes, then purge their records from: user.bbs, userpriv.bbs, and 
# messages.log in each of the message directories.  The deletion is most easily
# accomplished with grep -vf , sed, awk, or ed.

NAME="`basename $0`"				# The Name of this Script
HOMEDIR="`grep '^bbs:' /etc/passwd | awk -F\":\" '{print $6}'`"	# XBBS home dir
BINDIR="`head -21 $HOMEDIR/.config.bbs | tail -1`"		# XBBS binaries
USERFIL="`head -7 $HOMEDIR/.config.bbs | tail -1`"		# Users dBASE
PRIVFIL="`head -13 $HOMEDIR/.config.bbs | tail -1`"		# Privlege File
MSGMENU="`head -23 $HOMEDIR/.config.bbs | tail -1`"		# Message Areas
MSGLOG="messages.log"						# Message Log 
export NAME HOMEDIR BINDIR USERFIL PRIVFIL MSGMENU MSGLOG
echo "\014\n\n\n\tX B B S    U S E R    P U R G E    M E N U \n\n"
#
#  Save a copy of all files that will be modified
#
if [ -f ${USERFIL}.o ]
then
	echo "${USERFIL}.o exists.  Ok to overwrite it? \c"
	read ANS
	case $ANS in
		[yY]*) :;;
		*) echo "${NAME}: Aborting ..."; exit 1;;
	esac
else
	cp $USERFIL ${USERFIL}.o
fi
if [ -f ${PRIVFIL}.o ]
then
	echo "${PRIVFIL}.o exists.  Ok to overwrite it? \c"
	read ANS
	case $ANS in
		[yY]*) :;;
		*) echo "${NAME}: Aborting ..."; exit 1;;
	esac
else
	cp $PRIVFIL ${PRIVFIL}.o
fi
#
# Allign the users file
#
FLAG=0; export FLAG
echo "\nAllinging $USERFIL file ...\nPlease stand by ...\c"
echo "$USERFIL" >/tmp/$NAME.tmp
# You will have put the path to your allign program here
#$BINDIR/allign/allign </tmp/$NAME.tmp 2>&1 > /dev/null || (echo "${NAME}: cannot allign, aborting ..."; FLAG=1)
$USERFIL/allign </tmp/$NAME.tmp 2>&1 > /dev/null || (echo "${NAME}: cannot allign, aborting ..."; FLAG=1)
rm -f /tmp/$NAME.tmp
if [ $FLAG -eq 1 ];then exit 1;fi
#
# Display Menu
#
echo "\014"
cat << EOT


		X B B S   U S E R    P U R G E    M E N U


	N.  Purge Users by NAME
	D.  Purge Users by DATE
	C.  Purge Users that have ONLY CALLED ONCE
	P.  Purge Users by PRIVLEGE LEVEL
	B.  Purge Users by PRIVLEGE LEVEL & ONLY CALLED ONCE

	Q.  Quit to Unix
?
EOT
read CHOICE
case $CHOICE in 
	[nN]*) echo "${NAME}: This command is not implemented yet";;
	[dD]*) echo "${NAME}: This command is not implemented yet";;
# 
# Find all user records with first-session-date = last-session-date, and
# present them for deletion from users data base.
#
	[cC]*) echo "\nSearching $USERFIL for One-time-callers...\c";
		rm -f /tmp/$NAME.found /tmp/$NAME.prv.rm /tmp/$NAME.priv > /dev/null 2>&1 ;
		awk -F"~" '$5 == $7 {print}' $USERFIL >> /tmp/$NAME.found && echo "Search Completed!";
# This trap needs to address processing the other files created by split
		if [ `wc -l /tmp/$NAME.found | awk '{print $1}'` -gt 900 ]
		then
			echo "File contains more than 900 lines; being split.."
			split /tmp/$NAME.found /tmp/$NAME.found.
			cp /tmp/$NAME.found.aa /tmp/$NAME.found
		fi;
		echo "Please stand by ... \c";
		for I in `awk -F"~" '{print $1"~"$2"~"}' /tmp/$NAME.found`
		do
			J="`echo \"$I\" | awk -F\"~\" '{print $1, $2, }'`"
			export J
			echo "\nPriv Record: \c"
			fgrep "$J" $PRIVFIL | tee /tmp/$NAME.priv
			if [ -s /tmp/$NAME/priv ]; then echo "\007";fi
			echo "User Record: \c"
			fgrep "$I" /tmp/$NAME.found
			echo "\n\tRemove (y,N,p,q)? \c"; read REMOVE
			case $REMOVE in
				[yY]*) echo "$I" >> /tmp/$NAME.rm;
				      cat /tmp/$NAME.priv >> /tmp/$NAME.prv.rm;;
				[pP]*) break;;
				[bB]*) echo "Not yet emplemented";;
				[qQ]*) exit 1;; # Add exit & clean up code here
				*) continue;;
			esac
			echo
		done;
		rm -f /tmp/$NAME.found /tmp/$NAME.priv;
		#
		# Create Purged  USERFIL
		#
	# This trap needs to address processing the other files created by split
		if [ `wc -l /tmp/$NAME.rm | awk '{print $1}'` -gt 200 ]
		then
			echo "File contains more than 200 lines; being split.."
			split /tmp/$NAME.rm /tmp/$NAME.rm.
			cp /tmp/$NAME.rm.aa /tmp/$NAME.rm
		fi
		fgrep -vf /tmp/$NAME.rm $USERFIL >${USERFIL}NEW;
		cp ${USERFIL}NEW $USERFIL && rm ${USERFIL}NEW;
		#
		# Create Purged PRIVFIL
		#
	# This trap needs to address processing the other files created by split
		if [ `wc -l /tmp/$NAME.prv.rm | awk '{print $1}'` -gt 200 ]
		then
			echo "File contains more than 200 lines; being split.."
			split /tmp/$NAME.prv.rm /tmp/$NAME.prv.rm.
			cp /tmp/$NAME.prv.rm.aa /tmp/$NAME.prv.rm
		fi
		fgrep -vf /tmp/$NAME.prv.rm $PRIVFIL >${PRIVFIL}NEW;
		cp ${PRIVFIL}NEW $PRIVFIL && rm ${PRIVFIL}NEW;
		#
		# Create Purged MSGFIL
		#
		for J in `awk 'NR > 1 {print $1}' $MSGMENU`
		do
			cd $BINDIR/$J
			fgrep -vf /tmp/$NAME.prv.rm $MSGLOG >${MSGLOG}NEW
			cp $MSGLOG o$MSGLOG && (cp ${MSGLOG}NEW $MSGLOG; rm ${MSGLOG}NEW)
		done;
		# add clean-up code here
		rm /tmp/$NAME.rm /tmp/$NAME.prv.rm;;
	[pP]*) echo "${NAME}: This command is not implemented yet";;
	[qQ]*) exit 0;;
	*) ;;
esac
exec $0
# trap 1 2 3 15
============================  E N D    O F    P U R G E  ====================

===================  B E G I N N I N G    O F    M V F I L E . S H  ======
:
#mvfile.sh 	Version 1.0 Beta
#	This Bourn shell script will assist the Sysop in moving
#	files that have been uploaded by XBBS users to their 
#	respective directories.
#
#	Copyright Dighera Data Services September 5, 1987
#

NAME=`basename $0`	# The name of this program
SRCDIR=""		# Directory name containing files to be moved
DESTDIR=""		# Directory name that will receive file
JUNKDIR=/usr/tmp	# Destination for junked files
FLINE=""		# Line from files.bbs that describes file
HOMEDIR="`grep '^bbs:' /etc/passwd | awk -F\":\" '{print $6}'`"	# XBBS home dir
ORGDIR=`cat $HOMEDIR/.config.bbs | awk 'NR == 21 {print}' -`	# XBBS Origin 
AREAS_BBS=`cat $HOMEDIR/.config.bbs | awk 'NR == 22 {print}' -`	# File w/ areas
AREAS=`cat $AREAS_BBS | awk 'NR > 1 { print $1 }'`	# All file areas
# AREA_NO=`expr \`wc -l $AREAS_BBS | awk '{print $1}'\` - 1`
set $AREAS
AREA_NO=$#
MENU="cat /usr/tmp/$NAME.mnu"
export NAME HOMEDIR ORGDIR AREAS_BBS AREAS AREA_NO SRCDIR FLINE DESTDIR MENU SORT DAYS
trap "echo \"\007$0: Aborted\"; eval rm /usr/tmp/$NAME.mnu; exit 2" 1 2

#	Make Menu File
echo "\014\n\t    X B B S    F I L E    D I S P E R S A L    M E N U\n\n" > /usr/tmp/$NAME.mnu
echo "\t\tEnter the Number of Your Choice --\n" >> /usr/tmp/$NAME.mnu
for I
do
	echo "$I" >> /usr/tmp/$NAME.mu
done
cat /usr/tmp/$NAME.mu | pr -3t -n -o8 >>/usr/tmp/$NAME.mnu
echo >> /usr/tmp/$NAME.mnu
rm /usr/tmp/$NAME.mu

#
#	Main Program Begins
#
cd $ORGDIR	# No doubt this is the cause of the exec $0's failing
$MENU
echo "Enter the Number of the Source Directory\ncontaining the files you wish to move: \c"
read SRCDIR
case $SRCDIR in
  1[123] | [0123456789]) SRCDIR=`echo $AREAS | awk '{print $'$SRCDIR'}'`;;
  *) echo "Invalid Input\007"; sleep 3; exec $0;; 	# Bug here $0
esac
# This section needs work !!!!!!!!!!!!!!!!!!!!!
while true
do
   head -6 /usr/tmp/$NAME.mnu
   cat << EOT

	1.  Sort $SRCDIR ALPHABETICALLY (default)
	2.  Sort $SRCDIR REVERSED ALPHABETICAL
	3.  Sort $SRCDIR BEGINNING with Specific Characters
	4.  Sort $SRCDIR OLDest first
	5.  Sort $SRCDIR NEWest first
	6.  Show $SRCDIR files LESS THAN A NUMBER OF DAYS OLD
	7.  Show $SRCDIR files MORE THAN A NUMBER OF DAYS OLD
?
EOT
   read CHOICE
   case $CHOICE in
	1) CMD="ls $SRCDIR"; break;;
	2) CMD="ls -r $SRCDIR"; break;;
# The choice below only returns ONE filename; bug
	3) echo "\n\tEnter characters for begining of file name \c"; read SORT;
		CMD='basename `ls $SRCDIR/$SORT*`'; break;;
	4) CMD="ls -tr $SRCDIR"; break;;
	5) CMD="ls -t $SRCDIR"; break;;
# The two choices below don't fine any filenames; bug
	6) echo "Enter the NUMBER of DAYS";read DAYS; CMD="find $SRCDIR -ctime -$DAYS -print"; break;;
	7) echo "Enter the NUMBER of DAYS";read DAYS; CMD="find $SRCDIR -ctime +$DAYS -print"; break;;
	*) CMD="ls $SRCDIR"; break;;
   esac
done
#
#	Main Loop
#
echo "$CMD"
for J in `eval "$CMD"`
do
   if [ ! -f $SRCDIR/$J ] ;then continue; fi	# Don't process directories
   $MENU
   echo "\tQ.\tQuit to Unix\n\tN.\tNext File (don't move this one)\n\tJ.\tJunk this File (in $JUNKDIR)\n"
   FLINE="`grep ^$J $SRCDIR/files.bbs || (echo \"\007$0: File $J probabily not referenced in $SRCDIR/files.bbs.\"; sleep 3; continue)`"
   test `echo "$FLINE" | wc -l` -gt 1 && (echo "\007$0: File $J probabily referenced more than once in $SRCDIR/files.bbs"; sleep 3 ; continue)
   echo "Move?: $FLINE\n"
   ls -la $SRCDIR/$J
   echo "\nEnter the Number of the Distination Directory: \c"
   read CHOICE
   case $CHOICE in
 	[qQ]*) exit;;
 	[nN]*) continue;;
	[jJ]*) mv $SRCDIR/$J $JUNKDIR;
 		grep -v "$FLINE" $SRCDIR/files.bbs > /usr/tmp/$NAME.$$ || (echo " $0: grep error" ; sleep 3; continue);
		if [ -s /usr/tmp/$NAME.$$ ] ;then cp /usr/tmp/$NAME.$$ $SRCDIR/files.bbs
		else echo "\007$0: 0 length file error"; exit 1 ; fi
		rm /usr/tmp/$NAME.$$;
		echo $FLINE >> $JUNKDIR/files.bbs;;
 	[0-9] | 1[0-2]) DESTDIR=`echo $AREAS | awk '{print $'$CHOICE'}'`;
 		grep -v "$FLINE" $SRCDIR/files.bbs > /usr/tmp/$NAME.$$ || (echo " $0: grep error" ; sleep 3; continue);
		mv $SRCDIR/$J $DESTDIR;
		if [ -s /usr/tmp/$NAME.$$ ] ;then cp /usr/tmp/$NAME.$$ $SRCDIR/files.bbs
		else echo "\007$0: 0 length file error"; exit 1 ; fi
		rm /usr/tmp/$NAME.$$;
 		echo $FLINE >> $DESTDIR/files.bbs;;
# Add edit option here for $DESTDIR/files.bbs
 	*) echo "\007Your entery '$CHOICE' is not amoung the valid choices. Continuing ..."; sleep 2 ;;
   esac
done
rm /usr/tmp/$NAME.mnu
trap 1 2 3 9 15
===========================  E N D    O F    M V F I L E . S H   =============

