#!/bin/bash
lockfile="/var/lock/subsys/sync-repos/rsync_updates"
if [ -f ${lockfile} ]; then
echo "Updates via rsync already running."
logger -t rsync "Unable to start new repo sync, one is already running."
exit 0
fi
# Global Vars
RSYNC="`which rsync`"
OPTS="--delay-updates --delete-delay --devices --hard-links --links --partial --perms --progress --recursive --sparse --specials --timeout=600 --times"
DST="/storage/www/repos"
# private mirror
# Where to grab Gentoo Portage tree from
# run normal or verbose
if [ "$1" != "-v" ]; then
OPTS="$OPTS --quiet"
fi
if [ -d ${DST}/ ] ; then
# Note that we are doing an update right now
touch ${lockfile}
MSG="Starting sync of repos"
echo "${MSG}"
logger -t rsync "${MSG}"
# CentOS Repos
MSG="Starting sync of CentOS repos"
echo "${MSG}"
logger -t rsync "${MSG}"
${RSYNC} ${OPTS} ${SRC_GATECH}/centos/ ${DST}/CentOS/
# EPEL Repos
MSG="Starting sync of EPEL repos"
echo "${MSG}"
logger -t rsync "${MSG}"
FEDORA_OPTS="--hard-links --numeric-ids"
${RSYNC} ${OPTS} ${FEDORA_OPTS} ${SRC_GATECH}/fedora-epel/ ${DST}/Fedora-EPEL/
# Update Fedora Mirror Manager
MSG="Notifying Mirror Manager of updates"
echo "${MSG}"
logger -t rsync "${MSG}"
/usr/bin/report_mirror
# ELRepo
MSG="Starting sync of ELRepo repos"
echo "${MSG}"
logger -t rsync "${MSG}"
# Fedora
#MSG="Starting sync of Fedora repos"
#echo "${MSG}"
#logger -t rsync "${MSG}"
#FEDORA_OPTS="--numeric-ids"
#${RSYNC} ${OPTS} ${FEDORA_OPTS} ${SRC_GATECH}/fedora-enchilada ${DST}/Fedora/
# Gentoo
MSG="Starting sync of Gentoo repos"
echo "${MSG}"
logger -t rsync "${MSG}"
GENTOO_OPTS="--exclude=/releases/historical"
${RSYNC} ${OPTS} ${GENTOO_OPTS} ${SRC_GATECH}/gentoo ${DST}/Gentoo
# Gentoo Portage
MSG="Starting sync of Gentoo Portage Tree"
echo "${MSG}"
logger -t rsync "${MSG}"
${RSYNC} ${OPTS} ${SRC_PORTAGE} ${DST}/gentoo-portage
# Linux Mint
MSG="Starting sync of Linux Mint repos"
echo "${MSG}"
logger -t rsync "${MSG}"
MSG="Starting sync of OpenCSW packages"
echo "${MSG}"
logger -t rsync "${MSG}"
OPENCSW_OPTS="--hard-links"
# RPMforge
MSG="Starting sync of RPMforge repos"
echo "${MSG}"
logger -t rsync "${MSG}"
${RSYNC} ${OPTS} ${SRC_GATECH}/RPMforge/* ${DST}/RPMforge/
# Puppet Labs
MSG="Starting sync of Puppet Labs repos"
echo "${MSG}"
logger -t rsync "${MSG}"
# Ubuntu
MSG="Starting sync of Ubuntu releases repos"
echo "${MSG}"
logger -t rsync "${MSG}"
${RSYNC} ${OPTS} ${SRC_GATECH}/ubuntu-releases/* ${DST}/Ubuntu/releases/
MSG="Starting sync of Ubuntu archive repos"
echo "${MSG}"
logger -t rsync "${MSG}"
${RSYNC} ${OPTS} ${SRC_GATECH}/ubuntu/* ${DST}/Ubuntu/archive/
# Cleanup
MSG="Syncing of repos complete"
echo "${MSG}"
logger -t rsync "${MSG}"
/bin/rm -f ${lockfile}
else
echo "Target directory ${DST}/ is not present."
logger -t rsync "Unable to sync repos, ${DST}/ is not present."
fi