added the shell scripts used to manage the official multiplayer servers

This commit is contained in:
Gunter Labes 2007-11-19 22:10:39 +00:00
parent ec12f029d3
commit db3fe9066d
5 changed files with 195 additions and 0 deletions

28
utils/mp-server/new_release Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
if [ "$1" == "-n" ]; then
echo=echo
else
echo=""
fi
shift
if ! [ $# -ge 1 ]; then
echo "Syntax: $0 [-n] <new minor version>"
exit 1
fi
[ $1 -ge 2 ] || exit 1
if ! ps -C wesnothd-1.3-prev>/dev/null; then
echo "Previous server isn't running!"
exit 1
fi
# update the motd
$echo sed -i -e "s/motd=\(.*\)1\.3\.$(($1-1))/motd=\11.3.$1/g" ~/servers/1.3-prev/wesnothd.cfg
$echo killall -SIGHUP wesnothd-1.3-prev || exit 1
$echo sed -i -e "s/motd=\(.*\)1\.3\.$(($1-1))/motd=\11.3.$1/g" ~/servers/1.3/wesnothd.cfg
$echo killall -SIGHUP wesnothd-1.3 || exit 1
$echo send_server_command 1.3 msg Version 1.3.$1 released! New users with the previous version will be redirected to a temporary server that will run until binaries for all major OSs are out.
# update dev server redirect; must be before updating the previous server redirect!
$echo sed -i -e "/\[redirect\]/N;s/version=\(.*\)1\.3\.$(($1-1))/version=\11.3.$(($1+1))/g" ~/servers/trunk/wesnothd.cfg
# update previous server redirect
$echo sed -i -e "/\[redirect\]/N;s/version=\(.*\)1\.3\.$(($1-2))/version=\11.3.$(($1-1))/g" ~/servers/trunk/wesnothd.cfg
# reload the config
$echo killall -SIGHUP wesnothd-trunk

51
utils/mp-server/run_server Executable file
View file

@ -0,0 +1,51 @@
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Syntax: $0 <server version>"
exit 1
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
[ -d "$SERVERBASE/logs" ] || mkdir $SERVERBASE/logs
[ -d "$SERVERBASE" ] || exit 1
ulimit -Ss 2048
ulimit -c unlimited
# send the standard server message to the appropriate server when killing it with ctrl+c
trap "$HOME/bin/send_server_message $SERVER; sleep 2; kill %1; echo -n 'terminated: '; date; exit 0" SIGINT
while [ true ]
do
if ps -C wesnothd-$SERVER >/dev/null; then
sleep 10
else
DATE=$(date +"%Y%m%d-%H%M%S")
PORT=$(cat $SERVERBASE/port)
REV=$(ls -l $SERVERBASE/build | sed -e 's,.*wesnothd-\(svn-.*\)_.*/,\1,')
cd $SERVERBASE/build || exit 1
[ -x bin/wesnothd-$SERVER ] || exit 1
nice -n 3 bin/wesnothd-$SERVER -c $SERVERBASE/wesnothd.cfg --port $PORT --threads 30 > $SERVERBASE/logs/wesnothd.$DATE.$REV.log 2>&1 &
PID=$!
echo -n "started $SERVER server (revision: $REV, pid: $PID) at: "; date
cd $SERVERBASE
rm -f old.log oldlobby.log
mv current.log old.log > /dev/null 2>&1
mv currentlobby.log oldlobby.log > /dev/null 2>&1
ln -s logs/wesnothd.$DATE.$REV.log current.log
ln -s logs/lobby.$DATE.$REV.log currentlobby.log
# wait a bit so the server is likely up and listening
sleep 1
case $SERVER in
1.2 ) (cd $HOME/source/trunk/utils/; ./mp-lobby-logger-1.2.pl -j -p $PORT -l $SERVERBASE/currentlobby.log >> $SERVERBASE/logs/lobby-chat.log 2>&1 &)
;;
1.3 ) (cd $HOME/source/trunk/utils/; ./mp-lobby-logger.pl -j -p $PORT -l $SERVERBASE/currentlobby.log >> $SERVERBASE/logs/lobby-chat.log 2>&1 &)
;;
* )
esac
# wait for the server to terminate
wait $PID
cd
fi
done

View file

@ -0,0 +1,22 @@
#!/bin/sh
if ! [ $# -ge 2 ]; then
echo "Syntax: $0 <server version> <command [arguments]>"
exit 1
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
SOCKET=$SERVERBASE/build/var/run/socket
if ! [ -e $SOCKET ]; then
echo "$SOCKET not found, using the 'oldbuild'."
SOCKET=$SERVERBASE/oldbuild/var/run/socket
fi
if ! [ -p $SOCKET ]; then
echo "$SOCKET is not a named pipe (fifo)"
exit 1
fi
shift
echo $* > $SOCKET

View file

@ -0,0 +1,28 @@
#!/bin/sh
if ! [ $# -ge 1 ]; then
echo "Syntax: $0 <server version> [message]"
exit 1
fi
shift
if [ "$*" == "" ]; then
message="The server will get restarted now. Please don't forget to save your game!"
echo "Sending standard message: $message"
else
message=$*
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
SOCKET=$SERVERBASE/build/var/run/socket
if ! [ -e $SOCKET ]; then
echo "$SOCKET not found, sending to the 'oldbuild'."
SOCKET=$SERVERBASE/oldbuild/var/run/socket
fi
if ! [ -p $SOCKET ]; then
echo "$SOCKET is not a named pipe (fifo)"
exit 1
fi
echo "msg $message" > $SOCKET

66
utils/mp-server/update_server Executable file
View file

@ -0,0 +1,66 @@
#!/bin/sh
if [ $# -gt 2 -o $# -lt 1 ]; then
echo "Syntax: $0 <server version> [<revision>]"
exit 1
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
BUILD=$HOME/servers/builds
SOURCE=$HOME/source
TRUNK=$SOURCE/trunk/
STABLE=$SOURCE/1.2/
SOCKET=$SERVERBASE/build/var/run/socket
if ! [ -d $SERVERBASE ]; then
echo "$SERVER server not found."
exit 1
fi
if ! [ -d $SOURCE ]; then
echo "$SOURCE not found."
exit 1
fi
if [ "$SERVER" = "1.2" ]; then
cd $STABLE || exit 1
else
cd $TRUNK || exit 1
fi
REVISION=""
if [ "$2" != "" ]; then
REVISION="-r $2"
fi
echo 'svn update...'
rev=$(svn up $REVISION | tail -n 1 | sed -e 's/[^0-9]//g')
if [ "$rev" == "" ]; then
echo "No revision information found."
exit 1
fi
# reminder for local changes
echo "to $rev"
svn status
DIR=wesnothd-svn-${rev}_$SERVER
mkdir $BUILD/$DIR
echo 'autogen.sh and configure...'
./autogen.sh > $BUILD/$DIR/autogen.log
./configure --prefix=$BUILD/$DIR --program-suffix=-$SERVER --enable-server --enable-raw-sockets --disable-game --with-fifodir=$BUILD/$DIR/var/run --disable-nls --enable-debug --enable-lite > $BUILD/$DIR/configure.log
#CXXFLAGS='-DNETWORK_USE_RAW_SOCKETS'
make clean > /dev/null
echo 'make...'
make > $BUILD/$DIR/make.log
echo 'make install...'
make install > $BUILD/$DIR/install.log
cd $SERVERBASE
if [ -p $SOCKET ]; then
rm -f oldbuild
mv build oldbuild
else #the server under build has never been started, keep the oldbuild link to the (currently) running server
rm -f build
fi
ln -s ../builds/$DIR/ build