labs: split out process_begin_files

Move the processing of *.begin status files into a separate function.
Call that function only if the host's status directory is shared with
the client scripts (through VirtualBox guest-additions).

Change-Id: I7716528c02aa4f8b5fc0901ff91ba5d37b5a0d9f
This commit is contained in:
Roger Luethi 2014-09-11 13:21:57 +02:00
parent 7dbce8f985
commit d14c75c38a

View File

@ -157,6 +157,17 @@ function autostart_reset {
clean_dir "$STATUS_DIR"
}
function process_begin_files {
local processing=("$STATUS_DIR"/*.sh.begin)
if [ -n "${processing[0]-}" ]; then
local file
for file in "${processing[@]}"; do
echo >&2 -en "\nVM processing $(basename "$file" .begin)"
rm "$file"
done
fi
}
# Wait until all autofiles are processed (indicated by a "$STATUS_DIR/done"
# file created either by osbashauto or ssh_process_autostart)
function wait_for_autofiles {
@ -176,13 +187,7 @@ function wait_for_autofiles {
fi
# Note: begin files (created by indicate_current_auto) are only visible
# if the STATUS_DIR directory is shared between host and VM
local processing=("$STATUS_DIR"/*.sh.begin)
if [ -n "${processing[0]-}" ]; then
for f in "${processing[@]}"; do
echo >&2 -en "\nVM processing $(basename "$f" .begin)"
rm "$f"
done
fi
${WBATCH:-:} process_begin_files
echo >&2 -n .
sleep 1
done