From b1f997164ef6c34dbcdefdd7c7ee044255f83333 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 1 Apr 2012 20:00:28 +0100 Subject: sysprep: script: Miscellaneous fixes and cleanups to shell script. --- sysprep/sysprep_operation_script.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sysprep/sysprep_operation_script.ml') diff --git a/sysprep/sysprep_operation_script.ml b/sysprep/sysprep_operation_script.ml index 5e47733b..044fd784 100644 --- a/sysprep/sysprep_operation_script.ml +++ b/sysprep/sysprep_operation_script.ml @@ -83,16 +83,24 @@ and run_scripts mp scripts = let cmd = sprintf "\ set -e -sysprep_unmount () +#set -x +cleanup () { + status=$? cd / count=10 - while ! fusermount -u %s && [ $count -gt 0 ]; do + while ! fusermount -u %s >/dev/null 2>&1 && [ $count -gt 0 ]; do sleep 1 ((count--)) done + if [ $count -eq 0 ]; then + echo \"fusermount: failed to unmount directory\" %s >&2 + exit 1 + fi + exit $status } -trap sysprep_unmount INT TERM QUIT EXIT ERR\n" (Filename.quote mp) ^ +trap cleanup INT TERM QUIT EXIT ERR\n" + (Filename.quote mp) (Filename.quote mp) ^ String.concat "\n" scripts in let args = [| sh; "-c"; cmd |] in -- cgit