#!/bin/sh
#
# Dasygenis Master Update Vulnerable Applications
# http://arch.ece.uowm.gr
#
# July, 2015
version="018"



execscript=/scripts/system/portmaster_run.sh

if [ ! -f "$execscript" ] ; then
        echo execscript $execscript absent, download it from arch.ece.uowm.gr. Aborting now..
        exit 8
fi


#fetch and check the database
pkg=`pkg audit -F | grep "is vulnerable" | cut -f 1 -d" " | sort | uniq`

if [ -z "$pkg" ] ; then
	echo No vulnerable apps found
	exit 
fi

#Here we have vuln apps...
echo "Found these vulnerable apps and update will commence:"
echo "$pkg"
sleep 4
for i in $pkg
do
echo "============================================================"
echo "============================================================"
echo "============================================================"
echo "===============Updating: $i"
echo "============================================================"
echo "============================================================"
echo "============================================================"

$execscript $i

echo "============================================================"
echo "============================================================"
sleep 10
done

