Try to get vmbuild to wait for virtualbox to terminate.
[cdist.git] / vmbuild
1 #!/bin/bash
2
3 if [ "$1" == "" -o "$2" == "" ]; then
4     echo "Syntax: $0 <target> <checkout> [<output-dir>]"
5     exit 1
6 fi
7
8 IFS='-' read distro version bits <<< $1
9
10 checkout=$2
11 output=$3
12
13 if [ "$bits" == "32" ]; then
14     port=2000
15 elif [ "$bits" == "64" ]; then
16     port=2001
17 else
18     echo "Unrecognised bit depth $bits"
19     exit 1
20 fi
21
22 nohup vboxheadless --startvm fedora-22-$bits &
23 vbox=$!
24 sleep 10
25 ssh -p $port carl@localhost "rm -rf fedora-*"
26 ssh -p $port carl@localhost cdist -p dcpomatic -c $checkout -t host package
27 if [ "$output" != "" ]; then
28     scp -P $port carl@localhost:fedora-22-$bits/* $output/
29 fi
30 ssh -p $port carl@localhost "sudo /sbin/poweroff"
31 while [[ ( -d /proc/$vbox ) && ( -z `grep zombie /proc/$vbox/status` ) ]]; do
32     sleep 1
33 done