- #!/bin/bash
- function PrimaryXml {
- wget -q -O - $1/repodata/repomd.xml \
- | grep primary.xml \
- | sed -n -e 's/.*"\(.*\)".*/\1/p'
- }
- function GetPackages {
- wget -q -O - $1`PrimaryXml $1` \
- | zcat \
- | grep rpm \
- | grep location \
- | sed -n -e 's/.*<location href=\"\(.*\)\".*/\1/p' \
- | grep -v src.rpm
- }
- function DownloadPackages {
- GetPackages $1 | while read i ; do
- if [ ! -f $i ] ; then
- test -d `dirname $i` || mkdir -p `dirname $i`
- echo "Downloading $1$i..."
- wget -q -O $i $1$i
- fi
- done
- echo "Download complete."
- }
- Url="https://repo.saltstack.com/yum/redhat/7/x86_64/2016.11/"
- Url="https://repo.saltstack.com/yum/redhat/7/x86_64/2017.7/"
- DownloadPackages $Url