source: branches/stable/tools/action2qemu @ 1334

Last change on this file since 1334 was 1334, checked in by bruno, 12 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
RevLine 
[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(
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
[1334]21. $TOOLHOME/qemu-env
[1288]22
23if [ _"$1" != _"" ]; then
24    export SCRIPT=$1
25    shift
26else
27    echo "Syntax: action2qemu script [[vm1][..|vmx]]"
28    exit -1
29fi
30
31if [ _"$1" = _"" ]; then
32    export VMS=`cat ${TOOLHOME}/DISTROS` 
33else
34    export VMS="$*"
35    single=1
36fi
37
38chmod 755 $SCRIPT
39
40for 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
67done
68
69) 2>&1 | tee /tmp/action2qemu.log
Note: See TracBrowser for help on using the repository browser.