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

This Month's Specials

Air Assault Task Force- Save $8.00
winSPWW2- Save $5.00

   







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

Reply
 
Thread Tools Display Modes
  #1  
Old September 19th, 2006, 12:11 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

OK all of you Linux people. Have fun with THIS one. This is my bl_game.sh for creating small blitz games.
Code:

#!/bin/bash

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

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

MPASS=`makepasswd`
WURDnum=`echo $RANDOM$RANDOM % 118614 |bc`
WURD=`egrep "^....$|^.....$|^......$|^.......$|^........$|^.... .....$" \
/usr/share/dict/words|head -$WURDnum|tail -1`
GAME=bl_$WURD
MAP=eye.map
DIR=~/dominions3/savedgames/$GAME
ERA=$1
if [ -z "$1" ]
then
ERA=`echo $RANDOM % 3 + 1 |bc`
fi

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
MAP=$GAME.map
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 >$DIR/game.log 2>$DIR/game.err &

echo $DESC >>BLITZ_games.txt

PID=`ps a | grep $GAME | grep dom3 | cut -d" " -f2`
echo "kill -9 "$PID >$DIR/kill.sh
echo $MPASS >$DIR/master.txt
ls -blart /tmp/dominion* |tail -1 >$DIR/tmp.sh
echo " " >$DIR/pre.sh
echo " " >$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/" >$DIR/pre.sh
echo "cp /dev/null $DIR/pre.sh" >>$DIR/pre.sh

echo "cp $DIR/game.log $DIR/~game.log" >$DIR/post.sh
echo "cp /dev/null $DIR/game.log" >>$DIR/post.sh

__________________
-- 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
  #2  
Old September 19th, 2006, 12:23 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

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?
__________________
-- 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
  #3  
Old September 30th, 2006, 12:56 AM

Neophyte Neophyte is offline
Private
 
Join Date: Nov 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Neophyte is on a distinguished road
Default 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.

Thank's!
Reply With Quote
  #4  
Old September 30th, 2006, 12:01 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

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 63.199.8.158 OR dom3minions.com for a game. (also 63.199.8.157 host.dom3minions.com which I use for blitz games)
__________________
-- 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
  #5  
Old September 30th, 2006, 03:07 PM

Neophyte Neophyte is offline
Private
 
Join Date: Nov 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Neophyte is on a distinguished road
Default Re: Linux Admining

Upon reflection, the whole IP thing is probably a switch issue not a computer issue anyhow - i.e. addyXZ internally is in all ways equivalent to addyYZ 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.
Reply With Quote
  #6  
Old October 14th, 2006, 12: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

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
http://www.shrapnelcommunity.com/thr...270&Forum=f187

The switches are:
--uploadtime
--uploadmaxp
__________________
-- 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
  #7  
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
  #8  
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
  #9  
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
Reply

Bookmarks

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

Thread Tools
Display Modes

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 02:57 PM.


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