diff --git a/elements/centos7/README.rst b/elements/centos7/README.rst index 64c172681..4adb4f1d9 100644 --- a/elements/centos7/README.rst +++ b/elements/centos7/README.rst @@ -4,3 +4,11 @@ centos7 Use Centos 7 cloud images as the baseline for built disk images. For further details see the redhat-common README. + +DIB_DISTRIBUTION_MIRROR: + :Required: No + :Default: None + :Description: To use a CentOS Yum mirror, set this variable to the mirror URL + before running bin/disk-image-create. This URL should point to + the directory containing the ``5/6/7`` directories. + :Example: ``DIB\_DISTRIBUTION\_MIRROR=http://amirror.com/centos`` diff --git a/elements/centos7/pre-install.d/01-set-centos-mirror b/elements/centos7/pre-install.d/01-set-centos-mirror new file mode 100755 index 000000000..8e2007a92 --- /dev/null +++ b/elements/centos7/pre-install.d/01-set-centos-mirror @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} + +[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0 + +# Only set the mirror for the Base, Extras and Updates repositories +# The others arn't enabled and do not exist on all mirrors +sed -e "s|^#baseurl=http://mirror.centos.org/centos|baseurl=$DIB_DISTRIBUTION_MIRROR|;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Base.repo