Index: /trunk/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh
===================================================================
--- /trunk/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh	(revision 68200)
+++ /trunk/src/VBox/Main/UnattendedTemplates/debian_postinstall.sh	(revision 68201)
@@ -107,4 +107,15 @@
 }
 
+# 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;
+}
 
 #
@@ -223,7 +234,37 @@
     log_command_in_target systemctl -q enable vboxtxs
 
-# Not systemd:  Add support for upstart later...
+# System V like:
+elif [ -e /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 /etc/rc.d/init.d/ ]; then
+        MY_INIT_D_PATH="${MY_TARGET}/etc/rc.d"
+        log_command ln -s "../../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PATH}/init.d/"
+    else
+        MY_INIT_D_PATH="${MY_TARGET}/etc"
+        log_command ln -s    "../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_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_PATH}/rc0.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc1.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc6.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc2.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc3.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc4.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc5.d/S35vboxtxs"
+    fi
 else
-    echo "** error: No systemd unit dir found.  Using upstart or something?" | tee -a "${MY_LOGFILE}"
+    echo "** error: Unknown init script system." | tee -a "${MY_LOGFILE}"
 fi
 
Index: /trunk/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg
===================================================================
--- /trunk/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg	(revision 68200)
+++ /trunk/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg	(revision 68201)
@@ -81,11 +81,10 @@
 # Post install happens in a different script.
 %post --nochroot --log=/mnt/sysimage/root/ks-post.log
-cp /run/install/repo/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+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
-
-# eject /dev/sr0 - this causes reboot trouble with fedora 26, and is documented to no be a good idea...
-# init 5
-
+umount /tmp/vboxcdrom
 %end
 
Index: /trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg
===================================================================
--- /trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg	(revision 68200)
+++ /trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg	(revision 68201)
@@ -24,5 +24,5 @@
 
 # System language
-lang en_US
+lang @@VBOX_INSERT_LOCALE@@
 
 # SELinux configuration
@@ -33,8 +33,8 @@
 
 # System timezone
-timezone  Europe/London
+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
+network  --bootproto=dhcp --device=eth0 --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@@
 
 # System bootloader configuration
@@ -53,9 +53,12 @@
 
 # Reboot after installation
-reboot
+# Note! Not sure exctly when the --eject option was added. Need to find out an make it optional.
+reboot --eject
 
-%packages
+# 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
@@ -67,13 +70,31 @@
 @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
 
-%post --log=/root/ks-post.log
-## @todo fix this.
-cp /cdrom/vboxpostinstall.sh /root/vboxpostinstall.sh && chmod a+x /root/vboxpostinstall.sh && /bin/bash /root/vboxpostinstall.sh
-eject /dev/sr0
-eject /dev/sr1
-eject /dev/sr2
-init 5
+# 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
+
Index: /trunk/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh
===================================================================
--- /trunk/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh	(revision 68200)
+++ /trunk/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh	(revision 68201)
@@ -25,5 +25,5 @@
 MY_LOGFILE="${MY_TARGET}/var/log/vboxpostinstall.log"
 MY_CHROOT_CDROM="/cdrom"
-MY_CDROM_NOCHROOT="/run/install/repo"
+MY_CDROM_NOCHROOT="/tmp/vboxcdrom"
 MY_EXITCODE=0
 MY_DEBUG="" # "yes"
@@ -96,4 +96,15 @@
 }
 
+# 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;
+}
 
 #
@@ -203,7 +214,37 @@
     log_command_in_target systemctl -q enable vboxtxs
 
-# Not systemd:  Add support for upstart later...
+# System V like:
+elif [ -e /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 /etc/rc.d/init.d/ ]; then
+        MY_INIT_D_PATH="${MY_TARGET}/etc/rc.d"
+        log_command ln -s "../../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_PATH}/init.d/"
+    else
+        MY_INIT_D_PATH="${MY_TARGET}/etc"
+        log_command ln -s    "../../opt/validationkit/linux/vboxtxs" "${MY_INIT_D_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_PATH}/rc0.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc1.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc6.d/K65vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc2.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc3.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc4.d/S35vboxtxs"
+        log_command ln -s "../init.d/vboxtxs" "${MY_INIT_D_PATH}/rc5.d/S35vboxtxs"
+    fi
 else
-    echo "** error: No systemd unit dir found.  Using upstart or something?" | tee -a "${MY_LOGFILE}"
+    echo "** error: Unknown init script system." | tee -a "${MY_LOGFILE}"
 fi
 
