This wiki is archived and useful information is being migrated to the main bzflag.org website

Difference between revisions of "Rotating Maps"

From BZFlagWiki
Jump to: navigation, search
(show how to start the windows script and a few other changes)
(remove the redundant examples, just make it a plain posix shell script and match the other script more closely)
Line 37: Line 37:
  
  
== Linux ==
+
== POSIX Shell (Mac OS X, Linux, BSD, IRIX, etc) ==
  
 
Save the script below as '''rotate.sh'''
 
Save the script below as '''rotate.sh'''
Line 45: Line 45:
 
After editing the CONFIGPATH and path to bzfs, type '''chmod a+x rotate.sh''' and then '''./rotate.sh''' to run the script.
 
After editing the CONFIGPATH and path to bzfs, type '''chmod a+x rotate.sh''' and then '''./rotate.sh''' to run the script.
  
b=0
+
<pre>
if [ $1 ]; then
+
#!/bin/sh
    CONFIGPATH=$1 
+
else
+
    CONFIGPATH="/your/path/to/configfiles"
+
fi
+
+
until [ $b -lt 0 ]; do
+
    cd $CONFIGPATH
+
    ls -1 > /tmp/confnos
+
   
+
    LIMIT=$(awk 'END { print NR }' /tmp/confnos)
+
+
    for (( a=1; a <= LIMIT ; a++ ))
+
    do
+
      COM="NR=="$a
+
      FILE=$(awk $COM /tmp/confnos)
+
      FILE="$CONFIGPATH/$FILE"
+
      bzfs -conf $FILE
+
    done
+
done
+
  
 +
if [ $1 ] ; then
 +
  CONFIGPATH=$1 
 +
else
 +
  CONFIGPATH="/your/path/to/configfiles"
 +
fi
 +
cd $CONFIGPATH || echo "$CONFIGPATH not found"
  
== Mac OS X ==
+
BZFSPATH=/usr/local/bin/bzfs
  
Save the script below as '''rotate.sh'''
+
abort=0
 
+
while [ $abort -ne 0 ]; do
Put all your config files in the CONFIGPATH directory.
+
  for b in *.conf ; do
 
+
     $BZFSPATH -conf $b
After editing the CONFIGPATH and path to bzfs, type '''chmod a+x rotate.sh''' and then '''./rotate.sh''' to run the script.
+
     if [ $? -ne 0 ] ; then
 
+
      abort=1
b=0
+
      break
CONFIGPATH="/path/to/config/files"
+
    fi
cd $CONFIGPATH
+
  done
until [ $b -lt 0 ]; do
+
  echo "Reached end of rotation, starting over."
    for FILE in *
+
done
     do
+
</pre>
      RUNFILE=$CONFIGPATH"/"$FILE
+
      /path/to/bzfs/bzfs -conf $RUNFILE
+
     done
+
done
+

Revision as of 00:40, 20 February 2007

Windows

Copy and the script below into notepad and save it as start-server.bat.

All paths should be in 8.3 notation e.g. progra~1 not program files

Don't forget to add -g and -time <secs> to your config files.

Press CTRL-C twice and "y" to answer "Terminate Batch Job (y/n)?" to exit.

You will probably need to edit the paths to the bzfs binary and your configuration files.

You should have all your config files in the same directory as you specified in the script.

To run the server, you just need to double-click on start-server.bat.

@ECHO OFF

BREAK ON

SET BZFSPATH=c:\progra~1\bzflag~1.2\bzfs.exe

IF "%1" == "" SET CONFDIR=c:\your\path\to\conf\files

IF NOT "%1" == "" SET CONFDIR=%1


:loop_top

ECHO.

FOR %%b IN (%CONFDIR%\*.conf) DO %BZFSPATH% -conf %%b

ECHO "Reached end of rotation, starting over.


GOTO loop_top


POSIX Shell (Mac OS X, Linux, BSD, IRIX, etc)

Save the script below as rotate.sh

Put all your config files in the CONFIGPATH directory.

After editing the CONFIGPATH and path to bzfs, type chmod a+x rotate.sh and then ./rotate.sh to run the script.

#!/bin/sh

if [ $1 ] ; then
   CONFIGPATH=$1   
else
   CONFIGPATH="/your/path/to/configfiles"
fi
cd $CONFIGPATH || echo "$CONFIGPATH not found"

BZFSPATH=/usr/local/bin/bzfs

abort=0
while [ $abort -ne 0 ]; do
  for b in *.conf ; do
    $BZFSPATH -conf $b
    if [ $? -ne 0 ] ; then
      abort=1
      break
    fi
  done
  echo "Reached end of rotation, starting over."
done