Last change
on this file since 3012 was 1334, checked in by Bruno Cornec, 17 years ago |
- Add a test env (local for laptop + QEMU based)
- creates qemu-env for reuse of code
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | # Script to act on various distributions with qemu
|
---|
6 | #
|
---|
7 |
|
---|
8 | # Syntax: action2qemu script [[vm1][..|vmx]]
|
---|
9 |
|
---|
10 | (
|
---|
11 | dname=`dirname $0`
|
---|
12 | prem=`echo $dname |cut -c1`
|
---|
13 | if [ _${prem} = _"/" ]; then
|
---|
14 | export TOOLHOME=$dname
|
---|
15 | else
|
---|
16 | export TOOLHOME=${PWD}/$dname
|
---|
17 | fi
|
---|
18 |
|
---|
19 | . $TOOLHOME/common-env
|
---|
20 | . $TOOLHOME/distro-env
|
---|
21 | . $TOOLHOME/qemu-env
|
---|
22 |
|
---|
23 | if [ _"$1" != _"" ]; then
|
---|
24 | export SCRIPT=$1
|
---|
25 | shift
|
---|
26 | else
|
---|
27 | echo "Syntax: action2qemu script [[vm1][..|vmx]]"
|
---|
28 | exit -1
|
---|
29 | fi
|
---|
30 |
|
---|
31 | if [ _"$1" = _"" ]; then
|
---|
32 | export VMS=`cat ${TOOLHOME}/DISTROS`
|
---|
33 | else
|
---|
34 | export VMS="$*"
|
---|
35 | single=1
|
---|
36 | fi
|
---|
37 |
|
---|
38 | chmod 755 $SCRIPT
|
---|
39 |
|
---|
40 | for m in $VMS; do
|
---|
41 | echo "Working on $m"
|
---|
42 | vmp=0
|
---|
43 | if [ ! -f /users/qemu/$m.qemu ]; then
|
---|
44 | echo "VM unaccessible. Verify NFS mount"
|
---|
45 | exit -1
|
---|
46 | fi
|
---|
47 | ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
|
---|
48 | if [ $? -ne 0 ]; then
|
---|
49 | # Virtual machine alreday started
|
---|
50 | vmp=1
|
---|
51 | $TOOLHOME/mkqemu $m &
|
---|
52 | sleep 300
|
---|
53 | fi
|
---|
54 | ssh -q -p $sp root@localhost "mkdir -p ${TOOLHOME}"
|
---|
55 | scp -P $sp -p $SCRIPT root@localhost:${TOOLHOME}
|
---|
56 | bn=`basename "$SCRIPT"`
|
---|
57 | ssh -q -p $sp root@localhost "${TOOLHOME}/$bn"
|
---|
58 | if [ $vmp -eq 1 ]; then
|
---|
59 | ssh -q -p $sp root@localhost "halt -p"
|
---|
60 | sleep 300
|
---|
61 | proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
|
---|
62 | if [ "$proces" != "" ]; then
|
---|
63 | kill $proces
|
---|
64 | sleep 10
|
---|
65 | fi
|
---|
66 | fi
|
---|
67 | done
|
---|
68 |
|
---|
69 | ) 2>&1 | tee /tmp/action2qemu.log
|
---|
Note:
See
TracBrowser
for help on using the repository browser.