ZDaemon Forum Index ZDaemon
Client/Server DOOM
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A script for handle (and rotate) many servers at once

 
Post new topic   Reply to topic    ZDaemon Forum Index -> ZDaemon Development
View previous topic :: View next topic  
Author Message
shinobi-cl
Dominating!


Joined: 31 Jul 2007
Location: Xile

PostPosted: Sun Feb 21, 2010 12:12 am    Post subject: A script for handle (and rotate) many servers at once Reply with quote

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


[DETAIL B10]
!mainwad=brit10
hostname="running brit10 now"

[DETAIL B11]
!mainwad=brit11

[DETAIL ABC03]
!mainwad=abcdmv4
!verbatim=<<+++
addmap MAP03
maplist
+++

[DETAIL ABC05]
!mainwad=abcdmv4
!verbatim=<<+++
addmap MAP05
maplist
+++

[DETAIL ABC28]
!mainwad=abcdmv4
!verbatim=<<+++
addmap MAP28
maplist
+++


Next, specify your servers

[SERVER Alpha]
!path=/home/zdaemon/zserv/Alpha
!port=10700

[SERVER Beta]
!path=/home/zdaemon/zserv/Beta
!port=10701


Then you create the rotation


[ROTATION]
Alpha=B10,B11
Beta=ABC01,ABC03,ABC28

Now, to have your servers running.

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.

Here is an example crontab
Code:

1 4 * * 1 perl /opt/zserv/zservrotation.pl
2 4 * * 1 sh /opt/zserv/start_zservrota.sh


* 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.

Download script here http://sites.google.com/site/shinobicl/home-page/more-d-m-stu/scripts

You are gonna need Config::IniFiles, get it with

> perl -MCPAN -e 'install Config::IniFiles'

from your console


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

[DETAILS 2]
!mainwad=uacarena
!extrawads=xdehload shinwm2_extrawep
hostname="Shinobi.cl's UAC ARENA (OS Settings) + modded weapons"
dmflags=480300   
dmflags2=1114144

[DETAILS 3]
!mainwad=rlight1
!extrawads=xdehload shinwm2_extrawep
hostname="Welkin's R-LIGHT (NS Settings) + modded weapons"
dmflags=282756   
dmflags2=131168

[DETAILS 4]
!mainwad=cduel1_
hostname="Chaindude's C-DUEL (NS Settings)"
dmflags=284836   
dmflags2=131169

[DETAILS 5]
!mainwad=legend-a
!extrawads=pk_weapons_zd_v2a
hostname="Zero99's LEGEND (OS Settings)"
dmflags=480300   
dmflags2=1114144

[DETAILS 6]
!mainwad=elv
!extrawads=pk_weapons_zd_v2a
hostname="Cybershark's ELV (OS Settings)"
motd="ELV OLD SCHOOL SETTINGS, INSTANT WEAPON SWITCHING"
dmflags=480300   
dmflags2=1114144

[DETAILS 7]
!mainwad=chernobyl1
!extrawads=pk_weapons_zd_v2a
hostname="VincentPrice's CHERNOBYL (OS Settings)"
dmflags=480300   
dmflags2=1114144

[SERVER B]
!path=/opt/zserv/BETA
!port=10669

[SERVER G]
!path=/opt/zserv/GAMMA
!port=10671

[SERVER D]
!path=/opt/zserv/DELTA
!port=10672

[ROTATION]
B=1, 2, 3, 4, 5, 6, 7
G=6, 7, 1, 2, 3, 4, 5
D=4, 5, 6, 7, 1, 2, 3



Well. there it is... sorry for the long post.


Last edited by shinobi-cl on Sat Aug 07, 2010 5:59 pm; edited 7 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
shinobi-cl
Dominating!


Joined: 31 Jul 2007
Location: Xile

PostPosted: Sun Feb 21, 2010 3:47 am    Post subject: Reply with quote

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".

!verbatim =<<+++
setaltwads "doom2=freedm062"
addmap map01
addmap map02
maplist
add_cvaroverride map01 sv_vote_limit "9999"
add_cvaroverride map01 sv_infiniteammo "true"
+++

+++ is a "delimiter token'. This is very sensitive, but you can use anything as this token. Trailing spaces are part of the token too!

Examples: ('_' are spaces)
This is ok:
!verbatim=<<TEXT
setaltwads="doom2=freedm062"
TEXT

This is wrong:
!verbatim=<<TEXT
setaltwads="doom2=freedm062"
TEXT_


Last edited by shinobi-cl on Sun Feb 21, 2010 8:42 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
shinobi-cl
Dominating!


Joined: 31 Jul 2007
Location: Xile

PostPosted: Sun Feb 21, 2010 4:22 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
rygrass
God like!


Joined: 06 Nov 2005
Location: Aussie Clan:eV

PostPosted: Sun Feb 21, 2010 7:31 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Stealth
Gone with the wind


Joined: 09 Nov 2004

PostPosted: Sun Apr 04, 2010 4:18 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    ZDaemon Forum Index -> ZDaemon Development All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group