[vbox-dev] [PATCH] vbox-unattended in C++ ! was: [proposal: Unattended Guest OS Installs for VirtualBox ?]

Alexey Eromenko al4321 at gmail.com
Mon Jan 9 21:50:14 PST 2012


Reviewable version of my patch:

diff -uNr 2//vbox/doc/manual/user_ChangeLogImpl.xml
1//vbox/doc/manual/user_ChangeLogImpl.xml
--- 2//vbox/doc/manual/user_ChangeLogImpl.xml	2012-01-10
07:05:38.000000000 +0200
+++ 1//vbox/doc/manual/user_ChangeLogImpl.xml	2012-01-10
01:30:31.000000000 +0200
@@ -14,7 +14,11 @@

       <listitem>
         <para>Support for up to 36 network cards, in combination with an
-          ICH9 chipset configuration (bug #8805).</para>
+          ICH9 chipset configuration (wish #8805).</para>
+      </listitem>
+
+      <listitem>
+        <para>Automated virtual machine install (Linux hosts only;
wish #5810).</para>
       </listitem>

     </itemizedlist>
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/Makefile.kmk
1//vbox/src/VBox/Frontends/VirtualBox/Makefile.kmk
--- 2//vbox/src/VBox/Frontends/VirtualBox/Makefile.kmk	2012-01-10
07:05:17.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/Makefile.kmk	2012-01-10
02:54:16.000000000 +0200
@@ -355,7 +355,8 @@
 	src/wizards/firstrun/UIFirstRunWzd.h \
 	src/wizards/importappliance/UIImportApplianceWzd.h \
 	src/wizards/newhd/UINewHDWizard.h \
-	src/wizards/newvm/UINewVMWzd.h
+	src/wizards/newvm/UINewVMWzd.h \
+	src/wizards/newvm/libunattended.h

 VirtualBox_QT_MOCHDRS.darwin += \
     src/platform/darwin/UIWindowMenuManager.h
@@ -532,7 +533,8 @@
 	src/wizards/firstrun/UIFirstRunWzd.cpp \
 	src/wizards/importappliance/UIImportApplianceWzd.cpp \
 	src/wizards/newhd/UINewHDWizard.cpp \
-	src/wizards/newvm/UINewVMWzd.cpp
+	src/wizards/newvm/UINewVMWzd.cpp \
+	src/wizards/newvm/libunattended.cpp

 VirtualBox_SOURCES.win += \
 	src/runtime/UIFrameBufferDirectDraw.cpp
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.cpp
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.cpp
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.cpp	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.cpp	2012-01-10
07:00:02.000000000 +0200
@@ -0,0 +1,214 @@
+/*
+This is the core logic of unattended script generators.
+
+Copyright 2011-2012 (C) Alexey Eromenko "Technologov". All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
modification, are
+permitted provided that the following conditions are met:
+
+   1. Redistributions of source code must retain the above copyright
notice, this list of
+      conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above
copyright notice, this list
+      of conditions and the following disclaimer in the documentation
and/or other materials
+      provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Alexey Eromenko "Technologov" ''AS IS''
AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
<COPYRIGHT HOLDER> OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation
are those of the
+authors and should not be interpreted as representing official
policies, either expressed
+or implied, of Alexey Eromenko "Technologov".
+*/
+
+#include <iostream>
+#include <fstream>
+#include <string>
+using namespace std;
+#include <stdlib.h>
+
+#include "libunattended.h"
+
+// Generic Logic
+LibUnattended::LibUnattended()
+{
+  system("mkdir -p /tmp/bootiso/");
+}
+
+void LibUnattended::cretaeIsoLinuxFolder(string strMachineFolder)
+{
+  string format_command = strMachineFolder;
+  format_command += "/isolinux";
+  system((char*)format_command.c_str());
+}
+
+string& LibUnattended::replaceAll(string& context, const string&
from, const string& to)
+{
+  size_t first = 0;
+  size_t last = string::npos;
+  // This is similar to python's string.replace()
+  // Technologov: I'm sorry but the C++ strings library is sooo *ulgy*.
+  // taken from:
+  // http://www.cppbook.com/index.php?title=String_replace
+  size_t currentPos = first;
+  size_t found;
+  if( from.empty() )
+    return context;
+  while( (found = context.find(from, currentPos)) != string::npos )
+  {
+    if( found >= last )
+      break;
+    context.replace(found, from.size(), to);
+    currentPos = found + to.size();
+  }
+  return context;
+}
+
+ifstream::pos_type size;
+
+string LibUnattended::readFileToString(string strReadfilepath)
+{
+  // input: strReadfilepath -- path to file
+  // return: string with file contents
+  ifstream file ((char*)strReadfilepath.c_str(),
+    ios::in|ios::ate|ios::binary);
+
+  if (file.is_open())
+  {
+    size = file.tellg();
+    char * memblock;
+    memblock = new char [size];
+    file.seekg (0, ios::beg);
+    file.read (memblock, size);
+    file.close();
+    //cout << "the complete file content is in memory\n";
+    string filereadstr=memblock;
+    delete[] memblock;
+    return filereadstr;
+  }
+  else
+  {
+    cout << "Unable to open file\n";
+    return "";
+  }
+}
+
+void LibUnattended::writeStringToFile(string strWritefilepath, string strData)
+{
+  ofstream myfile;
+  myfile.open ((char*)strWritefilepath.c_str(), ios::out|ios::binary);
+  myfile << strData;
+  myfile.close();
+}
+
+void LibUnattended::prepareFormattedFloppy(string strFloppyImagePath)
+{
+  // this function creates 1.44 MB floppy image + formats it in FAT12 format.
+  string dd_command = "dd if=/dev/zero of=$floppy count=1440 bs=1024";
+  dd_command = replaceAll(dd_command, "$floppy", strFloppyImagePath);
+  system((char*)dd_command.c_str());
+  string format_command = "/sbin/mkfs.msdos $floppy";
+  format_command = replaceAll(format_command, "$floppy", strFloppyImagePath);
+  system((char*)format_command.c_str());
+}
+
+void LibUnattended::copyFilesToFloppy(string strFloppyImagePath,
string file1, string file2)
+{
+  // This function copies up to 2 files to the floppy image (usually
NT5+NT6 scripts)
+  string format_command = "mcopy -i $floppy $file1 $file2 ::";
+  format_command = replaceAll(format_command, "$floppy", strFloppyImagePath);
+  format_command = replaceAll(format_command, "$file1", file1);
+  format_command = replaceAll(format_command, "$file2", file2);
+  system((char*)format_command.c_str());
+}
+
+void LibUnattended::prepareGenericScript(string strTemplateFilePath,
string strTargetFilePath,
+  string user, string password, string ProductKey, string arch)
+{
+  string final_script = readFileToString(strTemplateFilePath);
+  final_script = replaceAll(final_script, "$user", user);
+  final_script = replaceAll(final_script, "$password", password);
+  final_script = replaceAll(final_script, "$ProductKey", ProductKey);
+  final_script = replaceAll(final_script, "$arch", arch);
+  writeStringToFile(strTargetFilePath, final_script);
+}
+
+void LibUnattended::extractLinuxAdditionsFromISO(string target_path,
string VBoxGuestAdditionsISO)
+{
+  string format_command = "cd $target_path && 7z e
$VBoxGuestAdditionsISO VBoxLinuxAdditions.run";
+  format_command = replaceAll(format_command, "$target_path", target_path);
+  format_command = replaceAll(format_command,
"$VBoxGuestAdditionsISO", VBoxGuestAdditionsISO);
+  system((char*)format_command.c_str());
+}
+
+void LibUnattended::prepareUnattendedLinuxCD(string isopath, string
sourcepath, string isolinuxpath)
+{
+  string format_command = "cd $sourcepath && genisoimage -o $isopath -r -b \
+    $isolinuxpathisolinux.bin  -c $isolinuxpathboot.cat -no-emul-boot \
+    -boot-load-size 4  -boot-info-table -R -J -v -T .";
+  format_command = replaceAll(format_command, "$sourcepath", sourcepath);
+  format_command = replaceAll(format_command, "$isopath", isopath);
+  format_command = replaceAll(format_command, "$isolinuxpath", isolinuxpath);
+  system((char*)format_command.c_str());
+}
+// End of Generic Logic
+
+// Red Hat Logic
+
+void LibUnattended::extractFromRedHatISO(string isopath, string
target_path, string VBoxGuestAdditionsISO)
+{
+  string format_command = "cd $target_path && rm -Rvf * && 7z e
$isopath isolinux/ && rm -Rvf isolinux/";
+  format_command = replaceAll(format_command, "$target_path", target_path);
+  format_command = replaceAll(format_command, "$isopath", isopath);
+  system((char*)format_command.c_str());
+  extractLinuxAdditionsFromISO(target_path, VBoxGuestAdditionsISO);
+}
+// End of Red Hat Logic
+// Debian Logic
+
+void LibUnattended::extractFromDebianISO(string isopath, string
target_path, string VBoxGuestAdditionsISO)
+{
+  string format_command = "cd $target_path && rm -Rvf * && 7z x
$isopath install.386/ install.amd/ isolinux/";
+  format_command = replaceAll(format_command, "$target_path", target_path);
+  format_command = replaceAll(format_command, "$isopath", isopath);
+  system((char*)format_command.c_str());
+  extractLinuxAdditionsFromISO(target_path, VBoxGuestAdditionsISO);
+}
+// End of Debian Logic
+// SUSE Logic
+void LibUnattended::extractFromSuseISO(string isopath, string target_path,
+    string VBoxGuestAdditionsISO, string arch)
+{
+  string format_command = "cd $target_path && rm -Rvf * && 7z e $isopath \
+      boot/$arch/loader/initrd \
+      boot/$arch/loader/linux \
+      boot/$arch/loader/isolinux.bin";
+  format_command = replaceAll(format_command, "$target_path", target_path);
+  format_command = replaceAll(format_command, "$isopath", isopath);
+  format_command = replaceAll(format_command, "$arch", arch);
+  system((char*)format_command.c_str());
+  extractLinuxAdditionsFromISO(target_path, VBoxGuestAdditionsISO);
+}
+// End of SUSE Logic
+
+
+/*
+int main ()
+{
+  // main() function lets me test libunattended separately, without
recompiling whole VBox.
+  // It must be commented out, if I'm using it as part of VBox.
+  LibUnattended libu;
+  libu.prepareGenericScript("/tmp/win_nt6_template_autounattend.xml",
"/tmp/autounattend.xml",
+                     "myuser", "123456q", "my-key", "x86");
+  libu.prepareFormattedFloppy("/tmp/winfloppy.img");
+  libu.copyFilesToFloppy("/tmp/winfloppy.img", "/tmp/winnt5.sif",
"/tmp/autounattend.xml");
+  return 0;
+}
+//*/
\ No newline at end of file
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.h
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.h
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.h	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/libunattended.h	2012-01-10
05:43:44.000000000 +0200
@@ -0,0 +1,27 @@
+#ifndef __libunattended_h__
+#define __libunattended_h__
+
+#include <string>
+using namespace std;
+
+class LibUnattended
+{
+  public:
+    LibUnattended();
+    void cretaeIsoLinuxFolder(string strMachineFolder);
+    string& replaceAll(string& context, const string& from, const string& to);
+    string readFileToString(string strReadfilepath);
+    void writeStringToFile(string strWritefilepath, string strData);
+    void prepareGenericScript(string strTemplateFilePath, string
strTargetFilePath,
+      string user, string password, string ProductKey, string arch);
+    void prepareFormattedFloppy(string strFloppyImagePath);
+    void copyFilesToFloppy(string strFloppyImagePath, string file1,
string file2);
+    void extractLinuxAdditionsFromISO(string target_path, string
VBoxGuestAdditionsISO);
+    void prepareUnattendedLinuxCD(string isopath, string sourcepath,
string isolinuxpath);
+
+    void extractFromRedHatISO(string isopath, string target_path,
string VBoxGuestAdditionsISO);
+    void extractFromDebianISO(string isopath, string target_path,
string VBoxGuestAdditionsISO);
+    void extractFromSuseISO(string isopath, string target_path,
string VBoxGuestAdditionsISO, string arch);
+};
+
+#endif // __libunattended_h__
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp	2012-01-10
07:05:17.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp	2012-01-10
06:01:35.000000000 +0200
@@ -28,10 +28,22 @@
 #include "UIMessageCenter.h"
 #include "UIMachineSettingsStorage.h"
 #include "VBoxDefs.h"
+#include "libunattended.h"

 /* Using declarations: */
 using namespace VBoxGlobalDefs;

+bool g_bUnattendedEnabled = false;
+QString g_strPathCDROM1="abc.iso";
+QString g_strPathCDROM2="abc.iso";
+QString g_strISOpath;
+QString g_strUser;
+QString g_strPassword;
+QString g_strProductKey;
+QString g_strMachineFolder;
+;
+#include <QMessageBox>
+
 /* Globals */
 struct osTypePattern
 {
@@ -143,9 +155,12 @@
     /* Create & add pages */
     addPage(new UINewVMWzdPage1);
     addPage(new UINewVMWzdPage2);
+    addPage(new UINewVMWzdPageU);
     addPage(new UINewVMWzdPage3);
     addPage(new UINewVMWzdPage4);
     addPage(new UINewVMWzdPage5);
+
+    g_bUnattendedEnabled = false;

     /* Initial translate */
     retranslateUi();
@@ -218,11 +233,32 @@
             this, SLOT(sltNameChanged(const QString&)));
     connect(m_pTypeSelector, SIGNAL(osTypeChanged()),
             this, SLOT(sltOsTypeChanged()));
+    connect(m_pUnattendedCheckBox, SIGNAL(clicked()),
+            this, SLOT(sltUnattendedChanged()));

     /* Setup contents */
     m_pTypeSelector->activateLayout();
 }

+void UINewVMWzdPage2::testUnattendedAvailability()
+{
+    /*This function tests if current guest OS supports unattended installs*/
+    QString type = field("type").value<CGuestOSType>().GetId();
+
+    if (type.contains("Windows200") || // 2000 / 2003 / 2008
+        type.contains("WindowsXP") || type.contains("WindowsVista") ||
+        type.contains("Windows7") || type.contains("RedHat") ||
+        type.contains("SUSE") || type.contains("Debian"))
+    {
+      m_pUnattendedCheckBox->setEnabled(true);
+    }
+    else // Default:
+    {
+      g_bUnattendedEnabled=false;
+      m_pUnattendedCheckBox->setEnabled(false);
+      m_pUnattendedCheckBox->setChecked(false);
+    }
+}
 void UINewVMWzdPage2::sltNameChanged(const QString &strNewText)
 {
     /* Search for a matching OS type based on the string the user typed
@@ -235,6 +271,8 @@
             m_pTypeSelector->blockSignals(false);
             break;
         }
+
+    testUnattendedAvailability();
 }

 void UINewVMWzdPage2::sltOsTypeChanged()
@@ -243,6 +281,13 @@
      * type guessing anymore. So simply disconnect the text edit signal. */
     disconnect(m_pNameEditor, SIGNAL(textChanged(const QString&)),
                this, SLOT(sltNameChanged(const QString&)));
+
+    testUnattendedAvailability();
+}
+
+void UINewVMWzdPage2::sltUnattendedChanged()
+{
+    g_bUnattendedEnabled = m_pUnattendedCheckBox->checkState();
 }

 void UINewVMWzdPage2::retranslateUi()
@@ -259,8 +304,9 @@
     /* Fill and translate */
     retranslateUi();

-    /* 'Name' field should have focus initially */
+    /* 'Name' field should have focus initially */
     m_pNameEditor->setFocus();
+
 }

 void UINewVMWzdPage2::cleanupPage()
@@ -303,6 +349,7 @@

     /* Initialize machine dir value: */
     m_strMachineFolder = strMachineFolder;
+    g_strMachineFolder = strMachineFolder;
     return true;
 }

@@ -328,6 +375,7 @@
 void UINewVMWzdPage2::setMachineFolder(const QString &strMachineFolder)
 {
     m_strMachineFolder = strMachineFolder;
+    g_strMachineFolder = strMachineFolder;
 }

 UINewVMWzdPage3::UINewVMWzdPage3()
@@ -776,9 +824,9 @@
             usbController.SetEnabledEhci(true);
     }

-    /* Create a floppy controller if recommended */
+    /* Create a floppy controller if recommended, or if required by
Unattended Install */
     QString ctrFloppyName = getNextControllerName(KStorageBus_Floppy);
-    if (type.GetRecommendedFloppy()) {
+    if (type.GetRecommendedFloppy() || unattendedRequiresFloppy(type)) {
         m_Machine.AddStorageController(ctrFloppyName, KStorageBus_Floppy);
         CStorageController flpCtr =
m_Machine.GetStorageControllerByName(ctrFloppyName);
         flpCtr.SetControllerType(KStorageControllerType_I82078);
@@ -882,14 +930,19 @@

StorageSlot(ctrHdBus, 0, 0), this);
             }

-            /* Attach empty CD/DVD ROM Device */
-            m.AttachDevice(ctrDvdName, 1, 0, KDeviceType_DVD, CMedium());
-            if (!m.isOk())
-                msgCenter().cannotAttachDevice(m,
VBoxDefs::MediumType_DVD, QString(), StorageSlot(ctrDvdBus, 1, 0),
this);
+            /* Attach a CD/DVD ROM Device */
+            if (g_bUnattendedEnabled)
+            {
+                constructUnattendedMachine(m, type, ctrDvdName, ctrFloppyName);
+            }
+            else
+                m.AttachDevice(ctrDvdName, 1, 0, KDeviceType_DVD, CMedium());
+                if (!m.isOk())
+                    msgCenter().cannotAttachDevice(m,
VBoxDefs::MediumType_DVD, QString(), StorageSlot(ctrDvdBus, 1, 0),
this);


-            /* Attach an empty floppy drive if recommended */
-            if (type.GetRecommendedFloppy()) {
+            /* Attach an empty floppy drive if recommended, when not
in unattended install mode */
+            if (type.GetRecommendedFloppy() && (!g_bUnattendedEnabled)) {
                 m.AttachDevice(ctrFloppyName, 0, 0,
KDeviceType_Floppy, CMedium());
                 if (!m.isOk())
                     msgCenter().cannotAttachDevice(m,
VBoxDefs::MediumType_Floppy, QString(),
@@ -987,3 +1040,268 @@
 {
     m_Machine = machine;
 }
+
+bool UINewVMWzdPage5::unattendedRequiresFloppy(CGuestOSType &type)
+{
+    if (!g_bUnattendedEnabled)  return false;
+    QString ostype = field("type").value<CGuestOSType>().GetId();
+    if (ostype.contains("Windows") || ostype.contains("Debian"))
+        return true;
+    else
+        return false;
+}
+
+void UINewVMWzdPage5::constructUnattendedMachine(CMachine &machine,
+  CGuestOSType &type, QString &ctrDvdName, QString &ctrFloppyName)
+{
+    /*This function prepares the VM for unattended install,
+    by generating custom CD ISO and floppy images, and attaching
+    them to VM.*/
+    CMachine m = machine;
+    // boot order: HDD->CD-ROM->Floppy (first number = boot priority)
+    // second number = device. devices: 1 = floppy, 2 = CD, 3 = HDD,
4 = Network (PXE)
+    m.SetBootOrder(1, KDeviceType_HardDisk);
+    m.SetBootOrder(2, KDeviceType_DVD);
+    m.SetBootOrder(3, KDeviceType_Floppy);
+
+    //////////////////////////////////////////////////////////////////////////
+    // Here we will generate the necessary ISO and Floppy Images            //
+    //////////////////////////////////////////////////////////////////////////
+    QString ostype = field("type").value<CGuestOSType>().GetId();
+    QString pathFloppy = g_strMachineFolder+"/floppy_script.img";
+    QString pathCDcustom = "";
+    QString VBoxGuestAdditionsISO = "/tmp/VBoxGuestAdditions.iso";
+    QMessageBox msgBox;
+    msgBox.setText(pathFloppy);
+    msgBox.exec();
+
+    QString arch = "x86";
+    if (ostype.contains(64)) arch = "x64";
+    //*
+    LibUnattended libunattended;
+    libunattended.cretaeIsoLinuxFolder(g_strMachineFolder.toStdString());
+
+    if (ostype.contains("Windows"))
+    {
+        QString winNT5_Target_File = g_strMachineFolder+"/winnt.sif";
+        QString winNT6_Target_File = g_strMachineFolder+"/autounattend.xml";
+        libunattended.prepareFormattedFloppy(pathFloppy.toStdString());
+        // NT5
+        libunattended.prepareGenericScript("/tmp/win_nt5_template_winnt.sif",
+                                          winNT5_Target_File.toStdString(),
+                                          g_strUser.toStdString(),
+                                          g_strPassword.toStdString(),
+                                          g_strProductKey.toStdString(),
+                                          "");
+        // NT6
+        libunattended.prepareGenericScript("/tmp/win_nt6_template_autounattend.xml",
+                                          winNT6_Target_File.toStdString(),
+                                          g_strUser.toStdString(),
+                                          g_strPassword.toStdString(),
+                                          g_strProductKey.toStdString(),
+                                          arch.toStdString());
+
+        libunattended.copyFilesToFloppy(pathFloppy.toStdString(),
+                                        winNT5_Target_File.toStdString(),
+                                        winNT6_Target_File.toStdString());
+    }
+    else if (ostype.contains("Debian"))
+    {
+        QString debarch="386";
+        if (ostype.contains(64)) debarch = "amd";
+        pathCDcustom = g_strMachineFolder+"/debian_boot.iso";
+
+        libunattended.prepareFormattedFloppy(pathFloppy.toStdString());
+        libunattended.extractFromDebianISO(g_strISOpath.toStdString(),
+                                           "/tmp/bootiso/",
+
VBoxGuestAdditionsISO.toStdString());
+        // prepares Debian preseed script
+        libunattended.prepareGenericScript("/tmp/linux_debian_template_preseed.cfg",
+                                           "/tmp/bootiso/preseed.cfg",
+                                            g_strUser.toStdString(),
+                                            g_strPassword.toStdString(),
+                                            g_strProductKey.toStdString(),
+                                            "");
+
+        // prepares Debian isolinux script
+        libunattended.prepareGenericScript("/tmp/linux_debian_template_isolinux.cfg",
+
"/tmp/bootiso/isolinux/isolinux.cfg",
+                                            "",
+                                            "",
+                                            "",
+                                            debarch.toStdString());
+        libunattended.prepareUnattendedLinuxCD(pathCDcustom.toStdString(),
"/tmp/bootiso/", "isolinux/");
+        libunattended.copyFilesToFloppy(pathFloppy.toStdString(),
"/tmp/bootiso/preseed.cfg", "");
+    }
+    else if (ostype.contains("RedHat"))
+    {
+        pathFloppy = "";  // disable floppy
+        pathCDcustom = g_strMachineFolder+"/redhat_boot.iso";
+    }
+    else if (ostype.contains("SUSE"))
+    {
+        pathFloppy = "";  // disable floppy
+        pathCDcustom = g_strMachineFolder+"/suse_boot.iso";
+        QString susearch="i386";
+        if (ostype.contains(64)) susearch = "amd64";
+        libunattended.extractFromSuseISO(g_strISOpath.toStdString(),
+                           "/tmp/bootiso/",
+                           VBoxGuestAdditionsISO.toStdString(),
+                           susearch.toStdString());
+
+        // prepares SUSE autoyast script
+        libunattended.prepareGenericScript("/tmp/linux_suse_template_autoinst.xml",
+                                           "/tmp/bootiso/autoinst.xml",
+                                            g_strUser.toStdString(),
+                                            g_strPassword.toStdString(),
+                                            "",
+                                            "");
+
+        // prepares SUSE isolinux script
+        libunattended.prepareGenericScript("/tmp/linux_suse_template_isolinux.cfg",
+                                           "/tmp/bootiso/isolinux.cfg",
+                                            "",
+                                            "",
+                                            "",
+                                            susearch.toStdString());
+        libunattended.prepareUnattendedLinuxCD(pathCDcustom.toStdString(),
"/tmp/bootiso/", "");
+    }
+    else
+    {
+        // Unsupported guest OS
+        pathFloppy = "";  // disable floppy
+    }
+    //*/
+    if (pathFloppy != "")
+    {
+        // Attach unattended Floppy image to controller
+        QString myQfloppy =
vboxGlobal().openMedium(VBoxDefs::MediumType_Floppy, pathFloppy);
+        CMedium myCfloppy = vboxGlobal().findMedium(myQfloppy).medium();
+        m.AttachDevice(ctrFloppyName, 0, 0, KDeviceType_Floppy, myCfloppy);
+        if (!m.isOk())
+            msgCenter().cannotAttachDevice(m,
VBoxDefs::MediumType_Floppy, QString(),
+
StorageSlot(KStorageBus_Floppy, 0, 0), this);
+    }
+    // debug
+    //QMessageBox msgBox;
+    //msgBox.setText(ostype);
+    //msgBox.exec();
+
+    QString tempCD1, tempCD2;
+    QString myQmediumCD1, myQmediumCD2;
+    CMedium myCmediumCD1, myCmediumCD2;
+    // Windows boots from original CD, Linux must boot from custom-made CD:
+    // So for Linux guests we swap CD1 and CD2.
+    if (ostype.contains("SUSE") || ostype.contains("Debian") ||
ostype.contains("RedHat"))
+    {
+        tempCD1 = pathCDcustom;
+        tempCD2 = g_strISOpath;
+    }
+    else // Windows
+    {
+        tempCD1 = g_strISOpath;
+        tempCD2 = VBoxGuestAdditionsISO;
+    }
+    KStorageBus ctrDvdBus = type.GetRecommendedDvdStorageBus();
+
+    myQmediumCD1 = vboxGlobal().openMedium(VBoxDefs::MediumType_DVD, tempCD1);
+    myCmediumCD1 = vboxGlobal().findMedium(myQmediumCD1).medium();
+    m.AttachDevice(ctrDvdName, 1, 0, KDeviceType_DVD, myCmediumCD1);
+    if (!m.isOk())
+        msgCenter().cannotAttachDevice(m, VBoxDefs::MediumType_DVD,
QString(), StorageSlot(ctrDvdBus, 1, 0), this);
+
+    myQmediumCD2 = vboxGlobal().openMedium(VBoxDefs::MediumType_DVD, tempCD2);
+    myCmediumCD2 = vboxGlobal().findMedium(myQmediumCD2).medium();
+    m.AttachDevice(ctrDvdName, 1, 1, KDeviceType_DVD, myCmediumCD2);
+    if (!m.isOk())
+        msgCenter().cannotAttachDevice(m, VBoxDefs::MediumType_DVD,
QString(), StorageSlot(ctrDvdBus, 1, 1), this);
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+UINewVMWzdPageU::UINewVMWzdPageU()
+{
+    Ui::UINewVMWzdPageU::setupUi(this);
+
+    connect(m_pISOpathEditor, SIGNAL(textChanged(const QString&)),
+            this, SLOT(sltISOpathChanged(const QString&)));
+    connect(m_pUserEditor, SIGNAL(textChanged(const QString&)),
+            this, SLOT(sltUserChanged(const QString&)));
+    connect(m_pPasswordEditor, SIGNAL(textChanged(const QString&)),
+            this, SLOT(sltPasswordChanged(const QString&)));
+    connect(m_pProductKeyEditor, SIGNAL(textChanged(const QString&)),
+            this, SLOT(sltProductKeyChanged(const QString&)));
+}
+
+void UINewVMWzdPageU::sltISOpathChanged(const QString &strText)
+{
+    g_strISOpath = strText;
+}
+
+void UINewVMWzdPageU::sltUserChanged(const QString &strText)
+{
+    g_strUser = strText;
+}
+
+void UINewVMWzdPageU::sltPasswordChanged(const QString &strText)
+{
+    g_strPassword = strText;
+}
+
+void UINewVMWzdPageU::sltProductKeyChanged(const QString &strText)
+{
+    g_strProductKey = strText;
+}
+
+void UINewVMWzdPageU::retranslateUi()
+{
+    //Ui::UINewVMWzdPageU::retranslateUi(this);
+    setTitle(tr("Automated Installer!"));
+}
+
+void UINewVMWzdPageU::initializePage()
+{
+    /*This function passes parameters from the GUI dialog
+    to the variables. */
+    //retranslateUi();
+    //g_strPathCDROM1 = m_pISOpathEditor;
+    //g_strPathCDROM2 = "/opt/VirtualBox/additions/VBoxGuestAdditions.iso";
+    QString type = field("type").value<CGuestOSType>().GetId();
+    // Debug:
+    QMessageBox msgBox;
+    msgBox.setText(type);
+    msgBox.exec();
+
+    m_pISOpathEditor->setEnabled(true);
+    m_pUserEditor->setEnabled(true);
+    m_pPasswordEditor->setEnabled(true);
+    m_pProductKeyEditor->setEnabled(true);
+    if (g_bUnattendedEnabled && (type.contains("Windows200") || //
2000 / 2003 / 2008
+        type.contains("WindowsXP") || type.contains("WindowsVista") ||
+        type.contains("Windows7")))
+    {
+      true;
+    }
+    else if (g_bUnattendedEnabled && (type.contains("RedHat") ||
+        type.contains("SUSE") || type.contains("Debian")))
+    {
+        m_pProductKeyEditor->setEnabled(false);
+    }
+    else // Default:
+    {
+      m_pISOpathEditor->setEnabled(false);
+      m_pUserEditor->setEnabled(false);
+      m_pPasswordEditor->setEnabled(false);
+      m_pProductKeyEditor->setEnabled(false);
+    }
+}
+
+bool UINewVMWzdPageU::isComplete() const
+{
+    return true;
+}
+
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.h
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.h
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.h	2012-01-10
07:05:17.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.h	2012-01-10
03:49:17.000000000 +0200
@@ -28,6 +28,7 @@
 /* Generated includes */
 #include "UINewVMWzdPage1.gen.h"
 #include "UINewVMWzdPage2.gen.h"
+#include "UINewVMWzdPageU.gen.h"
 #include "UINewVMWzdPage3.gen.h"
 #include "UINewVMWzdPage4.gen.h"
 #include "UINewVMWzdPage5.gen.h"
@@ -75,6 +76,7 @@

     void sltNameChanged(const QString &strNewText);
     void sltOsTypeChanged();
+    void sltUnattendedChanged();

 protected:

@@ -82,6 +84,7 @@

     void initializePage();
     void cleanupPage();
+    void testUnattendedAvailability();

     bool validatePage();

@@ -186,6 +189,10 @@
 private:

     bool constructMachine();
+    void constructUnattendedMachine(CMachine &machine, CGuestOSType &type,
+                                    QString &ctrDvdName,
+                                    QString &ctrFloppyName);
+    bool unattendedRequiresFloppy(CGuestOSType &type);

     CMachine machine() const;
     void setMachine(const CMachine &machine);
@@ -199,5 +206,25 @@
     int m_iSASCount;
 };

+class UINewVMWzdPageU : public QIWizardPage, public Ui::UINewVMWzdPageU
+{
+    Q_OBJECT;
+
+public:
+    UINewVMWzdPageU();
+
+protected:
+    void retranslateUi();
+    void initializePage();
+    bool isComplete() const;
+
+protected slots:
+    void sltISOpathChanged(const QString &strText);
+    void sltUserChanged(const QString &strText);
+    void sltPasswordChanged(const QString &strText);
+    void sltProductKeyChanged(const QString &strText);
+
+};
+
 #endif // __UINewVMWzd_h__

diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage2.ui
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage2.ui
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage2.ui	2012-01-10
07:05:17.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage2.ui	2012-01-10
01:25:12.000000000 +0200
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <comment>
- VBox frontends: Qt4 GUI ("VirtualBox"):
+ VBox frontends: Qt4 GUI (&quot;VirtualBox&quot;):

      Copyright (C) 2009 Oracle Corporation

@@ -9,18 +9,12 @@
      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
+     Foundation, in version 2 as it comes in the &quot;COPYING&quot;
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.
  </comment>
  <class>UINewVMWzdPage2</class>
  <widget class="QWidget" name="UINewVMWzdPage2">
-  <property name="sizePolicy">
-   <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
-    <horstretch>0</horstretch>
-    <verstretch>0</verstretch>
-   </sizepolicy>
-  </property>
   <property name="geometry">
    <rect>
     <x>0</x>
@@ -36,7 +30,7 @@
    </sizepolicy>
   </property>
   <layout class="QVBoxLayout" name="m_pLayout1">
-   <property name="bottomMargin" >
+   <property name="bottomMargin">
     <number>0</number>
    </property>
    <item>
@@ -74,7 +68,17 @@
     </widget>
    </item>
    <item>
+    <widget class="QCheckBox" name="m_pUnattendedCheckBox">
+     <property name="text">
+      <string>Auto&amp;mated Install</string>
+     </property>
+    </widget>
+   </item>
+   <item>
     <spacer name="m_pSpacer1">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
      <property name="sizeHint" stdset="0">
       <size>
        <width>0</width>
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPageU.ui
1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPageU.ui
--- 2//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPageU.ui	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPageU.ui	2012-01-08
16:20:19.000000000 +0200
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <comment>
+     Copyright (C) 2012 by Alexey Eromenko "Technologov"
+ </comment>
+ <class>UINewVMWzdPageU</class>
+ <widget class="QWidget" name="UINewVMWzdPageU">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>600</width>
+    <height>400</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0" colspan="2">
+    <widget class="QLabel" name="label_11">
+     <property name="text">
+      <string>General Virtual Machine settings:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="2">
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Path to ISO / DVD</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="m_pISOpathEditor"/>
+     </item>
+     <item>
+      <widget class="QToolButton" name="toolButton">
+       <property name="text">
+        <string>...</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QLabel" name="label_8">
+     <property name="text">
+      <string>Enter specific unattended virtual machine install
settings:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>user</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1">
+    <widget class="QLineEdit" name="m_pUserEditor"/>
+   </item>
+   <item row="5" column="0">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>password [1]</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1">
+    <widget class="QLineEdit" name="m_pPasswordEditor"/>
+   </item>
+   <item row="6" column="0">
+    <widget class="QLabel" name="label_5">
+     <property name="text">
+      <string>product key [2]</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="1">
+    <widget class="QLineEdit" name="m_pProductKeyEditor"/>
+   </item>
+   <item row="7" column="0" colspan="2">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>[1] password is both for 'user' and for
'root'/Administrator</string>
+     </property>
+    </widget>
+   </item>
+   <item row="8" column="0" colspan="2">
+    <widget class="QLabel" name="label_6">
+     <property name="text">
+      <string>[2] is required for Windows guests only; else ignored.</string>
+     </property>
+    </widget>
+   </item>
+   <item row="9" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff -uNr 2//vbox/src/VBox/Frontends/VirtualBox/VBoxUI.pro
1//vbox/src/VBox/Frontends/VirtualBox/VBoxUI.pro
--- 2//vbox/src/VBox/Frontends/VirtualBox/VBoxUI.pro	2012-01-10
07:05:17.000000000 +0200
+++ 1//vbox/src/VBox/Frontends/VirtualBox/VBoxUI.pro	2012-01-08
16:20:45.000000000 +0200
@@ -52,9 +52,11 @@
     src/wizards/clonevm/UICloneVMWizardPage3.ui \
     src/wizards/newvm/UINewVMWzdPage1.ui \
     src/wizards/newvm/UINewVMWzdPage2.ui \
+    src/wizards/newvm/UINewVMWzdPageU.ui \
     src/wizards/newvm/UINewVMWzdPage3.ui \
     src/wizards/newvm/UINewVMWzdPage4.ui \
     src/wizards/newvm/UINewVMWzdPage5.ui \
+    src/wizards/newvm/UINewVMWzdPage6.ui \
     src/wizards/newhd/UINewHDWizardPageWelcome.ui \
     src/wizards/newhd/UINewHDWizardPageFormat.ui \
     src/wizards/newhd/UINewHDWizardPageVariant.ui \
diff -uNr 2//vbox/vbox-unattended/linux_debian_template_isolinux.cfg
1//vbox/vbox-unattended/linux_debian_template_isolinux.cfg
--- 2//vbox/vbox-unattended/linux_debian_template_isolinux.cfg	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_debian_template_isolinux.cfg	2012-01-03
20:32:26.000000000 +0200
@@ -0,0 +1,8 @@
+default debian
+prompt 0
+timeout 1
+
+label debian
+  kernel /install.$arch/vmlinuz
+  append initrd=/install.$arch/initrd.gz
debian-installer/locale=en_US console-setup/layoutcode=us
netcfg/choose_interface=auto priority=critical
preseed/file=/floppy/preseed.cfg --
+  #append video=vesa:ywrap,mtrr vga=788
initrd=/install.$arch/gtk/initrd.gz auto-install/enabled=true
netcfg/choose_interface=auto priority=critical
preseed/file=/floppy/preseed.cfg --
diff -uNr 2//vbox/vbox-unattended/linux_debian_template_preseed.cfg
1//vbox/vbox-unattended/linux_debian_template_preseed.cfg
--- 2//vbox/vbox-unattended/linux_debian_template_preseed.cfg	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_debian_template_preseed.cfg	2012-01-02
15:00:52.000000000 +0200
@@ -0,0 +1,63 @@
+d-i debian-installer/locale string en_US
+d-i console-keymaps-at/keymap select us
+
+# network config
+d-i netcfg/choose_interface select auto
+d-i netcfg/get_hostname string localhost
+d-i netcfg/get_domain string localdomain
+d-i netcfg/disable_dhcp     boolean false
+
+# time & clock
+d-i clock-setup/ntp boolean false
+d-i clock-setup/utc boolean true
+d-i time/zone select US/Eastern
+
+# HDD partitioning + format
+d-i partman-auto/method string regular
+d-i partman-auto/choose_recipe select atomic
+d-i partman/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+
+# users
+d-i passwd/root-login boolean true
+d-i passwd/root-password password $password
+d-i passwd/root-password-again password $password
+d-i passwd/user-fullname string $user
+d-i passwd/username string $user
+d-i passwd/user-password password $password
+d-i passwd/user-password-again password $password
+
+# packages
+tasksel tasksel/first multiselect standard, desktop
+tasksel tasksel/desktop multiselect kde
+d-i pkgsel/include string openssh-server build-essential autoconf dkms synaptic
+d-i pkgsel/upgrade select none
+popularity-contest popularity-contest/participate boolean true
+
+# silence extra repositories, grub and reboot
+d-i apt-setup/security_host string
+d-i apt-setup/volatile_host string
+d-i apt-setup/services-select multiselect
+d-i grub-installer/only_debian boolean true
+d-i finish-install/reboot_in_progress note
+
+# custom scripts; Step is done in d-i after installed all packages,
but before guest OS reboot:
+# It is generating "rc.local" file, which will act as first-boot
script, after reboot:
+d-i preseed/late_command string \
+mv /target/etc/rc.local /target/etc/rc.local.backup; \
+echo false > /target/etc/X11/default-display-manager; \
+echo '#!/bin/bash' > /target/etc/rc.local;\
+echo 'mkdir /mnt/cdrom' >> /target/etc/rc.local;\
+echo 'echo' >> /target/etc/rc.local;\
+echo 'echo "Installing VirtualBox Guest Additions..."' >>
/target/etc/rc.local;\
+echo 'mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom' >> /target/etc/rc.local;\
+echo 'bash /mnt/cdrom/VBoxLinuxAdditions.run' >> /target/etc/rc.local;\
+echo 'eject /dev/cdrom' >> /target/etc/rc.local;\
+echo 'usermod -a -G vboxsf $user' >> /target/etc/rc.local;\
+echo 'echo "/usr/bin/kdm" >/etc/X11/default-display-manager' >>
/target/etc/rc.local;\
+echo 'mv /etc/rc.local.backup /etc/rc.local' >> /target/etc/rc.local;\
+echo '/etc/init.d/kdm start &' >> /target/etc/rc.local;\
+echo 'exit 0' >> /target/etc/rc.local;\
+chmod a+rx /target/etc/rc.local
\ No newline at end of file
diff -uNr 2//vbox/vbox-unattended/linux_rhel_template_isolinux.cfg
1//vbox/vbox-unattended/linux_rhel_template_isolinux.cfg
--- 2//vbox/vbox-unattended/linux_rhel_template_isolinux.cfg	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_rhel_template_isolinux.cfg	2011-12-31
20:51:20.000000000 +0200
@@ -0,0 +1,7 @@
+default redhat
+prompt 0
+timeout 1
+
+label redhat
+  kernel vmlinuz
+  append initrd=initrd.img  ks=cdrom:/ks.cfg
diff -uNr 2//vbox/vbox-unattended/linux_rhel_template_ks.cfg
1//vbox/vbox-unattended/linux_rhel_template_ks.cfg
--- 2//vbox/vbox-unattended/linux_rhel_template_ks.cfg	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_rhel_template_ks.cfg	2012-01-01
18:30:31.000000000 +0200
@@ -0,0 +1,46 @@
+lang en_US
+langsupport --default en_US
+network --bootproto dhcp
+cdrom
+keyboard us
+zerombr yes
+clearpart --all
+part / --size 3000 --grow
+part swap --recommended
+install
+mouse generic3ps/2
+firewall --enabled
+timezone --utc Europe/London
+xconfig --resolution=800x600
+rootpw $password
+reboot
+auth --useshadow --enablemd5
+bootloader --location=mbr
+key --skip
+%packages --resolvedeps
+kernel-source
+@ X Window System
+@ GNOME Desktop Environment
+@ Graphical Internet
+@ Development Tools
+
+# "post" step is done in Anaconda right after all packages are
installed, but before reboot.
+%post --log=/root/ks-post.log
+/usr/sbin/adduser $user
+/usr/sbin/usermod -p $userpassword_encrypted $user
+mkdir -p /mnt/cdrom
+sed -i 's/GRAPHICAL=yes/GRAPHICAL=no/' /etc/sysconfig/init
+cp /etc/rc.d/rc.local /etc/rc.local.backup
+
+# Generating "rc.local" file, which will act as first-boot script,
after reboot:
+cat >>/etc/rc.d/rc.local <<EOF
+echo
+echo "Installing VirtualBox Guest Additions..."
+mount -t iso9660 -o ro /dev/hdc /mnt/cdrom
+bash /mnt/cdrom/VBoxLinuxAdditions.run
+eject /dev/hdc
+usermod -a -G vboxsf $user
+sed -i 's/GRAPHICAL=no/GRAPHICAL=yes/' /etc/sysconfig/init
+mv /etc/rc.local.backup /etc/rc.d/rc.local
+init 5
+EOF
\ No newline at end of file
diff -uNr 2//vbox/vbox-unattended/linux_suse_template_autoinst.xml
1//vbox/vbox-unattended/linux_suse_template_autoinst.xml
--- 2//vbox/vbox-unattended/linux_suse_template_autoinst.xml	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_suse_template_autoinst.xml	2012-01-10
06:18:06.000000000 +0200
@@ -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>
\ No newline at end of file
diff -uNr 2//vbox/vbox-unattended/linux_suse_template_isolinux.cfg
1//vbox/vbox-unattended/linux_suse_template_isolinux.cfg
--- 2//vbox/vbox-unattended/linux_suse_template_isolinux.cfg	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/linux_suse_template_isolinux.cfg	2012-01-10
06:22:01.000000000 +0200
@@ -0,0 +1,7 @@
+default suse
+prompt 0
+timeout 1
+
+label suse
+  kernel linux
+  append initrd=initrd splash=silent instmode=cd
autoyast=device://cdrom1/autoinst.xml
diff -uNr 2//vbox/vbox-unattended/win_nt5_template_winnt.sif
1//vbox/vbox-unattended/win_nt5_template_winnt.sif
--- 2//vbox/vbox-unattended/win_nt5_template_winnt.sif	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/win_nt5_template_winnt.sif	2012-01-10
04:10:20.000000000 +0200
@@ -0,0 +1,44 @@
+[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 = "$password"
+AutoLogon = Yes
+AutoLogonCount = 1
+OEMSkipRegional = 1
+OemSkipWelcome = 1
+TimeZone = 85
+ServerWelcome = No
+
+[UserData]
+ProductKey = "$ProductKey"
+FullName = "$user"
+OrgName = ""
+ComputerName = *
+
+[Identification]
+JoinWorkgroup = WORKGROUP
+
+[Networking]
+InstallDefaultComponents = Yes
+
+[Display]
+XResolution = 800
+YResolution = 600
+BitsPerPel = 32
+
+[GuiRunOnce]
+Command0="E:\VBoxWindowsAdditions.exe /S /xres=800 /yres=600 /depth=32"
+Command1="shutdown -r -t 0"
diff -uNr 2//vbox/vbox-unattended/win_nt6_template_autounattend.xml
1//vbox/vbox-unattended/win_nt6_template_autounattend.xml
--- 2//vbox/vbox-unattended/win_nt6_template_autounattend.xml	1970-01-01
02:00:00.000000000 +0200
+++ 1//vbox/vbox-unattended/win_nt6_template_autounattend.xml	2012-01-10
04:04:09.000000000 +0200
@@ -0,0 +1,108 @@
+<?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="$arch" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS">
+      <InputLocale>en-US</InputLocale>
+      <SystemLocale>en-US</SystemLocale>
+      <UILanguage>en-US</UILanguage>
+      <UserLocale>en-US</UserLocale>
+    </component>
+
+    <component name="Microsoft-Windows-Setup"
processorArchitecture="$arch" 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>$ProductKey</Key>
+        <WillShowUI>OnError</WillShowUI>
+      </ProductKey>
+      <AcceptEula>true</AcceptEula>
+    </UserData>
+
+    <ImageInstall>
+      <OSImage>
+        <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="oobeSystem">
+    <component name="Microsoft-Windows-Shell-Setup"
processorArchitecture="$arch" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS">
+      <AutoLogon>
+      <Password>
+        <Value>$password</Value>
+        <PlainText>true</PlainText>
+      </Password>
+      <Enabled>true</Enabled>
+      <Username>$user</Username>
+      </AutoLogon>
+
+      <UserAccounts>
+      <LocalAccounts>
+        <LocalAccount wcm:action="add">
+        <Name>$user</Name>
+        <Group>administrators;users</Group>
+        <Password>
+          <Value>$password</Value>
+          <PlainText>true</PlainText>
+        </Password>
+        </LocalAccount>
+      </LocalAccounts>
+      </UserAccounts>
+
+      <VisualEffects>
+        <FontSmoothing>ClearType</FontSmoothing>
+      </VisualEffects>
+
+      <OOBE>
+        <ProtectYourPC>3</ProtectYourPC>
+        <HideEULAPage>true</HideEULAPage>
+        <SkipUserOOBE>true</SkipUserOOBE>
+        <SkipMachineOOBE>true</SkipMachineOOBE>
+        <NetworkLocation>Home</NetworkLocation>
+      </OOBE>
+
+      <FirstLogonCommands>
+        <SynchronousCommand wcm:action="add">
+          <Order>1</Order>
+          <Description>Turn Off Network Selection pop-up</Description>
+          <CommandLine>cmd /c reg add
"HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff"</CommandLine>
+        </SynchronousCommand>
+        <SynchronousCommand wcm:action="add">
+          <Order>2</Order>
+          <Description>Install VirtualBox Guest Additions</Description>
+          <CommandLine>E:\VBoxWindowsAdditions.exe</CommandLine>
+        </SynchronousCommand>
+      </FirstLogonCommands>
+
+      <TimeZone>GMT Standard Time</TimeZone>
+    </component>
+
+  </settings>
+
+</unattend>


-- 
-Alexey Eromenko "Technologov"




More information about the vbox-dev mailing list