Skip to content

Instantly share code, notes, and snippets.

@aspiers
Created May 29, 2013 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspiers/5668937 to your computer and use it in GitHub Desktop.
Save aspiers/5668937 to your computer and use it in GitHub Desktop.
#!/bin/bash
ibs=aspiers@10.11.0.159:/mounts/dist/ibs
# should use http://download.suse.de/update/ not euklid?
# mairix:m:20120803222629.93475e8vgyyav9it@imap.suse.de
updates=aspiers@euklid.suse.de:/mirror/SuSE/zypp-patches.suse.de/x86_64/update
sles_updates=$updates/SLE-SERVER
cloud_updates=$updates/SUSE-CLOUD
dest=/data/install/mirrors
excludes='--exclude=i586 --exclude=ia64 --exclude=src'
me=`basename $0`
usage () {
# Call as: usage [EXITCODE] [USAGE MESSAGE]
exit_code=1
if [[ "$1" == [0-9] ]]; then
exit_code="$1"
shift
fi
if [ -n "$1" ]; then
echo "$*" >&2
echo
fi
cat <<EOF >&2
Usage: $me [options] [REPO [REPO ...]]
Options:
-h, --help Show this help and exit
-l, --local HOST Mirror from the specified local mirror
rather than from upstream
EOF
exit "$exit_code"
}
if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
usage 0
fi
local=
if [ "$1" == '-l' ] || [ "$1" == '--local' ]; then
if [ $# -lt 2 ]; then
usage "--local requires server name"
fi
local="$2"
shift 2
fi
if [ -z "$local" ] && ! vpn-is-up; then
echo "Looks like VPN is not working; aborting" >&2
exit 1
fi
if [ $# = 0 ]; then
repos='Devel:Cloud SUSE-Cloud-1.0-Updates SUSE-Cloud-1.0-Pool SLES11-SP1-Pool SLES11-SP1-Updates SLES11-SP2-Core SLES11-SP2-Updates SLES11-SP3-Pool SLES11-SP3-Updates'
else
repos="$*"
fi
rsync="rsync -avzP $excludes"
rsync="$rsync --delete"
for repo in $repos; do
echo "-------------------- $repo ------------------------"
case $repo in
Devel:Cloud)
src=$ibs/Devel:/Cloud/SLE_11_SP2/
;;
SUSE-Cloud-1.0-Updates)
src=$cloud_updates/1.0/
;;
SUSE-Cloud-1.0-Pool)
src=$cloud_updates/1.0-POOL/
;;
SLES11-SP1-Pool)
src=$sles_updates/11-SP1-POOL/
;;
SLES11-SP1-Updates)
src=$sles_updates/11-SP1/
;;
SLES11-SP2-Core)
src=$sles_updates/11-SP2-CORE/
;;
SLES11-SP2-Updates)
src=$sles_updates/11-SP2/
;;
SLES11-SP3-Pool)
src=$sles_updates/11-SP3-POOL/
;;
SLES11-SP3-Updates)
src=$sles_updates/11-SP3/
;;
*)
echo "Unrecognized repo $repo; aborting" >&2
exit 1
;;
esac
[ -n "$local" ] && src=$local:$dest/$repo/sle-11-x86_64/
[ -d $dest/$repo/ ] || mkdir -p $dest/$repo/
$rsync $src $dest/$repo/sle-11-x86_64
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment