Merge "Auto-update ISO_URL"
This commit is contained in:
@@ -442,8 +442,8 @@ function download {
|
||||
fi
|
||||
fi
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo -e >&2 "${CError:-}Unable to download ${CData:-}$url${CError:-}, quitting.${CReset:-}"
|
||||
exit 1
|
||||
echo -e >&2 "${CError:-}Unable to download ${CData:-}$url${CError:-}.${CReset:-}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -451,11 +451,34 @@ function get_iso_name {
|
||||
basename "${ISO_URL:-}"
|
||||
}
|
||||
|
||||
function find_install-iso {
|
||||
local iso_name=$1
|
||||
# If ISO image is missing from IMG_DIR, try downloading it.
|
||||
function download_iso_if_necessary {
|
||||
local iso_name=$(get_iso_name)
|
||||
if [ ! -f "$ISO_DIR/$iso_name" ]; then
|
||||
echo >&2 "$iso_name not in $ISO_DIR; downloading"
|
||||
download "$ISO_URL" "$ISO_DIR" "$iso_name"
|
||||
echo >&2 "$iso_name not in $ISO_DIR; downloading."
|
||||
if ! download "$ISO_URL" "$ISO_DIR" "$iso_name"; then
|
||||
echo -e >&2 "${CError:-}Download failed.${CReset:-}"
|
||||
# Remove empty file
|
||||
rm "$ISO_DIR/$iso_name"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo >&2 "$iso_name already in $ISO_DIR."
|
||||
fi
|
||||
}
|
||||
|
||||
# Get ISO image for installation. If the download fails, get an alternative URL
|
||||
# and try again.
|
||||
function find_install-iso {
|
||||
if ! download_iso_if_necessary; then
|
||||
# No local ISO file and download failed
|
||||
echo -e >&2 "${CStatus:-}Trying to find alternative.${CReset:-}"
|
||||
update_iso_variables
|
||||
|
||||
if ! download_iso_if_necessary; then
|
||||
echo -e >&2 "${CError:-}Exiting.${CReset:-}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
# Booting the operating system installer
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
readonly ISO_URL=http://releases.ubuntu.com/14.04/ubuntu-14.04.3-server-amd64.iso
|
||||
readonly ISO_MD5=9e5fecc94b3925bededed0fdca1bd417
|
||||
readonly ISO_URL_BASE=http://releases.ubuntu.com/14.04/
|
||||
|
||||
ISO_URL=$ISO_URL_BASE/ubuntu-14.04.3-server-amd64.iso
|
||||
ISO_MD5=9e5fecc94b3925bededed0fdca1bd417
|
||||
|
||||
readonly _PS_ssh=http://git.openstack.org/cgit/openstack/training-labs/plain/labs/osbash/lib/osbash/netboot/preseed-ssh-v2.cfg
|
||||
readonly _PS_vbadd=http://git.openstack.org/cgit/openstack/training-labs/plain/labs/osbash/lib/osbash/netboot/preseed-vbadd.cfg
|
||||
@@ -27,6 +29,26 @@ readonly _BOOT_ARGS="/install/vmlinuz
|
||||
initrd=/install/initrd.gz
|
||||
console-setup/ask_detect=false"
|
||||
|
||||
# Fallback function to find current ISO image in case the file in ISO_URL is
|
||||
# neither on the disk nor at the configured URL.
|
||||
# This mechanism was added because old Ubuntu ISOs are removed from the server
|
||||
# as soon as a new ISO appears.
|
||||
function update_iso_variables {
|
||||
# Get matching line from distro repo's MD5SUMS file, e.g.
|
||||
# "9e5fecc94b3925bededed0fdca1bd417 *ubuntu-14.04.3-server-amd64.iso"
|
||||
local distro_info=$(wget -O - $ISO_URL_BASE/MD5SUMS|grep server-amd64)
|
||||
|
||||
# First part (removing everything after first space) is the md5sum
|
||||
ISO_MD5=${distro_info%% *}
|
||||
|
||||
# Second part (keeping everything after ' *') is the ISO file name
|
||||
local iso_file=${distro_info#* \*}
|
||||
|
||||
ISO_URL=$ISO_URL_BASE/$iso_file
|
||||
|
||||
echo -e >&2 "${CStatus:-}New ISO_URL: ${CData:-}$ISO_URL${CReset:-}"
|
||||
}
|
||||
|
||||
function vbox_distro_start_installer {
|
||||
local vm_name=$1
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@ function vm_install_base {
|
||||
vm_mem "$vm_name" "${VM_BASE_MEM:=512}"
|
||||
|
||||
if [ -z "${INSTALL_ISO-}" ]; then
|
||||
local iso_name=$(get_iso_name)
|
||||
|
||||
if [ -z "$iso_name" ]; then
|
||||
if [ -z "$ISO_URL" ]; then
|
||||
echo -e >&2 "${CMissing:-}Either ISO URL or name needed (ISO_URL, INSTALL_ISO).${CReset:-}"
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_ISO=$ISO_DIR/$iso_name
|
||||
# Don't look for ISO image if we are only doing wbatch
|
||||
${OSBASH:-:} find_install-iso "$iso_name"
|
||||
${OSBASH:-:} find_install-iso
|
||||
|
||||
INSTALL_ISO=$ISO_DIR/$(get_iso_name)
|
||||
fi
|
||||
|
||||
echo >&2 -e "${CInfo:-}Install ISO:\n\t${CData:-}$INSTALL_ISO${CReset:-}"
|
||||
|
||||
Reference in New Issue
Block a user