VGA-Planets Hosting Scripts v3.3
These consist of bash-scripts to save a turn, run the host and send
one or all results. It is assumed you:
- know what bash is (tcsh does not work; not tested under other shells),
- can process your mail automatically (using a .forward file or with
procmail; you can also pipe incoming mails to SaveTrn and
SendRst by hand),
- can work with crontab (if you want hosting to happen at previously set
times. You can also run RunHost from the command line).
- Use PHost... That is, the Turn Number is taken from a PHost
``host.log''. If you change the commands to do that, you can use any hosting
program you want. But there is no general set of commands for this. The same
holds for errorcodes allowed after the check by PHost in SaveTrn.
So, if your not discouraged by the above... Now the advantages:
- Easy configurable,
- Extensive checking on incoming turns and result-requests,
- Allows for manual and automatic hosting/mail-processing,
- Different games can use different sets of data.
- You can set a minimum amount of required turns before (automatic) hosting
takes place.
Copyright
This package falls under the GNU Public License. However, if you want to help
your fellow hosts with the same scripts, pass any error or other improvement on
to the author, so newer versions with fewer bugs
and more functionality can be provided from a central point.
Contents
This package contains:
- SetEnv
- CheckEnv
- CreateGame
- RunHost
- SendRst
- SaveTrn
- host.html
- player.html
- Makefile
- a sample mail processing script, mail.processor
- a sample commands file
- a sample authorized file
Added later will be:
- rehost
- repair.timestamp.c
Installing the scripts
Make a directory like $HOME/vga/host/scripts where you put all
the scripts.
Makefile
Edit Makefile with your favorite editor, where you fill at the open
spots in the first non-comment block:
- The shell you want to be used by the scripts (the shell is bash, but in
case it is not located at the usual /bin/bash, enter the proper path
here),
- The basic directory, where all games will be subdirectories of,
- The scripts directory, where all these scripts are currently.
Make sure the names for the basic and scripts directories do not end in a
slash! Then run make. In all scripts the proper shell, BASEDIR and
SCRIPTDIR will be filled in. (A temporary file is made on /tmp and
deleted immediately.)
You can also invoke the make program like this:
make MYSHELL=/bin/bash BASEDIR='~/vga/host' SCRIPTDIR='~/vga/host/scripts'
so no editor is needed. Again, the directories do not end in slashes.
SetEnv
In SetEnv you should change all environment variables to something you
like by hand (TEMPDIR may be the same as BASEDIR). This
script is used by all other scripts (except CheckEnv).
CheckEnv
This script is complete as is. It is called by all other scripts, except
SetEnv and CreateGame.
Using the scripts
First, master and configurate a game in a subdirectory of TEMPDIR,
which has the name gamename. That name has to be in lowercase entirely
(I have had experience with players who can not type ``Gamename'', but try
jokes like ``GAMENAME'', ``GameName'' and ``gamename''. To ease submitting for
those ... players, the entire subject is converted to lowercase).
CreateGame
Then, run CreateGame with the gamename as parameter. Note that
none of the scripts ever accepts a slash as last character of the gamename. It
complains there is no file named commands. This file should contain
the commands which have to be run for the hosting session. See the example in
this package. It should be placed in the BACKUPDIR, together with the
authorized file (also example included). When both are set, rerun
CreateGame and voila, the game is ready to be played. Of course you
could have skipped the first run of CreateGame.
An extra set of files is created: gameinfo with some numbers in it,
among which the amount of players (check it, Mr. Host!) and the minimum amount
of turns available before hosting actually takes place (change this to a number
you agreed upon with your players directly after the first
hostrun!). Also, all data is packed together in gamedata.zip and this
file is backed up as b_up_000.zip.
The claim by CreateGame that the game is backed up is only
partially true: to be able rehost after a HD-crash, you can back up in another
place (e.g. in another directory which is on another disk in the same UNIX
filesystem, as supported by the scripts, see SetEnv). (Note that
further backups are not made, since rehosting is not implemented yet.)
RunHost
When this has been done, run RunHost once, which will automatically
send the players their results. After that, send your players the config files
they need (like pconfig.src) and make sure they can look at the file
players.html somehow. Also, change the MinimumTurnsRequired:
option in the file gameinfo and set up the crontab entries. Check
whether there is a file trn000.zip with exactly one file in it:
seed which contains the seed used by PHost.
SendRst
RunHost used this script in its simplest modus: Send all results
without further checking. There are two other modi:
- Send one or all results after full checking (done by the host).
- not tested!Send one or more result after full checking (on a
players request by e-mail),
The first modus is for RunHost only. The second modus is for manually sending
results by the host. The last modus is supposed to be called when an incoming
mail contains a command-subject for it. The script assumes the first word in
the subject is the trigger for that, recognized by a mail program like
procmail. All words in the subject except the first one are used. Also, you can
pipe such a message to SendRst by hand as host.
The second one is for the host, when something went wrong with sending all
results after hosting (in the logfile there is a line saying:
RunHost: gamename ``somegame'' hosted
, but not a line saying:
RunHost: gamename ``somegame'' all results sent
not in any other case. After the problem has been solved, just give
SendRst gamename 0
and the results of all players will be sent to them. By typing
SendRst gamename 5
all relevant data (player5.rst, util5.dat, etc) for player 5 are mailed
to him/her.
SaveTrn
not tested! In the same way as the third modus of SendRst
incoming mail is checked. Now a single turn is extracted and saved if it is a
correct turn. Any error reported by PHost results in rejection of the turn,
except for a yellow alert, which is filtered out (Phost can repair the problem,
so there is no problem). Note that PHost checks only this turn, not other
player's turns as well. If you use another checking program, you must change
SaveTrn appropriately.
It is strongly advised (i.e. mentioned in player.html
that you did) to let the turn- and result-request by your players enter your
mail-database as well, that is, configure procmail as such. These scripts clean
up the mess they made, including the copy they made of the mail. Only delete
these mails after the appropriate hostrun.
In this way it is also possible to extract a turn from a players mail and
zip it into trnXXX.zip by hand, but you should do this only when you
are very sure these scripts are mistaken.
Possible Errors from the scripts
All errors are accompanied by some text (sent to you in the form of an e-mail),
explaining what happened. Errors with a number of 4 and higher are ``internal''
(the lock has been set before the error was encountered; it was released by the
error handler) and might just mean the file system is full. If you do not
understand the message given, you are either not qualified as host, or you can
mail me because I was not as clear as I should.
Safety
To check for unauthorized access to results or unauthorized submission of
turns, the first line of a UNIX mail (starting with From without `:')
should be used. Ask players to give all their addresses they wnat to request
results/submit turns from. This is not 100% safe, so a password for players
might be incorporated later.
To prevent simultaneous access from the scripts on files like
trnXXX.zip, there is a lock set once a script enters a critical
part. These locks are kept per game, so if game3 crashes somehow, game1 can
continue. Note that the lock is set by removing a lockfile and thus
released by replacing it. The name of the lockfile is .lock.
To be able to see what happens, all scripts administrate their actions in a
logfile, at BASEDIR/logfile. Most scripts make two entries: one at the
start and one when they are finished. RunHost also makes one after
hosting, but before sending the results and SendRst does not make any
entries when called by RunHost.
All encountered errors are sent to the host by e-mail. If the error is about
a submitted turn or a result request, the player receives the same e-mail.
Bugs
I know none, but there are of course many (3.3 is not tested with false turns,
result-requests and more sneaky tricks).
History
| version | Description
|
|---|
| 1: | What I used for my first hosting games (tribes, M38C)
|
| 2: | What Jurjen uses at the Arena. He made little adaptations of his
own, improving where needed, thus giving valuable hints for version 3.
|
| 3: | New, much better maintainable (and configurable by others)
version of the scripts. Includes docs, setup-script and much more.
|
| 3.3: | First operable version 3.
|
Future
- Enable rehosting.
- Improve security by adding passwords?
- Extend e-mail processing with extensive command parsing?
Thanks
To Jurjen Niezink.
To all players of my two games and in the Arena (especially TopDog).
Author: Kero van Gelder
Last revision: 7 VI 1998