[mohaa] Server restart script
Andrew (KARZAC) Furbey
andrewfurbey at hotmail.com
Wed Aug 18 09:13:36 EDT 2004
Hey, i got these 3 files now
serverconfig.sh
#Root directory
GAMEDIR="/opt/lampp/htdocs/MOHAA2"
#Program to run
PROG="./spearhead_lnxded"
#Port
PORT="12203"
#Gamespy port
GSPORT="12307"
#Config
CONFIG="server.cfg"
startserver.sh
#Put here path to config file
/opt/lampp/htdocs/MOHAA2/mainta/server.cfg
#Enters game dir
cd $GAMEDIR
#Loop forever
while [ 1 ]
do
#Check for a specific IP to set
if [ "$IP" == "67.18.236.202" ]
then
IPS="67.18.236.202"
else
IPS=" +set net_IP $IP"
fi
#Starts the server
$PROG +exec $CONFIG +set net_port $PORT +set net_ip $IPS +set
net_gamespy_port $GSPORT
+set vm_game 0 +set ttycon 0 +set dedicated 2
# Sleep a while
sleep 10
done
serverkill.sh
#Put here path to config file
serverconfig.sh
#Searches for pid of server
ps auxwww | grep $PROG | grep $PORT | grep $CONFIG | grep -v grep | gawk
'{print $2}' | xargs kill
#Checks kill exit status
if [ 0 != $? ]
then
echo "Server Down"
else
echo "Server Killed"
fi
When i run the command ./startserver.sh
i got these lines come up
/startserver.sh: line 1: sv_hostname: command not found
/startserver.sh: line 9: sv_maxclients: command not found
/startserver.sh: line 10: timelimit: command not found
/startserver.sh: line 11: fraglimit: command not found
/startserver.sh: line 12: maprotationtime: command not found
/startserver.sh: line 14: roundlimit: command not found
/startserver.sh: line 42: map: command not found
/startserver.sh: line 43: sv_maplist: command not found
/startserver.sh: line 44: sv_runspeed: command not found
/startserver.sh: line 16: +exec: command not found
/startserver.sh: line 17: +set: command not found
/startserver.sh: line 16: +exec: command not found
/startserver.sh: line 17: +set: command not found
and the server wont start, Any ideas?
Thanks
----- Original Message -----
From: "Luca Fabbro" <luca.fabbro at procne.it>
To: <mohaa at icculus.org>
Sent: Wednesday, August 18, 2004 9:20 AM
Subject: Re: [mohaa] Server restart script
> I'm using the following files to kill the right mohaa process
>
> I'm not using screen so if you whant to use it you shold change the row
> that starts the server :)
>
> A kinfd of config in one file
>
> #Root directory
> GAMEDIR="/usr/local/games/mohaa"
> #Program to run
> PROG="./mohaa_lnxded"
> #Port
> PORT="12210"
> #Gamespy port
> GSPORT="12307"
> #Config
> CONFIG="my_mohaa.cfg"
>
> The start up script
>
> #Put here path to config file
> . my_config_file
> #Enters game dir
> cd $GAMEDIR
> #Loop forever
> while [ 1 ]
> do
> #Check for a specific IP to set
> if [ "$IP" == "" ]
> then
> IPS=""
> else
> IPS=" +set net_IP $IP"
> fi
> #Starts the server
> $PROG +exec $CONFIG +set net_port $PORT$IPS +set net_gamespy_port $GSPORT
> +set vm_game 0 +set ttycon 0 +set dedicated 2
> # Sleep a while
> sleep 10
> done
>
> The kill script is the following
> #Put here path to config file
> . my_config_file
> #Searches for pid of server
> ps auxwww | grep $PROG | grep $PORT | grep $CONFIG | grep -v grep | gawk
> '{print $2}' | xargs kill
> #Checks kill exit status
> if [ 0 != $? ]
> then
> echo "Server Down"
> else
> echo "Server Killed"
> fi
>
> Hope that this helps
>
> Ciao
> Luca
>
> At 02.41 18/08/2004, you wrote:
> >Hey Josh, i got that script working to write the PID file, and it
displays
> >the PID with other numbers Quote:
> >
> > 3887 2141 69 03
> >
> >Could you help me with a full script that could run that then kill the
prces
> >number which would be 3887,
> >
> >Would be the greatest help iv had.
> >
> >Thankyou
> >----- Original Message -----
> >From: "Josh Berry" <games at chickenmonkey.co.uk>
> >To: <mohaa at icculus.org>
> >Sent: Wednesday, August 18, 2004 12:09 AM
> >Subject: Re: [mohaa] Server restart script
> >
> >
> > > For a quick and very, very dirty hack you can do:
> > >
> > > ps -ef | grep mohaa_lnxded | grep -v grep > temp; sed 's/ /:/g'
temp
> > > > temp2; gawk -F: '{ print $2 }' temp2
> > >
> > > This will print the PID of the mohaa process to console. Alternatively
> > > you could add a "> pid.txt" onto the end to write the pid to a file
> > > called pid.txt. Note that this will create two temporary files in the
> > > location of the script.
> > >
> > > You can then read from the file and into other scripts to do whatever
> > > with.
> > >
> > > If you run multiple servers on one box then you will have to modify
the
> > > grep bit to make it return only a single line ... so for example
> > >
> > > ps -ef | grep mohaa_lnxded | grep 123.123.123.123 | grep -v grep >
temp
> > >
> > > where 132.etc is the IP address of your server (assuming you have
"+set
> > > net_IP 123.123.123.123" in the startup line for your server so it
> > > displays when you do a ps -ef
> > >
> > > Hope that helps
> > > josh
> > >
> > > On Tue, 2004-08-17 at 21:47, Andrew (KARZAC) Furbey wrote:
> > > > You can run scripts up using php commands over the web(aslong as its
on
> >the
> > > > same box), thats how i can start my servers, im trying to figure
away
> >for a
> > > > script to find the PID for a program running and kill it, but the
PID
> > > > changes everytime, im not that advanced at coding yet :/
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "Robert Mount" <rmount at pobox.com>
> > > > To: <mohaa at icculus.org>
> > > > Sent: Tuesday, August 17, 2004 6:40 PM
> > > > Subject: [mohaa] Server restart script
> > > >
> > > >
> > > > > ----- Original Message -----
> > > > > From: "Andrew (KARZAC) Furbey" <andrewfurbey at hotmail.com>
> > > > > To: <mohaa at icculus.org>
> > > > > Sent: Tuesday, August 17, 2004 11:53 AM
> > > > > Subject: Re: [mohaa] mohaa process freezes
> > > > >
> > > > >
> > > > > > does anyone know of a script that can restart a server when it
> >crashes
> > > > BUT
> > > > > > it leaves the procces running, i think it might be what your
talking
> > > > > > about,
> > > > > > but i was running the server as "root", and it used to crash
about
> >twice
> > > > a
> > > > > > day also, then created a user account and started it via that,
and
> >its
> > > > > > still
> > > > > > running, no crashes 2 days later.
> > > > >
> > > > > Here's my script:
> > > > >
> > > > > ****
> > > > > #!/bin/bash
> > > > > #
> > > > > # MOH Server loop
> > > > > #
> > > > > clear
> > > > >
> > > > > while [ 1 ] # Loop `forever'
> > > > > do
> > > > > echo "Starting the server"
> > > > > cd /home/mohsh01
> > > > > screen -m -D -S mohsh01 ./spearhead_lnxded +set net_ip 1.1.1.1
+exec
> > > > > server.cfg
> > > > > sleep 60
> > > > > echo "Done sleeping"
> > > > >
> > > > > done
> > > > > *****
> > > > >
> > > > > I use this command from another script to start my servers:
> > > > > su mohsh01 -c "/opt/control/mohsh01 &"
> > > > >
> > > > > I run this as the user "mohsh01" not as root. Only problem with
this
> >is
> > > > > there's no web control for it that i can figure out. I'd love to
have
> >a
> > > > > looper (as above) with some way to shut the server down over the
web.
> > > > >
> > > > > --Rob
> > > > >
> > > > >
> > > > >
> > >
> > >
>
>
More information about the Mohaa
mailing list