[mohaa] console reattatch

Eric Koldeweij eric at no-sense.net
Sat Jul 20 06:14:28 EDT 2002


Damon,

These are my scripts, with auto-restart and everything. It can handle 
more than one server, does auto-restart and you can stop/restart any 
server at will. I have the cvars common to every server stored in 
default.cfg (so it gets executed automagically) and on the cmdline I 
specify the cfg files with server-specific settings.
It also saves the output from killed/crashed sessions in mohaaxxx.out.save
I do not use screen BTW.

Note, it worx for Q3 and RTOCW (and prolly all other Q3-engine based 
games) too.

===== Start-mohaa ========
#!/bin/bash
# Written by Aragon 2002-02-18/2002-07-19.
# Permission to copy/spread/change/maim/mangle granted :)
# usage: start-mohaa <servernum> <IP> <port> <cfgfile...>
# server num is a unique ID for each server, I use 1, 2 etc...
# example: start-mohaa 1 192.168.0.1 12203 myownsettings.cfg dmmaps.cfg

# directory where mohaa is located
MOHHOME= /home/mohaa/

# Get arguments
ID=$1
shift
IP=$1
shift
PORT=$1
shift

# build up MOHAA command line
CMDLINE="$MOHHOME/mohaa_lnxded +set net_ip $IP +set net_port $PORT +set 
dedicated 1 +set logfile 1"
while [ $# -gt 0 ]; do
    [ -f main/$1 ] && CMDLINE="$CMDLINE +exec $1"
    shift
done
CMDLINE="$CMDLINE > $MOHHOME/mohaa$ID.out 2> $MOHHOME/mohaa$ID.out"

cd $MOHHOME

# Fire it up, babe!
rm -f $MOHHOME/stop$ID
while [ ! -f $MOHHOME/stop$ID ];
do
    [ -f mohaa$ID.out ] && cat mohaa$ID.out >> mohaa$ID.out.save

    $CMDLINE &

    echo $! > $MOHHOME/mohaa$ID.pid

    wait
done

rm -f $MOHHOME/stop$ID $MOHHOME/mohaa$ID.pid
========================

======== stop-mohaa =======
#!/bin/bash
# Written by Aragon 2002-02-18/2002-07-19.
# Permission to copy/spread/change/maim/mangle granted :)
# usage: stop-mohaa <id>
# example: stop-mohaa 1

ID=$1

MOHHOME=/home/mohaa

if [ -f $MOHHOME/mohaa$ID.pid ]; then
    touch $MOHHOME/stop$ID
    kill -9 `cat $MOHHOME/mohaa$ID.pid`
fi
=====================

Restart a server by just killing it.

Have fun!

Grts,
Eric.

Damon wrote:

>Lo.
>Thn y'all - very informative learnt a few things. now i need to learn how to
>write a restarting script...  anyone got a faq on that :)
>Damon
>
>
>-----Original Message-----
>From: Chunky Kibbles [mailto:chunky at icculus.org]
>Sent: 20 July 2002 09:08
>To: mohaa at icculus.org
>Subject: Re: [mohaa] console reattatch
>
>
>On Fri, Jul 19, 2002 at 07:48:19PM -0400, Ryan C. Gordon wrote:
>
>>>Two questions: First, is screen -d and screen -r switches for detach and
>>>remote? Also, I am trying to execute this from my command prompt but
>>>
>screen
>
>>screen is a separate program...there are probably redhat RPMs for it
>>somewhere (very possibly on the RedHat install discs and not installed by
>>default).
>>
>
>I've missed the rest of this thread, but I wrote a brief tutorial on
>screen(1) if it help:
>http://icculus.org/~chunky/writing/screen+cmdline
>
>It starts about 35 lines down...
>
>Gary (-;
>





More information about the Mohaa mailing list