Subject: [PATCH] Add ability to set a command for firstboot and not
only a
script
In principle yes, in practice this patch isn't right:
---
sysprep/sysprep_operation_firstboot.ml | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/sysprep/sysprep_operation_firstboot.ml
b/sysprep/sysprep_operation_firstboot.ml
index 3473c47..6f61d15 100644
--- a/sysprep/sysprep_operation_firstboot.ml
+++ b/sysprep/sysprep_operation_firstboot.ml
@@ -24,20 +24,23 @@ open Common_gettext.Gettext
module G = Guestfs
-let files = ref []
+let params = ref []
let firstboot_perform g root =
- (* Read the files and add them using the {!Firstboot} module. *)
- let files = List.rev !files in
+ (* Read command or files and add them using the {!Firstboot} module. *)
+ let params = List.rev !params in
let i = ref 0 in
List.iter (
- fun filename ->
+ fun param->
incr i;
let i = !i in
- let content = read_whole_file filename in
- Firstboot.add_firstboot_script g root i content
- ) files;
- if files <> [] then [ `Created_files ] else []
+ if Sys.file_exists param then
The trouble here is depending on the existence of a local file this
fragile. You wouldn't find out that you'd made a mistake on the
command line until much later on (at first boot of the guest).
In virt-builder we're doing something better, I think. Firstly there
are --firstboot & --firstboot-command options:
http://libguestfs.org/virt-builder.1.html
Secondly this is implemented without any magic:
https://github.com/libguestfs/libguestfs/blob/master/builder/builder.ml#L650
It'd be nice if virt-sysprep worked compatibly.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/