From 7fa46610944651ce615380f2227557952fa96e35 Mon Sep 17 00:00:00 2001 From: Gunter Labes Date: Sat, 26 Apr 2008 18:10:52 +0000 Subject: [PATCH] send error messages to STDERR get the server port from the redirect.cfg (which needs to be changed anyway) --- utils/mp-server/new_release | 8 ++++---- utils/mp-server/revert_build | 4 ++-- utils/mp-server/run_server | 21 +++++++++++---------- utils/mp-server/send_server_command | 9 +++++---- utils/mp-server/send_server_message | 9 +++++---- utils/mp-server/update_server | 12 ++++++------ 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/utils/mp-server/new_release b/utils/mp-server/new_release index 5a4f41255c9..cab6abbc5a2 100755 --- a/utils/mp-server/new_release +++ b/utils/mp-server/new_release @@ -6,7 +6,7 @@ else echo="" fi if ! [ $# -ge 1 ]; then - echo "Syntax: $0 [-n] " + echo "Syntax: $0 [-n] " >&2 exit 1 fi [ $1 -ge 1 ] || exit 1 @@ -31,14 +31,14 @@ $echo sed -i -e "/motd=/s/$PREV_VERSION/$NEW_VERSION/g" $PREV_SERVER_CONFIG $echo killall -SIGHUP wesnothd-$DEV_VERSION-prev || exit 1 # check if we currently allow the previous version to prevent announcing the same version twice if ! [ $(grep "versions_accepted=.*$PREV_VERSION" $DEV_SERVER_CONFIG) ]; then - echo "Previous version $PREV_VERSION currently not allowed. Announcing the right version? Aborting..." + echo "Previous version $PREV_VERSION currently not allowed. Announcing the right version? Aborting..." >&2 exit 1 fi $echo sed -i -e "/versions_accepted=/s/$PREV_VERSION/$NEXT_VERSION/" $DEV_SERVER_CONFIG $echo sed -i -e "/motd=/s/$PREV_VERSION/$NEW_VERSION/g" $DEV_SERVER_CONFIG # update previous version redirect $echo sed -i -e "/\[redirect\]/N;/version=/s/$PPREV_VERSION/$PREV_VERSION/" $PREV_SERVER_REDIRECT -$echo sed -i -e "s,#{./$DEV_VERSION-prev-redirect.cfg},{./$DEV_VERSION-prev-redirect.cfg}," $DEV_SERVER_CONFIG +$echo sed -i -e "s,#\({./$DEV_VERSION-prev-redirect.cfg}\),\1," $DEV_SERVER_CONFIG # reload the config $echo killall -SIGHUP wesnothd-$DEV_VERSION wesnothd-trunk || exit 1 -$echo send_server_command $DEV_VERSION msg Version $NEW_VERSION has been released! New users with the previous version will now get redirected to a temporary server that will run until binaries for all major OSs are out. +$echo $HOME/bin/send_server_command $DEV_VERSION msg Version $NEW_VERSION has been released! New users with the previous version will now get redirected to a temporary server that will run until binaries for all major OSes are out. diff --git a/utils/mp-server/revert_build b/utils/mp-server/revert_build index 1dd5149fd48..02018509eb4 100755 --- a/utils/mp-server/revert_build +++ b/utils/mp-server/revert_build @@ -1,6 +1,6 @@ #!/bin/sh if ! [ $# -eq 1 ]; then - echo "Syntax: $0 " + echo "Syntax: $0 " >&2 exit 1 fi @@ -8,7 +8,7 @@ SERVER=$1 SERVERBASE=$HOME/servers/$SERVER if ! [ -d $SERVERBASE ]; then - echo "$SERVER server not found." + echo "$SERVER server not found." >&2 exit 1 fi diff --git a/utils/mp-server/run_server b/utils/mp-server/run_server index f561beb1394..cd2b5ed84dc 100755 --- a/utils/mp-server/run_server +++ b/utils/mp-server/run_server @@ -1,6 +1,6 @@ #!/bin/sh if [ $# -lt 1 ]; then - echo "Syntax: $0 []" + echo "Syntax: $0 []" >&2 exit 1 fi @@ -11,7 +11,7 @@ SERVERBASE=$HOME/servers/$SERVER SOURCE=$HOME/source/trunk if ! [ -d "$SERVERBASE" ]; then - echo "Server '$SERVER' not found." + echo "Server '$SERVER' not found." >&2 exit 1 fi [ -d "$SERVERBASE/logs" ] || mkdir $SERVERBASE/logs @@ -30,7 +30,6 @@ case $SERVER in ;; * ) esac -OPTIONS="-c $SERVERBASE/wesnothd.cfg --port $PORT --threads $THREADS $PARAMETERS" ulimit -Ss 2048 ulimit -c unlimited @@ -43,18 +42,20 @@ do if ps -C wesnothd-$SERVER >/dev/null; then sleep 10 else - DATE=$(date +"%Y%m%d-%H%M%S") - BUILDDIR=$(ls -l $SERVERBASE/build | sed -e 's,.*\(\.\./builds/wesnothd-.*/\),\1,') - REV=$(ls -l $SERVERBASE/build | sed -e 's,.*wesnothd-\(svn-.*\)_.*/,\1,') - LOG=wesnothd.$DATE.$REV.log cd $SERVERBASE/build || exit 1 if ! [ -x bin/wesnothd-$SERVER ]; then - echo "Executable 'bin/wesnothd-$SERVER' not found." + echo "Executable 'bin/wesnothd-$SERVER' not found." >&2 exit 1 fi - nice -n 3 bin/wesnothd-$SERVER $OPTIONS > $SERVERBASE/logs/$LOG 2>&1 & + DATE=$(date +"%Y%m%d-%H%M%S") + PORT=$(sed -re '/port=/!d;s/[ \t]*port="?([0-9]+)"?/\1/' $SERVERBASE/redirect.cfg) + BUILDDIR=$(ls -l $SERVERBASE/build | cut -d ' ' -f 12) + REV=r$(echo "$BUILDDIR" | sed -re "s,.*wesnothd-svn-([0-9:SM]+)_$SERVER/$,\1,") + LOG=wesnothd.$DATE.$REV.log + COMMAND="bin/wesnothd-$SERVER -c $SERVERBASE/wesnothd.cfg --port $PORT --threads $THREADS $PARAMETERS" + nice -n 3 $COMMAND > $SERVERBASE/logs/$LOG 2>&1 & PID=$! - echo -n "started $SERVER server (revision: $REV, pid: $PID) at: "; date + echo "started $SERVER server with command: '$COMMAND' (revision: $REV, pid: $PID) at: $DATE" ln -s ../../$SERVER/logs/$LOG $LOG.$PID rm -f $SERVERBASE/old.log mv $SERVERBASE/current.log $SERVERBASE/old.log > /dev/null 2>&1 diff --git a/utils/mp-server/send_server_command b/utils/mp-server/send_server_command index 9e10991fc8b..83af9936a96 100755 --- a/utils/mp-server/send_server_command +++ b/utils/mp-server/send_server_command @@ -1,6 +1,6 @@ #!/bin/sh if ! [ $# -ge 2 ]; then - echo "Syntax: $0 " + echo "Syntax: $0 " >&2 exit 1 fi @@ -8,15 +8,16 @@ SERVER=$1 SERVERBASE=$HOME/servers/$SERVER SOCKET=$SERVERBASE/build/var/run/socket if ! [ -d "$SERVERBASE" ]; then - echo "Server '$SERVER' not found." + echo "Server '$SERVER' not found." >&2 exit 1 fi if ! [ -e $SOCKET ]; then - echo "$SOCKET not found, using the 'oldbuild'." + echo "$SOCKET not found, using the 'oldbuild'." >&2 SOCKET=$SERVERBASE/oldbuild/var/run/socket fi if ! [ -p $SOCKET ]; then - echo "$SOCKET is not a named pipe (fifo)" + echo "$SOCKET is not a named pipe (fifo)." >&2 + echo "Is the $SERVER server running?" >&2 exit 1 fi diff --git a/utils/mp-server/send_server_message b/utils/mp-server/send_server_message index 49e803fd384..5a3d081a27f 100755 --- a/utils/mp-server/send_server_message +++ b/utils/mp-server/send_server_message @@ -1,6 +1,6 @@ #!/bin/sh if ! [ $# -ge 1 ]; then - echo "Syntax: $0 [message]" + echo "Syntax: $0 [message]" >&2 exit 1 fi @@ -8,7 +8,7 @@ SERVER=$1 SERVERBASE=$HOME/servers/$SERVER SOCKET=$SERVERBASE/build/var/run/socket if ! [ -d "$SERVERBASE" ]; then - echo "Server '$SERVER' not found." + echo "Server '$SERVER' not found." >&2 exit 1 fi shift @@ -20,11 +20,12 @@ else fi if ! [ -e $SOCKET ]; then - echo "$SOCKET not found, sending to the 'oldbuild'." + echo "$SOCKET not found, sending to the 'oldbuild'." >&2 SOCKET=$SERVERBASE/oldbuild/var/run/socket fi if ! [ -p $SOCKET ]; then - echo "$SOCKET is not a named pipe (fifo)" + echo "$SOCKET is not a named pipe (fifo)." >&2 + echo "Is the $SERVER server running?" >&2 exit 1 fi diff --git a/utils/mp-server/update_server b/utils/mp-server/update_server index f639a920f67..af91bb47b52 100755 --- a/utils/mp-server/update_server +++ b/utils/mp-server/update_server @@ -1,7 +1,7 @@ #!/bin/sh if [ $# -gt 2 -o $# -lt 1 ]; then - echo "Syntax: $0 []" + echo "Syntax: $0 []" >&2 exit 1 fi @@ -11,12 +11,12 @@ SOURCE=$HOME/source SOCKET=$SERVERBASE/build/var/run/socket if ! [ -d $SERVERBASE ]; then - echo "$SERVER server not found." + echo "$SERVER server not found." >&2 exit 1 fi if ! [ -d $SOURCE ]; then - echo "$SOURCE not found." + echo "$SOURCE not found." >&2 exit 1 fi # only really needed on server.wesnoth.org @@ -28,7 +28,7 @@ case $SERVER in ;; 1.4 ) cd $SOURCE/1.4 || exit 1 CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7" - #SCONS=yes + SCONS=yes ;; * ) cd $SOURCE/trunk || exit 1 CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -O0" @@ -42,10 +42,10 @@ if [ "$2" != "" ]; then fi echo -n 'svn update... ' svn up $REVISION > /dev/null -rev=$(svnversion -n src/) +rev=$(svnversion -cn src/ | cut -d: -f2) echo "to $rev" if [ "$rev" = "" ]; then - echo "No revision information found." + echo "No revision information found." >&2 exit 1 fi # reminder for local changes