Author: soliton
Date: Tue May 19 00:15:18 2009
New Revision: 35744
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35744&view=rev
Log:
consistently quote variables that may have spaces in them
Modified:
trunk/utils/mp-server/run_server
Modified: trunk/utils/mp-server/run_server
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/mp-server/run_server?rev=35744&r1=35743&r2=35744&view=diff
==============================================================================
--- trunk/utils/mp-server/run_server (original)
+++ trunk/utils/mp-server/run_server Tue May 19 00:15:18 2009
@@ -6,28 +6,29 @@
dietail() {
echo >&2 "$@"
echo >&2 "tail $LOG:"
- tail $SERVERBASE/logs/$LOG
+ tail "$SERVERBASE/logs/$LOG"
exit 1
}
[ $# -ge 1 ] || die "Syntax: $0 <server version> [--test] [<additional
parameters for wesnothd>]"
SERVER=$1
-SERVERBASE=$HOME/servers/$SERVER
+SERVERBASE="$HOME/servers/$SERVER"
[ -d "$SERVERBASE" ] || die "Server '$SERVER' not found."
-[ -d "$SERVERBASE/logs" ] || mkdir $SERVERBASE/logs
+[ -d "$SERVERBASE"/logs ] || mkdir "$SERVERBASE"/logs
+[ -d "$SERVERBASE"/replays ] || mkdir "$SERVERBASE"/replays
shift
if [ "$1" = "--test" ]; then
shift
- PARAMETERS=$*
- cd $SERVERBASE/build || exit 1
- bin/wesnothd-$SERVER -c $SERVERBASE/wesnothd.cfg --port 15001
$PARAMETERS
+ PARAMETERS="$@"
+ cd "$SERVERBASE"/build || exit 1
+ bin/wesnothd-$SERVER -c "$SERVERBASE"/wesnothd.cfg --port 15001
$PARAMETERS
# remove the socket so it looks like we never ran the server
rm var/run/socket
exit 0
fi
-PARAMETERS=$*
+PARAMETERS="$@"
THREADS=4
PORT=15000
@@ -61,26 +62,24 @@
while [ true ]
do
- cd $SERVERBASE/build || exit 1
+ cd "$SERVERBASE"/build || exit 1
[ -x bin/wesnothd-$SERVER ] || die "Executable 'bin/wesnothd-$SERVER'
not found."
DATE=$(date +"%Y%m%d-%H%M%S")
- [ ! -f "$SERVERBASE/redirect.cfg" ] || PORT=$(sed -re '/port=/!d;s/[
\t]*port="?([0-9]+)"?/\1/' $SERVERBASE/redirect.cfg)
- BUILDDIR=$(ls -ld $SERVERBASE/build | sed -e
's,.*\(\.\./builds/wesnothd-.*/\),\1,')
- REV=r$(echo "$BUILDDIR" | sed -re
"s,.*wesnothd-svn-([0-9:SM]+)_$SERVER/$,\1,")
+ [ ! -f "$SERVERBASE"/redirect.cfg ] || PORT=$(sed -nre '/port=/s/[
\t]*port="?([0-9]+)"?/\1/p' "$SERVERBASE"/redirect.cfg)
+ BUILDDIR=$(ls -ld "$SERVERBASE"/build | sed -nre
's,.*(\.\./builds/wesnothd-[^ ]+/),\1,p')
+ REV=r$(echo $BUILDDIR | sed -nre
"s,.*wesnothd-svn-([0-9:SM]+)_$SERVER/$,\1,p")
LOG="wesnothd.$DATE.$REV.log"
- COMMAND="bin/wesnothd-$SERVER -c $SERVERBASE/wesnothd.cfg --port $PORT
--threads $THREADS $PARAMETERS"
- $COMMAND &> "$SERVERBASE/logs/$LOG" &
-
+ bin/wesnothd-$SERVER -c "$SERVERBASE"/wesnothd.cfg --port $PORT
--threads $THREADS $PARAMETERS &> "$SERVERBASE/logs/$LOG" &
PID=$!
- echo "started $SERVER server with command: '$COMMAND' (revision: $REV,
pid: $PID) logging to: $LOG"
+ echo "started $SERVER server with command: 'wesnothd-$SERVER -c
\"$SERVERBASE\"/wesnothd.cfg --port $PORT --threads $THREADS $PARAMETERS'
(revision: $REV, pid: $PID) logging to: $LOG"
# create some convenient links
ln -s "$SERVERBASE/logs/$LOG" "$LOG.$PID"
- rm -f $SERVERBASE/old.{log,pid}
- mv $SERVERBASE/current.log $SERVERBASE/old.log &> /dev/null
- mv $SERVERBASE/current.pid $SERVERBASE/old.pid &> /dev/null
- echo $PID > $SERVERBASE/current.pid
- ln -s "logs/$LOG" $SERVERBASE/current.log
+ rm -f "$SERVERBASE"/old.{log,pid}
+ mv "$SERVERBASE"/current.log "$SERVERBASE"/old.log &> /dev/null
+ mv "$SERVERBASE"/current.pid "$SERVERBASE"/old.pid &> /dev/null
+ echo $PID > "$SERVERBASE"/current.pid
+ ln -s "logs/$LOG" "$SERVERBASE"/current.log
# wait for the server to terminate
wait $PID
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits