Difference between revisions of "Old Mirror"

From CSLabsWiki
m (updated dom0)
(Scripts)
Line 19: Line 19:
   
 
==Scripts==
 
==Scripts==
Mirror is maintained by many small scripts, this page documents them all. The following are located in the directory: ''/etc/mirrorlogs''
+
Mirror is maintained by many small scripts, this page documents them all. The following are located in the directory: ''/etc/mirrorscripts''
   
 
=== rsyncVars ===
 
=== rsyncVars ===

Revision as of 21:04, 6 December 2007

Hostname: mirror.clarkson.edu
Status: Running


Mirror is an open source projects mirror that mirrors different Linux distributions (see below) and the Linux kernel itself. It can be accessed through a web interface or by anonymous FTP.

Mirrored Software

  • ArchLinux
  • Fedora (ON HOLD)
  • Kernel.org
  • Ubuntu

Scripts

Mirror is maintained by many small scripts, this page documents them all. The following are located in the directory: /etc/mirrorscripts

rsyncVars

This scriptlet defines all the variables used in the scripts that actually do the mirroring.

<source lang="bash">## Master Include File for the Mirror Rsync Scripts

    1. DISTRO MUST BE DEFINED BEFORE SOURCING THIS FILE!
    1. Define program paths

TOUCH=/usr/bin/touch DATE=/bin/date RSYNC=/usr/bin/rsync CHGRP=/bin/chgrp RM=/bin/rm

    1. Define File Paths

LOGFILE=/var/log/mirrorlogs/${DISTRO}-$(${DATE} +%m-%d-%y) LOCKFILE=/var/lock/${DISTRO}.lck DEST=/aoedisk/${DISTRO}

    1. Rsync Options

RSYNCOPTS='-avrH --partial --stats --delay-updates --delete --delete-after' </source>

template

This is the master template for all the new mirror scripts (meaning that Archlinux's and Kernel.org's don't follow this exactly). Just plugin URL and DISTRO and you are good to go.

<source lang="bash">#!/bin/bash -

    1. Template Mirror Script for mirror.clarkson.edu
    2. Copyright 2007 Chris Peterman <petermcv@clarkson.edu>
    3. Licensed under the GPLv2
    1. Define which distro we are mirroring here

DISTRO=

    1. Define the URL which we rsync from

URL=

    1. Load all the variable from the master include file

source /etc/mirrorscripts/rsyncVars

    1. Make sure another instance of this script isn't running right now

if [ ! -e ${LOCKFILE} ] then

       ## No one else is running, put down a lockfile so no one interupts us
       ${TOUCH} ${LOCKFILE}
       ## Begin the Rsync, send all output to the logfiles
       ${RSYNC} ${RSYNCOPTS} ${URL} ${DEST} > ${LOGFILE}
       ## Change the group ownership of the log files to Mirrorlogs
       ${CHGRP} mirrorlogs ${LOGFILE}
       ## Remove the lockfile, we are done
       ${RM} ${LOCKFILE}
       ## Send a good exit code
       exit 0

else

       ## Someone else was running. Not really an error so we exit with a successful error code
       exit 0

fi </source>

archlinux

This is Archlinux's rsync script. It was created before the prototype, and is a little different than others.

<source lang="bash">#!/bin/bash -

    1. Define which distro we are mirroring

DISTRO=archlinux

    1. Load all the variables from the master include file

source /etc/mirrorscripts/rsyncVars

    1. Make sure another instance of this script isn't running right now

if [ ! -e ${LOCKFILE} ] then ## No one else is running, put down a lockfile to make sure no one interrupts us ${TOUCH} ${LOCKFILE} ## Begin the Rsync, send all output to the logfiles ${RSYNC} ${RSYNCOPTS} distro.ibiblio.org::distros/archlinux/ ${DEST} > ${LOGFILE} ## Change the group ownership of the log files to Mirrorlogs ${CHGRP} mirrorlogs ${LOGFILE} ## Remove the lockfile, we are done ${RM} ${LOCKFILE} ## Send a good exit code exit 0 else ## Someone else was running. Not really an error so we exit with a successful error code exit 0 fi </source>

linux

This is the script for Kernel.org. It is notable because we actually rsync two different modules at once.

<source lang="bash">#!/bin/bash -

    1. Define which distro we are mirroring

DISTRO=linux

    1. Load all the variables from the master include file

source /etc/mirrorscripts/rsyncVars

    1. Make sure another instance of this script isn't running right now

if [ ! -e ${LOCKFILE} ] then ## No one else is running, put down a lockfile to make sure no one interrupts us ${TOUCH} ${LOCKFILE}

## Begin the Rsync, send all output to the logfiles ${RSYNC} ${RSYNCOPTS} ftp.uofo.lkams.kernel.org::ftp/pub/linux/ ${DEST} > ${LOGFILE} ${RSYNC} ${RSYNCOPTS} ftp.uofo.lkams.kernel.org::ftp/pub/software/ /aoedisk/software >> ${LOGFILE}

## Change the group ownership of the logs to Mirrorlogs ${CHGRP} mirrorlogs ${LOGFILE}

## We are done, remove the lockfile ${RM} ${LOCKFILE}

## Send a clean exit code exit 0 else ## Another copy of the script was running, not really an error on our part, so send a successful error code exit 0 fi </source>