.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

Reply
 
Thread Tools Display Modes
  #21  
Old October 17th, 2006, 03:22 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default 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.
http://host.dom3minions.com/bin/blitz_chk.cgi

Code:

#!/bin/bash
echo "Content-type: text/html"
echo -e "\n\n"

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


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
do
echo "era $era game <b>$game</b> on port <b>$port</b><br>"
cd $game
for fyle in `ls -1 *.2h`
do
echo $fyle "<br>"
done
cd /home/dom3/dominions3/savedgames
echo "<br>"
done

__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #22  
Old November 28th, 2006, 07:14 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default 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
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #23  
Old November 28th, 2006, 07:37 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default 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 <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 &
(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
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #24  
Old January 6th, 2007, 08:54 AM
Tals's Avatar

Tals Tals is offline
Corporal
 
Join Date: Oct 2003
Location: UK
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Tals is on a distinguished road
Default 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?

Tals
Reply With Quote
  #25  
Old January 23rd, 2007, 05:33 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default 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.
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #26  
Old September 1st, 2008, 02:08 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Linux Admining


Since this subject is coming up again I thought Id bump this.

Gandalf Parker
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #27  
Old January 30th, 2009, 12:40 PM
Lihaässä's Avatar

Lihaässä Lihaässä is offline
Corporal
 
Join Date: Jan 2009
Location: Espoo, Finland
Posts: 147
Thanks: 23
Thanked 2 Times in 2 Posts
Lihaässä is on a distinguished road
Default Re: Linux Admining

Hi,

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
Reply With Quote
  #28  
Old January 30th, 2009, 05:08 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default 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.
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
The Following User Says Thank You to Gandalf Parker For This Useful Post:
  #29  
Old January 30th, 2009, 05:39 PM

Ornedan Ornedan is offline
Private
 
Join Date: May 2008
Posts: 29
Thanks: 3
Thanked 4 Times in 4 Posts
Ornedan is on a distinguished road
Default 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.


dom3serv:
Code:
#! /usr/bin/env python

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


# Common options
common = ["--scoredump",
          "--tcpserver",
          "--quickhost",
          "--textonly"
          ]


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


# 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:])
else:
    print "Starting new game %s" % (GAME,)
    if not exists(join(HOME,"dominions3","savedgames",GAME)):
        mkdir(join(HOME,"dominions3","savedgames",GAME))
    execvp("dom3", ["dom3"] + common + newgame + argv[1:])

dom3backup:
Code:
#! /bin/bash

game=$1
savedir="$HOME/dominions3/savedgames"
gamedir="$savedir/$game"
backupdir="$HOME/dominions3/backups/$game"

fatherland="$gamedir/ftherlnd"

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

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:]]+$"`
    else
        turn=1
    fi
    backupfile="$backupdir/turn_$turn.tar.bz2"
else
    backupfile="$backupdir/pregame.tar.bz2"
fi


# Make sure backup dir exists

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

# Create backupfile for this turn

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


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

Last edited by Ornedan; January 30th, 2009 at 05:48 PM..
Reply With Quote
The Following User Says Thank You to Ornedan For This Useful Post:
  #30  
Old January 31st, 2009, 04:25 AM
Lihaässä's Avatar

Lihaässä Lihaässä is offline
Corporal
 
Join Date: Jan 2009
Location: Espoo, Finland
Posts: 147
Thanks: 23
Thanked 2 Times in 2 Posts
Lihaässä is on a distinguished road
Default Re: Linux Admining

Thanks G
Reply With Quote
Reply

Bookmarks

Tags
admin, automation, command line, hosting, linux, script, server, switches


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 04:35 PM.


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