.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   Utility: Linux Admining (http://forum.shrapnelgames.com/showthread.php?t=30044)

Gandalf Parker September 1st, 2006 01:39 PM

Linux Admining
To answer the question in another thread that started this:

To admin remotely in text mode you have to login to a text-mode terminal. Two popular protocols are telnet and ssh. You can find terminal emulation programs that give you added features at your end which can be quite useful. I like NetTerm but its been a really REALLY long time since Ive looked at what was out there available.

Gandalf Parker September 1st, 2006 01:51 PM

Re: Linux Admining
Here is an example of a script I use to start a Dom3 game.

cd /home/dom3/dominions3
mkdir $DIR

nice dom3 -T --makemap $GAME \
--mapaa --mapsize 1000 1000 --mapprov 250

nohup nice dom3 -g $GAME --port $PORT -STdddddddddd \
--preexec $DIR/pre_$GAME.sh \
--postexec $DIR/post_$GAME.sh \
--mapfile $GAME.map \
--era 3 --hofsize 15 --indepstr 6 \
--totalvp 18 --requiredvp 15 --summervp \
--magicsites 35 --renaming \
--hours 24 -q \
>>$DIR/$GAME.log 2>>$DIR/$GAME.err &

touch $DIR/pre_$GAME.sh
touch $DIR/post_$GAME.sh
chmod +x $DIR/*.sh

Gandalf Parker September 1st, 2006 02:02 PM

Re: Linux Admining
It looks like alot but its simple to use. You just change the first two lines to start a new game. The GAME and PORT variables.

Then it makes a gamesave directory. I know that the game makes one once the game starts but I need it before that.

This script generates a random map for the game to use that is named the same as the game. In this case, Armageddon. Thats a new Dom3 feature. When people join the game they will get the map sent to them. There are many map switches if you want to mess with them. Just add them there.
Just insert a # and remark it out if you dont want a random map. Change the --mapfile setting from $GAME to whatever map you want to use.

The game call itself adds many things you might not want. the ddddd heavy level of debug creates HUGE logs but they are fun to look at. You can change that to one d or take it off completely. I direct all of the games text responses to a log and the errors to an err file named for the game. In this case Armaggedon.log and Armageddon.err

the last 3 lines make sure that you have a pre and post shell that are in the right place and executable. They start out empty but you can easily edit them anytime even if the game has already started. They are great for various cleanup or management needs that popup.

Digest that abit and then I will put up a more complicated one. >:)

tibbs September 1st, 2006 03:15 PM

Re: Linux Admining
Thanks for all the useful info. I want to avoid using Telnet because it doesn't encrypt but I will look into NetTerm and SSH.

And this will take me a long time to digest. I just learned about the touch command and I think I need to re-read it because I have forgotten.

And it looks like I need to learn how to create scripts. This should keep me busy over the weekend.


Gandalf Parker September 1st, 2006 04:52 PM

Re: Linux Admining
Any commands you can type in to run can be put into a text file. If you make it executable (chmod +x file) then it becomes a script. You only have to iron out all of the steps one time. Then you put them into a script and forget all that trial and error you did.

The touch was a trick. It usually updates the creation date. But if the file doesnt exist then it makes one. That way you safely create a file but if one is already there then you wont destroy it.

alexti September 2nd, 2006 03:04 AM

Re: Linux Admining
I'd recommend PuTTY, especially if your client desktop is Windows.

Arker September 2nd, 2006 05:08 PM

Re: Linux Admining

Gandalf Parker said:
Any commands you can type in to run can be put into a text file. If you make it executable (chmod +x file) then it becomes a script.

It also helps to put the magic numbers in.


should be the very first thing in the file.

And to make sure the permissions are right

chmod 755 file

Gandalf Parker September 2nd, 2006 06:33 PM

Re: Linux Admining
The script I did isnt shell specific. Some later ones I do have a shell line since they use special shell variables for things like randoms.

And yeah I guess for public info its probably best to chmod 755 but +x for executable seems easier for people to remember even if it is sloppy.

Of course for public info I probably shouldnt have mentioned telnet since trying to argue down ssh is something only security people would do.

So did everyone follow that script? No questions?

tibbs September 5th, 2006 02:39 PM

Re: Linux Admining
I didn't get a chance to try it yet. I was busy with painting a few rooms in the house. Hopefully early this week.

Bluebird September 10th, 2006 08:21 PM

Re: Linux Admining
Just as a hint: I am normally hosting games on unix using the 'screen' command. It is a like a 'window manager' for text consoles and has many features (too many to list them here). The nicest one is that you can 'detach' a terminal session which continues running even if you logout, and later 'reattach' to that terminal session on next login.

Gandalf Parker September 10th, 2006 10:00 PM

Re: Linux Admining
PRE hosting script


# make backups
#maybe later I will make it rotating backups
zip -9 $GAME.zip $DIR/*

# blank the log file since it grows by about 5 meg each turn
# this way Im only logging one turn at a time
cp /dev/null $DIR/$GAME.log

# update the viewable copies of the shell files
cp /home/dom3/dominions3/$GAME.sh $WEB/$GAME_sh.txt
cp $DIR/pre_$GAME.sh $WEB/pre_$GAME_sh.txt
cp post_$GAME.sh $WEB/post_$GAME_sh.txt

# mark the time and load at the beginning of hosting
echo pre >>$DIR/system_load.txt
uptime >>$DIR/system_load.txt

Gandalf Parker September 10th, 2006 10:04 PM

Re: Linux Admining
POST hosting script

# mark time and system load after host processing
#and make it available for viewing in the games web dir
echo post >>$DIR/system_load.txt
uptime >>$DIR/system_load.txt
echo " " >>$DIR/system_load.txt
cp $DIR/system_load.txt $WEB/system_load.txt

# rotate the score html files
mv $WEB/scores-4.html $WEB/scores-5.html
mv $WEB/scores-3.html $WEB/scores-4.html
mv $WEB/scores-2.html $WEB/scores-3.html
mv $WEB/scores-1.html $WEB/scores-2.html
mv $WEB/scores.html $WEB/scores-1.html
cp $DIR/scores.html $WEB/scores.html
cp $DIR/stats.txt $WEB/stats.txt

# zip up the debug log and then zero the log
zip -9 $DIR/$GAME.zip $DIR/$GAME.log
mv $DIR/$GAME.zip $WEB/$GAME.zip
cp $DIR/$GAME.log "$DIR/OLD"$GAME".log"
cp /dev/null $DIR/$GAME.log

# email notify players that have asked to be told of turns
cat $DIR/notify.txt |/usr/sbin/sendmail gandalf@example.com
cat $DIR/notify.txt |/usr/sbin/sendmail bogus@example.net

Gandalf Parker September 10th, 2006 10:17 PM

Re: Linux Admining
the notify.txt that is sent to players

Subject: the Armageddon game processed

Your turn is ready at

(courtesy of Gandalf Parker at Any1can.net)


the notification could also be changed to include the turn number. It could also easily be changed to include emailing the turn file.

Which makes you automatically think PbEM. If a game had its own email address such as armageddon@dom3minons.com then something like procmail could manage incoming emails to place the .2h files (which means "to host") into the game directory. It could also kick off a script to check for all turns being in and then run/quit the host. This would raise the number of games that a server can run by many levels.

Gandalf Parker September 14th, 2006 05:38 PM

Re: Linux Admining
I just realized that maybe this will interest some people....
Gandalf Parker

usage: dom3 [option(s)] [gamename]
-v --version Print version number and exit
-d Increase debug level
-g --host Generate new turn and exit
--verify Verify all 2h-files and exit (creates .chk files)
--statfile Create a player info file after each turn (stats.txt)
--scoredump Create a score file after each turn (scores.html)
--finalhost Generate new turn, send out final score msg and exit
-c --nocredits Disables the end credits
******* Network Options *******
-C --tcpclient Connect to a Dominions multiplayer server
-S --tcpserver Start a Dominions multiplayer server
--ipadr XXX Use this IP-adr when connecting to server
--port X Use this port nbr
--preexec CMD Execute this command before each turn generation
--postexec CMD Execute this command after each turn generation
-t --hosttime X Y Host on day X (0=sunday) hour Y (0-23)
--minutes X Set host interval in minutes
-h --hours X Set host interval in hours
--pauseday X Stop timer on this day (0=sunday)
-q --quickhost Host as soon as all turns are done
-n --nonationsel No nation selection when resuming a network game
--noclientstart Clients cannot start the game during Choose Participants
--uploadtime X Game is created after this many minutes.
--uploadmaxp X Game is created if this many players join.
--closed X Nation closed X=nation number (0-79)
--easyai X Nation ai controlled X=nation number (0-79)
--normai X Nation ai controlled X=nation number (0-79)
--diffai X Nation ai controlled X=nation number (0-79)
--mightyai X Nation ai controlled X=nation number (0-79)
--impai X Nation ai controlled X=nation number (0-79)
******* New Game Options *******
--mapfile XXX Filename of map. E.g. eye.map
--randmap X Make and use a random map with X prov per player (10,15,20)
--research X Research difficulty 0-3 (default 1)
--hofsize X Size of Hall of Fame 5-15 (default 10)
--indepstr X Strength of Independents 0-9 (default 5)
--magicsites X Magic site frequency 0-75 (default 40)
--eventrarity X Random event rarity 1-2, 1=common 2=rare
--totalvp X Vic. points available in the world 0-25
--capitalvp One extra victory per capital
--requiredvp X Vic. points required for victory (default total/2)
--summervp Vic. points are accumulated each summer
--richness X Money multiple 50-300 (default 100)
--resources X Resource multiple 50-300 (default 100)
--supplies X Supply multiple 50-300 (default 100)
--masterpass XX Master password. E.g. masterblaster
--startprov X Number of starting provinces (1-9)
--renaming Enable commander renaming
--noscoregraphs Disable score graphs
--nonationinfo No info at all on other nations
--era X New game created in this era (1-3)
-M --enablemod XXX Enable the mod with filename XXX
******* Random Map Options *******
--makemap XXX Generate a random map with filename XXX and exit
--riverpart X 100 = normal amount of rivers, 0=no rivers
--seapart X Percent of map that is below water level (default=30)
--mountpart X Percent of map that is mountains (default=20)
--forestpart X Percent of lands that are forests (default=20)
--farmpart X Percent of lands that are farm lands (default=15)
--wastepart X Percent of lands that are wastes (default=10)
--swamppart X Percent of lands that are swamps (default=10)
--mapaa Enable antialiasing for random maps
--mapsize W H Set width and height of random map (default=1600 1200)
--mapprov X Set number of provinces (default=150)
--passmount Don't use impassable mountains on random maps
--mapgcol RGBA Ground color 0-255 (default=170 146 116 255)
--mapscol RGBA Sea color 0-255 (default=54 54 130 255)
--mapbcol RGBA Ground border color 0-255 (x4)
--mapsbcol RGBA Sea border color 0-255 (x4)
--mapnoise X Ground color noise 0-255 (default 15)
--borderwidth X Border width 0-500 (default 100)
******* Video Options *******
-w --window Run Dominions 3 in a window
-u --fullscreen Use the entire screen
--bitplanes X Try to use a color depth of X bits per pixel
--zbuffer X Try to use a depth buffer of X bits per pixel (default=16)
-T --textonly Use this with --tcpserver to get graphicless server
--gamma X Set gamma function (brightness) 0.1 - 5.0 (default=1.0)
--opacity X Set gui opacity 0 - 100
-r --res X Y Set screen resolution / window size (default=800 600)
--animback Use animated backgrounds
-a --noanimback Don't use animated backgrounds
--fade Use fade effects
-f --nofade No fade effects
--nopopups No helpful popups
--fps X Aim for this nbr of frames per second (default=20)
--maxfps X Maximum nbr of frames per second (default=50)
--filtering X Quality of OpenGL filtering 0-3 (default=2)
--maxtexsize X Max texture size in pixels 32-4096 (default=unlimited)
--treequal X Tree quality 1-5 (default=3)
--texqual X Texture quality 1-5 (default=3)
--nolightfx No light effects in battles
--partamount X Max nbr of particles 0-8 (0=none, 4=default, 8=max)
--nograss Don't draw the grass
--noarcade Don't draw floating damage numbers
--noglext Don't use any OpenGL extensions
--vsync Enable vsync
-V --novsync Disable vsync
--renderpath X Use different optimizations 0-1 (0=good for low mem cards)
-x --fastgrx Faster graphics (use 3 times for best performance (-xxx))
-p --perftest Run a performance test and exit
******* Audio Options *******
-s --nosound No sound effects or music
-m --nomusic No music
--musicvol X Set music volume, 0-100
--clickvol X Set mouse click volume, 0-100
--defsound Use default sound device
--directsound Use direct sound
--waveout Use waveout for sound
Example: dom3 -wm Run Dominons 3 in a window and without music

Gandalf Parker September 19th, 2006 12:11 PM

Re: Linux Admining
OK all of you Linux people. Have fun with THIS one. This is my bl_game.sh for creating small blitz games.
<font class="small">Code:</font><hr /><pre>

OP1=`echo $RANDOM % 79|bc`
OP2=`echo $RANDOM % 79|bc`
OP3=`echo $RANDOM % 79|bc`
for OP in $OP1 $OP2 $OP3
if [ $OP -eq 25 ]
then $OP=0

until [ $PTtest -eq 0 ]; do
PORT=`echo $RANDOM % 1000 + 8000|bc`
PTtest=`netstat -an|grep -c :$PORT`

WURDnum=`echo $RANDOM$RANDOM % 118614 |bc`
WURD=`egrep "^....$|^.....$|^......$|^.......$|^........$|^... ......$" \
/usr/share/dict/words|head -$WURDnum|tail -1`
if [ -z "$1" ]
ERA=`echo $RANDOM % 3 + 1 |bc`

DESC=" era $ERA game $GAME on port $PORT "
echo $DESC
#with $OP1 $OP2 $OP3
# --normai $OP1 --normai $OP2 --normai $OP3 \

dom3 -T --makemap $GAME --mapaa --mapsize 640 480 --mapprov 30
echo $DESC
mkdir $DIR

nohup dom3 -g $GAME --port $PORT -ST --statfile --scoredump \
--preexec $DIR/pre.sh --postexec $DIR/post.sh \
--era $ERA --indepstr 6 --hofsize 15 --magicsites 65 \
--renaming --mapfile $MAP --masterpass $MPASS \
-q --hours 24 &gt;$DIR/game.log 2&gt;$DIR/game.err &amp;

echo $DESC &gt;&gt;BLITZ_games.txt

PID=`ps a | grep $GAME | grep dom3 | cut -d" " -f2`
echo "kill -9 "$PID &gt;$DIR/kill.sh
echo $MPASS &gt;$DIR/master.txt
ls -blart /tmp/dominion* |tail -1 &gt;$DIR/tmp.sh
echo " " &gt;$DIR/pre.sh
echo " " &gt;$DIR/post.sh

chmod +x $DIR/*.sh

# to stop the game immeadaitely after start
# unremark the next line
#cp $DIR/kill.sh $DIR/post.sh

echo "mv ~/dominions3/maps/$GAME.* $DIR/" &gt;$DIR/pre.sh
echo "cp /dev/null $DIR/pre.sh" &gt;&gt;$DIR/pre.sh

echo "cp $DIR/game.log $DIR/~game.log" &gt;$DIR/post.sh
echo "cp /dev/null $DIR/game.log" &gt;&gt;$DIR/post.sh
</pre><hr />

Gandalf Parker September 19th, 2006 12:23 PM

Re: Linux Admining
Some highlists on that blitz script...

It selects random opponents (presently rem'd out in its use)

It selects a random port and it tests to see if that port is in use

It creates a random password and uses that as the master password for the game

It chooses a random word from the system spelling dictionary and uses that as the game name (some very interesting results have come from that)

It chooses a random era

It creates a random map for the game of 640x480 and 30 provinces. Suitable for a 2 or 3 player blitz game

It creates a game log and a game error file

It adds the games description (game name, port, settings) to a BLITZ_games.txt so that if I whip off 10 quick new games I can just upload that text to announce them

It creates a quick-kill shell in the games directory

It creates pre and post shells.

Sets up the pre shell to move the blitz map to the game directory once the game starts. That saves on cleanup of the games later.

Sets up the post shell to rotate the logs which can get very large depending on how many d's you use on the games command line

Any questions?

Neophyte September 30th, 2006 12:56 AM

Re: Linux Admining
Does the IP address need to be specified (in the script) if one is IP forwarding through a firewall? If so, the address needs to be the address that remote clients will be using, correct? I hope I got the terminology right.


Gandalf Parker September 30th, 2006 12:01 PM

Re: Linux Admining
I understand your question but Im afraid that I dont know the answer. I dont know of any way to tell the game which IP to run on. I think that when hosting, the game only concerns itself with port. So if the clients address hits the firewall, and the firewall forwards it to the right machine, things should be transparent to the user. But Im afraid thats just guesswork on my part.

By the way, Dom3 handles both IP or domain name for the server. Thats something I have tested quite abit. So Im able to send people to either OR dom3minions.com for a game. (also host.dom3minions.com which I use for blitz games)

Neophyte September 30th, 2006 03:07 PM

Re: Linux Admining
Upon reflection, the whole IP thing is probably a switch issue not a computer issue anyhow - i.e. addyX:portZ internally is in all ways equivalent to addyY:portZ externally with IP forwarding setup. Should have thought of this last night, but it was late, and my networking knowledge is sporadic.

Thank's for the reply - I'll test out your scripts once Dom3 shows up hopefully next week.

Gandalf Parker October 14th, 2006 12:08 PM

Re: Linux Admining
PbEM scripting has been ironed out. The key is two switches which will start a game hosting automatically. The thread where this was discussed fully is at

The switches are:

Gandalf Parker October 17th, 2006 03:22 PM

Re: Linux Admining
Im rather proud of this altho it will make others cringe at its ugliness. I wanted a way for people to check which games need players. Doing an "ls" of the game directory from a CGI was easy enough but I realized that instead of using "ls" of the directorys as fact that the game exists, I should use the "ps". Then starting a game will automatically cause it to show, and if a game finishes or crashes then it will automatically not appear. I also arranged for it to pull the port from the ps display and show that.

<font class="small">Code:</font><hr /><pre>
echo "Content-type: text/html"
echo -e "\n\n"

echo "&lt;H2&gt;&lt;b&gt;Dominions 3 Blitz games&lt;/b&gt;&lt;/H2&gt;"
echo "These are 2-player games on tiny maps&lt;br&gt;"
echo '&lt;a href="http://host.dom3minions.com/how-to.html"&gt;how to join a game&lt;/a&gt;&lt;b

cd /home/dom3/dominions3/savedgames
ps ax |grep dom3|grep bl_ | \
while read n n n n n n game n port n n n n n n n n era n
echo "era $era game &lt;b&gt;$game&lt;/b&gt; on port &lt;b&gt;$port&lt;/b&gt;&lt;br&gt;"
cd $game
for fyle in `ls -1 *.2h`
echo $fyle "&lt;br&gt;"
cd /home/dom3/dominions3/savedgames
echo "&lt;br&gt;"
</pre><hr />

Gandalf Parker November 28th, 2006 07:14 PM

Re: Linux Admining
Not much reaction to the fancy stuff. Maybe I shoud move the other direction...

Here is the simplest way to start a game in linux text mode so that you can be the server....

dom3 -STq
(take note that is a Q as in quick, not a G like in game)
it will ask you what port to use..
it will ask you to name the game..
it will ask you what era the game should be for
it will then wait for people to join and tell you each time someone does

When one of the players hits the "start game" then it will stop to show you a list of all the maps on your machine numbered, then ask you to type in the number of the map you want to use.

What it will NOT do is tell the machine to keep running the game in the background if you hang up your connection. I will cover that next.

Gandalf Parker

Gandalf Parker November 28th, 2006 07:37 PM

Re: Linux Admining
The simplest way to start a game in text mode on a linux server for continual running.. well there isnt one. The problem is that telling it to run continual and background tends to cut off your ability to answer the questions. I havent been able to get the answers to work coming from a text file with something like &lt;input.txt. So you will need to provide the answers on one line.

The simplest line I can come up with is..
nohup dom3 -STq fastgame --port 9999 --mapfile eye.map --era 1 &amp;
(again thats a Q not a G)
Of course you can change "fastgame" to any name you want, and 9999 to any port, eye.map to the map file for any map you have in the maps directory, and era to 1 2 or 3.

If you want to play with adding other settings then type
dom3 -h
which will give you a text screen of all the switches.

Gandalf Parker

Tals January 6th, 2007 08:54 AM

Re: Linux Admining
Great thread GP. I'm keen to run it from the text line and not have it running unattended - i.e always in a window. Is there a way of stopping it refreshing once a minute?

Also are there any commands you can give it whilst in text mode?


Gandalf Parker January 23rd, 2007 05:33 PM

Re: Linux Admining
Sorry that I didnt notice this.

There is no way to stop it refreshing. I tend to run it to a file then use a file viewer.

As far as I know there are no commands that will work on it when its running text mode. I prefer to script the starts of all of my games since any changes or updates involve having to stop the game and then restart it. I much prefer edting the script and restarting it than trying to type it all out again. Especially if you dont remember some of it.

Gandalf Parker September 1st, 2008 02:08 PM

Re: Linux Admining
Since this subject is coming up again I thought Id bump this.

Gandalf Parker

Lihaässä January 30th, 2009 12:40 PM

Re: Linux Admining

We're trying to figure out is there a way to host dom3 from a server computer with identical cd-key as one of the players? Nothing illegal, but none of our friends want to keep server running 24/7 and we have an existing server which could be used.

Thanks, nice thread

Gandalf Parker January 30th, 2009 05:08 PM

Re: Linux Admining
Its not supposed to be a problem.
The host doesnt check its own key against the players. But Im pretty sure it does have to be a good key (cant use one off a public list since they get banned pretty quick). Ive used my own key with no trouble even when the host is on the linux server and Im playing from my windows desktop.

Ornedan January 30th, 2009 05:39 PM

Re: Linux Admining
My server wrapper and backup scripts. For this thread, I think the interesting bit is the backup script, since it's parametrized by game name.

Both scripts assume the game directory is ~/dominions3

The server wrapper passes all parameters directly to dom3. It only deals with the last parameter, which is assumed to be the name of the game. The wrapper is mainly for having a bunch of default parameters that I want to have all the time.

The backup script writes the backups to ~/dominions/backups. It reads the scores.html file to determine current turn, so the game needs to be run with --scoredump on.


#! /usr/bin/env python

from os import environ, execvp, mkdir
from os.path import exists, join
from sys import argv

# Common options
common = ["--scoredump",

# Newgame standard options
newgame = ["--masterpass", "*****",

# Start game
HOME = environ["HOME"]
GAME = argv[-1]
EXECS = ["--preexec", "dom3backup %s" % (GAME,)
#        ,"--postexec", "command %s" % (GAME,)

common = common + EXECS

if exists(join(HOME,"dominions3","savedgames",GAME,"ftherlnd")):
    print "Resuming game %s" % (GAME,)
    execvp("dom3", ["dom3"] + common + argv[1:])
    print "Starting new game %s" % (GAME,)
    if not exists(join(HOME,"dominions3","savedgames",GAME)):
    execvp("dom3", ["dom3"] + common + newgame + argv[1:])


#! /bin/bash



if [ ! -d $gamedir ]; then
    echo "Can't backup non-existent game!"

if [ -f $fatherland ]; then
    if [ -f $gamedir/scores.html ]; then
        turn=`grep -Eo -m 1 "Dominions 3 Scores, $game turn ([[:digit:]]+)" $gamedir/scores.html | grep -Eo "[[:digit:]]+$"`

# Make sure backup dir exists

if [ ! -d $backupdir ]; then
    mkdir -p $backupdir

# Create backupfile for this turn

echo "Creating backup file $backupfile"
tar cjf $backupfile -C $savedir $game > /dev/null

Regarding that unattendedness stuff, I run my server processes each in their own window under GNU screen, so they'll print their log to a terminal, but I don't have to have a local/remote login open all the time. But that's more a part of the fact that my setup currently requires me to start each game manually.

Lihaässä January 31st, 2009 04:25 AM

Re: Linux Admining
Thanks G

Gandalf Parker January 31st, 2009 01:00 PM

Re: Linux Admining

Originally Posted by Ornedan (Post 670770)
My server wrapper and backup scripts. For this thread, I think the interesting bit is the backup script, since it's parametrized by game name.

Excellent scripts.
I will definetly copy them and use them as examples as I work on consolidating mine. My stuff grew over time and I have a script to start each game type, and a script to restart for each game type, and one to kill/delete for each game type, and one to search/display dead games which the players didnt bother to turn off. Not to mention the many version 1, version 2, test this, test that scripts.

I really need to clean it all up and create larger scripts with options, I especailly like how you broke the common options from the newgame options for start and restart.

Gandalf Parker January 31st, 2009 01:07 PM

Re: Linux Admining
For backups I like to end it with a mime emailing to an account on another system. Backup on the same device is handy, on another device (drive, tape, etc) is handier, and on a completely different system is way handier.

Lihaässä March 5th, 2009 01:18 PM

Re: Linux Admining
First game finished using server hosting.. man that was simple! A new question occurred however while planning a new game. According to this list: http://www.dom3minions.com/docs/CommandLine.txt, its not possible to assign more than 1 victory point / province. I'm planning to set up game with one 3-vp and three 2-vp provinces in addition to 10 regular 1-vp provinces.

Any ideas is this possible? How?

Thanks already!

llamabeast March 5th, 2009 02:10 PM

Re: Linux Admining
I think you have to start the game using the GUI, then run it as a command line game once it's started. The detailed VP settings are curiously absent from the command line options.

Gandalf Parker March 5th, 2009 02:17 PM

Re: Linux Admining
Only time for quick answer. Ask if confusing.

For me, easiest is appending a few commands to the end of the games .map file

If someone elses map, dupe to new name. It will use the same image file so not much work involved.

per peer-pressure preoccupation
My maps, mods, and mullings can be found at

Lihaässä March 5th, 2009 02:19 PM

Re: Linux Admining
Thanks llamabeast - I think it's not possible to use GUI in our case. Sounds really mysterious why such commands are not available. Any other options?

Apparently me and Gandalf replied at the same time - I'll look into his solution. Thanks!

Lihaässä September 17th, 2009 05:38 PM

Re: Linux Admining
Im trying to make a working, simple backup option for a hosting script. How do the commands --postexec and --preexec commands work? At the moment my script looks like this? It works ok without the --postexec command. At the moment the game refuses to start up.


# Tällä käynnistellään dqotonen domi hostaukset
# jee

BUP=["rsync -a /home/dom/dominions3/savedgames/* /backup/"]


$DOM -S -T --port $PORT -g $GAME --era $ERA --mapfile $MAP -q --indepstr 9 --uploadmaxp $START --diffai $AID --enablemod $MOD --postexec $BUP

vfb September 17th, 2009 06:17 PM

Re: Linux Admining
It's probably the [] characters in $BUP, if it's calling system() to run the postexec command then it won't work, because system() does a "/bin/sh -c":


$ /bin/sh -c ["/bin/ls -a"]
/bin/sh: [/bin/ls: No such file or directory

I put my postexec commands in a script and that worked fine:


        --port $PORT -ST${DEBUG} ${SCOREOPT} ${RENAMEOPT} \
        --era ${ERA} \
        --uploadmaxp ${PLAYERS} --noclientstart \
        --requiredvp 0 --totalvp 0  \
        --mapfile ${MAP} \
        --enablemod ${MOD} \
        -q \
        --masterpass ${MASTERPASS} \
        --preexec ${DOM3DIR}/prehost.sh --postexec ${DOM3DIR}/posthost.sh \
        >>$DOM3LOGDIR/$DOM3GAME.log 2>>$DOM3LOGDIR/$GAME.err

Also, do you need -g? The help for that shows:


-g  --host          Generate new turn and exit

Lihaässä September 18th, 2009 03:50 AM

Re: Linux Admining
Thanks vfb. I'm almost there, you are correct, there is no need for "-g" command. At the moment the script looks like below. The game starts but when trying to play a turn it just closes the gamewindow. It also says "send, broken pipe"


# Tällä käynnistellään dqotonen domi hostaukset
# jee

BUP={rsync -a /home/dom/dominions3/savedgames/* /backup/}


$DOM -S -T --port $PORT $GAME --era $ERA --mapfile $MAP \
-q --indepstr 9 --uploadmaxp $START --diffai $AID --enablemod $MOD --postexec $BUP

vfb September 18th, 2009 03:58 AM

Re: Linux Admining
Did you try this?

BUP="rsync -a /home/dom/dominions3/savedgames/* /backup/"

Lihaässä September 18th, 2009 04:08 AM

Re: Linux Admining
Yeah, after that it asks for the game name and this happens.


-- Waiting for participants to connect -- , time left: 1 seconds
Arcoscephale  open
Ermor  open
Man  open
Ulm  open
Marignon  open
Mictlan  open
T'ien Ch'i  open
Jomon  open
Agartha  open
Abysia  open
Caelum  open
C'tis  open
Pangaea  open
Midg�rd  human controlled
Utg�rd  open
Patala  open
Gath  open
Atlantis  open
R'lyeh  open
Pythium  open
Bogarus  open
Enter game name: rivers
N�got gick fel!
fg: bad u
N�got gick fel!
fg: bad u
dom_server.sh: line 19: 20308 Aborted                $DOM -S -T --port $PORT $GAME --era $ERA --mapfile $MAP -q --indepstr 9 --uploadmaxp $START --diffai $AID --enablemod $MOD --preexec $BUP

Gandalf Parker September 18th, 2009 12:40 PM

Re: Linux Admining
I generally use pre.sh and post.sh

Also I think you want --preexec rather than --postexec

Once the game hosts, saving a copy is not much use since it will match the game itself. Players will complain about the hosting results in which case you want to be able to return to the files prior to hosting.

By the way, I find it more useful in many many ways to do
nice zip -9 game.zip * -x *game.zip -x z*
and then attach it to a email going to an address off-system.
That provides:
A) backup
B) dated multiple backups allowing restore to multiple points
C) security in case of system crashes or hard drive failures
D) ease of forwarding the latest games files to someone else in case they volunteer to pick up running the game for some reason

Lihaässä September 20th, 2009 03:33 PM

Re: Linux Admining
Thanks for the answers and help! I'm still struggling with the script, but will make it work somehow. Fortunately backing up files isn't mandatory. Happiness is :)

Lihaässä September 23rd, 2009 02:05 PM

Re: Linux Admining
Done! Thanks to my awesome anonymous friend and you guys my script is ready for hosting. Feel free to copy if you need such a simple script. :D


# Tällä käynnistellään dqotonen domi hostaukset
# Jos tämä toimii siis!



$DOM -S -T --port $PORT $GAME --era $ERA --mapfile $MAP \
-q --indepstr $IND --uploadmaxp $START --diffai $AID --normai $NID \
--noscoregraphs --hofsize $HOF --enablemod $MOD \
--preexec /home/dom/backup.sh


rsync -a /home/dom/dominions3/savedgames/ /home/dom/dominions3/backup/

Ornedan September 24th, 2009 04:04 AM

Re: Linux Admining

Originally Posted by Lihaässä (Post 711774)

rsync -a /home/dom/dominions3/savedgames/ /home/dom/dominions3/backup/

I see a couple of problems here:
  • You copy all games every time any game hosts. Which clobbers the backups of all games other than the one about to be hosted.
  • You only maintain a backup of the latest turn. This will cause trouble when the game manages to **** itself up so that it crashes at next hosting, because by the time you notice it crashing, you've clobbered the backup from before it broke.
    (Yes, this can happen. Guess what made me think it was a good thing I was already backing up all truns?)

If you look approximately halfway up the thread, I've posted a backup script that has neither of those particular issues.

Lihaässä September 24th, 2009 08:52 AM

Re: Linux Admining
You are correct, the script is simple but easily altered to backup only one game.. in this case /home/dom/dominions3/backup/Rivers/
I hope that the game won't crash and use this one. :)

Your script was too much for me and I didn't understand it. Thanks for your input. I will look it again when I find the time.

Ornedan September 24th, 2009 09:24 AM

Re: Linux Admining
Most of my backup script is about finding the current turn number and handling edge cases like being somehow called to backup a non-existent game (not detecting conditions like that will at best result in the script crashing and at worst data loss as it goes blindly ahead to do something stupid).


--preexec /home/dom/backup.sh "$GAME"

rsync -a "/home/dom/dominions3/savedgames/$1" /home/dom/dominions3/backup

would have your backup command be parametrised by game name, so it'll backup each game to separate directory. Though I guess that might have been what you meant?

Ornedan September 24th, 2009 10:23 AM

Re: Linux Admining
Looks like edit period ran out... It should have been

--preexec "/home/dom/backup.sh \"$GAME\""

Lihaässä September 24th, 2009 10:48 AM

Re: Linux Admining
It works perfectly! :D

lch September 30th, 2009 07:00 AM

Re: Linux Admining
Hi there, I see that people are sharing their Linux server scripts here. In case it helps: somebody contacted me about the Linux server scripts that I use for administrating my Dom3 games around June, here's what I sent back. Configuration is done by editing the GAME and PORT variables inside the scripts, and by setting the player's email addresses for email notification in the post-exec script.

Main script "MyGame.sh", this is being started in a "screen" session
PHP Code:



mkdir $DIR 

# reset timer for the stats.php script
if [ -e $DIR/ftherlnd ]
  touch $DIR

~/Dom3/dom3 $GAME --port $PORT -STddd --scoredump --renaming \
era 2 --mapfile 'MyGameMap.map' \
masterpass MyGamePassword \
noclientstart --uploadmaxp 7 \
hofsize 15 --indepstr 6 --renaming \
preexec /home/dom3/dominions3/${GAME}_pre.sh --postexec /home/dom3/dominions3/${GAME}_post.sh \
$DIR/$GAME.log 2>>$DIR/$GAME.err 

Pre-hosting script "MyGame_pre.sh", this is being started before hosting and makes a backup of the game/turn data
PHP Code:



# make backups
pushd "$DIR/.."
tar czf "/home/dom3/dominions3/backups/"$GAME-$(date +%s)-pre.tgz $GAME

# blank the log files after backup
cp /dev/null $DIR/$GAME.log
/dev/null $DIR/$GAME.err 

Post-hosting script "MyGame_post.sh", this is being started after hosting and makes a backup of the game/turn data, updates my online game statistics and sends a notification to the other players
PHP Code:


=`echo $GAME | tr "[:upper:]" "[:lower:]"`
SENDMAIL="sendmail -t "

# make backups & save scores
pushd "$DIR/.."
tar czf "/home/dom3/dominions3/backups/"$GAME-$(date +%s)-post.tgz $GAME
/home/dom3/dominions3/backups/scores2mysql.php "$GAME/scores.html"

# blank the log files after backup
cp /dev/null $DIR/$GAME.log
/dev/null $DIR/$GAME.err

# email notify players that have asked to be told of turns

# the actual sendmail needs a single dot "." in the last line at the end of the message, nbsmtp does not
'$GAME' Dom3 game server <$GAMElow@my-own.email>
$GAME has hosted!

The Dominions 3 game you are playing in ($GAMEhas processed a new turn.
Please connect to server dom3.servegame.com port $PORT to play your next turn!

Here is the turn status page for the gamehttp://dom3.servegame.com/stats/stats.php?game=$GAME


I am not hosting games right now and my Dom3 activities are in hiatus, but maybe these shell scripts are an inspiration for somebody else. I needed to use PHP syntax highlighting environment here because the CODE environment doesn't display the shell code correctly. (double <)

All times are GMT -4. The time now is 11:32 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2022, Shrapnel Games, Inc. - All Rights Reserved.