[Libguestfs] [PATCH 03/11] customize: fix windows firstboot script

Cédric Bosdonnat cbosdonnat at suse.com
Thu May 12 13:29:11 UTC 2016


Sync the windows firstboot script with its linux brother. Also change
the main redirection to append to the log rather than overwriting it.
With this change, the firstboot script will resist reboots in the
executed scripts.
---
 customize/firstboot.ml | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index aa5b694..83bd808 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -232,7 +232,7 @@ set log=%%firstboot%%\\log.txt
 set scripts=%%firstboot%%\\scripts
 set scripts_done=%%firstboot%%\\scripts-done
 
-call :main > \"%%log%%\" 2>&1
+call :main >> \"%%log%%\" 2>&1
 exit /b
 
 :main
@@ -244,15 +244,14 @@ if not exist \"%%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%%\"
-  )
+  move \"%%%%f\" \"%%scripts_done%%\"
+  pushd \"%%scripts_done%%\"
+  call \"%%%%~nf\"
+  popd
 )
 
 echo uninstalling firstboot service
+rmdir /S /Q \"%%scripts_done%%\"
 rhsrvany.exe -s firstboot uninstall
 " firstboot_dir_win in
 
-- 
2.6.6




More information about the Libguestfs mailing list