]> git.ipfire.org Git - thirdparty/strongswan.git/blob - testing/scripts/kstart-umls
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / testing / scripts / kstart-umls
1 #!/bin/bash
2 # starts the UML instances in a konsole (requires KDE)
3 #
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
6 #
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # for more details.
16 #
17 # RCSID $Id: kstart-umls,v 1.6 2005/08/30 22:13:12 as Exp $
18
19 DIR=`dirname $0`
20
21 source $DIR/function.sh
22
23 [ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
24
25 source $DIR/../testing.conf
26
27 if [ "$#" -eq 0 ]
28 then
29 HOSTS=$STRONGSWANHOSTS
30 else
31 HOSTS=$*
32 fi
33
34 BOOTING_HOSTS=""
35 count_max=12
36 count=0
37
38 for host in $HOSTS
39 do
40 up=0
41
42 if [ -d ~/.uml/${host} ]
43 then
44 pid=`cat ~/.uml/${host}/pid`
45 up=`ps up $pid | wc -l`
46 fi
47
48 if [ $up -eq 2 ]
49 then
50 cecho " * Great, ${host} is already running!"
51 else
52 rm -rf ~/.uml/${host}
53 BOOTING_HOSTS="$BOOTING_HOSTS ${host}"
54 let "count_max += 12"
55
56 UMLHOSTFS=$BUILDDIR/root-fs/gentoo-fs-${host}
57 [ -f $UMLHOSTFS ] || die "!! uml root file system '$UMLHOSTFS' not found"
58
59 cecho-n " * Starting ${host}.."
60 eval konsole -title ${host} -e "$UMLKERNEL \
61 umid=${host} \
62 ubda=$UMLHOSTFS \
63 \$SWITCH_${host} \
64 mem=${MEM}M con=pty con0=fd:0,fd:1" &
65 cecho "done"
66 fi
67 done
68
69 if [ -z "$BOOTING_HOSTS" ]
70 then
71 exit 0
72 fi
73
74 cecho " * Waiting for the uml instances to finish booting"
75
76 for host in $BOOTING_HOSTS
77 do
78 cecho-n " * Checking on $host.."
79
80 while [ $count -lt $count_max ] && [ ! -d ~/.uml/$host ]
81 do
82 cecho-n "."
83 sleep 5
84 let "count+=1"
85 done
86
87 if [ $count -ge $count_max ]
88 then
89 cecho "exit"
90 exit 1
91 fi
92
93 pid=`cat ~/.uml/$host/pid`
94 up=`ps up $pid | grep agetty | wc -l`
95
96 while [ $count -lt $count_max ] && [ $up -eq 0 ]
97 do
98 cecho-n "."
99 sleep 5
100 up=`ps up $pid | grep agetty | wc -l`
101 let "count+=1"
102 done
103
104 if [ $count -ge $count_max ]
105 then
106 cecho "exit"
107 exit 1
108 else
109 cecho "up"
110 fi
111 done
112
113 cecho " * All uml instances are up now"