#!/bin/sh

# Installation
# - copy to BBHOME/ext/mkbb
# - edit BBHOME/etc/bbdef.sh and add "mkfinger.sh" to the BBMKBBEXT variable
# - restart Big Brother

# Written by Jeff Stoner <jstoner@blackboard.com>
# Released into the Public Domain.

WHOAMI=`id -un`

if [ ! "$BBHOME" ]; then
   echo "mkfinger - BBHOME not set. Aborting."
   exit 1
fi
if [ ! "$BBTMP" ]; then
   { . $BBHOME/etc/bbdef.sh }
fi

if [ ! "$BBVAR" ]; then
   LOGS="$BBHOME/www/logs"
else
   LOGS="$BBVAR/logs"
fi

if [ ! "$BBOUT" ]; then
   BBOUT="$BBHOME/BBOUT"
fi

if [ ! "$WHOAMI" = "$BBUSER" ]; then
   echo "mkfinger - who am I supposed to be: $WHOAMI $BBUSER" >> $BBOUT
   exit 1
fi

cd $LOGS

RED_STATUS=`$GREP -E "\bred\b" *`
YELLOW_STATUS=`$GREP -E "\byellow\b" *`

FINGER_STATUS="$RED_STATUS
$YELLOW_STATUS"

cd $HOME
echo "Big Brother Status: `/bin/date`

$FINGER_STATUS" > ./.plan

exit 0

