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

All times are GMT -4. The time now is 03:40 PM.

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