[gnome-boxes] Use provided username & password in express install
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Use provided username & password in express install
- Date: Sat, 5 Nov 2011 00:48:45 +0000 (UTC)
commit 6c4109ca86c424dfb4fec99e1ff1551b898c7893
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat Nov 5 02:32:52 2011 +0200
Use provided username & password in express install
data/ks.cfg | 2 ++
data/win2k.sif | 4 ++--
data/win2k3.sif | 4 ++--
data/winxp.sif | 4 ++--
src/unattended-installer.vala | 38 +++++++++++++++++++++++++++++++++++---
5 files changed, 43 insertions(+), 9 deletions(-)
---
diff --git a/data/ks.cfg b/data/ks.cfg
index 5c348ef..e10a6ff 100644
--- a/data/ks.cfg
+++ b/data/ks.cfg
@@ -20,6 +20,8 @@ logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=768 --grow
logvol / --fstype ext4 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
reboot
+user --name=BOXES_USERNAME --password=BOXES_PASSWORD
+
%packages
@base
@core
diff --git a/data/win2k.sif b/data/win2k.sif
index d0a0a19..07c859d 100644
--- a/data/win2k.sif
+++ b/data/win2k.sif
@@ -23,8 +23,8 @@
[UserData]
ProductID=
- FullName="OZ"
- ComputerName=Whatever
+ FullName="BOXES_USERNAME"
+ ComputerName=BOXES_HOSTNAME
[Display]
BitsPerPel=16
diff --git a/data/win2k3.sif b/data/win2k3.sif
index e888fd1..0daa3aa 100644
--- a/data/win2k3.sif
+++ b/data/win2k3.sif
@@ -24,9 +24,9 @@
[UserData]
ProductKey=
- FullName="OZ"
+ FullName="BOXES_USERNAME"
OrgName=""
- ComputerName=Whatever
+ ComputerName=BOXES_HOSTNAME
[LicenseFilePrintData]
AutoMode=PerServer
diff --git a/data/winxp.sif b/data/winxp.sif
index c860bff..0daa3aa 100644
--- a/data/winxp.sif
+++ b/data/winxp.sif
@@ -24,9 +24,9 @@
[UserData]
ProductKey=
- FullName="OZ"
+ FullName="BOXES_USERNAME"
OrgName=""
- ComputerName=Nothing
+ ComputerName=BOXES_HOSTNAME
[LicenseFilePrintData]
AutoMode=PerServer
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index b8acd71..55ca99d 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -25,6 +25,9 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
protected Gtk.Entry username_entry;
protected Gtk.Entry password_entry;
+ private Regex username_regex;
+ private Regex password_regex;
+
public UnattendedInstaller.copy (InstallerMedia media,
string unattended_src_path,
string unattended_dest_name) throws GLib.Error {
@@ -38,6 +41,9 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
this.unattended_src_path = unattended_src_path;
this.unattended_dest_name = unattended_dest_name;
+ username_regex = new Regex ("BOXES_USERNAME");
+ password_regex = new Regex ("BOXES_PASSWORD");
+
setup_ui ();
}
@@ -187,13 +193,39 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
}
private async void copy_unattended_file (Cancellable? cancellable) throws GLib.Error {
- debug ("Putting unattended file: %s", unattended_dest_name);
+ var unattended_src = File.new_for_path (unattended_src_path);
+ var unattended_tmp_path = get_unattended_dir (unattended_dest_name);
+ var unattended_tmp = File.new_for_path (unattended_tmp_path);
+
+ debug ("Creating unattended file at '%s'..", unattended_tmp_path);
+ var input_stream = yield unattended_src.read_async (Priority.DEFAULT, cancellable);
+ var output_stream = yield unattended_tmp.replace_async (null,
+ false,
+ FileCreateFlags.REPLACE_DESTINATION,
+ Priority.DEFAULT,
+ cancellable);
+ var buffer = new uint8[1024];
+ size_t bytes_read;
+ while ((bytes_read = yield input_stream.read_async (buffer, Priority.DEFAULT, cancellable)) > 0) {
+ var str = ((string) buffer).substring (0, (long) bytes_read);
+ str = username_regex.replace (str, str.length, 0, username_entry.text);
+ str = password_regex.replace (str, str.length, 0, password_entry.text);
+ yield output_stream.write_async (str.data, Priority.DEFAULT, cancellable);
+ }
+ yield output_stream.close_async (Priority.DEFAULT, cancellable);
+ debug ("Created unattended file at '%s'..", unattended_tmp_path);
+
+ debug ("Copying unattended file '%s' into floppy drive/image '%s'", unattended_dest_name, floppy_path);
// FIXME: Perhaps we should use libarchive for this?
string[] argv = { "mcopy", "-i", floppy_path,
- unattended_src_path,
+ unattended_tmp_path,
"::" + unattended_dest_name };
yield exec (argv, cancellable);
- debug ("Put unattended file: %s", unattended_dest_name);
+ debug ("Copied unattended file '%s' into floppy drive/image '%s'", unattended_dest_name, floppy_path);
+
+ debug ("Deleting temporary file '%s'", unattended_tmp_path);
+ unattended_tmp.delete (cancellable);
+ debug ("Deleted temporary file '%s'", unattended_tmp_path);
}
private async bool unattended_floppy_exists (Cancellable? cancellable) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]