#!/bin/bash
# Squota - Screwed Quota                Copyright (c) 1996 Gary Barrueto
#=============================================================================
# Squotaday - This one adds the total at the end of each day and logs it
#=============================================================================
# Load varibles
#=============================================================================

. /var/adm/Squota/quotavars

#=============================================================================
# Start from the first user listed on /var/adm/Squota/quota.users
#=============================================================================

while test $EMPTY != $PULENGTH
do
  EMPTY=`expr $EMPTY + 1`

#=============================================================================
# Get the users name
#=============================================================================

  USERSHOME=`head -$EMPTY $HQ/quota.users | tail -1`
    if test -d $WHATDIR/$USERSHOME
      then

#============================================================================
# echo out daily totals, format with sed to make " " to " + " to use w/ expr
#============================================================================

	FSTOTAL=`echo \`cat $HQ/$USERSHOME.$MON\`  | sed 's/ / + /g'`

#============================================================================
# use expr to do math, then divide today with # of days...
#============================================================================

        echo $DAY$USERSHOME `expr \( $FSTOTAL \) / $DAY` / `expr $FSLIMIT \* 1024`K >> $HQ/quota.daily.$MON
    fi
done
