
At least on baldras' version of screen, the stuff command argument here absolutely needs to be wrapped in single or double quotes to work. I actually fixed this months ago but forgot to commit.
26 lines
854 B
Bash
Executable file
26 lines
854 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> <command [arguments]>"
|
|
|
|
SERVER=$1
|
|
SERVERBASE=$HOME/servers/$SERVER
|
|
SOCKET=$SERVERBASE/build/var/run/socket
|
|
|
|
[ -d "$SERVERBASE" ] || die "Server '$SERVER' not found."
|
|
|
|
[ -e $SOCKET ] || { notfound oldbuild; [ -e $SOCKET ] || notfound revertedbuild; }
|
|
[ -p $SOCKET ] || die "$SOCKET is not a named pipe (fifo).
|
|
Is the $SERVER server running?"
|
|
|
|
shift
|
|
echo "$@" > $SOCKET
|
|
|
|
# hack to start the irc echo for the old instance on a restart
|
|
case "$1" in
|
|
restart*)
|
|
# delay for a bit to make sure we get the right log file since log rotation is also delayed
|
|
sleep 10
|
|
screen -S wesnoth-mp-servers -X eval "select lobby-echo" "stuff \"/wl-old $SERVER\012\"" ;;
|
|
esac
|