Unverified Commit 31971f1b authored by Juon Kawakami's avatar Juon Kawakami 🥗
Browse files

init

parent 342fea6f
#!/bin/bash
. $(dirname $0)/config.sh
for HOST in $SERVER_HOSTS; do
scp -r $1 $REMOTE_USER@$HOST:$2 &
done
wait
#!/bin/bash
. $(dirname $0)/config.sh
PATH=$PATH:$HOME/scripts/evaluation
cd $HOME/$EVALDIR
for DIR in *; do
echo $DIR "==="
#if [[ -d $DIR && ! -s $DIR/index.html ]]; then
if [[ $DIR != "viewer" ]]; then
mapSummary.sh $DIR ||echo "error"
# echo $DIR
fi;
done;
make_overview.py > index.html
#!/bin/bash
. $(dirname $0)/config.sh
LOGFILE=$(readlink -f $1)
MAP=$2
TEAM=$3
MAP_EVALDIR=$HOME/$EVALDIR/$MAP
mkdir -p $MAP_EVALDIR/$TEAM
cd $MAP_EVALDIR
if [[ $LOGFILE == *.gz ]]; then
echo "logfile is gzipped: ${LOGFILE%.gz}"
LOGFILE_GZ=$LOGFILE
LOGFILE=${LOGFILE%.gz}
if [ ! -f $LOGFILE ]; then
gunzip -c $LOGFILE_GZ > $LOGFILE
fi;
elif [[ $LOGFILE == *.7z ]]; then
echo "logfile is 7zipped: ${LOGFILE%.7z}"
LOGFILE_7Z=$LOGFILE
LOGFILE=${LOGFILE%.7z}
if [ ! -f $LOGFILE ]; then
7za e $LOGFILE_7Z
fi;
fi;
cd $HOME/$KERNELDIR/boot
./logextract.sh $LOGFILE $MAP_EVALDIR/$TEAM
cd $MAP_EVALDIR
for screen in $TEAM/*.png; do
tn=${screen%.png}-tn.jpg
convert -format jpg -thumbnail 100x75 -strip -quality 95 PNG8:"$screen" "$tn"
done
if [ ! -f snapshot-init.png ]; then
cp $TEAM/snapshot-init.png snapshot-init.png
convert -format png -thumbnail 400x300 -strip -quality 95 PNG8:snapshot-init.png snapshot-init-small.png
fi
echo "Final score is: $(cat $TEAM/final-score.txt)"
echo "Rebuilding summary page for $RUNNING_MAP"
mapSummary.sh $MAP
#!/bin/bash
. $(dirname $0)/config.sh
CLUSTER=$1
SERVER=$(getServerHost $CLUSTER)
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
if [ ! -z $RUNNING_TEAM ]; then
echo "There is still a server running on cluster $CLUSTER"
echo "${TEAM_NAMES[$RUNNING_TEAM]} ($RUNNING_TEAM) on $RUNNING_MAP"
exit 1
fi;
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$STATFILE_NAME 2>/dev/null)
if [ -z $RUNNING_TEAM ]; then
echo "No run recorded on cluster $CLUSTER"
exit 1
fi;
echo "Evaluating run of ${TEAM_NAMES[$RUNNING_TEAM]} ($RUNNING_TEAM) on $RUNNING_MAP"
rsync -rcLv $REMOTE_USER@$SERVER:$RECORDSDIR $HOME
rsync -rcLv $REMOTE_USER@$SERVER:$LOGDIR $HOME
MAP_EVALDIR=$HOME/$EVALDIR/$RUNNING_MAP
if [ ! -d $MAP_EVALDIR/$RUNNING_TEAM ]; then
# gunzip -c $HOME/$RESCUE_LOGFILE.gz > $HOME/$RESCUE_LOGFILE.tmp
7za e $HOME/$RESCUE_LOGFILE.7z
evalLog.sh $HOME/$RESCUE_LOGFILE $RUNNING_MAP $RUNNING_TEAM
rm $HOME/$RESCUE_LOGFILE
else
echo "Rebuilding summary page for $RUNNING_MAP"
mapSummary.sh $RUNNING_MAP
fi
#!/bin/bash
. $(dirname $0)/config.sh
for HOST in $CLIENT_HOSTS; do
rsync -rcLv $REMOTE_USER@$HOST:$1 $2
done
#!/bin/bash
. $(dirname $0)/config.sh
for HOST in $SERVER_HOSTS; do
rsync -rcLv $REMOTE_USER@$HOST:$1 $2
done
#!/bin/bash
. $(dirname $0)/config.sh
$(dirname $0)/gatherFromClients.sh $LOGDIR $HOME
$(dirname $0)/gatherFromKernels.sh $LOGDIR $HOME
#!/bin/bash
. $(dirname $0)/config.sh
echo "unpacking..."
zcat $1 > rescue.log.tmp
DIR=$(pwd)
cd $KERNELDIR/boot
./getScore.sh $DIR/rescue.log.tmp
cd $DIR
rm rescue.log.tmp
#!/bin/bash
. $(dirname $0)/config.sh
MAPS="VC1 Paris1 Kobe1 Berlin1 Istanbul1 Kobe2 Paris2 Istanbul2 Berlin2 VC2 Paris3 Istanbul3 Berlin3 Kobe3 Istanbul4 Berlin4 Paris4 VC4 Paris5 Berlin5 Kobe4 Istanbul5 VC5"
DIR=$(pwd)
for map in $MAPS; do
FILES=$(find $LOGDIR -name *$map*|grep kernel)
mkdir -p $DISTDIR/$map
for f in $FILES; do
cp "$f" $DISTDIR/$map
done
done
#!/bin/bash
. $(dirname $0)/config.sh
MAP=$1
MAP_EVALDIR=$HOME/$EVALDIR/$MAP
EVAL_SCRIPTS=$HOME/scripts/evaluation
PATH=$PATH:$EVAL_SCRIPTS
cd $MAP_EVALDIR
if [ -f scores.tmp ]; then
rm scores.tmp
fi
if [ -f final-scores.txt ]; then
rm final-scores.txt
fi
NUM_PROCESSED=0
for TEAM in $TEAM_SHORTHANDS; do
NAME=${TEAM_NAMES[$TEAM]}
if [ -s $TEAM/init-score.txt ]; then
cp $TEAM/init-score.txt init-score.txt
echo -n "\"$NAME\" ">> scores.tmp
cat $TEAM/scores.txt >> scores.tmp
echo >> scores.tmp
echo "$TEAM"
# echo -n "$TEAM " >> final-scores.txt
# cat $TEAM/final-score.txt >> final-scores.txt
# echo >> final-scores.txt
for screen in $TEAM/*.png; do
tn=${screen%.png}-tn.jpg
convert -format jpg -thumbnail 100x75 -strip -quality 95 PNG8:"$screen" "$tn"
done
if [ ! -f snapshot-init.png ]; then
cp $TEAM/snapshot-init.png snapshot-init.png
convert -format png -thumbnail 400x300 -strip -quality 95 PNG8:snapshot-init.png snapshot-init-small.png
fi
LOGFILES=$(ls $HOME/$LOGDIR/$DAY/kernel/*$NAME-$MAP.7z 2>/dev/null)
echo $HOME/$LOGDIR/$DAY/kernel/*$NAME-$MAP.7z
echo === $LOGFILES
if [[ -f "$LOGFILES" && ! -f $MAP_EVALDIR/$LOGFILES ]]; then
cp $LOGFILES $MAP_EVALDIR
fi;
NUM_PROCESSED=$((NUM_PROCESSED+1))
# echo "recompressing ..."
# bzip2 $LOGFILE
fi
done
# create map tgz
echo $MAP_EVALDIR
if [[ -d $MAP_EVALDIR && -d $HOME/$MAPDIR/$MAP && ! -f $MAP_EVALDIR/$MAP.7z ]]; then
cd $HOME/$MAPDIR
7za a -m0=lzma2 $MAP.7z $MAP
mv $MAP.7z $MAP_EVALDIR/
fi;
cd $MAP_EVALDIR
transpose.py scores.tmp > scores.dat
export RCR_MAP=$MAP
export RCR_COUNT=$NUM_PROCESSED
echo $RCR_COUNT teams processed
gnuplot $EVAL_SCRIPTS/plot-scores.gnu
make_html.py $MAP > index.html
#!/bin/bash
DAY="2010"
processLine(){
line="$@" # get all args
# just echo them, but you may need to customize it according to your need
# for example, F1 will store first field of $line, see readline2 script
# for more examples
# F1=$(echo $line | awk '{ print $1 }')
echo $line
}
read_file () {
### Main script stars here ###
# Store file name
FILE=$1
# Make sure we get file name as command line argument
# Else read it from standard input device
if [ "$1" == "" ]; then
FILE="/dev/stdin"
else
# make sure file exist and readable
if [ ! -f $FILE ]; then
echo "$FILE : does not exists"
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE: can not read"
exit 2
fi
fi
# read $FILE using the file descriptors
# Set loop separator to end of line
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<"$FILE"
while read -r line
do
# use $line variable to process line in processLine() function
processLine $line
done
exec 0<&3
# restore $IFS which was used to determine what the field separators are
IFS=$BAKIFS
exit 0
}
read_map(){
read_file
}
read_team_name(){
OPTIONS="ASP BON BRV ESK FAN MFT MRL POS SBC SDS SEU SOS SMP Exit"
select team in $OPTIONS; do
if [ "$team" = "Exit" ]; then
echo done
exit
else
echo "Team Selected: $team"
read_day
fi
done
}
read_file
#!/bin/bash
. $(dirname $0)/config.sh
CLUSTER=$1
MAP=$2
TEAM=$3
NAME=${TEAM_NAMES[$TEAM]}
SERVER=$(getServerHost $CLUSTER)
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
if [ ! -z $RUNNING_TEAM ]; then
echo "There is already a server running on cluster $CLUSTER"
echo "${TEAM_NAMES[$RUNNING_TEAM]} ($RUNNING_TEAM) on $RUNNING_MAP"
exit 1
fi;
echo "Starting run for team $NAME ($TEAM) on map $MAP on cluster $CLUSTER."
echo "Starting kernel..."
ssh $REMOTE_USER@$SERVER $SCRIPTDIR/remoteStartKernel.sh $MAP $NAME&
#!/bin/bash
. $(dirname $0)/config.sh
cd $LOCAL_HOMEDIR
case "$1" in
dist)
$(dirname $0)/syncKernels.sh $KERNELDIR $KERNELDIR
# $(dirname $0)/syncClients.sh $KERNELDIR
;;
maps)
$(dirname $0)/syncKernels.sh $MAPDIR $MAPDIR
;;
code)
if [ ! -z "$2" ]; then
$(dirname $0)/syncClients.sh $CODEDIR/$2 $CODEDIR/
else
$(dirname $0)/syncClients.sh $CODEDIR $CODEDIR
fi
;;
logs)
$(dirname $0)/gatherFromClients.sh $LOGDIR $HOME
$(dirname $0)/gatherFromKernels.sh $LOGDIR $HOME
;;
all)
$(dirname $0)/syncKernels.sh ~/scripts/ ~/scripts/
$(dirname $0)/syncClients.sh ~/scripts/ ~/scripts/
$(dirname $0)/syncKernels.sh $KERNELDIR/ $KERNELDIR/
# $(dirname $0)/syncClients.sh $KERNELDIR $KERNELDIR
$(dirname $0)/syncKernels.sh $MAPDIR/ $MAPDIR/
$(dirname $0)/syncClients.sh $CODEDIR/ $CODEDIR/
$(dirname $0)/gatherFromClients.sh $LOGDIR $HOME
$(dirname $0)/gatherFromKernels.sh $LOGDIR $HOME
;;
esac
#! /bin/bash
. $(dirname $0)/config.sh
TEAM=$1
HOST=$2
TYPE=$3
MAP=$4
declare -A CODES
CODES[1]=fire
CODES[2]=police
CODES[3]=ambulance
T=$(date +"%d-%m-%Y--%k-%M-%S")
LOGFILE=$HOME/$LOGDIR/$DAY/$TEAM/$MAP-$T-${CODES[$TYPE]}.log
mkdir -p $HOME/$LOGDIR/$DAY/$TEAM
cd $HOME/$CODEDIR/$TEAM
echo Starting agents on machine $(hostname)
# firebrigade
if (( $TYPE == 1)); then
echo "Running: /bin/sh \"start.sh\" -1 -1 0 0 0 0 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "start.sh" -1 -1 0 0 0 0 $HOST 2>&1 | tee $LOGFILE
fi
# policeforce
if (( $TYPE == 2)); then
echo "Running: /bin/sh \"start.sh\" 0 0 -1 -1 0 0 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "start.sh" 0 0 -1 -1 0 0 $HOST 2>&1 | tee $LOGFILE
fi
# ambulance
if (( $TYPE == 3)); then
echo "Running: /bin/sh \"start.sh\" 0 0 0 0 -1 -1 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "start.sh" 0 0 0 0 -1 -1 $HOST 2>&1 | tee $LOGFILE
fi
#! /bin/bash
. $(dirname $0)/config.sh
MAP=$1
TEAM=$2
NAME=${TEAM_NAMES[$TEAM]}
#export DISPLAY=:0
cd $HOME
if [ -d $MAPDIR/$MAP/config ]; then
CONFIG=$HOME/$MAPDIR/$MAP/config
else
CONFIG=config
fi
if [ -d $MAPDIR/$MAP/map ]; then
THISMAPDIR=$HOME/$MAPDIR/$MAP/map
else
THISMAPDIR=$HOME/$MAPDIR/$MAP
fi
TIME="`date +%m%d-%H%M%S`"
MAPNAME="`basename $MAP`"
RECORDS_LOGDIR=$HOME/records-logs/$DAY/$NAME
KERNEL_LOGDIR=$HOME/kernel-logs/$DAY/$TIME-$NAME-$MAPNAME
mkdir -p $RECORDS_LOGDIR
mkdir -p $KERNEL_LOGDIR
cd $KERNELDIR/boot
RESCUE_LOG=$LOGDIR/$DAY/kernel/$TIME-$NAME-$MAPNAME
echo "RUNNING_TEAM=$TEAM" >> $LOCKFILE_NAME
echo "RUNNING_MAP=$MAP" >> $LOCKFILE_NAME
./start-comprun.sh -m $THISMAPDIR -c $CONFIG -t $NAME -l $KERNEL_LOGDIR -j -r $RECORDS_LOGDIR &
echo "PID=$!" >> $LOCKFILE_NAME
wait
echo "RUNNING_TEAM=$TEAM" >> $STATFILE_NAME
echo "RUNNING_MAP=$MAP" >> $STATFILE_NAME
echo "RESCUE_LOGFILE=$RESCUE_LOG" >> $STATFILE_NAME
echo "Zipping logfile..."
mkdir -p $HOME/$LOGDIR/$DAY/kernel/
cp $KERNEL_LOGDIR/rescue.log $HOME/$RESCUE_LOG
7za a -m0=lzma2 $HOME/$RESCUE_LOG.7z $HOME/$RESCUE_LOG
rm -f $HOME/$RESCUE_LOG
#gzip --best $HOME/$RESCUE_LOG
rm $LOCKFILE_NAME
echo "All done"
#! /bin/bash
. $(dirname $0)/config.sh
MAP=$1
TEAM=$2
NAME=${TEAM_NAMES[$TEAM]}
#export DISPLAY=:0
cd $HOME
if [ -d $MAPDIR/$MAP/config ]; then
CONFIG=$HOME/$MAPDIR/$MAP/config
else
CONFIG=config
fi
if [ -d $MAPDIR/$MAP/map ]; then
THISMAPDIR=$HOME/$MAPDIR/$MAP/map
else
THISMAPDIR=$HOME/$MAPDIR/$MAP
fi
TIME="`date +%m%d-%H%M%S`"
MAPNAME="`basename $MAP`"
KERNEL_LOGDIR=$HOME/kernel-logs/$DAY/$TIME-$NAME-$MAPNAME-precompute
mkdir -p $KERNEL_LOGDIR
cd $KERNELDIR/boot
RESCUE_LOG=$LOGDIR/$DAY/kernel/$TIME-$NAME-$MAPNAME-precompute
echo "RUNNING_TEAM=$TEAM" >> $LOCKFILE_NAME
echo "PRECOMPUTE=yes" >> $LOCKFILE_NAME
echo "RUNNING_MAP=$MAP" >> $LOCKFILE_NAME
./start-precompute.sh -m $THISMAPDIR -c $CONFIG -t $NAME -l $KERNEL_LOGDIR &
echo "PID=$!" >> $LOCKFILE_NAME
wait
echo "RUNNING_TEAM=$TEAM" >> $STATFILE_NAME
echo "PRECOMPUTE=yes" >> $STATFILE_NAME
echo "RUNNING_MAP=$MAP" >> $STATFILE_NAME
echo "RESCUE_LOGFILE=$RESCUE_LOG" >> $STATFILE_NAME
echo "Zipping logfile..."
mkdir -p $HOME/$LOGDIR/$DAY/kernel/
cp $KERNEL_LOGDIR/rescue.log $HOME/$RESCUE_LOG
gzip $HOME/$RESCUE_LOG
rm $LOCKFILE_NAME
echo "Precomputation done"
#! /bin/bash
. $(dirname $0)/config.sh
TEAM=$1
HOST=$2
TYPE=$3
MAP=$4
declare -A CODES
CODES[1]=fire
CODES[2]=police
CODES[3]=ambulance
T=$(date +"%d-%m-%Y--%k-%M-%S")
LOGFILE=$HOME/$LOGDIR/$DAY/$TEAM/$MAP-$T-${CODES[$TYPE]}-precompute.log
mkdir -p $HOME/$LOGDIR/$DAY/$TEAM
cd $HOME/$CODEDIR/$TEAM
echo Starting precomputation on machine $(hostname)
# firebrigade
if (( $TYPE == 1)); then
echo "Running: /bin/sh \"precompute.sh\" 1 0 0 0 0 0 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "precompute.sh" 1 0 0 0 0 0 $HOST 2>&1 | tee $LOGFILE
fi
# policeforce
if (( $TYPE == 2)); then
echo "Running: /bin/sh \"precompute.sh\" 0 0 1 0 0 0 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "precompute.sh" 0 0 1 0 0 0 $HOST 2>&1 | tee $LOGFILE
fi
# ambulance
if (( $TYPE == 3)); then
echo "Running: /bin/sh \"precompute.sh\" 0 0 0 0 1 0 $HOST 2>&1 | tee $LOGFILE"
/bin/sh "precompute.sh" 0 0 0 0 1 0 $HOST 2>&1 | tee $LOGFILE
fi
#!/bin/bash
. $(dirname $0)/config.sh
CLUSTER=$1
MAP=$2
TEAM=$3
NAME=${TEAM_NAMES[$TEAM]}
SERVER=$(getServerHost $CLUSTER)
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
if [ ! -z $RUNNING_TEAM ]; then
echo "There is already a server running on cluster $CLUSTER"
echo "${TEAM_NAMES[$RUNNING_TEAM]} ($RUNNING_TEAM) on $RUNNING_MAP"
exit 1
fi;
echo "Starting run for team $NAME ($TEAM) on map $MAP on cluster $CLUSTER."
if [ -f "$CODEDIR/$TEAM/precompute.sh" ]; then
echo "Starting kernel for precomputation..."
ssh $REMOTE_USER@$SERVER $SCRIPTDIR/remoteStartKernelPrecompute.sh $MAP $TEAM&
sleep 6
for i in 1 2 3; do
CLIENT=$(getClientHost $CLUSTER $i)
ssh $REMOTE_USER@$CLIENT $SCRIPTDIR/remoteStartPrecompute.sh $TEAM $SERVER $i $MAP&
done;
sleep $PRECOMPUTE_TIMEOUT
echo "stopping precomputation run"
cancelRun.sh $CLUSTER
fi
echo "Starting kernel..."
ssh $REMOTE_USER@$SERVER $SCRIPTDIR/remoteStartKernel.sh $MAP $TEAM&
sleep 8
STATDIR=$LOCAL_HOMEDIR/$EVALDIR/$MAP/$TEAM
mkdir -p $STATDIR
#cd $LOCAL_HOMEDIR/$KERNELDIR/boot
#./extract-view.sh $NAME $SERVER $STATDIR&
#cd $HOME
sleep 8
for i in 1 2 3; do
CLIENT=$(getClientHost $CLUSTER $i)
ssh $REMOTE_USER@$CLIENT $SCRIPTDIR/remoteStartAgents.sh $TEAM $SERVER $i $MAP&
done;
sleep 2
echo "Waiting fo run to finish..."
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
while [ ! -z $RUNNING_TEAM ]; do
sleep 5
unset RUNNING_TEAM
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
done
echo "Evaluating run..."
cancelRun.sh $CLUSTER
evalRun.sh $CLUSTER
#!/bin/bash
. $(dirname $0)/config.sh
CLUSTER=$1
MAP=$2
TEAM=$3
NAME=${TEAM_NAMES[$TEAM]}
SERVER=$(getServerHost $CLUSTER)
for i in 1 2 3; do
CLIENT=$(getClientHost $CLUSTER $i)
ssh $REMOTE_USER@$CLIENT $SCRIPTDIR/remoteStartAgents.sh $TEAM $SERVER $i $MAP&
done;
#!/bin/bash
. $(dirname $0)/config.sh
CLUSTER=$1
MAP=$2
TEAM=$3
NAME=${TEAM_NAMES[$TEAM]}
SERVER=$(getServerHost $CLUSTER)
eval $(ssh $REMOTE_USER@$SERVER cat $KERNELDIR/boot/$LOCKFILE_NAME 2>/dev/null)
if [ ! -z $RUNNING_TEAM ]; then
echo "There is already a server running on cluster $CLUSTER"
echo "${TEAM_NAMES[$RUNNING_TEAM]} ($RUNNING_TEAM) on $RUNNING_MAP"
exit 1
fi;
echo "Starting run for team $NAME ($TEAM) on map $MAP on cluster $CLUSTER."
echo "Starting kernel..."
ssh $REMOTE_USER@$SERVER $SCRIPTDIR/remoteStartKernel.sh $MAP $NAME&
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment