#!/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=$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