#!/bin/bash
# A script to update a CentOS7 Yum Repository
REPOS=(base updates extras)
for REPO in ${REPOS[@]}
do
echo "Updating repository: ${REPO} "
/usr/bin/reposync --repoid=${REPO} --download_path=/repo -g -n -l -m
if [ -e /repo/${REPO}/comps.xml ]; then
/usr/bin/createrepo -v -g /repo/${REPO}/comps.xml /repo/${REPO}/
else
/usr/bin/createrepo -v /repo/${REPO}/
fi
done
chown -R apache:apache /repo/*
restorecon -Rv /repo/*
exit 0