mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-19 08:23:22 +00:00

Respect server options given as script arguments. Fix killing background process in trap. Use printf instead of echo. Keep upper case variable names reserved for env variables. Logfilter scripts converted to sed -E and removed GNUisms.
26 lines
769 B
Bash
Executable File
26 lines
769 B
Bash
Executable File
#!/bin/sh
|
|
die() { printf '%s\n' "$*" >&2; exit 1; }
|
|
notfound() { printf '%s not found, sending to the "%s".\n' "$fifo" "$1" >&2; fifo=$serverbase/$1/var/run/socket; }
|
|
|
|
[ $# -ge 1 ] || die "Syntax: $0 <server version> [<message>]"
|
|
|
|
server=$1
|
|
serverbase=$HOME/servers/$server
|
|
fifo=$serverbase/build/var/run/socket
|
|
shift
|
|
|
|
[ -d "$serverbase" ] || die "Server '$server' not found."
|
|
|
|
if [ "$*" = "" ]; then
|
|
message="The server will get restarted now. Please don't forget to save your game!"
|
|
printf 'Sending standard message: \n' "$message"
|
|
else
|
|
message=$*
|
|
fi
|
|
|
|
[ -e "$fifo" ] || { notfound oldbuild; [ -e "$fifo" ] || notfound revertedbuild; }
|
|
[ -p "$fifo" ] || die "$fifo is not a named pipe (fifo).
|
|
Is the $server server running?"
|
|
|
|
printf 'msg %s\n' "$message" > "$fifo"
|