function PrimaryXml {
wget -q -O - $1/repodata/repomd.xml \
| grep primary.xml \
| sed -n -e 's/.*"\(.*\)".*/\1/p'
}
function GetPackages {
BaseUrl="$1"
Include=`echo $2 | tr ' ' '|'`
Exclude=`echo $3 | tr ' ' '|'`
wget -q -O -
| zcat \
| grep
| ( [ -z "$Include" ] && cat || grep -E "($Include)" ) \
| ( [ -z "$Exclude" ] && cat || grep -vE "($Exclude)" ) \
}
function DownloadPackages {
BaseUrl="$1"
Mode=0
Include=""
Exclude=""
shift
while (($#)); do
if [[ "$1" == "-v" ]] ; then
Mode=1
else
if [ $Mode -eq 1 ] ; then
Exclude="$Exclude $1"
else
Include="$Include $1"
fi
fi
shift
done
GetPackages
if [ ! -f $i ] ; then
test -d `dirname $i` || mkdir -p `dirname $i`
echo "Downloading
wget -q -O $i
fi
done
echo "Download complete."
}
Url="https://repo.saltstack.com/yum/redhat/7/x86_64/2017.7/"