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

Lihaässä September 18th, 2009 04:08 AM

Re: Linux Admining
 
Yeah, after that it asks for the game name and this happens.

Code:

-- Waiting for participants to connect -- , time left: 1 seconds
Arcoscephale  open
Ermor  open
Man  open
Ulm  open
Marignon  open
Mictlan  open
T'ien Ch'i  open
Jomon  open
Agartha  open
Abysia  open
Caelum  open
C'tis  open
Pangaea  open
Midg�rd  human controlled
Utg�rd  open
Patala  open
Gath  open
Atlantis  open
R'lyeh  open
Pythium  open
Bogarus  open
Enter game name: rivers
N�got gick fel!
fg: bad u
N�got gick fel!
fg: bad u
dom_server.sh: line 19: 20308 Aborted                $DOM -S -T --port $PORT $GAME --era $ERA --mapfile $MAP -q --indepstr 9 --uploadmaxp $START --diffai $AID --enablemod $MOD --preexec $BUP


Gandalf Parker September 18th, 2009 12:40 PM

Re: Linux Admining
 
I generally use pre.sh and post.sh

Also I think you want --preexec rather than --postexec

Once the game hosts, saving a copy is not much use since it will match the game itself. Players will complain about the hosting results in which case you want to be able to return to the files prior to hosting.

By the way, I find it more useful in many many ways to do
nice zip -9 game.zip * -x *game.zip -x z*
and then attach it to a email going to an address off-system.
That provides:
A) backup
B) dated multiple backups allowing restore to multiple points
C) security in case of system crashes or hard drive failures
D) ease of forwarding the latest games files to someone else in case they volunteer to pick up running the game for some reason

Lihaässä September 20th, 2009 03:33 PM

Re: Linux Admining
 
Thanks for the answers and help! I'm still struggling with the script, but will make it work somehow. Fortunately backing up files isn't mandatory. Happiness is :)

Lihaässä September 23rd, 2009 02:05 PM

Re: Linux Admining
 
Done! Thanks to my awesome anonymous friend and you guys my script is ready for hosting. Feel free to copy if you need such a simple script. :D

Code:

#!/bin/bash
# Tällä käynnistellään dqotonen domi hostaukset
# Jos tämä toimii siis!

GAME="Rivers"
MAP="Rivers.map"
ERA="3"
MOD="CBcomplete_1.6.dm"
AID="0"
NID="0"
START="5"
HOF="15"
IND="5"

PORT="3737"
DOM="/home/dom/dominions3/dom3"

$DOM -S -T --port $PORT $GAME --era $ERA --mapfile $MAP \
-q --indepstr $IND --uploadmaxp $START --diffai $AID --normai $NID \
--noscoregraphs --hofsize $HOF --enablemod $MOD \
--preexec /home/dom/backup.sh

Code:

#!/bin/bash
rsync -a /home/dom/dominions3/savedgames/ /home/dom/dominions3/backup/


Ornedan September 24th, 2009 04:04 AM

Re: Linux Admining
 
Quote:

Originally Posted by Lihaässä (Post 711774)
Code:

#!/bin/bash
rsync -a /home/dom/dominions3/savedgames/ /home/dom/dominions3/backup/


I see a couple of problems here:
  • You copy all games every time any game hosts. Which clobbers the backups of all games other than the one about to be hosted.
  • You only maintain a backup of the latest turn. This will cause trouble when the game manages to **** itself up so that it crashes at next hosting, because by the time you notice it crashing, you've clobbered the backup from before it broke.
    (Yes, this can happen. Guess what made me think it was a good thing I was already backing up all truns?)

If you look approximately halfway up the thread, I've posted a backup script that has neither of those particular issues.

Lihaässä September 24th, 2009 08:52 AM

Re: Linux Admining
 
You are correct, the script is simple but easily altered to backup only one game.. in this case /home/dom/dominions3/backup/Rivers/
I hope that the game won't crash and use this one. :)

Your script was too much for me and I didn't understand it. Thanks for your input. I will look it again when I find the time.

Ornedan September 24th, 2009 09:24 AM

Re: Linux Admining
 
Most of my backup script is about finding the current turn number and handling edge cases like being somehow called to backup a non-existent game (not detecting conditions like that will at best result in the script crashing and at worst data loss as it goes blindly ahead to do something stupid).


Doing
Code:

--preexec /home/dom/backup.sh "$GAME"
and
Code:

#!/bin/bash
rsync -a "/home/dom/dominions3/savedgames/$1" /home/dom/dominions3/backup

would have your backup command be parametrised by game name, so it'll backup each game to separate directory. Though I guess that might have been what you meant?

Ornedan September 24th, 2009 10:23 AM

Re: Linux Admining
 
Looks like edit period ran out... It should have been
Code:

--preexec "/home/dom/backup.sh \"$GAME\""

Lihaässä September 24th, 2009 10:48 AM

Re: Linux Admining
 
It works perfectly! :D

lch September 30th, 2009 07:00 AM

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


All times are GMT -4. The time now is 04:38 AM.

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