Use DIB_GRUB_TIMEOUT to set boot timeout

We currently re-run all the grub setup in 99-fix-grub-timeout which
shouldn't really be necessary (actually a little problematic; although
this is dib's fault, see Ibaaa81124098f3c6febe48e455d3e1cd0a5f1761)

Use the new timeout flag to set this in the bootloader element
directly.

I think it is also an advantage that if you build a testing image with
./tools/build_image.sh this is configurable now ... having to fiddle
the bootloader for debugging is something that happens more than you'd
like.

This is supported since dib 1.26.0

Change-Id: Iafc660a9a8c072af6bf1fd5e51c419abccef4d54
This commit is contained in:
Ian Wienand 2016-12-20 12:07:42 +11:00
parent 675ebee2e8
commit e5aa03b98a
3 changed files with 10 additions and 44 deletions

View File

@ -1,44 +0,0 @@
#!/bin/bash
# Copyright (C) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
# This is done in 50 because the vm element has, at 51, an bunch of code
# for properly handling grub. All we need to do here is get our values
# in to the files.
# dib-lint: disable=setu setpipefail
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -e
# Set grub timeout to zero to save boot time.
if [ -f /etc/default/grub ] ; then
sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' /etc/default/grub
if which update-grub &> /dev/null ; then
update-grub
else
if [[ $DISTRO_NAME == gentoo ]]; then
GRUB_CFG=/boot/grub/grub.cfg
else
GRUB_CFG=/boot/grub2/grub.cfg
fi
# If update-grub isn't available, use grub2-mkconfig directly
/usr/sbin/grub2-mkconfig -o "${GRUB_CFG}"
fi
elif [ -f /boot/grub/grub.conf ] ; then
sed -i -e 's/^timeout=[0-9]\+/timeout=0/' /boot/grub/grub.conf
fi

View File

@ -909,6 +909,7 @@ diskimages:
DIB_APT_LOCAL_CACHE: '0' DIB_APT_LOCAL_CACHE: '0'
DIB_DISABLE_APT_CLEANUP: '1' DIB_DISABLE_APT_CLEANUP: '1'
DIB_DISTRIBUTION_MIRROR: http://ftp.us.debian.org/debian/ DIB_DISTRIBUTION_MIRROR: http://ftp.us.debian.org/debian/
DIB_GRUB_TIMEOUT: '0'
- name: ubuntu-precise - name: ubuntu-precise
elements: elements:
- ubuntu-minimal - ubuntu-minimal
@ -928,6 +929,7 @@ diskimages:
DIB_APT_LOCAL_CACHE: '0' DIB_APT_LOCAL_CACHE: '0'
DIB_DISABLE_APT_CLEANUP: '1' DIB_DISABLE_APT_CLEANUP: '1'
FS_TYPE: ext3 FS_TYPE: ext3
DIB_GRUB_TIMEOUT: '0'
- name: ubuntu-trusty - name: ubuntu-trusty
elements: elements:
- ubuntu-minimal - ubuntu-minimal
@ -947,6 +949,7 @@ diskimages:
DIB_IMAGE_CACHE: /opt/dib_cache DIB_IMAGE_CACHE: /opt/dib_cache
DIB_APT_LOCAL_CACHE: '0' DIB_APT_LOCAL_CACHE: '0'
DIB_DISABLE_APT_CLEANUP: '1' DIB_DISABLE_APT_CLEANUP: '1'
DIB_GRUB_TIMEOUT: '0'
- name: ubuntu-xenial - name: ubuntu-xenial
elements: elements:
- ubuntu-minimal - ubuntu-minimal
@ -967,6 +970,7 @@ diskimages:
DIB_IMAGE_CACHE: /opt/dib_cache DIB_IMAGE_CACHE: /opt/dib_cache
DIB_APT_LOCAL_CACHE: '0' DIB_APT_LOCAL_CACHE: '0'
DIB_DISABLE_APT_CLEANUP: '1' DIB_DISABLE_APT_CLEANUP: '1'
DIB_GRUB_TIMEOUT: '0'
- name: centos-7 - name: centos-7
elements: elements:
- centos-minimal - centos-minimal
@ -985,6 +989,7 @@ diskimages:
DIB_CHECKSUM: '1' DIB_CHECKSUM: '1'
DIB_IMAGE_CACHE: /opt/dib_cache DIB_IMAGE_CACHE: /opt/dib_cache
QEMU_IMG_OPTIONS: compat=0.10 QEMU_IMG_OPTIONS: compat=0.10
DIB_GRUB_TIMEOUT: '0'
- name: fedora-24 - name: fedora-24
elements: elements:
- fedora-minimal - fedora-minimal
@ -1025,3 +1030,4 @@ diskimages:
DIB_CHECKSUM: '1' DIB_CHECKSUM: '1'
DIB_IMAGE_CACHE: /opt/dib_cache DIB_IMAGE_CACHE: /opt/dib_cache
QEMU_IMG_OPTIONS: compat=0.10 QEMU_IMG_OPTIONS: compat=0.10
DIB_GRUB_TIMEOUT: '0'

View File

@ -55,6 +55,10 @@ fi
## This will get dib to drop you into a shell on error, useful for debugging ## This will get dib to drop you into a shell on error, useful for debugging
# export break="after-error" # export break="after-error"
## If you need to debug the boot, setting this longer might help you
## break into the grub console. Or set it to 0 for fast boot.
# export DIB_GRUB_TIMEOUT=10
# The list of elements here should match nodepool/nodepool.yaml # The list of elements here should match nodepool/nodepool.yaml
disk-image-create -x --no-tmpfs -o $IMAGE_NAME \ disk-image-create -x --no-tmpfs -o $IMAGE_NAME \
$DISTRO \ $DISTRO \