This patch is an attempt to enhance the firstboot driver script for
Windows, and make it somewhat closer in functionality to what is done
for Linux guests.
Specifically, for every firstboot script it now will log its exit
status, and, if the script reported success, move it to -done directory.
Signed-off-by: Roman Kagan <rkagan(a)parallels.com>
---
customize/firstboot.ml | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index ffcee12..f529462 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -210,16 +210,39 @@ module Windows = struct
* scripts in the directory. Note we need to use CRLF line endings
* in this script.
*)
- let firstboot_script = "\
+ let firstboot_script = sprintf "\
@echo off
-echo starting firstboot service >>log.txt
+setlocal EnableDelayedExpansion
+set firstboot=%s
+set log=%%firstboot%%\\log.txt
-for /f %%f in ('dir /b scripts') do call \"scripts\\%%f\"
>>log.txt
+set scripts=%%firstboot%%\\scripts
+set scripts_done=%%firstboot%%\\scripts-done
-echo uninstalling firstboot service >>log.txt
-rhsrvany.exe -s firstboot uninstall >>log.txt
-" in
+call :main > \"%%log%%\" 2>&1
+exit /b
+
+:main
+echo starting firstboot service
+
+if not exist \"%%scripts_done%%\" (
+ mkdir \"%%scripts_done%%\"
+)
+
+for %%%%f in (\"%%scripts%%\"\\*.bat) do (
+ echo running \"%%%%f\"
+ call \"%%%%f\"
+ set elvl=!errorlevel!
+ echo .... exit code !elvl!
+ if !elvl! equ 0 (
+ move \"%%%%f\" \"%%scripts_done%%\"
+ )
+)
+
+echo uninstalling firstboot service
+rhsrvany.exe -s firstboot uninstall
+" firstboot_dir_win in
g#write (firstboot_dir // "firstboot.bat") (unix2dos firstboot_script);
--
2.1.0