autoRun.sh 1.01 KB
Newer Older
Juon Kawakami's avatar
init  
Juon Kawakami committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/bash

. $(dirname $0)/config.sh

MAPS="$*"

function getFreeCluster() {
COUNT="0 0 0"
while [ 1 ];do
for i in $CLUSTERS; do
    SERVER=$(getServerHost $i)
    RUNNING_TEAM=""
    PRECOMPUTE=""
    TURN="-"
    eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
    if [ ! -z $RUNNING_TEAM ]; then
	COUNT[$i]=0
    else
	COUNT[$i]=$(( ${COUNT[$i]} + 1 ))
    fi
	echo "cluster" $i "FREE " ${COUNT[$i]} "Time"
   if [ ${COUNT[$i]} -eq 5 ];then
	FREE=$i
	return;
   fi


done
	sleep 10
done
}


FREE=0


ALL=()
count=0;
uploadMaps.sh

TEAM_SHORTHANDS2=$(shuf -e $TEAM_SHORTHANDS)
echo $TEAM_SHORTHANDS2
echo "MAPS $MAPS"
echo "=========================="
for MAP in $MAPS; do
#	echo $MAP

	for TEAM in $TEAM_SHORTHANDS2; do
#	echo $TEAM
		ALL+="$MAP-$TEAM "
		count=$(( $count + 1 ))
	done
done
for item in $ALL; do
	arr=$(echo $item | tr "-" "\n")
	MAP=${arr[0]}
	TEAM=${arr[1]}

	getFreeCluster
	run.sh $FREE $MAP $TEAM &
	#xterm -T "run.sh $FREE $MAP $TEAM" -e "run.sh $FREE $MAP $TEAM" &
done