#
# weekly  -  shell script to be executed once per week to perform periodic
#            maintenance tasks on the Citadel/UX system.
# 
cd /usr/bbs

echo `date` Weekly BBS processing started.

# Purge out users who haven't called for two months, and rooms that haven't
# been posted in for two weeks
#
/usr/bbs/sysoputil -u
/usr/bbs/sysoputil -r

# Create a file called "?" in the help directory, listing all of the other
# help files.  This is a bit kludgey, but it does allow a user to type
# .<H>elp ?  to get a list of all available help files.
#
ls /usr/bbs/help >/usr/bbs/help/\?

# Now we remove any zero-length files in all of the room directories.
# Presumably any empty files are failed uploads and are not needed.
#
echo The following files have been deleted:
find /usr/bbs/files -size 0 -print -exec rm {} \;

# Do some maintenance on the file descriptions.  We remove the lines 
# pertaining to files which no longer exist, and also make sure that there
# is only one line per file.
#
for x in /usr/bbs/files/*
do
	cd $x
	cp /dev/null filedir2
	for y in *
	do
		cat filedir |grep -y $y >>filedir2
		done
	sort <filedir2 |uniq >filedir
	rm filedir2
	done

echo `date` Weekly BBS processing ended.
