From 3e44bda3a1c8d53ef188b0088c95b28b0e1356de Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 23 Apr 2012 20:58:56 +0300 Subject: Add reusable module of EC2 apt-get helpers. --- node/slave-helpers | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 node/slave-helpers (limited to 'node') diff --git a/node/slave-helpers b/node/slave-helpers new file mode 100755 index 0000000..c27e8a3 --- /dev/null +++ b/node/slave-helpers @@ -0,0 +1,37 @@ +#!/bin/bash + +############################################################################### +# Copyright (c) 2011 Linaro +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################### + + +setup_ubuntu_s3_mirror () { + sed -i.bk 's,^\(.*://[^.]*.ec2.archive.ubuntu.com\)/,\1.s3.amazonaws.com/,' /etc/apt/sources.list + echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99no-pipelining +} + +# Stubborn apt-get, retrying on errors +apt-get-retry () { + local fatal="yes"; + if [ "$1" == "--non-fatal" ]; then + fatal="" + shift + fi + local delay=1; + while [ $delay -lt 100 ]; do + if apt-get "$@"; then + return + fi + echo "apt-get failed, sleeping ${delay}s before retrying" + sleep $delay + delay=$((delay * 2)) + done + if [ -n "$fatal" ]; then + echo "apt-get failed after several attempts, aborting" + exit 1 + fi +} -- cgit v1.2.3