summaryrefslogtreecommitdiffstats
path: root/src/VBox/Main/UnattendedTemplates
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:19:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 14:19:18 +0000
commit4035b1bfb1e5843a539a8b624d21952b756974d1 (patch)
treef1e9cd5bf548cbc57ff2fddfb2b4aa9ae95587e2 /src/VBox/Main/UnattendedTemplates
parentInitial commit. (diff)
downloadvirtualbox-4035b1bfb1e5843a539a8b624d21952b756974d1.tar.xz
virtualbox-4035b1bfb1e5843a539a8b624d21952b756974d1.zip
Adding upstream version 6.1.22-dfsg.upstream/6.1.22-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Main/UnattendedTemplates')
-rw-r--r--src/VBox/Main/UnattendedTemplates/Makefile.kmk54
-rwxr-xr-xsrc/VBox/Main/UnattendedTemplates/debian_postinstall.sh315
-rw-r--r--src/VBox/Main/UnattendedTemplates/debian_preseed.cfg84
-rw-r--r--src/VBox/Main/UnattendedTemplates/fedora_ks.cfg90
-rw-r--r--src/VBox/Main/UnattendedTemplates/lgw_ks.cfg91
-rwxr-xr-xsrc/VBox/Main/UnattendedTemplates/lgw_postinstall.sh507
-rw-r--r--src/VBox/Main/UnattendedTemplates/ol_ks.cfg109
-rw-r--r--src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg109
-rwxr-xr-xsrc/VBox/Main/UnattendedTemplates/redhat_postinstall.sh311
-rw-r--r--src/VBox/Main/UnattendedTemplates/rhel3_ks.cfg141
-rw-r--r--src/VBox/Main/UnattendedTemplates/rhel4_ks.cfg120
-rw-r--r--src/VBox/Main/UnattendedTemplates/rhel5_ks.cfg119
-rw-r--r--src/VBox/Main/UnattendedTemplates/suse_autoinstall.xml72
-rw-r--r--src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg93
-rw-r--r--src/VBox/Main/UnattendedTemplates/win_nt5_unattended.sif60
-rw-r--r--src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml155
-rw-r--r--src/VBox/Main/UnattendedTemplates/win_postinstall.cmd147
17 files changed, 2577 insertions, 0 deletions
diff --git a/src/VBox/Main/UnattendedTemplates/Makefile.kmk b/src/VBox/Main/UnattendedTemplates/Makefile.kmk
new file mode 100644
index 00000000..55ef7f00
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/Makefile.kmk
@@ -0,0 +1,54 @@
+# $Id: Makefile.kmk $
+## @file
+# Top-level makefile for src/VBox/Main/UnattendedTemplates.
+#
+
+#
+# Copyright (C) 2017-2020 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+SUB_DEPTH = ../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+ifdef VBOX_WITH_UNATTENDED
+
+ # Note! When updating the source list here, VBOX_UNATTENDED_TEMPLATES in
+ # ../../Installer/Config.kmk must be updated too!
+ INSTALLS += VBoxUnattendedTemplates
+ VBoxUnattendedTemplates_INST = $(INST_UNATTENDED_TEMPLATES)
+ VBoxUnattendedTemplates_MODE = a+r,u+w
+ VBoxUnattendedTemplates_SOURCES = \
+ debian_preseed.cfg \
+ ubuntu_preseed.cfg \
+ rhel3_ks.cfg \
+ rhel4_ks.cfg \
+ rhel5_ks.cfg \
+ redhat67_ks.cfg \
+ ol_ks.cfg \
+ fedora_ks.cfg \
+ suse_autoinstall.xml \
+ win_nt5_unattended.sif \
+ win_nt6_unattended.xml \
+ \
+ debian_postinstall.sh \
+ redhat_postinstall.sh \
+ win_postinstall.cmd
+
+ ifndef VBOX_OSE
+ VBoxUnattendedTemplates_SOURCES += \
+ lgw_ks.cfg \
+ lgw_postinstall.sh
+ endif
+
+endif # VBOX_WITH_UNATTENDED
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
diff --git a/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh b/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh
new file mode 100755
index 00000000..18a6887d
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh
@@ -0,0 +1,315 @@
+#!/bin/bash
+## @file
+# Post installation script template for debian-like distros.
+#
+# Note! This script expects to be running w/o chroot.
+# Note! When using ubiquity, this is run after installation logs have
+# been copied to /var/log/installation.
+#
+
+#
+# Copyright (C) 2017-2020 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+
+#
+# Globals.
+#
+MY_TARGET="/target"
+MY_LOGFILE="${MY_TARGET}/var/log/vboxpostinstall.log"
+MY_CHROOT_CDROM="/cdrom"
+MY_CDROM_NOCHROOT="/cdrom"
+MY_EXITCODE=0
+MY_DEBUG="" # "yes"
+
+
+#
+# Do we need to exec using target bash? If so, we must do that early
+# or ash will bark 'bad substitution' and fail.
+#
+if [ "$1" = "--need-target-bash" ]; then
+ # Try figure out which directories we might need in the library path.
+ if [ -z "${LD_LIBRARY_PATH}" ]; then
+ LD_LIBRARY_PATH="${MY_TARGET}/lib"
+ fi
+ for x in \
+ ${MY_TARGET}/lib \
+ ${MY_TARGET}/usr/lib \
+ ${MY_TARGET}/lib/*linux-gnu/ \
+ ${MY_TARGET}/lib32/ \
+ ${MY_TARGET}/lib64/ \
+ ${MY_TARGET}/usr/lib/*linux-gnu/ \
+ ${MY_TARGET}/usr/lib32/ \
+ ${MY_TARGET}/usr/lib64/ \
+ ;
+ do
+ if [ -e "$x" ]; then LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${x}"; fi;
+ done
+ export LD_LIBRARY_PATH
+
+ # Append target bin directories to the PATH as busybox may not have tee.
+ PATH="${PATH}:${MY_TARGET}/bin:${MY_TARGET}/usr/bin:${MY_TARGET}/sbin:${MY_TARGET}/usr/sbin"
+ export PATH
+
+ # Drop the --need-target-bash argument and re-exec.
+ shift
+ echo "******************************************************************************" >> "${MY_LOGFILE}"
+ echo "** Relaunching using ${MY_TARGET}/bin/bash $0 $*" >> "${MY_LOGFILE}"
+ echo "** LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${MY_LOGFILE}"
+ echo "** PATH=${PATH}" >> "${MY_LOGFILE}"
+ exec "${MY_TARGET}/bin/bash" "$0" "$@"
+fi
+
+
+#
+# Commands.
+#
+
+# Logs execution of a command.
+log_command()
+{
+ echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+ echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+ echo "** Executing: $*" >> "${MY_LOGFILE}"
+ "$@" 2>&1 | tee -a "${MY_LOGFILE}"
+ MY_TMP_EXITCODE="${PIPESTATUS[0]}"
+ if [ "${MY_TMP_EXITCODE}" != "0" ]; then
+ if [ "${MY_TMP_EXITCODE}" != "${MY_IGNORE_EXITCODE}" ]; then
+ echo "** exit code: ${MY_TMP_EXITCODE}" | tee -a "${MY_LOGFILE}"
+ MY_EXITCODE=1;
+ else
+ echo "** exit code: ${MY_TMP_EXITCODE} (ignored)" | tee -a "${MY_LOGFILE}"
+ fi
+ fi
+}
+
+# Logs execution of a command inside the target.
+log_command_in_target()
+{
+ #
+ # We should be using in-target here, however we don't get any stderr output
+ # from it because of log-output. We can get stdout by --pass-stdout, but
+ # that's not helpful for failures.
+ #
+ # So, we try do the chroot prepping that in-target does at the start of the
+ # script (see below) and just use chroot here.
+ #
+ log_command chroot "${MY_TARGET}" "$@"
+ # log_command in-target --pass-stdout "$@" # No stderr output... :-(
+}
+
+# Checks if $1 is a command on the PATH inside the target jail.
+chroot_which()
+{
+ for dir in /bin /usr/bin /sbin /usr/sbin;
+ do
+ if [ -x "${MY_TARGET}${dir}/$1" ]; then
+ return 0;
+ fi
+ done
+ return 1;
+}
+
+#
+# Log header.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** VirtualBox Unattended Guest Installation - Late installation actions" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Started: $0 $*" >> "${MY_LOGFILE}"
+
+
+#
+# Setup the target jail ourselves since in-target steals all the output.
+#
+if [ -f /lib/chroot-setup.sh ]; then
+ MY_HAVE_CHROOT_SETUP="yes"
+ . /lib/chroot-setup.sh
+ if chroot_setup; then
+ echo "** chroot_setup: done" | tee -a "${MY_LOGFILE}"
+ else
+ echo "** chroot_setup: failed $?" | tee -a "${MY_LOGFILE}"
+ fi
+else
+ MY_HAVE_CHROOT_SETUP=""
+fi
+
+
+#
+# We want the ISO available inside the target jail.
+#
+if [ -d "${MY_TARGET}${MY_CHROOT_CDROM}" ]; then
+ MY_RMDIR_TARGET_CDROM=
+else
+ MY_RMDIR_TARGET_CDROM="yes"
+ log_command mkdir -p ${MY_TARGET}${MY_CHROOT_CDROM}
+fi
+
+if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ MY_UNMOUNT_TARGET_CDROM=
+ echo "** binding cdrom into jail: already done" | tee -a "${MY_LOGFILE}"
+else
+ MY_UNMOUNT_TARGET_CDROM="yes"
+ log_command mount -o bind "${MY_CDROM_NOCHROOT}" "${MY_TARGET}${MY_CHROOT_CDROM}"
+ if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ echo "** binding cdrom into jail: success" | tee -a "${MY_LOGFILE}"
+ else
+ echo "** binding cdrom into jail: failed" | tee -a "${MY_LOGFILE}"
+ fi
+ if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command find "${MY_TARGET}${MY_CHROOT_CDROM}"
+ fi
+fi
+
+
+#
+# Debug
+#
+if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command id
+ log_command ps
+ log_command ps auxwwwf
+ log_command env
+ log_command df
+ log_command mount
+ log_command_in_target df
+ log_command_in_target mount
+ #log_command find /
+ MY_EXITCODE=0
+fi
+
+
+#
+# Packages needed for GAs.
+#
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing packages for building kernel modules...' | tee -a "${MY_LOGFILE}"
+log_command_in_target apt-get -y install build-essential
+log_command_in_target apt-get -y install linux-headers-$(uname -r)
+
+
+#
+# GAs
+#
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing VirtualBox Guest Additions...' | tee -a "${MY_LOGFILE}"
+MY_IGNORE_EXITCODE=2 # returned if modules already loaded and reboot required.
+log_command_in_target /bin/bash "${MY_CHROOT_CDROM}/vboxadditions/VBoxLinuxAdditions.run" --nox11
+log_command_in_target /bin/bash -c "udevadm control --reload-rules" # GAs doesn't yet do this.
+log_command_in_target /bin/bash -c "udevadm trigger" # (ditto)
+MY_IGNORE_EXITCODE=
+log_command_in_target usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"
+@@VBOX_COND_END@@
+
+
+#
+# Test Execution Service.
+#
+@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing Test Execution Service...' | tee -a "${MY_LOGFILE}"
+log_command_in_target test "${MY_CHROOT_CDROM}/vboxvalidationkit/linux/@@VBOX_INSERT_OS_ARCH@@/TestExecService"
+log_command mkdir -p "${MY_TARGET}/opt/validationkit" "${MY_TARGET}/media/cdrom"
+log_command cp -R ${MY_CDROM_NOCHROOT}/vboxvalidationkit/* "${MY_TARGET}/opt/validationkit/"
+log_command chmod -R u+rw,a+xr "${MY_TARGET}/opt/validationkit/"
+if [ -e "${MY_TARGET}/usr/bin/chcon" -o -e "${MY_TARGET}/bin/chcon" -o -e "${MY_TARGET}/usr/sbin/chcon" -o -e "${MY_TARGET}/sbin/chcon" ]; then
+ MY_IGNORE_EXITCODE=1
+ log_command_in_target chcon -R -t usr_t "/opt/validationkit/"
+ MY_IGNORE_EXITCODE=
+fi
+
+# systemd service config:
+MY_UNIT_PATH="${MY_TARGET}/lib/systemd/system"
+test -d "${MY_TARGET}/usr/lib/systemd/system" && MY_UNIT_PATH="${MY_TARGET}/usr/lib/systemd/system"
+if [ -d "${MY_UNIT_PATH}" ]; then
+ log_command cp "${MY_TARGET}/opt/validationkit/linux/vboxtxs.service" "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command chmod 644 "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command_in_target systemctl -q enable vboxtxs
+
+# System V like:
+elif [ -e "${MY_TARGET}/etc/init.d/" ]; then
+
+ # Install the script. On rhel6 scripts are under /etc/rc.d/ with /etc/init.d and /etc/rc?.d being symlinks.
+ if [ -d "${MY_TARGET}/etc/rc.d/init.d/" ]; then
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc/rc.d"
+ log_command ln -s "../../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ else
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc"
+ log_command ln -s "../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ fi
+
+ # Use runlevel management script if found.
+ if chroot_which chkconfig; then # Redhat based sysvinit systems
+ log_command_in_target chkconfig --add vboxtxs
+ elif chroot_which insserv; then # SUSE-based sysvinit systems
+ log_command_in_target insserv vboxtxs
+ elif chroot_which update-rc.d; then # Debian/Ubuntu-based systems
+ log_command_in_target update-rc.d vboxtxs defaults
+ elif chroot_which rc-update; then # Gentoo Linux
+ log_command_in_target rc-update add vboxtxs default
+ # Fall back on hardcoded symlinking.
+ else
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc0.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc1.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc6.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc2.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc3.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc4.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc5.d/S35vboxtxs"
+ fi
+else
+ echo "** error: Unknown init script system." | tee -a "${MY_LOGFILE}"
+fi
+
+@@VBOX_COND_END@@
+
+
+#
+# Run user command.
+#
+@@VBOX_COND_HAS_POST_INSTALL_COMMAND@@
+echo '** Running custom user command ...' | tee -a "${MY_LOGFILE}"
+log_command @@VBOX_INSERT_POST_INSTALL_COMMAND@@
+@@VBOX_COND_END@@
+
+
+#
+# Unmount the cdrom if we bound it and clean up the chroot if we set it up.
+#
+if [ -n "${MY_UNMOUNT_TARGET_CDROM}" ]; then
+ echo "** unbinding cdrom from jail..." | tee -a "${MY_LOGFILE}"
+ log_command umount "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+if [ -n "${MY_RMDIR_TARGET_CDROM}" ]; then
+ log_command rmdir "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+if [ -n "${MY_HAVE_CHROOT_SETUP}" ]; then
+ if chroot_cleanup; then
+ echo "** chroot_cleanup: done" | tee -a "${MY_LOGFILE}"
+ else
+ echo "** chroot_cleanup: failed $?" | tee -a "${MY_LOGFILE}"
+ fi
+fi
+
+
+#
+# Log footer.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Final exit code: ${MY_EXITCODE}" >> "${MY_LOGFILE}"
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+
+exit ${MY_EXITCODE}
+
diff --git a/src/VBox/Main/UnattendedTemplates/debian_preseed.cfg b/src/VBox/Main/UnattendedTemplates/debian_preseed.cfg
new file mode 100644
index 00000000..13a248de
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/debian_preseed.cfg
@@ -0,0 +1,84 @@
+### Partitioning
+d-i partman-auto/disk string /dev/sda
+d-i partman-auto/method string regular
+d-i partman-lvm/device_remove_lvm boolean true
+d-i partman-md/device_remove_md boolean true
+d-i partman-auto/choose_recipe select atomic
+
+# This makes partman automatically partition without confirmation
+d-i partman-partitioning/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
+
+# Locale
+d-i debian-installer/locale string @@VBOX_INSERT_LOCALE@@
+d-i console-setup/ask_detect boolean false
+d-i console-setup/layoutcode string us
+d-i keyboard-configuration/xkb-keymap select us
+
+# Network
+d-i netcfg/get_hostname string @@VBOX_INSERT_HOSTNAME_WITHOUT_DOMAIN@@
+d-i netcfg/get_domain string @@VBOX_INSERT_HOSTNAME_DOMAIN@@
+d-i netcfg/choose_interface select auto
+
+# Clock
+@@VBOX_COND_IS_RTC_USING_UTC@@
+d-i clock-setup/utc-auto boolean true
+d-i clock-setup/utc boolean true
+@@VBOX_COND_END@@
+@@VBOX_COND_IS_NOT_RTC_USING_UTC@@
+d-i clock-setup/utc-auto boolean false
+d-i clock-setup/utc boolean false
+@@VBOX_COND_END@@
+d-i time/zone string @@VBOX_INSERT_TIME_ZONE_UX@@
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@d-i clock-setup/ntp boolean false@@VBOX_COND_END@@
+@@VBOX_COND_IS_NOT_INSTALLING_ADDITIONS@@d-i clock-setup/ntp boolean true@@VBOX_COND_END@@
+
+# Packages, Mirrors, Image
+d-i base-installer/kernel/override-image string linux-server
+d-i base-installer/kernel/override-image string linux-image-amd64
+## @todo use nearest mirror somehow...
+d-i mirror/country string @@VBOX_INSERT_COUNTRY@@
+## @todo proxy fun...
+d-i mirror/http/proxy string
+d-i pkgsel/install-language-support boolean false
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+d-i apt-setup/restricted boolean true
+d-i apt-setup/universe boolean true
+@@VBOX_COND_END@@@@VBOX_COND_IS_MINIMAL_INSTALLATION@@
+tasksel tasksel/first multiselect minimal
+d-i pkgsel/include string openssh-server
+d-i pkgsel/upgrade select none
+@@VBOX_COND_END@@
+
+# Users
+d-i passwd/user-fullname string @@VBOX_INSERT_USER_FULL_NAME@@
+d-i passwd/username string @@VBOX_INSERT_USER_LOGIN@@
+d-i passwd/user-password password @@VBOX_INSERT_USER_PASSWORD@@
+d-i passwd/user-password-again password @@VBOX_INSERT_USER_PASSWORD@@
+d-i passwd/root-login boolean true
+d-i passwd/root-password password @@VBOX_INSERT_ROOT_PASSWORD@@
+d-i passwd/root-password-again password @@VBOX_INSERT_ROOT_PASSWORD@@
+d-i user-setup/allow-password-weak boolean true
+d-i passwd/user-default-groups string admin
+
+# Grub
+d-i grub-installer/grub2_instead_of_grub_legacy boolean true
+d-i grub-installer/only_debian boolean true
+
+# Due notably to potential USB sticks, the location of the MBR can not be
+# determined safely in general, so this needs to be specified:
+#d-i grub-installer/bootdev string /dev/sda
+# To install to the first device (assuming it is not a USB stick):
+d-i grub-installer/bootdev string default
+
+d-i finish-install/reboot_in_progress note
+
+# Custom Commands.
+# Note! Debian netboot images use busybox, so no bash.
+# Tell script to use target bash.
+d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
+ && chmod +x /target/root/vboxpostinstall.sh \
+ && /bin/sh /target/root/vboxpostinstall.sh --need-target-bash --preseed-late-command
+
diff --git a/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg b/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg
new file mode 100644
index 00000000..c4c44c63
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg
@@ -0,0 +1,90 @@
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use CDROM installation media
+cdrom
+
+# Root password
+rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information
+auth --useshadow --passalgo=sha512
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+
+# SELinux configuration
+selinux --enforcing
+
+# Installation logging level
+logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=eth0 --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information
+part / --fstype ext4 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@
+
+# Reboot after installation
+# Note! the --eject option requires Fedora 6 or later. Doesn't seem to work tough.
+# Note! doesn't really work. Maybe related to https://bugzilla.redhat.com/show_bug.cgi?id=810553 ??
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@standard
+@hardware-support
+@@VBOX_COND_END@@@@VBOX_COND_IS_MINIMAL_INSTALLATION@@
+@core
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+dkms
+make
+bzip2
+perl
+
+%end
+
+# Post install happens in a different script.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+mkdir -p /tmp/vboxcdrom
+mount /dev/cdrom /tmp/vboxcdrom
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --fedora
+umount /tmp/vboxcdrom
+%end
+
diff --git a/src/VBox/Main/UnattendedTemplates/lgw_ks.cfg b/src/VBox/Main/UnattendedTemplates/lgw_ks.cfg
new file mode 100644
index 00000000..c45c597f
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/lgw_ks.cfg
@@ -0,0 +1,91 @@
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use DVD
+cdrom
+
+# Root password
+rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information
+auth --useshadow --passalgo=sha512
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+
+# Disable the unsupported hardware popup (vmmdev?).
+unsupported_hardware
+
+# SELinux configuration
+# selinux --enforcing
+
+# Installation logging level
+logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=enp0s3 --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information
+part / --fstype ext4 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@
+
+# Shut down after installation
+poweroff
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@base
+@core
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+dkms
+make
+bzip2
+perl
+
+%end
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h
+mkdir -p /tmp/vboxcdrom
+mount /dev/cdrom /tmp/vboxcdrom
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+%end
+
diff --git a/src/VBox/Main/UnattendedTemplates/lgw_postinstall.sh b/src/VBox/Main/UnattendedTemplates/lgw_postinstall.sh
new file mode 100755
index 00000000..b90ed65d
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/lgw_postinstall.sh
@@ -0,0 +1,507 @@
+#!/bin/bash
+## @file
+# Post installation script template for local gateway image.
+#
+# Note! This script expects to be running chrooted (inside new sytem).
+#
+
+#
+# Copyright (C) 2020 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+
+#
+# Globals.
+#
+MY_TARGET="/mnt/sysimage"
+MY_LOGFILE="${MY_TARGET}/var/log/vboxpostinstall.log"
+MY_CHROOT_CDROM="/cdrom"
+MY_CDROM_NOCHROOT="/tmp/vboxcdrom"
+MY_EXITCODE=0
+MY_DEBUG="" # "yes"
+
+
+#
+# Do we need to exec using target bash? If so, we must do that early
+# or ash will bark 'bad substitution' and fail.
+#
+if [ "$1" = "--need-target-bash" ]; then
+ # Try figure out which directories we might need in the library path.
+ if [ -z "${LD_LIBRARY_PATH}" ]; then
+ LD_LIBRARY_PATH="${MY_TARGET}/lib"
+ fi
+ for x in \
+ ${MY_TARGET}/lib \
+ ${MY_TARGET}/usr/lib \
+ ${MY_TARGET}/lib/*linux-gnu/ \
+ ${MY_TARGET}/lib32/ \
+ ${MY_TARGET}/lib64/ \
+ ${MY_TARGET}/usr/lib/*linux-gnu/ \
+ ${MY_TARGET}/usr/lib32/ \
+ ${MY_TARGET}/usr/lib64/ \
+ ;
+ do
+ if [ -e "$x" ]; then LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${x}"; fi;
+ done
+ export LD_LIBRARY_PATH
+
+ # Append target bin directories to the PATH as busybox may not have tee.
+ PATH="${PATH}:${MY_TARGET}/bin:${MY_TARGET}/usr/bin:${MY_TARGET}/sbin:${MY_TARGET}/usr/sbin"
+ export PATH
+
+ # Drop the --need-target-bash argument and re-exec.
+ shift
+ echo "******************************************************************************" >> "${MY_LOGFILE}"
+ echo "** Relaunching using ${MY_TARGET}/bin/bash $0 $*" >> "${MY_LOGFILE}"
+ echo "** LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${MY_LOGFILE}"
+ echo "** PATH=${PATH}" >> "${MY_LOGFILE}"
+ exec "${MY_TARGET}/bin/bash" "$0" "$@"
+fi
+
+
+#
+# Commands.
+#
+
+# Logs execution of a command.
+log_command()
+{
+ echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+ echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+ echo "** Executing: $*" >> "${MY_LOGFILE}"
+ "$@" 2>&1 | tee -a "${MY_LOGFILE}"
+ MY_TMP_EXITCODE="${PIPESTATUS[0]}" # bashism - whatever.
+ if [ "${MY_TMP_EXITCODE}" != "0" ]; then
+ if [ "${MY_TMP_EXITCODE}" != "${MY_IGNORE_EXITCODE}" ]; then
+ echo "** exit code: ${MY_TMP_EXITCODE}" | tee -a "${MY_LOGFILE}"
+ MY_EXITCODE=1;
+ else
+ echo "** exit code: ${MY_TMP_EXITCODE} (ignored)" | tee -a "${MY_LOGFILE}"
+ fi
+ fi
+}
+
+# Logs execution of a command inside the target.
+log_command_in_target()
+{
+ log_command chroot "${MY_TARGET}" "$@"
+}
+
+# Checks if $1 is a command on the PATH inside the target jail.
+chroot_which()
+{
+ for dir in /bin /usr/bin /sbin /usr/sbin;
+ do
+ if [ -x "${MY_TARGET}${dir}/$1" ]; then
+ return 0;
+ fi
+ done
+ return 1;
+}
+
+#
+# Log header.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** VirtualBox Unattended Guest Installation - Late installation actions" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Started: $0 $*" >> "${MY_LOGFILE}"
+
+
+#
+# We want the ISO available inside the target jail.
+#
+if [ -d "${MY_TARGET}${MY_CHROOT_CDROM}" ]; then
+ MY_RMDIR_TARGET_CDROM=
+else
+ MY_RMDIR_TARGET_CDROM="yes"
+ log_command mkdir -p ${MY_TARGET}${MY_CHROOT_CDROM}
+fi
+
+if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ MY_UNMOUNT_TARGET_CDROM=
+ echo "** binding cdrom into jail: already done" | tee -a "${MY_LOGFILE}"
+else
+ MY_UNMOUNT_TARGET_CDROM="yes"
+ log_command mount -o bind "${MY_CDROM_NOCHROOT}" "${MY_TARGET}${MY_CHROOT_CDROM}"
+ if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ echo "** binding cdrom into jail: success" | tee -a "${MY_LOGFILE}"
+ else
+ echo "** binding cdrom into jail: failed" | tee -a "${MY_LOGFILE}"
+ fi
+ if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command find "${MY_TARGET}${MY_CHROOT_CDROM}"
+ fi
+fi
+
+
+#
+# Debug
+#
+if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command id
+ log_command ps
+ log_command ps auxwwwf
+ log_command env
+ log_command df
+ log_command mount
+ log_command_in_target df
+ log_command_in_target mount
+ #log_command find /
+ MY_EXITCODE=0
+fi
+
+
+#
+# Proxy hack for yum
+#
+@@VBOX_COND_HAS_PROXY@@
+echo "" >> "${MY_TARGET}/etc/yum.conf"
+echo "proxy=@@VBOX_INSERT_PROXY@@" >> "${MY_TARGET}/etc/yum.conf"
+@@VBOX_COND_END@@
+
+#
+# Packages needed for GAs.
+#
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing packages for building kernel modules...' | tee -a "${MY_LOGFILE}"
+log_command_in_target yum -y install "kernel-devel-$(uname -r)"
+log_command_in_target yum -y install "kernel-headers-$(uname -r)"
+log_command_in_target yum -y install gcc
+log_command_in_target yum -y install binutils
+log_command_in_target yum -y install make
+log_command_in_target yum -y install dkms
+log_command_in_target yum -y install make
+log_command_in_target yum -y install bzip2
+log_command_in_target yum -y install perl
+
+
+#
+# GAs
+#
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing VirtualBox Guest Additions...' | tee -a "${MY_LOGFILE}"
+MY_IGNORE_EXITCODE=2 # returned if modules already loaded and reboot required.
+log_command_in_target /bin/bash "${MY_CHROOT_CDROM}/vboxadditions/VBoxLinuxAdditions.run" --nox11
+log_command_in_target /bin/bash -c "udevadm control --reload-rules" # GAs doesn't yet do this.
+log_command_in_target /bin/bash -c "udevadm trigger" # (ditto)
+MY_IGNORE_EXITCODE=
+log_command_in_target usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"
+@@VBOX_COND_END@@
+
+#
+# Local gateway support
+#
+log_command_in_target yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+#log_command_in_target yum -y update
+log_command_in_target yum -y install openvpn
+log_command_in_target yum -y install connect-proxy
+log_command_in_target usermod -a -G wheel "@@VBOX_INSERT_USER_LOGIN@@"
+
+echo "** Creating ${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/cloud-bridge.conf..." | tee -a "${MY_LOGFILE}"
+cat >"${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/cloud-bridge.conf" <<'EOT'
+# port 1194
+# proto udp
+port 443
+proto tcp-server
+dev tap0
+secret static.key
+keepalive 10 120
+compress lz4-v2
+push "compress lz4-v2"
+persist-key
+persist-tun
+status /var/log/openvpn-status.log
+log-append /var/log/openvpn.log
+verb 3
+EOT
+
+echo "** Creating ${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/cloud-bridge.sh..." | tee -a "${MY_LOGFILE}"
+cat >"${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/cloud-bridge.sh" <<'EOT'
+# Initialize variables
+br="br0"
+tap="tap0"
+vnic1=$1
+vnic2=$2
+vnic2_gw=$3
+target_mac=$4
+
+# Install openvpn if it is missing
+if ! yum list installed openvpn; then
+ sudo yum -y install openvpn
+fi
+
+# Let openvpn traffic through Linux firewall
+#sudo iptables -I INPUT -p udp --dport 1194 -j ACCEPT
+sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT
+
+# Switch to secondary VNIC
+sudo ip route change default via $vnic2_gw dev $vnic2
+sudo ip link set dev $vnic1 down
+
+# Bring up the cloud end of the tunnel
+sudo openvpn --config cloud-bridge.conf --daemon
+
+# Use target MAC for primary VNIC
+sudo ip link set dev $vnic1 address $target_mac
+
+# Bridge tap and primary VNIC
+sudo ip link add name $br type bridge
+sudo ip link set dev $vnic1 master $br
+sudo ip link set dev $tap master $br
+
+# Bring up all interfaces
+sudo ip link set dev $tap up
+sudo ip link set dev $vnic1 up
+sudo ip link set dev $br up
+EOT
+log_command chmod +x "${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/cloud-bridge.sh"
+
+echo "** Creating ${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/local-bridge.conf..." | tee -a "${MY_LOGFILE}"
+cat >"${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/local-bridge.conf" <<'EOT'
+dev tap0
+# proto udp
+# port 1194
+proto tcp-client
+port 443
+persist-key
+persist-tun
+secret static.key
+compress lz4-v2
+log-append /var/log/openvpn.log
+verb 3
+EOT
+
+echo "** Creating ${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/local-bridge.sh..." | tee -a "${MY_LOGFILE}"
+cat >"${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/local-bridge.sh" <<'EOT'
+echo Complete command line for debugging purposes:
+echo $0 $*
+
+# Make sure we are at home
+cd ~
+
+# Initialize variables
+user=opc
+cbr_ip1=$1
+cbr_ip2=$2
+target_mac=$3
+br="br0"
+tap="tap0"
+eth="enp0s8"
+
+proxy1_ssh=""
+proxy2_ssh=""
+proxy2_vpn=""
+case $4 in
+ HTTP | HTTPS)
+ proxy1_ssh="connect-proxy -w 30 -H $5:$6 %h %p"
+ ;;
+ SOCKS | SOCKS5)
+ proxy1_ssh="connect-proxy -w 30 -S $5:$6 %h %p"
+ ;;
+ SOCKS4)
+ proxy1_ssh="connect-proxy -w 30 -4 -S $5:$6 %h %p"
+ ;;
+esac
+case $7 in
+ HTTP | HTTPS)
+ proxy2_ssh="connect-proxy -w 30 -H $8:$9 %h %p"
+ proxy2_vpn="--http-proxy $8 $9"
+ ;;
+ SOCKS | SOCKS5)
+ proxy2_ssh="connect-proxy -w 30 -S $8:$9 %h %p"
+ proxy2_vpn="--socks-proxy $8 $9"
+ ;;
+ SOCKS4)
+ proxy2_ssh="connect-proxy -w 30 -4 -S $8:$9 %h %p"
+ proxy2_vpn="--socks-proxy $8 $9"
+ ;;
+esac
+
+# Generate pre-shared secret and share it with the server, bypassing proxy if necessary
+/usr/sbin/openvpn --genkey --secret static.key
+for i in 1 2 3 4
+do
+ # Go via proxy if set
+ scp ${proxy1_ssh:+ -o ProxyCommand="$proxy1_ssh"} static.key cloud-bridge.conf cloud-bridge.sh $user@$cbr_ip1:
+ if [ $? -eq 0 ]; then break; fi; sleep 15
+ # Go direct even if proxy is set
+ scp static.key cloud-bridge.conf cloud-bridge.sh $user@$cbr_ip1:
+ if [ $? -eq 0 ]; then proxy1_ssh=""; break; fi; sleep 15
+done
+
+# Get metadata info from the cloud bridge
+for i in 1 2 3 4; do metadata=$(ssh ${proxy1_ssh:+ -o ProxyCommand="$proxy1_ssh"} $user@$cbr_ip1 sudo oci-network-config) && break || sleep 15; done
+
+# Extract primary VNIC info
+vnic1_md=`echo "$metadata"|grep -E "\sUP\s"`
+vnic1_dev=`echo $vnic1_md|cut -d ' ' -f 8`
+vnic1_mac=`echo $vnic1_md|cut -d ' ' -f 12`
+# Extract secondary VNIC info
+vnic2_md=`echo "$metadata"|grep -E "\sDOWN\s"`
+vnic2_dev=`echo $vnic2_md|cut -d ' ' -f 8`
+vnic2_gw=`echo $vnic2_md|cut -d ' ' -f 5`
+
+# Configure secondary VNIC
+ssh ${proxy1_ssh:+ -o ProxyCommand="$proxy1_ssh"} $user@$cbr_ip1 sudo oci-network-config -c
+
+# Bring up the cloud bridge
+ssh ${proxy2_ssh:+ -o ProxyCommand="$proxy2_ssh"} $user@$cbr_ip2 /bin/sh -x cloud-bridge.sh $vnic1_dev $vnic2_dev $vnic2_gw $target_mac
+if [ $? -eq 0 ]
+then
+ # SSH was able to reach cloud via proxy, establish a tunnel via proxy as well
+ sudo /usr/sbin/openvpn $proxy2_vpn --config local-bridge.conf --daemon --remote $cbr_ip2
+else
+ # Retry without proxy
+ ssh $user@$cbr_ip2 /bin/sh -x cloud-bridge.sh $vnic1_dev $vnic2_dev $vnic2_gw $target_mac
+ # Establish a tunnel to the cloud bridge
+ sudo /usr/sbin/openvpn --config local-bridge.conf --daemon --remote $cbr_ip2
+fi
+
+# Bridge the openvpn tap device and the local Ethernet interface
+sudo ip link set dev $eth down
+sudo ip link add name $br type bridge
+sudo ip link set dev $eth master $br
+sudo ip link set dev $tap master $br
+
+# Bring up all interfaces
+sudo ip link set dev $tap up
+sudo ip link set dev $eth up
+sudo ip link set dev $br up
+EOT
+log_command chmod +x "${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/local-bridge.sh"
+
+echo "** Creating ${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/.ssh/config..." | tee -a "${MY_LOGFILE}"
+log_command mkdir "${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/.ssh"
+cat >"${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/.ssh/config" <<'EOT'
+Host *
+ StrictHostKeyChecking no
+EOT
+log_command chmod 400 "${MY_TARGET}/home/@@VBOX_INSERT_USER_LOGIN@@/.ssh/config"
+
+log_command_in_target chown -R @@VBOX_INSERT_USER_LOGIN@@:@@VBOX_INSERT_USER_LOGIN@@ "/home/@@VBOX_INSERT_USER_LOGIN@@"
+
+echo '** Creating /etc/systemd/system/keygen.service...' | tee -a "${MY_LOGFILE}"
+cat >"${MY_TARGET}/etc/systemd/system/keygen.service" <<'EOT'
+[Unit]
+Description=Boot-time ssh key pair generator
+After=vboxadd.service
+
+[Service]
+ExecStart=/bin/sh -c 'su - vbox -c "cat /dev/zero | ssh-keygen -q -N \\\"\\\""'
+ExecStartPost=/bin/sh -c 'VBoxControl guestproperty set "/VirtualBox/Gateway/PublicKey" "`cat ~vbox/.ssh/id_rsa.pub`" --flags TRANSIENT'
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
+EOT
+log_command chmod 644 "${MY_TARGET}/etc/systemd/system/keygen.service"
+log_command_in_target systemctl enable keygen.service
+
+echo '** Creating /etc/sudoers.d/020_vbox_sudo...' | tee -a "${MY_LOGFILE}"
+echo "@@VBOX_INSERT_USER_LOGIN@@ ALL=(ALL) NOPASSWD: ALL" > "${MY_TARGET}/etc/sudoers.d/020_vbox_sudo"
+
+#
+# Test Execution Service.
+#
+@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing Test Execution Service...' | tee -a "${MY_LOGFILE}"
+log_command_in_target test "${MY_CHROOT_CDROM}/vboxvalidationkit/linux/@@VBOX_INSERT_OS_ARCH@@/TestExecService"
+log_command mkdir -p "${MY_TARGET}/opt/validationkit" "${MY_TARGET}/media/cdrom"
+log_command cp -R ${MY_CDROM_NOCHROOT}/vboxvalidationkit/* "${MY_TARGET}/opt/validationkit/"
+log_command chmod -R u+rw,a+xr "${MY_TARGET}/opt/validationkit/"
+if [ -e "${MY_TARGET}/usr/bin/chcon" -o -e "${MY_TARGET}/bin/chcon" -o -e "${MY_TARGET}/usr/sbin/chcon" -o -e "${MY_TARGET}/sbin/chcon" ]; then
+ MY_IGNORE_EXITCODE=1
+ log_command_in_target chcon -R -t usr_t "/opt/validationkit/"
+ MY_IGNORE_EXITCODE=
+fi
+
+# systemd service config:
+MY_UNIT_PATH="${MY_TARGET}/lib/systemd/system"
+test -d "${MY_TARGET}/usr/lib/systemd/system" && MY_UNIT_PATH="${MY_TARGET}/usr/lib/systemd/system"
+if [ -d "${MY_UNIT_PATH}" ]; then
+ log_command cp "${MY_TARGET}/opt/validationkit/linux/vboxtxs.service" "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command chmod 644 "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command_in_target systemctl -q enable vboxtxs
+
+# System V like:
+elif [ -e "${MY_TARGET}/etc/init.d/" ]; then
+
+ # Install the script. On rhel6 scripts are under /etc/rc.d/ with /etc/init.d and /etc/rc?.d being symlinks.
+ if [ -d "${MY_TARGET}/etc/rc.d/init.d/" ]; then
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc/rc.d"
+ log_command ln -s "../../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ else
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc"
+ log_command ln -s "../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ fi
+
+ # Use runlevel management script if found.
+ if chroot_which chkconfig; then # Redhat based sysvinit systems
+ log_command_in_target chkconfig --add vboxtxs
+ elif chroot_which insserv; then # SUSE-based sysvinit systems
+ log_command_in_target insserv vboxtxs
+ elif chroot_which update-rc.d; then # Debian/Ubuntu-based systems
+ log_command_in_target update-rc.d vboxtxs defaults
+ elif chroot_which rc-update; then # Gentoo Linux
+ log_command_in_target rc-update add vboxtxs default
+ # Fall back on hardcoded symlinking.
+ else
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc0.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc1.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc6.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc2.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc3.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc4.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc5.d/S35vboxtxs"
+ fi
+else
+ echo "** error: Unknown init script system." | tee -a "${MY_LOGFILE}"
+fi
+
+@@VBOX_COND_END@@
+
+
+#
+# Run user command.
+#
+@@VBOX_COND_HAS_POST_INSTALL_COMMAND@@
+echo '** Running custom user command ...' | tee -a "${MY_LOGFILE}"
+log_command @@VBOX_INSERT_POST_INSTALL_COMMAND@@
+@@VBOX_COND_END@@
+
+
+#
+# Unmount the cdrom if we bound it and clean up the chroot if we set it up.
+#
+if [ -n "${MY_UNMOUNT_TARGET_CDROM}" ]; then
+ echo "** unbinding cdrom from jail..." | tee -a "${MY_LOGFILE}"
+ log_command umount "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+if [ -n "${MY_RMDIR_TARGET_CDROM}" ]; then
+ log_command rmdir "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+
+#
+# Log footer.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Final exit code: ${MY_EXITCODE}" >> "${MY_LOGFILE}"
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+
+exit ${MY_EXITCODE}
+
diff --git a/src/VBox/Main/UnattendedTemplates/ol_ks.cfg b/src/VBox/Main/UnattendedTemplates/ol_ks.cfg
new file mode 100644
index 00000000..7afedc6f
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/ol_ks.cfg
@@ -0,0 +1,109 @@
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use CDROM installation media
+cdrom
+
+# Root password
+rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information
+auth --useshadow --passalgo=sha512
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+
+# Disable the unsupported hardware popup (vmmdev?).
+#unsupported_hardware
+
+# SELinux configuration
+selinux --enforcing
+
+# Installation logging level
+logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=link --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information
+part / --fstype ext4 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@ --plaintext
+
+# Reboot after installation
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@base
+@core
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@development
+@basic-desktop
+@desktop-debugging
+@desktop-platform
+@fonts
+@general-desktop
+@graphical-admin-tools
+@remote-desktop-clients
+@x11
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+@@VBOX_COND_GUEST_VERSION[>8.0.0]@@
+elfutils-libelf-devel
+@@VBOX_COND_END@@
+dkms
+make
+bzip2
+perl
+
+#Package cloud-init is needed for possible automation the initial setup of virtual machine
+cloud-init
+
+%end
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h
+mkdir -p /tmp/vboxcdrom
+mount /dev/cdrom /tmp/vboxcdrom
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+%end
+
diff --git a/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg b/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg
new file mode 100644
index 00000000..73376099
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg
@@ -0,0 +1,109 @@
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use CDROM installation media
+cdrom
+
+# Root password
+rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information
+auth --useshadow --passalgo=sha512
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+
+# Disable the unsupported hardware popup (vmmdev?).
+#unsupported_hardware
+
+# SELinux configuration
+selinux --enforcing
+
+# Installation logging level
+logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=link --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information
+part / --fstype ext4 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@ --plaintext
+
+# Reboot after installation
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@base
+@core
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@development
+@basic-desktop
+@desktop-debugging
+@desktop-platform
+@fonts
+@general-desktop
+@graphical-admin-tools
+@remote-desktop-clients
+@x11
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+@@VBOX_COND_GUEST_VERSION[>8.0.0]@@
+elfutils-libelf-devel
+@@VBOX_COND_END@@
+dkms
+make
+bzip2
+perl
+
+#Package cloud-init is needed for possible automation the initial setup of virtual machine
+cloud-init
+
+%end
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h
+mkdir -p /tmp/vboxcdrom
+mount /dev/cdrom /tmp/vboxcdrom
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+%end
+
diff --git a/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh b/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh
new file mode 100755
index 00000000..231d5efe
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh
@@ -0,0 +1,311 @@
+#!/bin/bash
+## @file
+# Post installation script template for redhat- distros.
+#
+# Note! This script expects to be running chrooted (inside new sytem).
+#
+
+#
+# Copyright (C) 2017-2020 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+
+#
+# Globals.
+#
+MY_TARGET="/mnt/sysimage"
+MY_LOGFILE="${MY_TARGET}/var/log/vboxpostinstall.log"
+MY_CHROOT_CDROM="/cdrom"
+MY_CDROM_NOCHROOT="/tmp/vboxcdrom"
+MY_EXITCODE=0
+MY_DEBUG="" # "yes"
+GUEST_VERSION=@@VBOX_INSERT_GUEST_OS_VERSION@@
+GUEST_MAJOR_VERSION=@@VBOX_INSERT_GUEST_OS_MAJOR_VERSION@@
+
+#
+# Do we need to exec using target bash? If so, we must do that early
+# or ash will bark 'bad substitution' and fail.
+#
+if [ "$1" = "--need-target-bash" ]; then
+ # Try figure out which directories we might need in the library path.
+ if [ -z "${LD_LIBRARY_PATH}" ]; then
+ LD_LIBRARY_PATH="${MY_TARGET}/lib"
+ fi
+ for x in \
+ ${MY_TARGET}/lib \
+ ${MY_TARGET}/usr/lib \
+ ${MY_TARGET}/lib/*linux-gnu/ \
+ ${MY_TARGET}/lib32/ \
+ ${MY_TARGET}/lib64/ \
+ ${MY_TARGET}/usr/lib/*linux-gnu/ \
+ ${MY_TARGET}/usr/lib32/ \
+ ${MY_TARGET}/usr/lib64/ \
+ ;
+ do
+ if [ -e "$x" ]; then LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${x}"; fi;
+ done
+ export LD_LIBRARY_PATH
+
+ # Append target bin directories to the PATH as busybox may not have tee.
+ PATH="${PATH}:${MY_TARGET}/bin:${MY_TARGET}/usr/bin:${MY_TARGET}/sbin:${MY_TARGET}/usr/sbin"
+ export PATH
+
+ # Drop the --need-target-bash argument and re-exec.
+ shift
+ echo "******************************************************************************" >> "${MY_LOGFILE}"
+ echo "** Relaunching using ${MY_TARGET}/bin/bash $0 $*" >> "${MY_LOGFILE}"
+ echo "** LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${MY_LOGFILE}"
+ echo "** PATH=${PATH}" >> "${MY_LOGFILE}"
+ exec "${MY_TARGET}/bin/bash" "$0" "$@"
+fi
+
+
+#
+# Commands.
+#
+
+# Logs execution of a command.
+log_command()
+{
+ echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+ echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+ echo "** Executing: $*" >> "${MY_LOGFILE}"
+ "$@" 2>&1 | tee -a "${MY_LOGFILE}"
+ MY_TMP_EXITCODE="${PIPESTATUS[0]}" # bashism - whatever.
+ if [ "${MY_TMP_EXITCODE}" != "0" ]; then
+ if [ "${MY_TMP_EXITCODE}" != "${MY_IGNORE_EXITCODE}" ]; then
+ echo "** exit code: ${MY_TMP_EXITCODE}" | tee -a "${MY_LOGFILE}"
+ MY_EXITCODE=1;
+ else
+ echo "** exit code: ${MY_TMP_EXITCODE} (ignored)" | tee -a "${MY_LOGFILE}"
+ fi
+ fi
+}
+
+# Logs execution of a command inside the target.
+log_command_in_target()
+{
+ log_command chroot "${MY_TARGET}" "$@"
+}
+
+# Checks if $1 is a command on the PATH inside the target jail.
+chroot_which()
+{
+ for dir in /bin /usr/bin /sbin /usr/sbin;
+ do
+ if [ -x "${MY_TARGET}${dir}/$1" ]; then
+ return 0;
+ fi
+ done
+ return 1;
+}
+
+#
+# Log header.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** VirtualBox Unattended Guest Installation - Late installation actions" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Started: $0 $*" >> "${MY_LOGFILE}"
+
+
+#
+# We want the ISO available inside the target jail.
+#
+if [ -d "${MY_TARGET}${MY_CHROOT_CDROM}" ]; then
+ MY_RMDIR_TARGET_CDROM=
+else
+ MY_RMDIR_TARGET_CDROM="yes"
+ log_command mkdir -p ${MY_TARGET}${MY_CHROOT_CDROM}
+fi
+
+if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ MY_UNMOUNT_TARGET_CDROM=
+ echo "** binding cdrom into jail: already done" | tee -a "${MY_LOGFILE}"
+else
+ MY_UNMOUNT_TARGET_CDROM="yes"
+ log_command mount -o bind "${MY_CDROM_NOCHROOT}" "${MY_TARGET}${MY_CHROOT_CDROM}"
+ if [ -f "${MY_TARGET}${MY_CHROOT_CDROM}/vboxpostinstall.sh" ]; then
+ echo "** binding cdrom into jail: success" | tee -a "${MY_LOGFILE}"
+ else
+ echo "** binding cdrom into jail: failed" | tee -a "${MY_LOGFILE}"
+ fi
+ if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command find "${MY_TARGET}${MY_CHROOT_CDROM}"
+ fi
+fi
+
+
+#
+# Debug
+#
+if [ "${MY_DEBUG}" = "yes" ]; then
+ log_command id
+ log_command ps
+ log_command ps auxwwwf
+ log_command env
+ log_command df
+ log_command mount
+ log_command_in_target df
+ log_command_in_target mount
+ #log_command find /
+ MY_EXITCODE=0
+fi
+
+
+#
+# Add EPEL repository
+#
+EPEL_REPOSITORY="https://dl.fedoraproject.org/pub/epel/epel-release-latest-${GUEST_MAJOR_VERSION}.noarch.rpm"
+log_command_in_target wget ${EPEL_REPOSITORY}
+log_command_in_target yum localinstall -y "epel-release-latest-${GUEST_MAJOR_VERSION}.noarch.rpm"
+log_command_in_target yum install -y yum-utils
+log_command_in_target yum-config-manager --enable epel
+
+
+#
+# Packages needed for GAs.
+#
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing packages for building kernel modules...' | tee -a "${MY_LOGFILE}"
+log_command_in_target yum -y install "kernel-devel-$(uname -r)"
+log_command_in_target yum -y install "kernel-headers-$(uname -r)"
+log_command_in_target yum -y install gcc
+log_command_in_target yum -y install binutils
+log_command_in_target yum -y install make
+@@VBOX_COND_GUEST_VERSION[>8.0.0]@@
+log_command_in_target yum -y install elfutils-libelf-devel
+@@VBOX_COND_END@@
+log_command_in_target yum -y install dkms
+log_command_in_target yum -y install make
+log_command_in_target yum -y install bzip2
+log_command_in_target yum -y install perl
+
+
+#
+#Package cloud-init is needed for possible automation the initial setup of virtual machine
+#
+log_command_in_target yum -y install cloud-init
+log_command_in_target systemctl enable cloud-init-local.service
+log_command_in_target systemctl enable cloud-init.service
+log_command_in_target systemctl enable cloud-config.service
+log_command_in_target systemctl enable cloud-final.service
+
+
+#
+# GAs
+#
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing VirtualBox Guest Additions...' | tee -a "${MY_LOGFILE}"
+MY_IGNORE_EXITCODE=2 # returned if modules already loaded and reboot required.
+log_command_in_target /bin/bash "${MY_CHROOT_CDROM}/vboxadditions/VBoxLinuxAdditions.run" --nox11
+log_command_in_target /bin/bash -c "udevadm control --reload-rules" # GAs doesn't yet do this.
+log_command_in_target /bin/bash -c "udevadm trigger" # (ditto)
+MY_IGNORE_EXITCODE=
+log_command_in_target usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"
+@@VBOX_COND_END@@
+
+
+#
+# Test Execution Service.
+#
+@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@
+echo "--------------------------------------------------" >> "${MY_LOGFILE}"
+echo '** Installing Test Execution Service...' | tee -a "${MY_LOGFILE}"
+log_command_in_target test "${MY_CHROOT_CDROM}/vboxvalidationkit/linux/@@VBOX_INSERT_OS_ARCH@@/TestExecService"
+log_command mkdir -p "${MY_TARGET}/opt/validationkit" "${MY_TARGET}/media/cdrom"
+log_command cp -R ${MY_CDROM_NOCHROOT}/vboxvalidationkit/* "${MY_TARGET}/opt/validationkit/"
+log_command chmod -R u+rw,a+xr "${MY_TARGET}/opt/validationkit/"
+if [ -e "${MY_TARGET}/usr/bin/chcon" -o -e "${MY_TARGET}/bin/chcon" -o -e "${MY_TARGET}/usr/sbin/chcon" -o -e "${MY_TARGET}/sbin/chcon" ]; then
+ MY_IGNORE_EXITCODE=1
+ log_command_in_target chcon -R -t usr_t "/opt/validationkit/"
+ MY_IGNORE_EXITCODE=
+fi
+
+# systemd service config:
+MY_UNIT_PATH="${MY_TARGET}/lib/systemd/system"
+test -d "${MY_TARGET}/usr/lib/systemd/system" && MY_UNIT_PATH="${MY_TARGET}/usr/lib/systemd/system"
+if [ -d "${MY_UNIT_PATH}" ]; then
+ log_command cp "${MY_TARGET}/opt/validationkit/linux/vboxtxs.service" "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command chmod 644 "${MY_UNIT_PATH}/vboxtxs.service"
+ log_command_in_target systemctl -q enable vboxtxs
+
+# System V like:
+elif [ -e "${MY_TARGET}/etc/init.d/" ]; then
+
+ # Install the script. On rhel6 scripts are under /etc/rc.d/ with /etc/init.d and /etc/rc?.d being symlinks.
+ if [ -d "${MY_TARGET}/etc/rc.d/init.d/" ]; then
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc/rc.d"
+ log_command ln -s "../../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ else
+ MY_INIT_D_PARENT_PATH="${MY_TARGET}/etc"
+ log_command ln -s "../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PARENT_PATH}/init.d/"
+ fi
+
+ # Use runlevel management script if found.
+ if chroot_which chkconfig; then # Redhat based sysvinit systems
+ log_command_in_target chkconfig --add vboxtxs
+ elif chroot_which insserv; then # SUSE-based sysvinit systems
+ log_command_in_target insserv vboxtxs
+ elif chroot_which update-rc.d; then # Debian/Ubuntu-based systems
+ log_command_in_target update-rc.d vboxtxs defaults
+ elif chroot_which rc-update; then # Gentoo Linux
+ log_command_in_target rc-update add vboxtxs default
+ # Fall back on hardcoded symlinking.
+ else
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc0.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc1.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc6.d/K65vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc2.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc3.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc4.d/S35vboxtxs"
+ log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PARENT_PATH}/rc5.d/S35vboxtxs"
+ fi
+else
+ echo "** error: Unknown init script system." | tee -a "${MY_LOGFILE}"
+fi
+
+@@VBOX_COND_END@@
+
+
+#
+# Run user command.
+#
+@@VBOX_COND_HAS_POST_INSTALL_COMMAND@@
+echo '** Running custom user command ...' | tee -a "${MY_LOGFILE}"
+log_command @@VBOX_INSERT_POST_INSTALL_COMMAND@@
+@@VBOX_COND_END@@
+
+
+#
+# Unmount the cdrom if we bound it and clean up the chroot if we set it up.
+#
+if [ -n "${MY_UNMOUNT_TARGET_CDROM}" ]; then
+ echo "** unbinding cdrom from jail..." | tee -a "${MY_LOGFILE}"
+ log_command umount "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+if [ -n "${MY_RMDIR_TARGET_CDROM}" ]; then
+ log_command rmdir "${MY_TARGET}${MY_CHROOT_CDROM}"
+fi
+
+
+#
+# Log footer.
+#
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+echo "** Date: `date -R`" >> "${MY_LOGFILE}"
+echo "** Final exit code: ${MY_EXITCODE}" >> "${MY_LOGFILE}"
+echo "******************************************************************************" >> "${MY_LOGFILE}"
+
+exit ${MY_EXITCODE}
+
diff --git a/src/VBox/Main/UnattendedTemplates/rhel3_ks.cfg b/src/VBox/Main/UnattendedTemplates/rhel3_ks.cfg
new file mode 100644
index 00000000..797737a8
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/rhel3_ks.cfg
@@ -0,0 +1,141 @@
+#
+# Template for RHEL3 and derivatives.
+#
+# Note! RHEL3 kickstart typically just hangs if it finds something it doesn't like.
+# So, all changes to this file must be tested!
+#
+# N.B! AHCI is not supported by RHEL3
+#
+
+# Use text mode install
+text
+
+# Install OS instead of upgrade
+install
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@.UTF-8
+
+# rhel4+rhel3 needs:
+langsupport --default @@VBOX_INSERT_LOCALE@@.UTF-8 @@VBOX_INSERT_LOCALE@@.UTF-8
+
+# Use CDROM installation media
+cdrom
+
+# System authorization information (rhel5: no --passalgo=sha512)
+#auth --useshadow
+authconfig --enableshadow --enablemd5
+
+# Root password (rhel5 not --plaintext groks)
+rootpw @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# Network information
+# rhel3: doesn't like --onboot=on.
+network --bootproto=dhcp --device=eth0 --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# Firewall configuration
+firewall --disabled
+
+# System keyboard
+keyboard us
+
+# rhel3 wants mouse config.
+mouse genericwheelps/2 --device psaux
+
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+# rhel3 wants xconfig.
+# TODO: Dunno VRAM size, is that a problem? --videoram 32768
+xconfig --card "VESA driver (generic)" --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 24 --startxonboot --defaultdesktop gnome
+@@VBOX_COND_END@@
+
+# SELinux configuration
+# rhel3: disable selinux
+# selinux --enforcing
+
+# Installation logging level
+#rhel4 does not grok: logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information (rhel5: no ext4, so use ext3)
+part / --fstype ext3 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+#rhel4 does not grok, done in welcome sequence: user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@
+
+# Reboot after installation
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+grub
+kernel
+@ base
+@ core
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@ admin-tools
+@ development
+@ editors
+@ text-internet
+@ base-x
+@ graphics
+@ basic-desktop
+@ general-desktop
+@ gnome-desktop
+@ desktop-platform
+@ fonts
+@ graphical-admin-tools
+@ graphical-internet
+@ remote-desktop-clients
+@ sound-and-video
+@ x11
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script (rhel3 seems to need kernel-sources):
+kernel-source
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+dkms
+make
+bzip2
+perl
+# %end - rhel5 does not like this.
+
+
+# Pre install script for mounting the cdrom, to make sure it cannot be ejcted.
+# See https://bugzilla.redhat.com/show_bug.cgi?id=239002
+%pre
+mkdir -p /tmp/vboxcdrom
+mount -t iso9660 /tmp/cdrom /tmp/vboxcdrom || mount -t iso9660 /dev/hdc /tmp/vboxcdrom || mount -t iso9660 /dev/scd0 /tmp/vboxcdrom || mount -t iso9660 /dev/sdb /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+# rhel5: There is not /bin/bash, so use /bin/sh
+# rhel5: There is no /dev/cdrom, so try use /dev/hdc and /dev/sdb.
+# rhel3: no --log option
+%post --nochroot
+df -h
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/sh /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+rmdir /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
diff --git a/src/VBox/Main/UnattendedTemplates/rhel4_ks.cfg b/src/VBox/Main/UnattendedTemplates/rhel4_ks.cfg
new file mode 100644
index 00000000..54a2cdab
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/rhel4_ks.cfg
@@ -0,0 +1,120 @@
+# Template for RHEL5 and derivatives.
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use CDROM installation media
+cdrom
+
+# Root password (rhel5 not --plaintext groks)
+rootpw @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information (rhel5: no --passalgo=sha512)
+auth --useshadow
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+# rhel4 needs:
+langsupport --default=@@VBOX_INSERT_LOCALE@@.UTF-8 @@VBOX_INSERT_LOCALE@@.UTF-8
+
+
+# SELinux configuration
+selinux --enforcing
+
+# Installation logging level
+#rhel4 does not grok: logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=eth0 --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information (rhel5: no ext4, so use ext3)
+part / --fstype ext3 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+#rhel4 does not grok, done in welcome sequence: user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@
+
+# Reboot after installation
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@ base
+@ core
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@ admin-tools
+@ development
+@ editors
+@ text-internet
+@ base-x
+@ graphics
+@ basic-desktop
+@ general-desktop
+@ gnome-desktop
+@ desktop-platform
+@ fonts
+@ graphical-admin-tools
+@ graphical-internet
+@ remote-desktop-clients
+@ sound-and-video
+@ x11
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+dkms
+make
+bzip2
+perl
+# %end - rhel5 does not like this.
+
+
+# Pre install script for mounting the cdrom, to make sure it cannot be ejcted.
+# See https://bugzilla.redhat.com/show_bug.cgi?id=239002
+%pre
+mkdir -p /tmp/vboxcdrom
+mount -t iso9660 /tmp/cdrom /tmp/vboxcdrom || mount -t iso9660 /dev/hdc /tmp/vboxcdrom || mount -t iso9660 /dev/scd0 /tmp/vboxcdrom || mount -t iso9660 /dev/sdb /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+# rhel5: There is not /bin/bash, so use /bin/sh
+# rhel5: There is no /dev/cdrom, so try use /dev/hdc and /dev/sdb.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h 1>&2
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/sh /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+rmdir /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
diff --git a/src/VBox/Main/UnattendedTemplates/rhel5_ks.cfg b/src/VBox/Main/UnattendedTemplates/rhel5_ks.cfg
new file mode 100644
index 00000000..67bc998e
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/rhel5_ks.cfg
@@ -0,0 +1,119 @@
+# Template for RHEL5 and derivatives.
+#platform=x86, AMD64, or Intel EM64T
+#version=DEVEL
+
+# Firewall configuration
+firewall --disabled
+
+# Install OS instead of upgrade
+install
+
+# Use CDROM installation media
+cdrom
+
+# Root password (rhel5 not --plaintext groks)
+rootpw @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+
+# System authorization information (rhel5: no --passalgo=sha512)
+auth --useshadow
+
+# Use text mode install
+text
+
+# System keyboard
+keyboard us
+
+# System language
+lang @@VBOX_INSERT_LOCALE@@
+
+#rhel5 needs:
+@@VBOX_COND_HAS_NO_PRODUCT_KEY@@
+key --skip
+@@VBOX_COND_END@@
+@@VBOX_COND_HAS_PRODUCT_KEY@@
+key @@VBOX_INSERT_PRODUCT_KEY@@
+@@VBOX_COND_END@@
+
+
+# SELinux configuration
+selinux --enforcing
+
+# Installation logging level
+logging --level=info
+
+# System timezone
+timezone@@VBOX_COND_IS_RTC_USING_UTC@@ --utc@@VBOX_COND_END@@ @@VBOX_INSERT_TIME_ZONE_UX@@
+
+# Network information
+network --bootproto=dhcp --device=eth0 --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
+
+# System bootloader configuration
+bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
+zerombr
+
+# Partition clearing information
+clearpart --all --initlabel
+
+# Disk partitioning information (rhel5: no ext4, so use ext3)
+part / --fstype ext3 --size 6000 --grow --asprimary
+part swap --size 1024
+
+#Initial user
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@ --password=@@VBOX_INSERT_USER_PASSWORD_SH@@
+
+# Reboot after installation
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
+
+# Packages. We currently ignore missing packages/groups here to keep things simpler.
+%packages --ignoremissing
+@base
+@core
+@@VBOX_COND_IS_NOT_MINIMAL_INSTALLATION@@
+@development
+@basic-desktop
+@desktop-debugging
+@desktop-platform
+@fonts
+@general-desktop
+@graphical-admin-tools
+@remote-desktop-clients
+@x11
+@@VBOX_COND_END@@
+
+# Prepare building the additions kernel module, try get what we can from the cdrom as it may be impossible
+# to install anything from the post script:
+kernel-headers
+kernel-devel
+glibc-devel
+glibc-headers
+gcc
+dkms
+make
+bzip2
+perl
+# %end - rhel5 does not like this.
+
+
+# Pre install script for mounting the cdrom, to make sure it cannot be ejcted.
+# See https://bugzilla.redhat.com/show_bug.cgi?id=239002
+%pre
+mkdir -p /tmp/vboxcdrom
+mount -t iso9660 /tmp/cdrom /tmp/vboxcdrom || mount -t iso9660 /dev/hdc /tmp/vboxcdrom || mount -t iso9660 /dev/scd0 /tmp/vboxcdrom || mount -t iso9660 /dev/sdb /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
+
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs between fedora 26 to rhel5
+# and apparently there isn't any way to be certain that anaconda didn't unmount it already.
+# rhel5: There is not /bin/bash, so use /bin/sh
+# rhel5: There is no /dev/cdrom, so try use /dev/hdc and /dev/sdb.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h 1>&2
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/sh /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
+rmdir /tmp/vboxcdrom
+# %end - rhel5 does not like this.
+
diff --git a/src/VBox/Main/UnattendedTemplates/suse_autoinstall.xml b/src/VBox/Main/UnattendedTemplates/suse_autoinstall.xml
new file mode 100644
index 00000000..f6608692
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/suse_autoinstall.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE profile>
+<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
+ <general>
+ <mode>
+ <confirm config:type="boolean">false</confirm>
+ </mode>
+ </general>
+
+ <partitioning config:type="list">
+ <drive>
+ <use>all</use>
+ </drive>
+ </partitioning>
+
+ <software>
+ <!-- Those are necessray for Guest Additions -->
+ <packages config:type="list">
+ <package>gcc</package>
+ <package>automake</package>
+ <package>kernel-source</package>
+ <!-- 'smpppd' is required on openSUSE 11.4 -->
+ <package>smpppd</package>
+ </packages>
+
+ <patterns config:type="list">
+ <pattern>apparmor</pattern>
+ <pattern>apparmor_opt</pattern>
+ <pattern>base</pattern>
+ <pattern>kde</pattern>
+ <!--pattern>Basis-Devel</pattern-->
+ <!--pattern>devel_kernel</pattern-->
+ <pattern>default</pattern>
+ <pattern>sw_management</pattern>
+ <pattern>sw_management_kde4</pattern>
+ <pattern>yast2_install_wf</pattern>
+ </patterns>
+ </software>
+
+ <configure>
+ <x11>
+ <display_manager>kdm</display_manager>
+ </x11>
+
+ <networking>
+ <interfaces config:type="list">
+ <interface>
+ <bootproto>dhcp</bootproto>
+ <device>eth0</device>
+ <startmode>auto</startmode>
+ <usercontrol>yes</usercontrol>
+ </interface>
+ </interfaces>
+ </networking>
+
+ <users config:type="list">
+ <user>
+ <fullname>root</fullname>
+ <username>root</username>
+ <encrypted config:type="boolean">false</encrypted>
+ <user_password>$password</user_password>
+ </user>
+ <user>
+ <groups>video,dialout,vboxsf</groups>
+ <fullname>$user</fullname>
+ <username>$user</username>
+ <encrypted config:type="boolean">false</encrypted>
+ <user_password>$password</user_password>
+ </user>
+ </users>
+ </configure>
+</profile>
diff --git a/src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg b/src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg
new file mode 100644
index 00000000..8cdc6047
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg
@@ -0,0 +1,93 @@
+### Partitioning
+d-i partman-auto/disk string /dev/sda
+d-i partman-auto/method string regular
+d-i partman-lvm/device_remove_lvm boolean true
+d-i partman-md/device_remove_md boolean true
+d-i partman-auto/choose_recipe select atomic
+
+# This makes partman automatically partition without confirmation
+d-i partman-partitioning/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
+
+# Locale
+d-i debian-installer/locale string @@VBOX_INSERT_LOCALE@@
+d-i console-setup/ask_detect boolean false
+d-i console-setup/layoutcode string us
+d-i keyboard-configuration/xkb-keymap select us
+
+# Network
+d-i netcfg/get_hostname string @@VBOX_INSERT_HOSTNAME_WITHOUT_DOMAIN@@
+d-i netcfg/get_domain string @@VBOX_INSERT_HOSTNAME_DOMAIN@@
+d-i netcfg/choose_interface select auto
+
+# Clock
+@@VBOX_COND_IS_RTC_USING_UTC@@
+d-i clock-setup/utc-auto boolean true
+d-i clock-setup/utc boolean true
+@@VBOX_COND_END@@
+@@VBOX_COND_IS_NOT_RTC_USING_UTC@@
+d-i clock-setup/utc-auto boolean false
+d-i clock-setup/utc boolean false
+@@VBOX_COND_END@@
+d-i time/zone string @@VBOX_INSERT_TIME_ZONE_UX@@
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@d-i clock-setup/ntp boolean false@@VBOX_COND_END@@
+@@VBOX_COND_IS_NOT_INSTALLING_ADDITIONS@@d-i clock-setup/ntp boolean true@@VBOX_COND_END@@
+
+# Packages, Mirrors, Image
+d-i base-installer/kernel/override-image string linux-server
+d-i base-installer/kernel/override-image string linux-image-amd64
+## @todo use nearest mirror somehow...
+d-i mirror/country string @@VBOX_INSERT_COUNTRY@@
+d-i mirror/http/proxy string
+## @todo minimal install?
+d-i apt-setup/restricted boolean true
+d-i apt-setup/universe boolean true
+d-i pkgsel/install-language-support boolean false
+# Stuff we need to build additions modules:
+d-i pkgsel/include string build-essential linux-headers-generic perl make
+# Package cloud-init is needed for possible automation the initial setup of virtual machine
+d-i pkgsel/include cloud-init
+
+# Users
+d-i passwd/user-fullname string @@VBOX_INSERT_USER_FULL_NAME@@
+d-i passwd/username string @@VBOX_INSERT_USER_LOGIN@@
+d-i passwd/user-password password @@VBOX_INSERT_USER_PASSWORD@@
+d-i passwd/user-password-again password @@VBOX_INSERT_USER_PASSWORD@@
+d-i passwd/root-login boolean true
+d-i passwd/root-password password @@VBOX_INSERT_ROOT_PASSWORD@@
+d-i passwd/root-password-again password @@VBOX_INSERT_ROOT_PASSWORD@@
+d-i user-setup/allow-password-weak boolean true
+d-i passwd/user-default-groups string admin
+
+# Grub
+d-i grub-installer/grub2_instead_of_grub_legacy boolean true
+d-i grub-installer/only_debian boolean true
+
+# Due notably to potential USB sticks, the location of the MBR can not be
+# determined safely in general, so this needs to be specified:
+#d-i grub-installer/bootdev string /dev/sda
+# To install to the first device (assuming it is not a USB stick):
+d-i grub-installer/bootdev string default
+
+d-i finish-install/reboot_in_progress note
+
+# Custom Commands
+d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
+ && chmod +x /target/root/vboxpostinstall.sh \
+ && /bin/bash /root/vboxpostinstall.sh --preseed-late-command
+
+# Same as above, but for ubiquity.
+ubiquity ubiquity/success_command string vboxpostinstall.sh
+ubiquity ubiquity/success_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
+ && chmod +x /target/root/vboxpostinstall.sh \
+ && /bin/bash /target/root/vboxpostinstall.sh --ubiquity-success-command
+
+# automatically reboot after installation.
+ubiquity ubiquity/reboot boolean true
+
+## Skip downloading updates during installation (better for testing).
+# Seems this doesn't make any difference, so why bother.
+#ubiquity ubiquity/download_updates boolean false
+
diff --git a/src/VBox/Main/UnattendedTemplates/win_nt5_unattended.sif b/src/VBox/Main/UnattendedTemplates/win_nt5_unattended.sif
new file mode 100644
index 00000000..fe6a7018
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/win_nt5_unattended.sif
@@ -0,0 +1,60 @@
+;SetupMgrTag
+[Data]
+ AutoPartition = 1
+ MsDosInitiated = "0"
+ UnattendedInstall = "Yes"
+
+[Unattended]
+ UnattendMode = FullUnattended
+ OemSkipEula = Yes
+ OemPreinstall = No
+ TargetPath = \WINDOWS
+ Repartition = Yes
+ UnattendSwitch = "Yes"
+ DriverSigningPolicy = Ignore
+ WaitForReboot = "No"
+
+[GuiUnattended]
+ AdminPassword = "@@VBOX_INSERT_ROOT_PASSWORD@@"
+ EncryptedAdminPassword = No
+ AutoLogon = Yes
+ OEMSkipRegional = 1
+ OemSkipWelcome = 1
+; TODO: Make timezone configurable?
+ TimeZone = @@VBOX_INSERT_TIME_ZONE_WIN_INDEX@@
+ OemSkipWelcome = 1
+
+[UserData]
+; ProductKey was introduced in XP, ProductID was used in 2K and earlier.
+ ProductKey = "@@VBOX_INSERT_PRODUCT_KEY@@"
+ ProductID = "@@VBOX_INSERT_PRODUCT_KEY@@"
+; ; TODO: we're currently setting this up as Administrator only. We should respect the --user too.
+; ; Maybe consider: https://unattended.msfn.org/unattended.xp/view/web/27/SESSID=329e04d6824e220b0bb415d0665b1fe0/
+ FullName = "@@VBOX_INSERT_USER_LOGIN@@"
+ OrgName = ""
+ ComputerName = "@@VBOX_INSERT_HOSTNAME_WITHOUT_DOMAIN_MAX_15@@"
+
+[RegionalSettings]
+; ; TODO: If we implement locales below, we must also install the necessary language groups here. Fun.
+; LanguageGroup=1,2,3,4,5,6 - installed by default with XP
+
+; ; TODO: Implement mapping locales to windows LCIDs.
+; 0409:00000409 is US.
+; SystemLocale=00000419 - russian
+; ; TODO: Make Input locale configurable?
+; InputLocale=0409:00000409,0419:00000419 - US,Russian
+
+[LicenseFilePrintData]
+; This section is used for server installs.
+ AutoMode = "PerServer"
+ AutoUsers = "5"
+
+[Identification]
+ JoinWorkgroup = WORKGROUP
+
+[Networking]
+ InstallDefaultComponents = Yes
+
+[GuiRunOnce]
+ Command0="A:\VBOXPOST.CMD --xp-or-older"
+
diff --git a/src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml b/src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml
new file mode 100644
index 00000000..25201593
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<unattend xmlns="urn:schemas-microsoft-com:unattend"
+ xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
+
+ <settings pass="windowsPE">
+ <component name="Microsoft-Windows-International-Core-WinPE"
+ processorArchitecture="@@VBOX_INSERT_OS_ARCH_ATTRIB_DQ@@"
+ publicKeyToken="31bf3856ad364e35" language="neutral"
+ versionScope="nonSxS">
+ <InputLocale>en-US</InputLocale>
+ <SystemLocale>@@VBOX_INSERT_DASH_LOCALE@@</SystemLocale>
+ <UserLocale>@@VBOX_INSERT_DASH_LOCALE@@</UserLocale>
+ <!-- UILanguage must match the installation media language. Stuff like de-CH does not work for
+ example de_windows_7_enterprise_with_sp1_x64_dvd_u_677649.iso. However, stupidly we cannot
+ omit this element (kudos to brilliant minds at MS). -->
+ <UILanguage>@@VBOX_INSERT_LANGUAGE@@</UILanguage>
+ </component>
+
+ <component name="Microsoft-Windows-Setup"
+ processorArchitecture="@@VBOX_INSERT_OS_ARCH_ATTRIB_DQ@@"
+ publicKeyToken="31bf3856ad364e35" language="neutral"
+ versionScope="nonSxS">
+
+ <DiskConfiguration>
+ <WillShowUI>OnError</WillShowUI>
+ <Disk>
+ <DiskID>0</DiskID>
+ <WillWipeDisk>true</WillWipeDisk>
+ <CreatePartitions>
+ <CreatePartition>
+ <Order>1</Order>
+ <Type>Primary</Type>
+ <Extend>true</Extend>
+ </CreatePartition>
+ </CreatePartitions>
+ </Disk>
+ </DiskConfiguration>
+
+ <UserData>
+ <ProductKey>
+ <Key>@@VBOX_INSERT_PRODUCT_KEY_ELEMENT@@</Key>
+ <WillShowUI>OnError</WillShowUI>
+ </ProductKey>
+ <AcceptEula>true</AcceptEula>
+ </UserData>
+
+ <ImageInstall>
+ <OSImage>
+ <InstallFrom>
+ <!-- TODO: This stuff doesn't work for en_windows_vista_enterprise_sp1_x64_and_x86.iso ... -->
+ <MetaData wcm:action="add">
+ <Key>/IMAGE/INDEX</Key>
+ <Value>@@VBOX_INSERT_IMAGE_INDEX_ELEMENT@@</Value>
+ </MetaData>
+ <!-- <Path>d:\sources\install.wim</Path> - the w7 tests doesn't specify this -->
+ </InstallFrom>
+ <InstallTo>
+ <DiskID>0</DiskID>
+ <PartitionID>1</PartitionID>
+ </InstallTo>
+ <WillShowUI>OnError</WillShowUI>
+ <InstallToAvailablePartition>false</InstallToAvailablePartition>
+ </OSImage>
+ </ImageInstall>
+
+ <ComplianceCheck>
+ <DisplayReport>OnError</DisplayReport>
+ </ComplianceCheck>
+
+ </component>
+ </settings>
+
+ <settings pass="specialize">
+ <component name="Microsoft-Windows-Shell-Setup"
+ processorArchitecture="@@VBOX_INSERT_OS_ARCH_ATTRIB_DQ@@"
+ publicKeyToken="31bf3856ad364e35" language="neutral"
+ versionScope="nonSxS">
+ <ComputerName>@@VBOX_INSERT_HOSTNAME_WITHOUT_DOMAIN_MAX_15@@</ComputerName>
+ </component>
+ </settings>
+
+ <settings pass="oobeSystem">
+ <component name="Microsoft-Windows-Shell-Setup"
+ processorArchitecture="@@VBOX_INSERT_OS_ARCH_ATTRIB_DQ@@"
+ publicKeyToken="31bf3856ad364e35" language="neutral"
+ versionScope="nonSxS">
+ <AutoLogon>
+ <Password>
+ <Value>@@VBOX_INSERT_USER_PASSWORD_ELEMENT@@</Value>
+ <PlainText>true</PlainText>
+ </Password>
+ <Enabled>true</Enabled>
+ <Username>@@VBOX_INSERT_USER_LOGIN_ELEMENT@@</Username>
+ </AutoLogon>
+
+ <UserAccounts>
+@@VBOX_COND_IS_USER_LOGIN_NOT_ADMINISTRATOR@@
+ <AdministratorPassword>
+ <Value>@@VBOX_INSERT_ROOT_PASSWORD_ELEMENT@@</Value>
+ <PlainText>true</PlainText>
+ </AdministratorPassword>
+
+ <LocalAccounts>
+ <LocalAccount wcm:action="add">
+ <Name>@@VBOX_INSERT_USER_LOGIN_ELEMENT@@</Name>
+ <DisplayName>@@VBOX_INSERT_USER_FULL_NAME_ELEMENT@@</DisplayName>
+ <Group>administrators;users</Group>
+ <Password>
+ <Value>@@VBOX_INSERT_USER_PASSWORD_ELEMENT@@</Value>
+ <PlainText>true</PlainText>
+ </Password>
+ </LocalAccount>
+ </LocalAccounts>
+@@VBOX_COND_END@@
+@@VBOX_COND_IS_USER_LOGIN_ADMINISTRATOR@@
+ <AdministratorPassword>
+ <Value>@@VBOX_INSERT_USER_PASSWORD_ELEMENT@@</Value>
+ <PlainText>true</PlainText>
+ </AdministratorPassword>
+@@VBOX_COND_END@@
+ </UserAccounts>
+
+ <VisualEffects>
+ <FontSmoothing>ClearType</FontSmoothing>
+ </VisualEffects>
+
+ <OOBE>
+ <ProtectYourPC>3</ProtectYourPC>
+ <HideEULAPage>true</HideEULAPage>
+ <SkipUserOOBE>true</SkipUserOOBE>
+ <SkipMachineOOBE>true</SkipMachineOOBE>
+ <!-- Make this (NetworkLocation) default to public and make it configurable -->
+ <NetworkLocation>Home</NetworkLocation>
+ </OOBE>
+
+ <FirstLogonCommands>
+ <SynchronousCommand wcm:action="add">
+ <!-- For which OS versions do we need to do this? -->
+ <Order>1</Order>
+ <Description>Turn Off Network Selection pop-up</Description>
+ <CommandLine>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff"</CommandLine>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <Order>2</Order>
+ <Description>VirtualBox post guest install steps </Description>
+ <CommandLine>cmd.exe /c A:\VBOXPOST.CMD --vista-or-newer</CommandLine>
+ </SynchronousCommand>
+ </FirstLogonCommands>
+
+ <TimeZone>@@VBOX_INSERT_TIME_ZONE_WIN_NAME@@</TimeZone>
+ </component>
+
+ </settings>
+</unattend>
+
diff --git a/src/VBox/Main/UnattendedTemplates/win_postinstall.cmd b/src/VBox/Main/UnattendedTemplates/win_postinstall.cmd
new file mode 100644
index 00000000..93c7ad68
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/win_postinstall.cmd
@@ -0,0 +1,147 @@
+@echo off
+rem $Id: win_postinstall.cmd $
+rem rem @file
+rem Post installation script template for Windows.
+rem
+rem This runs after the target system has been booted, typically as
+rem part of the first logon.
+rem
+
+rem
+rem Copyright (C) 2017-2020 Oracle Corporation
+rem
+rem This file is part of VirtualBox Open Source Edition (OSE), as
+rem available from http://www.virtualbox.org. This file is free software;
+rem you can redistribute it and/or modify it under the terms of the GNU
+rem General Public License (GPL) as published by the Free Software
+rem Foundation, in version 2 as it comes in the "COPYING" file of the
+rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+rem
+
+rem Globals.
+set MY_LOG_FILE=C:\vboxpostinstall.log
+
+rem Log header.
+echo *** started >> %MY_LOG_FILE%
+echo *** CD=%CD% >> %MY_LOG_FILE%
+echo *** Environment BEGIN >> %MY_LOG_FILE%
+set >> %MY_LOG_FILE%
+echo *** Environment END >> %MY_LOG_FILE%
+
+
+@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
+rem
+rem Install the guest additions.
+rem
+
+rem First find the CDROM with the GAs on them.
+set MY_VBOX_ADDITIONS=E:\vboxadditions
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=D:\vboxadditions
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=F:\vboxadditions
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=G:\vboxadditions
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=E:
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=F:
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=G:
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=D:
+if exist %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe goto found_vbox_additions
+set MY_VBOX_ADDITIONS=E:\vboxadditions
+:found_vbox_additions
+echo *** MY_VBOX_ADDITIONS=%MY_VBOX_ADDITIONS%\ >> %MY_LOG_FILE%
+
+rem Then add signing certificate to trusted publishers
+echo *** Running: %MY_VBOX_ADDITIONS%\cert\VBoxCertUtil.exe ... >> %MY_LOG_FILE%
+%MY_VBOX_ADDITIONS%\cert\VBoxCertUtil.exe add-trusted-publisher %MY_VBOX_ADDITIONS%\cert\vbox*.cer --root %MY_VBOX_ADDITIONS%\cert\vbox*.cer >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+rem Then do the installation.
+echo *** Running: %MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe /S >> %MY_LOG_FILE%
+%MY_VBOX_ADDITIONS%\VBoxWindowsAdditions.exe /S
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+@@VBOX_COND_END@@
+
+
+@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@
+rem
+rem Install the Test Execution service
+rem
+
+rem First find the CDROM with the validation kit on it.
+set MY_VBOX_VALIDATION_KIT=E:\vboxvalidationkit
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=D:\vboxvalidationkit
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=F:\vboxvalidationkit
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=G:\vboxvalidationkit
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=E:
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=F:
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=G:
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=D:
+if exist %MY_VBOX_VALIDATION_KIT%\vboxtxs-readme.txt goto found_vbox_validation_kit
+set MY_VBOX_VALIDATION_KIT=E:\vboxvalidationkit
+:found_vbox_validation_kit
+echo *** MY_VBOX_VALIDATION_KIT=%MY_VBOX_VALIDATION_KIT%\ >> %MY_LOG_FILE%
+
+rem Copy over the files.
+echo *** Running: mkdir %SystemDrive%\Apps >> %MY_LOG_FILE%
+mkdir %SystemDrive%\Apps >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+echo *** Running: copy %MY_VBOX_VALIDATION_KIT%\win\* %SystemDrive%\Apps >> %MY_LOG_FILE%
+copy %MY_VBOX_VALIDATION_KIT%\win\* %SystemDrive%\Apps >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+echo *** Running: copy %MY_VBOX_VALIDATION_KIT%\win\%PROCESSOR_ARCHITECTURE%\* %SystemDrive%\Apps >> %MY_LOG_FILE%
+copy %MY_VBOX_VALIDATION_KIT%\win\%PROCESSOR_ARCHITECTURE%\* %SystemDrive%\Apps >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+rem Update the registry to autorun the service and make sure we've got autologon.
+echo *** Running: reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v NTConfiguration /d %SystemDrive%\Apps\vboxtxs.cmd >> %MY_LOG_FILE%
+reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v NTConfiguration /d %SystemDrive%\Apps\vboxtxs.cmd >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+echo *** Running: reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v PowerdownAfterShutdown /d 1 >> %MY_LOG_FILE%
+reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v PowerdownAfterShutdown /d 1 >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+echo *** Running: reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v ForceAutoLogon /d 1 >> %MY_LOG_FILE%
+reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /v ForceAutoLogon /d 1 >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+rem AutoAdminLogon too if administrator?
+
+rem Configure the firewall to allow TXS to listen.
+echo *** Running: netsh firewall add portopening TCP 5048 "TestExecService 5048" >> %MY_LOG_FILE%
+netsh firewall add portopening TCP 5048 "TestExecService 5048" >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+echo *** Running: netsh firewall add portopening TCP 5042 "TestExecService 5042" >> %MY_LOG_FILE%
+netsh firewall add portopening TCP 5042 "TestExecService 5042" >> %MY_LOG_FILE% 2>&1
+echo *** ERRORLEVEL: %ERRORLEVEL% >> %MY_LOG_FILE%
+
+@@VBOX_COND_END@@
+
+
+@@VBOX_COND_HAS_POST_INSTALL_COMMAND@@
+rem
+rem Run user command.
+rem
+echo *** Running custom user command ... >> %MY_LOG_FILE%
+echo *** Running: "@@VBOX_INSERT_POST_INSTALL_COMMAND@@" >> %MY_LOG_FILE%
+@@VBOX_INSERT_POST_INSTALL_COMMAND@@
+@@VBOX_COND_END@@
+
+echo *** done >> %MY_LOG_FILE%
+