source: branches/stable/tools/action2qemu @ 1327

Last change on this file since 1327 was 1327, checked in by bruno, 13 years ago

The script to be executed is now sent under $TOOLHOME to avoid execution problem of son-scripts in that directory (like in pkg2test)

  • 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(
11dname=`dirname $0`
12prem=`echo $dname |cut -c1`
13if [ _${prem} = _"/" ]; then
14    export TOOLHOME=$dname
15else
16    export TOOLHOME=${PWD}/$dname
17fi
18
19. $TOOLHOME/common-env
20. $TOOLHOME/distro-env
21
22if [ _"$1" != _"" ]; then
23    export SCRIPT=$1
24    shift
25else
26    echo "Syntax: action2qemu script [[vm1][..|vmx]]"
27    exit -1
28fi
29
30if [ _"$1" = _"" ]; then
31    export VMS=`cat ${TOOLHOME}/DISTROS` 
32else
33    export VMS="$*"
34    single=1
35fi
36
37chmod 755 $SCRIPT
38
39for m in $VMS; do
40    echo "Working on $m"
41    vmp=0
42    if [ ! -f /users/qemu/$m.qemu ]; then
43            echo "VM unaccessible. Verify NFS mount"
44            exit -1
45    fi
46    if [ _"$sp" = _"" ]; then
47        export sp=2222
48    fi
49    ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
50    if [ $? -ne 0 ]; then
51        # Virtual machine alreday started
52        vmp=1
53        $TOOLHOME/mkqemu $m &
54        sleep 300
55    fi
56    ssh -q -p $sp root@localhost "mkdir -p ${TOOLHOME}"
57    scp -P $sp -p $SCRIPT root@localhost:${TOOLHOME}
58    bn=`basename "$SCRIPT"`
59    ssh -q -p $sp root@localhost "${TOOLHOME}/$bn"
60    if [ $vmp -eq 1 ]; then
61        ssh -q -p $sp root@localhost "halt -p"
62        sleep 300
63        proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
64        if [ "$proces" != "" ]; then
65            kill $proces
66            sleep 10
67        fi
68    fi
69done
70
71) 2>&1 | tee /tmp/action2qemu.log
Note: See TracBrowser for help on using the repository browser.