Mercurial > hg > fD-testbed
annotate mrb/vm_stop.sh @ 0:9e5a3c884de6
Initial import of the virtual testbed.
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 17 Jun 2010 11:00:32 +0900 |
parents | |
children |
rev | line source |
---|---|
0
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 #!/bin/bash |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 # Check params |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 if [ -z "$1" ]; then echo "Donnez le nom de la VM en parametre"; exit 1; fi |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
5 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 VM=$1 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 shift |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
8 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 # First, check the VM is running |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 VBoxManage showvminfo "$VM" |grep "^State:\s*running" >/dev/null || { |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 echo $VM already stopped. |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 exit 0 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 } |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 echo "Shutting down $VM..." |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 if [ "$1" = "nochgcns" ]; |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 then |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 shift |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 else |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 # Change console to the 5th (alt-F5) |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 VBoxManage controlvm "$VM" keyboardputscancode 38 3f bf b8 >/dev/null |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 sleep 2 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
26 # Login in the VM |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
27 ./vm_login.sh "$VM" force |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
28 fi |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
30 # Issue a "shutdown -h now" order |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
31 VBoxManage controlvm "$VM" keyboardputscancode 1f 9f 23 a3 16 96 14 94 20 a0 18 98 11 91 31 b1 39 b9 0c 8c 23 a3 39 b9 31 b1 18 98 11 91 1c 9c >/dev/null |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
32 |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 # Wait for shutdown complete if told to |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 if [ "$1" = "waitterm" ]; then |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 while ( VBoxManage showvminfo "$VM" |grep "^State:\s*running" >/dev/null ); |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 do sleep 1; |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 done |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 echo $VM was shutdown |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 fi |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 # Done |
9e5a3c884de6
Initial import of the virtual testbed.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 |