FBB Weekly

Submitted by Thomas Nilsson on

#!/bin/sh
#
# Generates weekly report from the FBB to all
# users specified in the arguments. The "previous"
# week is used
#
# Arguments are where to send the file
# If no arguments are given then the FBB configuration
# files is consulted for calls to receive sysop's mail
#
# In crontab this will be something like
# 15 5 * * 1 fbb_weekly ab0xyz@cd1hjk ef2mno@pq3rst
#
# I take no responsibility for the usage. Use it at your
# own risk!
#
# v 0.5 2004-11-03 Thomas, SM0KBD
#
#
PATH="/bin/:/usr/bin/:/usr/sbin:"

if ( test -z `which fbbgetconf 2> /dev/null`) then
echo "Do you have FBB installed?"
exit
fi
MAILIN=`fbbgetconf impo`
BBS=`fbbgetconf call`
SYSOPS=`fbbgetconf sysm`
#
#
#
MAILTMP=/tmp/fbbweekly${$}
MAILLCK=${MAILIN/mail.in/mail.lck}

function get_lock() {
declare -i LOCKTIME=0
while ( test -f ${MAILLCK} ); do
LOCKTIME=$LOCKTIME+1
if ( [ $LOCKTIME -ge 120 ] ) then
rm ${MAILLCK}
else
sleep 30
fi
done;
touch ${MAILLCK}
}

function build_mail() {
(
echo "SP $1"
echo "Weekly FBB user statistics from $BBS"
echo ""
fbb_statistics $2
echo ""
echo "/EX"
) > $MAILTMP

get_lock
cat < $MAILTMP >> $MAILIN
rm $MAILLCK
rm $MAILTMP
}

if ( test -z $1) then
RECEIVERS=$SYSOPS
else
RECEIVERS=$@
fi

for i in $RECEIVERS ; do {
build_mail $i -1
}
done;

Attachment Size
fbb_weekly.txt 1.27 KB