Wednesday, December 2, 2015

Local Repo for UBUNTU

Use the following Script to rsync the Ubuntu repository locally for internal use.


#/bin/bash

fatal() {
  echo "$1"
  exit 1
}

warn() {
  echo "$1"
}

# Find a source mirror near you which supports rsync on
# rsync://<iso-country-code>.rsync.archive.ubuntu.com/ubuntu should always work
#RSYNCSOURCE=rsync://mirrors.kernel.org/ubuntu
RSYNCSOURCE=rsync://archive.ubuntu.com/ubuntu
#RSYNCSOURCE=rsync://mirror.pnl.gov/ubuntu/
#RSYNCSOURCE=rsync://ubuntu.osuosl.org/ubuntu/



# Define where you want the mirror-data to be on your mirror
BASEDIR=
#BASEDIR=/var/www/html/repo/ubuntu-08-06-2015/
 #BASEDIR=/var/www/html/repo/ubuntu-04-27-2015/

if [ ! -d ${BASEDIR} ]; then
  warn "${BASEDIR} does not exist yet, trying to create it..."
  mkdir -pv ${BASEDIR} || fatal "Creation of ${BASEDIR} failed."
fi

rsync --progress -v --recursive --times --links --hard-links --stats --exclude "Packages*" --exclude "Sources*" --exclude "Release*" ${RSYNCSOURCE} ${BASEDIR} || fatal "First stage of sync failed."

rsync --progress -v --recursive --times --links --hard-links --stats --delete --delete-after ${RSYNCSOURCE} ${BASEDIR} || fatal "Second stage of sync failed."

date -u > ${BASEDIR}/project/trace/$(hostname -f)
~

No comments: