1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | # Script allowing mondo packages production on various distributions with qemu
|
---|
6 | #
|
---|
7 |
|
---|
8 | if [ _"$1" == _"" ]; then
|
---|
9 | echo "Syntax: mkqemu [mondo version] ([vm].. )"
|
---|
10 | exit -1
|
---|
11 | fi
|
---|
12 |
|
---|
13 | if [ _"$2" == _"" ]; then
|
---|
14 | export SVN_VM="mdk101 mdk102 mdv2006 rh73 rh9 fc4 fc5 rhel3 rhel4 suse10 sles9 debian31"
|
---|
15 | else
|
---|
16 | export SVN_VM="$2"
|
---|
17 | fi
|
---|
18 |
|
---|
19 | cat > /tmp/mkmondo << EOF
|
---|
20 | #!/bin/bash
|
---|
21 |
|
---|
22 | export SVN_HOME=\$HOME/mondo/svn/branches
|
---|
23 | export SVN_SSH="ssh -l bcornec"
|
---|
24 | export SVN_EDITOR=vim
|
---|
25 | export LANG="C"
|
---|
26 | export LANGUAGE="C"
|
---|
27 | export LC_ALL="C"
|
---|
28 |
|
---|
29 | if [ -d \$SVN_HOME/$1 ]; then
|
---|
30 | cd \$SVN_HOME/$1
|
---|
31 | svn up
|
---|
32 | if [ \$? != 0 ]; then
|
---|
33 | echo "Verify SVN installation"
|
---|
34 | exit -1
|
---|
35 | fi
|
---|
36 | else
|
---|
37 | mkdir -p \$SVN_HOME
|
---|
38 | cd \$SVN_HOME
|
---|
39 | svn co svn+ssh://bcornec@svn.berlios.de/svnroot/repos/mondorescue/branches/$1 $1
|
---|
40 | if [ \$? != 0 ]; then
|
---|
41 | echo "Verify SVN installation"
|
---|
42 | exit -1
|
---|
43 | fi
|
---|
44 | fi
|
---|
45 | echo \$SVN_VM | grep -q "debian"
|
---|
46 | if [ \$? -eq 0 ]; then
|
---|
47 | \$SVN_HOME/$1/tools/mkdeb < /dev/null
|
---|
48 | else
|
---|
49 | \$SVN_HOME/$1/tools/mkrpm < /dev/null
|
---|
50 | fi
|
---|
51 | \$SVN_HOME/$1/tools/mkdeliv
|
---|
52 | EOF
|
---|
53 |
|
---|
54 | ipvm=10.0.2.15
|
---|
55 |
|
---|
56 |
|
---|
57 | for m in $SVN_VM; do
|
---|
58 | sp=22`host $m.mondo.musique-ancienne.org | cut -d. -f7`
|
---|
59 | vmp=0
|
---|
60 | if [ ! -f /users/vmplayer/$m.qemu ]; then
|
---|
61 | echo "VM unaccessible. Verify NFS mount"
|
---|
62 | exit -1
|
---|
63 | fi
|
---|
64 | ps auxww | grep qemu | grep -v grep | grep -q /users/vmplayer/$m.qemu
|
---|
65 | if [ $? -ne 0 ]; then
|
---|
66 | # Virtual machine alreday started
|
---|
67 | vmp=1
|
---|
68 | qemu -m 256 $QEMUOPT -redir tcp:${sp}:${ipvm}:22 /users/vmplayer/$m.qemu &
|
---|
69 | sleep 300
|
---|
70 | fi
|
---|
71 | scp -P $sp /tmp/mkmondo bruno@localhost:
|
---|
72 | ssh -p $sp bruno@localhost "chmod 755 ./mkmondo ; ./mkmondo" | tee /tmp/mkvm.log
|
---|
73 | if [ $vmp -eq 1 ]; then
|
---|
74 | ssh -p $sp root@localhost "halt -p"
|
---|
75 | sleep 300
|
---|
76 | proces=`ps auxww | grep qemu | grep -v grep | grep -q /users/vmplayer/$m.qemu | awk '{print $2}'`
|
---|
77 | if [ "$proces" != "" ]; then
|
---|
78 | kill $proces
|
---|
79 | fi
|
---|
80 | fi
|
---|
81 | done
|
---|