mail[Wesnoth-commits] r33740 - /trunk/utils/mp-server/send_server_message


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by soliton . de on March 17, 2009 - 04:35:
Author: soliton
Date: Tue Mar 17 04:35:04 2009
New Revision: 33740

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33740&view=rev
Log:
added sending to the revertedbuild + refactoring

Modified:
    trunk/utils/mp-server/send_server_message

Modified: trunk/utils/mp-server/send_server_message
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/mp-server/send_server_message?rev=33740&r1=33739&r2=33740&view=diff
==============================================================================
--- trunk/utils/mp-server/send_server_message (original)
+++ trunk/utils/mp-server/send_server_message Tue Mar 17 04:35:04 2009
@@ -1,16 +1,14 @@
 #!/bin/sh
-if ! [ $# -ge 1 ]; then
-       echo "Syntax: $0 <server version> [message]" >&2
-       exit 1
-fi
+die() {        echo >&2 "$@"; exit 1; }
+notfound() { echo >&2 "$SOCKET not found, sending to the '$1'."; 
SOCKET=$SERVERBASE/$1/var/run/socket; }
+
+[ $# -ge 1 ] || die "Syntax: $0 <server version> [message]"
 
 SERVER=$1
 SERVERBASE=$HOME/servers/$SERVER
 SOCKET=$SERVERBASE/build/var/run/socket
-if ! [ -d "$SERVERBASE" ]; then
-       echo "Server '$SERVER' not found." >&2
-       exit 1
-fi
+
+[ -d "$SERVERBASE" ] die "Server '$SERVER' not found."
 shift
 if [ "$*" = "" ]; then
        message="The server will get restarted now. Please don't forget to 
save your game!"
@@ -19,15 +17,9 @@
        message=$*
 fi
 
-if ! [ -e $SOCKET ]; then
-       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)." >&2
-       echo "Is the $SERVER server running?" >&2
-       exit 1
-fi
+[ -e $SOCKET ] || { notfound oldbuild; [ -e $SOCKET ] || notfound 
revertedbuild; }
+[ -p $SOCKET ] || die "$SOCKET is not a named pipe (fifo).
+Is the $SERVER server running?"
 
 echo "msg $message" > $SOCKET
 




Related Messages


Powered by MHonArc, Updated Tue Mar 17 04:40:31 2009