mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
Merge remote branch 'origin/android_branch' into android_branch
This commit is contained in:
commit
4581046954
1 changed files with 38 additions and 0 deletions
38
xwords4/relay/scripts/track_room.sh
Executable file
38
xwords4/relay/scripts/track_room.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e -u
|
||||
|
||||
CONNNAME=""
|
||||
LASTLINE=""
|
||||
INTERVAL=30
|
||||
|
||||
usage() {
|
||||
[ $# -gt 0 ] && echo "Error: $1"
|
||||
echo "Usage: $(basename $0) connname"
|
||||
exit 1
|
||||
}
|
||||
|
||||
read_row() {
|
||||
echo "select * from games where connname='${CONNNAME}';" | psql xwgames | grep $CONNNAME
|
||||
}
|
||||
|
||||
print_line() {
|
||||
echo "$(date): $LASTLINE"
|
||||
}
|
||||
|
||||
[ $# -eq 1 ] || usage
|
||||
|
||||
CONNNAME=$1
|
||||
LASTLINE=$(read_row $CONNNAME)
|
||||
[ -z "$LASTLINE" ] && usage "$CONNNAME not found"
|
||||
|
||||
print_line
|
||||
|
||||
while :; do
|
||||
sleep $INTERVAL
|
||||
NEWLINE=$(read_row)
|
||||
if [ "$NEWLINE" != "$LASTLINE" ]; then
|
||||
LASTLINE="$NEWLINE"
|
||||
print_line
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue