diff --git a/elements/ubuntu/README.md b/elements/ubuntu/README.md index 9c08bd75..009afe93 100644 --- a/elements/ubuntu/README.md +++ b/elements/ubuntu/README.md @@ -6,3 +6,5 @@ Overrides: use the environment variable DIB\_CLOUD\_IMAGES * To download a non-default release of Ubuntu cloud images, use the environment variable DIB\_RELEASE + * To use a different mirror rather than archive.ubuntu.com, use the + environment variable DIB\_DISTRIBUTION\_MIRROR diff --git a/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror b/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror new file mode 100755 index 00000000..9633e9cd --- /dev/null +++ b/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eu + +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} + +[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0 + +sudo sed -ie "s&http://archive.ubuntu.com/ubuntu&$DIB_DISTRIBUTION_MIRROR&" \ + /etc/apt/sources.list