Start-scans

Aus xinux.net
Zur Navigation springen Zur Suche springen
#!/bin/bash
CUSTOMER=$1
FORMAT="c402cc3e-b531-11e1-9163-406186ea4fc5"
MAIL="technik@xxx.de"
DATE=$(date +%x-%X)
REPORTDIR=/var/openvas-reports
LOG=/var/log/openvas/reports.log
if ! [ -d "$REPORTDIR" ]
then
        mkdir $REPORTDIR
fi

function watch_scan()
{
X=0
PROGRESS=$(omp -G | grep $TASKNAME | awk '{print $2}')
while [ "$X" -lt "1" ]
do
        if [ "$PROGRESS" == "Done" ]
        then
         cd $REPORTDIR
         X=$((X+1))
         ITEM="$TASKNAME-$TASKID-$RERPORTID-$DATE"
         echo "omp -R $REPORTID -f $FORMAT > $ITEM.pdf" >> $LOG
         omp -R $REPORTID -f $FORMAT > $ITEM.pdf
         echo $ITEM | mutt -s "$ITEM" $MAIL -a $ITEM.pdf

        else
                PROGRESS=$(omp -G | grep $TASKNAME | awk '{print $2}')
                omp -G | grep $TASKNAME
                sleep 10
        fi
done
}

omp -G | grep $CUSTOMER | while read LINE
do
 TASKID=$(echo $LINE | awk '{print $1}')
 TASKNAME=$(echo $LINE | awk '{print $NF}')
 REPORTID=$(omp -S $TASKID)
 watch_scan
done