mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
throw in the public flags; disallow unset variables
This commit is contained in:
parent
2a2f4d4395
commit
966616cbc4
1 changed files with 11 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -u -e
|
||||||
|
|
||||||
NGAMES=${NGAMES:-1}
|
NGAMES=${NGAMES:-1}
|
||||||
NROOMS=${NROOMS:-1}
|
NROOMS=${NROOMS:-1}
|
||||||
|
@ -51,7 +52,7 @@ connName() {
|
||||||
sort -u
|
sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ -n "$1" ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
*) usage
|
*) usage
|
||||||
;;
|
;;
|
||||||
|
@ -62,7 +63,7 @@ done
|
||||||
declare -A CHECKED_ROOMS
|
declare -A CHECKED_ROOMS
|
||||||
check_room() {
|
check_room() {
|
||||||
ROOM=$1
|
ROOM=$1
|
||||||
if [ -z "${CHECKED_ROOMS[$ROOM]}" ]; then
|
if [ -z ${CHECKED_ROOMS[$ROOM]:-""} ]; then
|
||||||
NUM=$(echo "SELECT COUNT(*) FROM games WHERE ntotal!=sum_array(nperdevice) AND room='$ROOM'" |
|
NUM=$(echo "SELECT COUNT(*) FROM games WHERE ntotal!=sum_array(nperdevice) AND room='$ROOM'" |
|
||||||
psql -q -t xwgames)
|
psql -q -t xwgames)
|
||||||
NUM=$((NUM+0))
|
NUM=$((NUM+0))
|
||||||
|
@ -82,8 +83,10 @@ build_cmds() {
|
||||||
check_room $ROOM
|
check_room $ROOM
|
||||||
NDEVS=$(($RANDOM%3+2))
|
NDEVS=$(($RANDOM%3+2))
|
||||||
DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]}
|
DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]}
|
||||||
|
# make one in three games public
|
||||||
|
[ $((RANDOM%3)) -eq 0 ] && PUBLIC="-A -R" || PUBLIC=""
|
||||||
|
|
||||||
unset OTHERS
|
OTHERS=""
|
||||||
for II in $(seq 2 $NDEVS); do
|
for II in $(seq 2 $NDEVS); do
|
||||||
OTHERS="-N $OTHERS"
|
OTHERS="-N $OTHERS"
|
||||||
done
|
done
|
||||||
|
@ -94,6 +97,7 @@ build_cmds() {
|
||||||
touch $LOG # so greps won't show errors
|
touch $LOG # so greps won't show errors
|
||||||
CMD="./obj_linux_memdbg/xwords -C $ROOM -r ${NAMES[$DEV]} $OTHERS"
|
CMD="./obj_linux_memdbg/xwords -C $ROOM -r ${NAMES[$DEV]} $OTHERS"
|
||||||
CMD="$CMD -d $DICT -p $PORT -a $HOST -f $FILE -z 1:3 $PLAT_PARMS"
|
CMD="$CMD -d $DICT -p $PORT -a $HOST -f $FILE -z 1:3 $PLAT_PARMS"
|
||||||
|
CMD="$CMD $PUBLIC"
|
||||||
CMDS[$COUNTER]=$CMD
|
CMDS[$COUNTER]=$CMD
|
||||||
FILES[$COUNTER]=$FILE
|
FILES[$COUNTER]=$FILE
|
||||||
LOGS[$COUNTER]=$LOG
|
LOGS[$COUNTER]=$LOG
|
||||||
|
@ -133,7 +137,7 @@ check_game() {
|
||||||
KEY=$1
|
KEY=$1
|
||||||
LOG=${LOGS[$KEY]}
|
LOG=${LOGS[$KEY]}
|
||||||
CONNNAME="$(connName $LOG)"
|
CONNNAME="$(connName $LOG)"
|
||||||
unset OTHERS
|
OTHERS=""
|
||||||
if [ -n "$CONNNAME" ]; then
|
if [ -n "$CONNNAME" ]; then
|
||||||
if grep -q '\[unused tiles\]' $LOG; then
|
if grep -q '\[unused tiles\]' $LOG; then
|
||||||
ALL_DONE=TRUE
|
ALL_DONE=TRUE
|
||||||
|
@ -143,7 +147,7 @@ check_game() {
|
||||||
CONNNAME2="$(connName $ALOG)"
|
CONNNAME2="$(connName $ALOG)"
|
||||||
if [ "$CONNNAME2" = "$CONNNAME" ]; then
|
if [ "$CONNNAME2" = "$CONNNAME" ]; then
|
||||||
if ! grep -q '\[unused tiles\]' $ALOG; then
|
if ! grep -q '\[unused tiles\]' $ALOG; then
|
||||||
unset OTHERS
|
OTHERS=""
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
OTHERS="$OTHERS $INDX"
|
OTHERS="$OTHERS $INDX"
|
||||||
|
@ -197,10 +201,10 @@ print_stats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "*********$0 starting: $(date)**************"
|
echo "*********$0 starting: $(date)**************"
|
||||||
|
STARTTIME=$(date +%s)
|
||||||
build_cmds
|
build_cmds
|
||||||
run_cmds
|
run_cmds
|
||||||
print_stats
|
print_stats
|
||||||
|
|
||||||
wait
|
wait
|
||||||
echo "*********$0 finished: $(date)**************"
|
echo "*********$0 finished: $(date) (took $(($(date +%s)-$STARTTIME)) seconds)**************"
|
||||||
|
|
Loading…
Reference in a new issue