(* libguestfs * Copyright (C) 2014 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *) (* Please read generator/README first. *) open Printf open Std_utils open Docstrings open Pr let generate_header = generate_header ~inputs:["generator/customize.ml"] (* Command-line arguments used by virt-customize, virt-builder and * virt-sysprep. *) type op = { op_name : string; (* argument name, without "--" *) op_type : op_type; (* argument value type *) op_discrim : string; (* argument discriminator in OCaml code *) op_shortdesc : string; (* single-line description *) op_pod_longdesc : string; (* multi-line description *) } and op_type = | Unit (* no argument *) | String of string (* string *) | StringPair of string (* string:string *) | StringList of string (* string,string,... *) | TargetLinks of string (* target:link[:link...] *) | PasswordSelector of string (* password selector *) | UserPasswordSelector of string (* user:selector *) | SSHKeySelector of string (* user:selector *) | StringFn of (string * string) (* string, function name *) | SMPoolSelector of string (* pool selector *) let ops = [ { op_name = "append-line"; op_type = StringPair "FILE:LINE"; op_discrim = "`AppendLine"; op_shortdesc = "Append line(s) to the file"; op_pod_longdesc = "\ Append a single line of text to the C. If the file does not already end with a newline, then one is added before the appended line. Also a newline is added to the end of the C string automatically. For example (assuming ordinary shell quoting) this command: --append-line '/etc/hosts:10.0.0.1 foo' will add either C<10.0.0.1 foo⏎> or C<⏎10.0.0.1 foo⏎> to the file, the latter only if the existing file does not already end with a newline. C<⏎> represents a newline character, which is guessed by looking at the existing content of the file, so this command does the right thing for files using Unix or Windows line endings. It also works for empty or non-existent files. To insert several lines, use the same option several times: --append-line '/etc/hosts:10.0.0.1 foo' --append-line '/etc/hosts:10.0.0.2 bar' To insert a blank line before the appended line, do: --append-line '/etc/hosts:' --append-line '/etc/hosts:10.0.0.1 foo'"; }; { op_name = "chmod"; op_type = StringPair "PERMISSIONS:FILE"; op_discrim = "`Chmod"; op_shortdesc = "Change the permissions of a file"; op_pod_longdesc = "\ Change the permissions of C to C. I: C by default would be decimal, unless you prefix it with C<0> to get octal, ie. use C<0700> not C<700>."; }; { op_name = "commands-from-file"; op_type = StringFn ("FILENAME", "customize_read_from_file"); op_discrim = "`CommandsFromFile"; op_shortdesc = "Read customize commands from file"; op_pod_longdesc = "\ Read the customize commands from a file, one (and its arguments) each line. Each line contains a single customization command and its arguments, for example: delete /some/file install some-package password some-user:password:its-new-password Empty lines are ignored, and lines starting with C<#> are comments and are ignored as well. Furthermore, arguments can be spread across multiple lines, by adding a C<\\> (continuation character) at the of a line, for example edit /some/file:\\ s/^OPT=.*/OPT=ok/ The commands are handled in the same order as they are in the file, as if they were specified as I<--delete /some/file> on the command line."; }; { op_name = "copy"; op_type = StringPair "SOURCE:DEST"; op_discrim = "`Copy"; op_shortdesc = "Copy files in disk image"; op_pod_longdesc = "\ Copy files or directories recursively inside the guest. Wildcards cannot be used."; }; { op_name = "copy-in"; op_type = StringPair "LOCALPATH:REMOTEDIR"; op_discrim = "`CopyIn"; op_shortdesc = "Copy local files or directories into image"; op_pod_longdesc = "\ Copy local files or directories recursively into the disk image, placing them in the directory C (which must exist). Wildcards cannot be used."; }; { op_name = "delete"; op_type = String "PATH"; op_discrim = "`Delete"; op_shortdesc = "Delete a file or directory"; op_pod_longdesc = "\ Delete a file from the guest. Or delete a directory (and all its contents, recursively). You can use shell glob characters in the specified path. Be careful to escape glob characters from the host shell, if that is required. For example: virt-customize --delete '/var/log/*.log'. See also: I<--upload>, I<--scrub>."; }; { op_name = "edit"; op_type = StringPair "FILE:EXPR"; op_discrim = "`Edit"; op_shortdesc = "Edit file using Perl expression"; op_pod_longdesc = "\ Edit C using the Perl expression C. Be careful to properly quote the expression to prevent it from being altered by the shell. Note that this option is only available when Perl 5 is installed. See L."; }; { op_name = "firstboot"; op_type = String "SCRIPT"; op_discrim = "`FirstbootScript"; op_shortdesc = "Run script at first guest boot"; op_pod_longdesc = "\ Install C