#!/bin/sh
# Version: 0.2.0
# Author: Dimitrios Dimitrakos mail@dimitrios.de
# $Id: cap.sh,v 1.3 2004/11/10 15:19:02 dimi Exp $

vco_user=`id -n -u`
homedir=`cat /etc/passwd|grep "^${vco_user}:"|cut -f6 -d ':'`
. $homedir/.vdrconvert/vdrconvert.env

#[ "$DEBUG" = "yes" ] && set -x

if [ ! -z "$SERVER" ]
then
        ssh $SERVER $0 $1
else
        SPOOLFILE=$VCOQUEUEDIR/$1

        if [ `cat $SPOOLFILE|nl|wc -l` -gt 1 ]
        then
            printf "All Lists\n\n"
            let sum=0
            for i in `cat $SPOOLFILE`
            do
                let res=0
                for k in `ls -Ls ${i}/[0-9]*.vdr|awk '{print $1'}`
                do 
                    res=`expr $res + $k`
                done
                spalten=`echo $i|sed 's/\// /g'|wc -w`
                Record=`echo $i|sed 's/\%//g'|cut -f $spalten -d '/'`
                printf "%-30s = %d\n" $Record `expr $res \/ 1024`
                sum=`expr $sum + $res`
            done
            printf "\nSum = %4d MB\n" `expr $sum \/ 1024`
        fi
        
        let sum=0
        [ `cat $SPOOLFILE|nl|wc -l` -gt 1 ] && printf "\n\nLast entry\n\n"
        for i in `cat $SPOOLFILE|tail -n 1`
        do
           let res=0
           for k in `ls -Ls ${i}/[0-9]*.vdr|awk '{print $1'}`
           do 
               res=`expr $res + $k`
           done
           spalten=`echo $i|sed 's/\// /g'|wc -w`
           Record=`echo $i|sed 's/\%//g'|cut -f $spalten -d '/'`
           printf "%.36s (%d) MB\n" $Record `expr $res \/ 1024`
           sum=`expr $sum + $res`
        done
        printf "\nSum = %4d MB\n" `expr $sum \/ 1024`
fi  
