Posted: Sun Feb 21, 2010 12:12 am Post subject: A script for handle (and rotate) many servers at once
For UNIX/LINUX/SOLARIS or Windows+CYGWIN
Hi...
I wrote a perl script that, reading a text file, can create a different zserv.cfg depending on a schedule.
This is the 1st version... if you think it might be useful for you... i'll gladly accept any ideas /recommendation. In my case, i'm using it on "TRIPA DE GATO" together with a cron job. All my duel servers now rotates each day, with a set of 7 1-on-1 maps.
Basically, you create a zservrotation.conf file with
1) General Settings
2) Detail of every possible server
3) How many zservers are you going to run at the same time
4) The rotation order
(You can specify the name/location of your config file as the only parameter of the perl script. zservrotation.conf is just the default name)
Example, you will have 2 servers. One will run brit10 one week, brit11 the other week. (quite boring, eh?)
The other server will run 3 different maps of the same wad. (lets say, ABCDMv4) Will change map once a week too.
So,.. you are a fan of ZDDL?, then you may want to use always their DMFLAGS
[GENERAL]
dmflags=201796
dmflags2=132608
hostname="My rotating servers"
!waddir=/var/wadfiles
You have 5 possible configs. So you create the following DETAIL sections
After doing this, create a cron job that calls a the perl script and a shell script called start_zservrota.sh, from the same location of the script (and config file). Call this once a week. Calling the shell 1 minute after the perl script it's ok.
* This runs the perl script each monday at 4:01 AM. A new configuration is created for each server.
* At 4:02 at mondays, current rotating servers are killed. And restarted again with the new configurations.
You may ask... "why zservrota?". Because the script will create those files by copying the original zserv executable to zservrota. That way, the script can kill all your rotating servers without killing your "static" ones.
Now you have 2 servers that changes every week. without you having to worry.
My own zservrotation.conf for TRIPA DE GATO. Not the real one, but very similar.
Code:
# How to create ZDaemon rotating servers
# --------------------------------------
# ** ONLY FOR LINUX/UNIX/SOLARIS **
# Requires: perl 5, 'killall' system command, access to crontab
#
# "basepath" indicates the location of both 'zservrotation.pl' and this file
# Logs are also recorded in this path.
# Specify your favorite settings in the GENERAL section
# Override them on the proper DETAIL section
# "motd" and "hostname" are added. I.e. GENERAL+' '+DETAIL is the final motd
# currentiteration is specially handled by the rotation script
#
# Specify your zserv path for each server you want to rotate
# Specify the rotation schedule using the wad "id".
# Configure your system's crontab to specify when to do the rotation.
#
# Properties stating with '!' are specific to this program, and are not part
# of any zserv.cfg configuration. !verbatim is the exception
[GENERAL]
motd="=== WELCOME TO TRIPA DE GATO ==="
hostname="# TRIPA DE GATO SERVER # -"
email=put.here@your.email.com.dont.ask.why.just.do.it
maxclients=16
maxplayers=2
timelimit=0
fraglimit=35
deathmatch=1
master_advertise=1
# skill here is from 0 to 4
skill=4
#Don't change this value unless absolutely necesary
!rotationexecutable=zservrota
!basepath=/opt/zserv
!iwad=doom2
!extrawads=zvox2
!waddir=/opt/zserv/WADS
!currentiteration=D:6,G:6,B:6
#- DON'T CHANGE THE currentiteration VALUES! Unless you want to experiment...
#- Example:
#- (Server1 will run with the DETAILS configuration with id=A)
#- (Server2 will run with the DETAILS configuration with id=B)
#-
#- currentiteration = Server1:1, Server2:4
#- ...
#- Server1 = A, B, C, D, E, F, G
#- Server2 = G, C, B, B, D, A, E
[DETAILS 1]
!mainwad=datadyne2
!extrawads=pk_weapons_zd_v2a
hostname="Dark/Pho3n!x's DATADYNE 2 (NS Settings)"
dmflags=282756
dmflags2=131168
Configuration file for zservrotation
--------------------------------------
All properties that starts without ! are transfered directly to the final zserv.cfg.
Example
someproperty=somevalue will appear as
set someproperty "somevalue"
in the zserv.cfg file for the server.
[GENERAL]
!iwad !waddir : Used when running the server, as a command line parameter
!rotationexecutable : Just leave it as is.
!extrawads : This goes just after the !mainwad specified in the [DETAILS x] section
!currentiteration : Indicates the position in the playing list. Create it with all 1. Is required. See the example in the 1st post.
!basepath : where the script and the config file is located
[DETAILS a]
!mainwad : This goes in 1st place in the command line parameter
!extrawads : This wad list goes _after_ the !extrawads in [GENERAL] section
[SERVER serverx]
!path : Location of the server directory
!port : port used. Goes in the command line.
The rotation is a combination of DETAILS and SERVER, with the DETAILS specified on the columns, and the SERVER in the rows
[ROTATION]
serverx = a, b, c
servery = a, c, c
serverz = b, a, a
Some properties are added, the others are overroded by the ones in [DETAILS]. For example, you can specify the same dmflags for all your 10 new-school servers in the [GENERAL] section, and having only one of them with old-school settings, by adding a dmflags=480300 (for example) in the respective [DETAILS] section.
The !extrawads, hostname, motd and !verbatim properties are added... so, the final property will be GENERAL property + DETAILS property.
The !verbatim property
Some server atributes are not specified as set property "value" in the zserv.cfg file, like "addmap" or "setaltwads".
For me is clear... but maybe not for others... You can use this script to manage many servers, even if they dont rotate. You can use this to create many servers in one file instead of editing many zserv.cfg files. Also, you can specify 'zserv' as !rotationexecutable if you don't plan to rotate any server.
This sounds awesome i wanted something like this 1 - 2 years ago when i was hosting some dedicated sever's as it would of helped out in a way as sometimes i didn't have time to change severs ect..
I might test this out soon or in a week as i got a sever i can trial on.
This is a great idea shinobi.. It's maybe slightly less than perfect but it can be improved on, as the beauty of scripting languages. I'll give this a shot perhaps in the next week and pass you any ideas/changes.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum