#!/bin/bash
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

WSUSOFFLINEPROGRAM=/opt/wsusoffline/sh/DownloadUpdates.sh
WSUSOFFLINECONFIG=/etc/conf.d/wsusoffline


if [ ! -f $WSUSOFFLINEPROGRAM ]
then
    echo "the Downloader $WSUSOFFLINEPROGRAM is not present."
    exit 0
fi

if [ -f $WSUSOFFLINECONFIG ]
then
	echo "source"
	source $WSUSOFFLINECONFIG
fi
#[ ! -z $WSUSOFFLINEOPTIONS ] || exit 0

echo $WSUSOFFLINEOPTIONS
pushd /opt/wsusoffline/sh
for i in $WSUSOFFLINEOPTIONS
do
	# process
	echo $(echo $i|sed 's/;/ /g')
	$WSUSOFFLINEPROGRAM $(echo $i|sed 's/;/ /g')
done
popd
echo "setting rights to the wsus user and group"
chown -R wsus:wsus /opt/wsusoffline