Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello again all.

I have a scripting question I hope someone can answer and figure out for me.

I have finally built a full time game server at home running Psyche. I want
to run several games on it, like Quake 3, Jedi Knight 2, Medal of Honor and
a couple of others. I've been looking on the net for two weeks for a good
script that will check if a game is running, if it has died, it will restart
it. I found one but it doesn't seem to work. My complete lack of scripting
ability doesn't allow me to troubleshoot this very well. There was another
guy on the lists who was asking about game servers, but I can't remember who
it was. I'm hoping someone can see the error in this script, and possibly
make it more featured for me for use and adaptation onto my gaming server.

Here is what I have so far, from somewhere on the net that I can no longer
find.

#!/bin/sh
quake3dir="/usr/local/games/quake3"
binname="q3ded"

cd $quake3dir
process=`ps auxwww | grep q3ded | grep -v grep | awk '{print $12}'`
if [ -z process ]; then
    echo "Couldn't find quake 3 running. Restarting it"
    nohup q3ded +set dedicated 1 +exec server.cfg &
    echo ""
fi 



When I forst got the script, the  #! was reversed, ie it was !#/bin/sh. That
was the first error I found and figured out on my own. But I'm lost now.

I understand some of the variables, as I also changed the binname one from
quake3 to the q3ded, which is the bin name of the server I am running.

The author claims to put this in a cron job on a 10 minute interval to make
sure the server has not died. I like that idea as the game will periodically
die out and require a reload. 

I think the problem is in the process line. I tried typing it in manually
from a prompt, and it doesn't give me any output. It seems to just skip the
nohup line and finish the script without running the server.

I'd appreciate any input on this. At a later date to get fancier, I'd like
to record the pid so that I can kill it from cron too. I'd like to only have
the server running at night and I'd like to rotate through the different
servers on a weekly basis. I can figure out how to do that from the cron,
but I need to know the pid's of the server when it starts up.

Thanks for your help.

-=/>Thom



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux