summaryrefslogtreecommitdiffstats
path: root/src/ceph/mirroring/mirror-ceph.sh
diff options
context:
space:
mode:
authorQiaowei Ren <qiaowei.ren@intel.com>2018-01-04 13:43:33 +0800
committerQiaowei Ren <qiaowei.ren@intel.com>2018-01-05 11:59:39 +0800
commit812ff6ca9fcd3e629e49d4328905f33eee8ca3f5 (patch)
tree04ece7b4da00d9d2f98093774594f4057ae561d4 /src/ceph/mirroring/mirror-ceph.sh
parent15280273faafb77777eab341909a3f495cf248d9 (diff)
initial code repo
This patch creates initial code repo. For ceph, luminous stable release will be used for base code, and next changes and optimization for ceph will be added to it. For opensds, currently any changes can be upstreamed into original opensds repo (https://github.com/opensds/opensds), and so stor4nfv will directly clone opensds code to deploy stor4nfv environment. And the scripts for deployment based on ceph and opensds will be put into 'ci' directory. Change-Id: I46a32218884c75dda2936337604ff03c554648e4 Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Diffstat (limited to 'src/ceph/mirroring/mirror-ceph.sh')
-rwxr-xr-xsrc/ceph/mirroring/mirror-ceph.sh102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/ceph/mirroring/mirror-ceph.sh b/src/ceph/mirroring/mirror-ceph.sh
new file mode 100755
index 0000000..ef80a63
--- /dev/null
+++ b/src/ceph/mirroring/mirror-ceph.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+set -e
+#
+# Script to mirror Ceph locally
+#
+# Please, choose a local source and do not sync in a shorter interval than
+# 3 hours.
+#
+SILENT=0
+
+# All available source mirrors
+declare -A SOURCES
+SOURCES[eu]="eu.ceph.com"
+SOURCES[de]="de.ceph.com"
+SOURCES[se]="se.ceph.com"
+SOURCES[cz]="cz.ceph.com"
+SOURCES[au]="au.ceph.com"
+SOURCES[us]="download.ceph.com"
+SOURCES[hk]="hk.ceph.com"
+SOURCES[fr]="fr.ceph.com"
+SOURCES[us-east]="us-east.ceph.com"
+SOURCES[us-west]="us-west.ceph.com"
+SOURCES[global]="download.ceph.com"
+
+function print_usage() {
+ echo "$0 [-q ] -s <source mirror> -t <target directory>"
+}
+
+while getopts ":qhs:t:" opt; do
+ case $opt in
+ q)
+ SILENT=1
+ ;;
+ s)
+ SOURCE=$OPTARG
+ ;;
+ t)
+ TARGET=$OPTARG
+ ;;
+ h)
+ HELP=1
+ ;;
+ \?)
+ print_usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ ! -z "$HELP" ] || [ -z "$TARGET" ] || [ -z "$SOURCE" ]; then
+ print_usage
+ exit 1
+fi
+
+if [ ! -d "$TARGET" ]; then
+ echo "$TARGET is not a valid target directory"
+ exit 1
+fi
+
+for i in "${!SOURCES[@]}"; do
+ if [ "$i" == "$SOURCE" ]; then
+ SOURCE_HOST=${SOURCES[$i]}
+ fi
+done
+
+if [ -z "$SOURCE_HOST" ]; then
+ echo -n "Please select one of the following sources:"
+ for i in "${!SOURCES[@]}"; do
+ echo -n " $i"
+ done
+ echo ""
+ exit 1
+fi
+
+RSYNC_OPTS="--stats --progress"
+if [ $SILENT -eq 1 ]; then
+ RSYNC_OPTS="--quiet"
+fi
+
+# We start a two-stage sync here for DEB and RPM
+# Based on: https://www.debian.org/mirror/ftpmirror
+#
+# The idea is to prevent temporary situations where metadata points to files
+# which do not exist
+#
+
+# Exclude all metadata files
+rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
+ --hard-links \
+ --exclude Packages* \
+ --exclude Sources* \
+ --exclude Release* \
+ --exclude InRelease \
+ --exclude i18n/* \
+ --exclude ls-lR* \
+ --exclude repodata/* \
+ ${TARGET}
+
+# Now also transfer the metadata and delete afterwards
+rsync ${RSYNC_OPTS} ${SOURCE_HOST}::ceph --recursive --times --links \
+ --hard-links --delete-after \
+ ${TARGET}