Thread: Utility Linux Admining
View Single Post
  #66  
Old October 22nd, 2010, 06:56 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

Now I have a new "check the game" script for personal games on the server. So far it looks like this..
Code:
Dominions 3 Scores, goongame turn 16

    goongame, Connections 1, Time 22h (quick host) 
*Py- (Man) Mac+ Ag- Ca+ Jo+ shi+ As-  


mid_agartha.2h 
mid_bakemono.trn*
mid_caelum.trn*
mid_gath.trn*
mid_jotunheim.trn*
mid_machaka.2h 
mid_man.2h 
mid_pythium.2h 
mid_vanheim.2h 

If the game is called goongame then cat goongame.cgi gives

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

cd /home/domgames/dominions3/savedgames/goongame/
head -9 scores.html
echo "<html>"
echo "<h4>"
tail game.log | \
grep Connections | tail -n 1
echo ""
tail game.log | \
egrep "\-|\+" |tail -n 1
echo ""
echo "</h4>"

  for fyle in `ls -1 *.2h`
    do
      nation=`echo $fyle|cut -d. -f1`
      if [ $nation.trn -nt ftherlnd ]
        then echo $nation".trn<font color=red>*</font>"
       else
        echo "<font color=black>"$nation".2h </font>"
      fi
    done

echo "</html>"
The first sections grabs the top of goongames latest scores.html (which dom3 creates).
That gives us a nice html header, and title, game name, and the turn number.

The next section grabs the tail end of the game.log twice (created by the dom3 debug switch).
That gives us game name, how much time is left on the timer, and the note (quickhost) if its on.
then it lists the nations and lets us know who is connected *, who has done a turn +, who hasnt done a turn -, and who is AI ( ).

The final section lists the player files with a red asterisk on anyone the game is still waiting on. Yes thats redundant but it has two purposes. The file names are sometimes clearer than the 2-letter codes, and it works even BEFORE the game starts so it makes an easy way for the person who is running the game to see who has turned in a pretender.

All of this is so that people can use a browser to check their games status as much as possible without having to load up Dom3 to connect in order to see it.

Last edited by Gandalf Parker; October 22nd, 2010 at 07:09 PM..
Reply With Quote