#!/bin/bash # # Sample script template for setting up a Mageia mirror server. # # This script does the minimum tasks to rsync your local mirror # from a Mageia source mirror. # # For that, please: # * define LOCAL_MIRROR and SOURCE_MIRROR vars; # * ideally, run this script every two hours for a public mirror. # # As soon as your mirror is ready, make sure to register it in our mirrors # database on http://mirrors.mageia.org/new . # # For more information, see http://mirrors.mageia.org/ or join # irc://irc.freenode.net/#mageia-sysadm # # Path to your local mirror repository. # You will need to dedicate about 700 GB. # LOCAL_MIRROR= # Remote rsync server you are using. # # * if your mirror is public, please use one of our Tier1 mirrors, listed on # http://mirrors.mageia.org/?tier1 # # * if your mirror is for private/internal use, please use one of the Tier2 # mirrors, listed on http://mirrors.mageia.org/?tier2 # SOURCE_MIRROR= # RSYNC=`which rsync` # Please at least use the following options: # --archive / -a (needed) # --hard-links / -H (needed) # --spare / -S (nice to have) # --delete-after (nice to have) # # Please do not use compression and checksum options, to not overload # remote server. # OPTIONS="-aHS --delete-after" # Lock file; makes sure we don't launch this script twice in a row. # LOCK_FILE=/tmp/mageia-mirror-rsync.lock if [ -z "$SOURCE_MIRROR" ]; then echo "No source mirror defined." exit 2 fi if [ -z "$LOCAL_MIRROR" ]; then echo "No local mirror defined." exit 3 fi if [ -f $LOCK_FILE ]; then echo "$LOCK_FILE lock file found." echo "=> A sync process is already running, no need to start another one." exit 0 fi echo $$ > $LOCK_FILE if [ ! -f $LOCK_FILE ]; then echo "$LOCK_FILE not found... Please check that it can be created." exit 1 fi echo `date` echo "Rsync'ing..." $RSYNC $OPTIONS $SOURCE_MIRROR $LOCAL_MIRROR echo "Done." echo `date` unlink $LOCK_FILE # Thank you!