Fix Ubuntu 18.04 LTS (Rocky) installation on Windows

Ubuntu 18.04 LTS (Bionic), the distribution we use for OpenStack Rocky,
uses systemd's rc-local service to handle /etc/rc.local. In order for
the service to run /etc/rc.local, the file must be an executable (i.e.,
a script with a shebang at the top and the permissions set
appropriately). Our current rc.local lacks these properties and our
mechanism for automatically executing scripts is never activated on
Bionic.

This changeset makes the necessary changes.

Fixes Bug 1800975

backport: rocky

Change-Id: Ie5e73cc68b7545d126a6eca06eafc1d1601618a8
This commit is contained in:
Roger Luethi 2018-11-03 10:30:15 +01:00
parent 3d38052a35
commit 63a77a85df
3 changed files with 300 additions and 2 deletions

View File

@ -0,0 +1,149 @@
# Based on
# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
#
# For details, see:
# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html
#-------------------------------------------------------------------------------
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/get_hostname string osbash
d-i netcfg/get_domain string unassigned-domain
#-------------------------------------------------------------------------------
# Proxy
#d-i mirror/http/proxy string http://192.168.178.20:3128/
d-i mirror/http/proxy string
#-------------------------------------------------------------------------------
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
d-i time/zone string Etc/UTC
#-------------------------------------------------------------------------------
### Partitioning
d-i partman-auto/disk string /dev/sda
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string regular
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#-------------------------------------------------------------------------------
# To create a normal user account.
d-i passwd/user-fullname string OpenStack user
d-i passwd/username string osbash
d-i passwd/user-password password osbash
d-i passwd/user-password-again password osbash
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
#-------------------------------------------------------------------------------
### Package selection
# (standard system utilities, OpenSSH server, Basic Ubuntu server)
tasksel tasksel/first standard system utilities
# Individual additional packages to install
# pkgsel/include disabled because it seems to cause non-deterministic installer
# errors with Ubuntu LTS 16.04.2; installing in late_command instead
#d-i pkgsel/include string openssh-server dkms localepurge
# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/
### Pkg:localepurge
# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates
localepurge localepurge/nopurge multiselect en_US
# Really remove all locales?
localepurge localepurge/none_selected boolean false
# Also delete localized man pages?
localepurge localepurge/mandelete boolean true
# Avoid note that localepurge will not take any action until configured
localepurge localepurge/remove_no note
# Inform about new locales?
localepurge localepurge/dontbothernew boolean false
# Display verbose output?
localepurge localepurge/verbose boolean false
# Display freed disk space?
localepurge localepurge/showfreedspace boolean true
# Accurate disk space calculation?
localepurge localepurge/quickndirtycalc boolean true
# Use dpkg --path-exclude?
localepurge localepurge/use-dpkg-feature bolean true
#-------------------------------------------------------------------------------
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none
# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
# Avoid warning about install CD not containing full support for language
d-i pkgsel/install-language-support boolean false
# Avoid reboot confirmation
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true
# Halt after installation
#d-i debian-installer/exit/poweroff boolean true
#ubiquity ubiquity/poweroff boolean true
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
# With Ubuntu 12.04 LTS, modesetting may result in a blank console
d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset
#-------------------------------------------------------------------------------
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations!
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
d-i preseed/late_command string DIR=/target/home/osbash/.ssh; \
mkdir -v $DIR; \
chmod 700 $DIR; \
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSnGKD4VTg7KhomNhFxjO8VfvSHZJzuFSvthK9jIeH2+M45QTR4batY+4qOtq9DzGgjsSVp6hP2QSfcVbZtSL3jjh3sjSN3ErT4UKeqRehNX/bCKmdHg0eK5m1EbPpJlY+fzSYj4qDw5x8rDeFoHVHydh2jyRFdd39/McaNQOYuQRmZbR9f7IISH99isIxmosYn3PeAfIVAcLqT9OcYPgPKJ+tsTvbFkYE2hOiS7Eek0C90KOVbJP01Vz3b/ccEYQ5WFlL0oqFkesVQ5I4cth1wMG26glbZO5SVT0GAldMwvm+H/wnVhQ/AjF5NmuIEGn45K4/c0csoIzWcKduPEyf osbash insecure public key' >> $DIR/authorized_keys; \
in-target chown -Rv osbash:osbash /home/osbash/.ssh; \
echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers; \
echo 'Defaults:osbash !requiretty' >> /target/etc/sudoers; \
in-target apt-get -y install openssh-server; \
echo "installed openssh" >> /target/root/preseed.log; \
in-target apt-get -y install localepurge; \
echo "installed localepurge" >> /target/root/preseed.log; \
in-target apt-get -y install dkms; \
echo "installed dkms" >> /target/root/preseed.log; \
chroot /target/ apt-get -y purge virtualbox-guest-dkms virtualbox-guest-utils >/target/root/01_vbox_purge 2>&1; \
mount /dev/sr1 /target/mnt; \
chroot /target /mnt/VBoxLinuxAdditions.run >/target/root/02_vbox_guestadd 2>&1; \
umount /target/mnt; \
sed -i 's/exit 0/# exit 0/' /target/etc/rc.local; \
echo '#!/bin/bash' > /target/etc/rc.local; \
echo 'exec > /root/bootstrap.log 2>&1;set -x;SCR=/media/sf_bootstrap/autostart/*activate_autostart.sh;while [ ! -f $SCR ];do sleep 2;done;bash $SCR;rm -v $SCR' >> /target/etc/rc.local; \
chmod a+x /target/etc/rc.local; \
echo "created /etc/rc.local" >> /target/root/preseed.log;

View File

@ -0,0 +1,149 @@
# Based on
# https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
#
# For details, see:
# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html
#-------------------------------------------------------------------------------
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/get_hostname string osbash
d-i netcfg/get_domain string unassigned-domain
#-------------------------------------------------------------------------------
# Proxy
#d-i mirror/http/proxy string http://192.168.178.20:3128/
d-i mirror/http/proxy string
#-------------------------------------------------------------------------------
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
d-i time/zone string Etc/UTC
#-------------------------------------------------------------------------------
### Partitioning
d-i partman-auto/disk string /dev/sda
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string regular
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#-------------------------------------------------------------------------------
# To create a normal user account.
d-i passwd/user-fullname string OpenStack user
d-i passwd/username string osbash
d-i passwd/user-password password osbash
d-i passwd/user-password-again password osbash
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
#-------------------------------------------------------------------------------
### Package selection
# (standard system utilities, OpenSSH server, Basic Ubuntu server)
tasksel tasksel/first standard system utilities
# Individual additional packages to install
# pkgsel/include disabled because it seems to cause non-deterministic installer
# errors with Ubuntu LTS 16.04.2; installing in late_command instead
#d-i pkgsel/include string openssh-server dkms localepurge
# http://sfxpt.wordpress.com/2013/06/09/get-the-debianubuntu-ready-and-customized-the-way-you-like-in-10-minutes/
### Pkg:localepurge
# Options explained at: http://anonscm.debian.org/cgit/collab-maint/localepurge.git/tree/debian/localepurge.templates
localepurge localepurge/nopurge multiselect en_US
# Really remove all locales?
localepurge localepurge/none_selected boolean false
# Also delete localized man pages?
localepurge localepurge/mandelete boolean true
# Avoid note that localepurge will not take any action until configured
localepurge localepurge/remove_no note
# Inform about new locales?
localepurge localepurge/dontbothernew boolean false
# Display verbose output?
localepurge localepurge/verbose boolean false
# Display freed disk space?
localepurge localepurge/showfreedspace boolean true
# Accurate disk space calculation?
localepurge localepurge/quickndirtycalc boolean true
# Use dpkg --path-exclude?
localepurge localepurge/use-dpkg-feature bolean true
#-------------------------------------------------------------------------------
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none
# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
# Avoid warning about install CD not containing full support for language
d-i pkgsel/install-language-support boolean false
# Avoid reboot confirmation
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true
# Halt after installation
#d-i debian-installer/exit/poweroff boolean true
#ubiquity ubiquity/poweroff boolean true
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
# With Ubuntu 12.04 LTS, modesetting may result in a blank console
d-i debian-installer/add-kernel-opts string vga=0x301 nomodeset
#-------------------------------------------------------------------------------
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations!
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
d-i preseed/late_command string DIR=/target/home/osbash/.ssh; \
mkdir -v $DIR; \
chmod 700 $DIR; \
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSnGKD4VTg7KhomNhFxjO8VfvSHZJzuFSvthK9jIeH2+M45QTR4batY+4qOtq9DzGgjsSVp6hP2QSfcVbZtSL3jjh3sjSN3ErT4UKeqRehNX/bCKmdHg0eK5m1EbPpJlY+fzSYj4qDw5x8rDeFoHVHydh2jyRFdd39/McaNQOYuQRmZbR9f7IISH99isIxmosYn3PeAfIVAcLqT9OcYPgPKJ+tsTvbFkYE2hOiS7Eek0C90KOVbJP01Vz3b/ccEYQ5WFlL0oqFkesVQ5I4cth1wMG26glbZO5SVT0GAldMwvm+H/wnVhQ/AjF5NmuIEGn45K4/c0csoIzWcKduPEyf osbash insecure public key' >> $DIR/authorized_keys; \
in-target chown -Rv osbash:osbash /home/osbash/.ssh; \
echo 'osbash ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers; \
echo 'Defaults:osbash !requiretty' >> /target/etc/sudoers; \
in-target apt-get -y install openssh-server; \
echo "installed openssh" >> /target/root/preseed.log; \
in-target apt-get -y install localepurge; \
echo "installed localepurge" >> /target/root/preseed.log; \
in-target apt-get -y install dkms; \
echo "installed dkms" >> /target/root/preseed.log; \
chroot /target/ apt-get -y purge virtualbox-guest-dkms virtualbox-guest-utils >/target/root/01_vbox_purge 2>&1; \
mount /dev/sr1 /target/mnt; \
chroot /target /mnt/VBoxLinuxAdditions.run >/target/root/02_vbox_guestadd 2>&1; \
umount /target/mnt; \
sed -i 's/exit 0/# exit 0/' /target/etc/rc.local; \
echo '#!/bin/bash' > /target/etc/rc.local; \
echo 'exec > /root/bootstrap.log 2>&1;set -x;SCR=/media/sf_bootstrap/autostart/*activate_autostart.sh;while [ ! -f $SCR ];do sleep 2;done;bash $SCR;rm -v $SCR' >> /target/etc/rc.local; \
chmod a+x /target/etc/rc.local; \
echo "created /etc/rc.local" >> /target/root/preseed.log;

View File

@ -90,8 +90,8 @@ PRESEED_HOST_DIR = ("http://git.openstack.org/cgit/openstack/training-labs/"
PRESEED_URL = {}
PRESEED_URL['ssh'] = PRESEED_HOST_DIR + "preseed-ssh-v6.cfg"
PRESEED_URL['shared_folder'] = PRESEED_HOST_DIR + "preseed-vbadd-v6.cfg"
PRESEED_URL['all'] = PRESEED_HOST_DIR + "preseed-all-v6.cfg"
PRESEED_URL['shared_folder'] = PRESEED_HOST_DIR + "preseed-vbadd-v7.cfg"
PRESEED_URL['all'] = PRESEED_HOST_DIR + "preseed-all-v7.cfg"
# Arguments for ISO image installer
_BOOT_ARGS = ("/install/vmlinuz"