Last change
on this file since 2232 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
|
Rev | Line | |
---|
[1288] | 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
|
---|
[1334] | 21 | . $TOOLHOME/qemu-env
|
---|
[1288] | 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
|
---|
[1327] | 54 | ssh -q -p $sp root@localhost "mkdir -p ${TOOLHOME}"
|
---|
| 55 | scp -P $sp -p $SCRIPT root@localhost:${TOOLHOME}
|
---|
[1288] | 56 | bn=`basename "$SCRIPT"`
|
---|
[1327] | 57 | ssh -q -p $sp root@localhost "${TOOLHOME}/$bn"
|
---|
[1288] | 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.