-
-
Save holodigm/c1de911334621df24766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# define $SHELL_VARS here | |
report_error () { | |
MESSAGE=$1 | |
SUBJECT=$2 | |
echo "$MESSAGE" | $MAILPROGRAM --subject="$SUBJECT" --toList=$EMAIL | |
} | |
echo "Starting mirror `date`" | |
# get new gems, saving output | |
echo "Mirroring gems" | |
$MIRRORSCRIPT > $HOME/gem_mirror_out.txt | |
# might as well quit | |
if [[ $? != 0 ]]; then | |
report_error "rubygem mirroring failed on $HOST" "$MIRRORSCRIPT failed" | |
exit | |
fi | |
# download all the new quick files | |
cd $MIRRORDIR/quick/Marshal.4.8/ | |
date | |
echo "Fetching quick{spec.rz}..." | |
for GEM in $( cat $HOME/gem_mirror_out.txt | grep ^Downloaded | awk '{print $2}' ); do | |
echo " ... fetching ${GEM}spec.rz" | |
wget -q http://rubygems.org/quick/Marshal.4.8/${GEM}spec.rz -O ${GEM}spec.rz | |
if [[ $? != 0 ]]; then | |
report_error "rubygem quick retrieval failed for '${GEM}spec.rz' on $HOST" "wget failed to retrieve '${GEM}spec.rz'" | |
exit | |
fi | |
done | |
# download the updated indices | |
cd $MIRRORDIR | |
date | |
echo "Fetching {,latest_,prerelease_}specs.4.8{,.gz}..." | |
for FILE in latest_specs.4.8 prerelease_specs.4.8 specs.4.8; do | |
echo " ... fetching ${FILE}.gz" | |
wget -q http://rubygems.org/${FILE}.gz -O ${FILE}.gz | |
if [[ $? != 0 ]]; then | |
report_error "rubygem spec fetching failed for '${FILE}.gz' on $HOST" "index fetching ${FILE}.gz failed" | |
exit | |
fi | |
# and expand them | |
gunzip -c ${FILE}.gz > $FILE | |
done | |
# sync over gems | |
date | |
echo "Rsync'ing mirror" | |
rsync -avz $MIRRORDIR/ $USER@$MIRRORSERVER:$MIRRORDIR | |
echo "Finished mirror `date`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment