Thread: Utility Linux Admining
View Single Post
  #50  
Old September 30th, 2009, 07:00 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default 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:
#!/bin/bash

GAME=MyGame
PORT
=1337
DIR
="/home/dom3/dominions3/savedgames/"$GAME

mkdir $DIR 
&>/dev/null

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

~/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:
#!/bin/bash

GAME=MyGame
PORT
=1337
DIR
="/home/dom3/dominions3/savedgames/$GAME"

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

# blank the log files after backup
cp /dev/null $DIR/$GAME.log
cp 
/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:
#!/bin/bash

GAME=MyGame
PORT
=1337
GAMElow
=`echo $GAME | tr "[:upper:]" "[:lower:]"`
DIR="/home/dom3/dominions3/savedgames/$GAME"
SENDMAIL="sendmail -t "

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

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

# email notify players that have asked to be told of turns
Player1=player1@email.com
Player2
=player2@email.com
Player3
=player3@email.com
Player4
=player4@email.com
Player5
=player5@email.com
Player6
=player6@email.com

# the actual sendmail needs a single dot "." in the last line at the end of the message, nbsmtp does not
$SENDMAIL <<EOF
From
'$GAME' Dom3 game server <$GAMElow@my-own.email>
Bcc$Player1$Player2$Player3$Player4$Player5$Player6$GAMElow@my-own.email
Subject
$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

EOF 
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 <)
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief

Last edited by lch; September 30th, 2009 at 07:11 AM..
Reply With Quote
The Following 2 Users Say Thank You to lch For This Useful Post: