#!/bin/sh
#
# Copyright (C) 2005 Mekensleep
#
# Mekensleep
# 24 rue vieille du temple
# 75004 Paris
#       licensing@mekensleep.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Authors:
#  Loic Dachary <loic@gnu.org>
#
set -e

COOKIES=$0.cookies
rm -f ${COOKIES}
#DUMP_HEADERS='--dump-header /dev/tty'
touch run-pokerserver.launching
MYSQL_ROOT_PASSWORD=--password='' sh run-pokerserver &
pokerserver_pid=$!
trap "kill $pokerserver_pid ; rm -f $0.{cookies,out}" EXIT INT QUIT
lockfile run-pokerserver.launching
rm -f run-pokerserver.launching

if [ "$(chase /var/www/test-poker-web)" != "$(chase ../pokerweb/pages)" ] ; then
    rm -f /var/www/test-poker-web
    ln -s $(chase ../pokerweb/pages) /var/www/test-poker-web
fi

rm -f ../pokerweb/pages/constants.php
sed -e 's/@POKER_SERVER_HOST@:19382/localhost:19482/' < ../pokerweb/conf/constants.php.in > ../pokerweb/pages/constants.php

. ../tests/pokerweb
