wesnoth/utils/mp-server/send_server_message
Gunter Labes 9b5f29b7f4 typo fix
2009-04-03 23:37:52 +00:00

25 lines
738 B
Bash
Executable file

#!/bin/sh
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
[ -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!"
echo "Sending standard message: $message"
else
message=$*
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