[Libguestfs] [PATCH 2/2] sysprep: Remove the data of dovecot

Wanlong Gao gaowanlong at cn.fujitsu.com
Fri Apr 27 06:18:53 UTC 2012


Remove the data of dovecot.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 sysprep/Makefile.am                       |    2 ++
 sysprep/sysprep_operation_dovecot_data.ml |   43 +++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 sysprep/sysprep_operation_dovecot_data.ml

diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index e2b4806..2424071 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -37,6 +37,7 @@ SOURCES = \
 	sysprep_operation_cron_spool.ml \
 	sysprep_operation_dhcp_client_state.ml \
 	sysprep_operation_dhcp_server_state.ml \
+	sysprep_operation_dovecot_data.ml \
 	sysprep_operation_flag_reconfiguration.ml \
 	sysprep_operation_hostname.ml \
 	sysprep_operation_logfiles.ml \
@@ -67,6 +68,7 @@ OBJECTS = \
 	sysprep_operation_cron_spool.cmx \
 	sysprep_operation_dhcp_client_state.cmx \
 	sysprep_operation_dhcp_server_state.cmx \
+	sysprep_operation_dovecot_data.cmx \
 	sysprep_operation_flag_reconfiguration.cmx \
 	sysprep_operation_hostname.cmx \
 	sysprep_operation_logfiles.cmx \
diff --git a/sysprep/sysprep_operation_dovecot_data.ml b/sysprep/sysprep_operation_dovecot_data.ml
new file mode 100644
index 0000000..bf01ef4
--- /dev/null
+++ b/sysprep/sysprep_operation_dovecot_data.ml
@@ -0,0 +1,43 @@
+(* virt-sysprep
+ * Copyright (C) 2012 FUJITSU LIMITED
+ *
+ * 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 Sysprep_operation
+
+module G = Guestfs
+
+let dovecot_data_perform g root =
+  let typ = g#inspect_get_type root in
+  if typ <> "windows" then (
+    let files = g#glob_expand "/var/lib/dovecot/*" in
+    Array.iter (
+      fun file -> try g#rm file with G.Error _ -> ()
+    ) files;
+    []
+  )
+  else []
+
+let dovecot_data_op = {
+  name = "dovecot-data";
+  enabled_by_default = true;
+  heading = "Remove the data of dovecot";
+  pod_description = None;
+  extra_args = [];
+  perform = dovecot_data_perform;
+}
+
+let () = register_operation dovecot_data_op
-- 
1.7.10




More information about the Libguestfs mailing list