wesnoth/utils/mp-server/send_server_message
Gunter Labes 93e1e73e98 replace == with = in test comparisons...
...(fixes bug #11496: Unportable test(1) construct)
2008-04-15 02:51:29 +00:00

33 lines
671 B
Bash
Executable File

#!/bin/sh
if ! [ $# -ge 1 ]; then
echo "Syntax: $0 <server version> [message]"
exit 1
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
SOCKET=$SERVERBASE/build/var/run/socket
if ! [ -d "$SERVERBASE" ]; then
echo "Server '$SERVER' not found."
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
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