From: "Richard W.M. Jones" <rjones(a)redhat.com>
---
po/POTFILES-ml | 1 +
sysprep/Makefile.am | 1 +
.../sysprep_operation_background_login_screen.ml | 124 ++++++++++++++++++++
3 files changed, 126 insertions(+)
create mode 100644 sysprep/sysprep_operation_background_login_screen.ml
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index 76043a0..8702efd 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -12,6 +12,7 @@ sysprep/main.ml
sysprep/sysprep_gettext.ml
sysprep/sysprep_operation.ml
sysprep/sysprep_operation_abrt_data.ml
+sysprep/sysprep_operation_background_login_screen.ml
sysprep/sysprep_operation_bash_history.ml
sysprep/sysprep_operation_blkid_tab.ml
sysprep/sysprep_operation_ca_certificates.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 5551c2d..4f9d2c6 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -40,6 +40,7 @@ CLEANFILES = \
# Filenames sysprep_operation_<name>.ml in alphabetical order.
operations = \
abrt_data \
+ background_login_screen \
bash_history \
blkid_tab \
ca_certificates \
diff --git a/sysprep/sysprep_operation_background_login_screen.ml
b/sysprep/sysprep_operation_background_login_screen.ml
new file mode 100644
index 0000000..6045ba8
--- /dev/null
+++ b/sysprep/sysprep_operation_background_login_screen.ml
@@ -0,0 +1,124 @@
+(* virt-sysprep
+ * Copyright (C) 2012 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.
+ *)
+
+open Printf
+
+open Utils
+open Sysprep_operation
+open Sysprep_gettext.Gettext
+
+module G = Guestfs
+
+let set_file, get_file =
+ let file = ref None in
+ let set_file name =
+ if !file <> None then (
+ failwith (s_"--background-login-screen option can only be given once")
+ );
+
+ (* Check the file is readable to avoid an error later on. *)
+ (try Unix.access name [Unix.R_OK]
+ with Unix.Unix_error _ ->
+ failwithf
+ (f_"background-login-screen: image file '%s' is not readable")
name
+ );
+ file := Some name
+ in
+ let get_file () = !file in
+ set_file, get_file
+
+(* Since the user used the --background-login-screen option, we
+ * should fail here because they probably want to know that this
+ * guest type is not supported.
+ *)
+let failed_to_set fs =
+ ksprintf
+ (fun msg -> failwith (s_"background-login-screen: failed: " ^ msg))
+ fs
+
+(* Upload the image file. The filename is supplied by the user, so
+ * don't use it directly. Return the final path.
+ *)
+let upload_image_file g file =
+ let dir = "/usr/share/background" in
+ let path = sprintf "%s/sysprep.img" dir in
+ g#mkdir_p dir;
+ g#upload file path;
+ path
+
+let do_dconf g file =
+ let path = upload_image_file g file in
+ let settings = sprintf "\
+# Created by virt-sysprep background-login-screen module.
+
+[org/gnome/settings-daemon/plugins/background]
+active=false
+
+[org/gnome/desktop/background]
+picture-uri='file://%s'
+picture-options='scaled'
+" path in
+ g#mkdir_p "/etc/dconf/db/gdm.d";
+ g#write "/etc/dconf/db/gdm.d/99-virt-sysprep-desktop" settings
+
+let background_login_screen_perform g root =
+ match get_file () with
+ | None -> []
+ | Some file ->
+ let typ = g#inspect_get_type root in
+ let distro = g#inspect_get_distro root in
+ match typ, distro with
+ | "linux",
("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based")
->
+ if g#is_dir "/etc/dconf" then ( (* Guest is using dconf? *)
+ do_dconf g file;
+ [`Created_files; `Dconf_needs_update]
+ ) else
+ failed_to_set "guest is not using dconf";
+
+ | _ ->
+ failed_to_set "guest type %s/%s is not supported" typ distro
+
+let background_login_screen_op = {
+ name = "background-login-screen";
+
+ (* enabled_by_default because we only do anything if the
+ * --background-login-screen parameter is used.
+ *)
+ enabled_by_default = true;
+
+ heading = s_"Customize background on login screen";
+ pod_description = Some (s_"\
+Set the background of the login screen. Supply a suitably
+sized image file using the I<--background-login-screen> parameter.
+
+Currently this is only implemented for Red Hat Enterprise Linux
+and Fedora guests running the GNOME display manager and dconf
+(ie. RHEL E<ge> 7, Fedora E<ge> 15).");
+
+ extra_args = [
+ ("--background-login-screen", Arg.String set_file,
+ s_"image" ^ " " ^ s_"file to use as background of login
screen"),
+ s_"\
+Set the background of the login screen."
+ ];
+
+ perform_on_filesystems = Some background_login_screen_perform;
+ perform_on_devices = None;
+}
+
+let () = register_operation background_login_screen_op
--
1.7.10.4