rubygems mirror script

This commit is contained in:
bigeagle 2016-08-18 13:55:54 +08:00
parent b5ea8682e2
commit 0328080802
No known key found for this signature in database
GPG Key ID: 9171A4571C27920A

49
rubygems.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
GEM=${GEM:-"gem"}
export HOME="/tmp/rubygems"
CONF="$HOME/.gem/.mirrorrc"
mkdir -p "$HOME/.gem"
INIT=${INIT:-"0"}
if [ ! -d "$TUNASYNC_WORKING_DIR" ]; then
mkdir -p $TUNASYNC_WORKING_DIR
INIT="1"
fi
echo "Syncing to $TUNASYNC_WORKING_DIR"
if [[ $INIT == "0" ]]; then
cat > $CONF << EOF
---
- from: https://rubygems.org
to: ${TUNASYNC_WORKING_DIR}
parallelism: 10
retries: 2
delete: true
skiperror: true
EOF
/usr/bin/timeout -s INT 7200 $GEM mirror
if [[ $? == 124 ]]; then
echo 'Sync timeout (/_\\)'
exit 1
fi
else
cat > $CONF << EOF
---
- from: https://rubygems.org
to: ${TUNASYNC_WORKING_DIR}
parallelism: 10
retries: 2
delete: true
skiperror: true
EOF
$GEM mirror
fi