[cod] bash script

Colin Hamilton mrcol at blueyonder.co.uk
Tue Jun 16 09:20:32 EDT 2009


> any of u folks have a good bash script i can steal from you? i have 
> made a post in ow forums but no luck so far
> i am running ow mod on ubuntu and the script i have made will start 
> the mod but will not run pb.
> i can start the server from ./cod4_lnxded and it will start pb normally.
> i hate to run this server without pb
> here it goes minus typin errors
>
> #!/bin/bash
>
> $port=28960
> $ip+175.15.26.266
> $slots=16
> cod5dir=home/tome/cod5
> mod=mods/mp_openwarfare
>
> ./cod4_lnxded \
> +set sv_punkbuster 1 \
> +set loc_language 0 \
> +exec server.cfg \
> +map_rotate
>
> exit 0
>
> a cliff notes version of the script(i am not near the server right 
> now) i am a noob to linux scripts but enjoy the linux flavor of server.
> i post this thinkin some of u have seen the post on ow but maybe there 
> is someone out there who has not
> tom
> any help would be appreciated
> ------------------------------------------------------------------------
>
> _______________________________________________
> cod mailing list
> cod at icculus.org
> http://icculus.org/mailman/listinfo/cod
>   
Here is something I knocked (might have borrowed and altered!) together 
a few years ago, nothing special but should get you close to where you 
want to be.


#!/bin/sh


SERVERTYPE="cod4"

BIN_PATH="/home/you/games/cod4/"

BINARY="cod4_lnxded"

PORT="28951"

CONFIG="server.cfg"

FSGAME="mods/pam"

PUNKBUSTER="+set sv_punkbuster 1"

###################################################
###################################################
##
## Dont edit anything below this line
##
###################################################

case $1 in
start)
  if ps aux | grep $SERVERTYPE | grep -v grep | grep $PORT > /dev/null
  then
       echo "$SERVETYPE server already running on port $PORT. Use stop 
command to kill this process, then retry"
  
   else
       if [ -x $BIN_PATH$BINARY ]; then
           if [ "$FSGAME" = "" ]; then
            echo "$SERVERTYPE server started on port $PORT, using $CONFIG"
            $BIN_PATH$BINARY +set net_port $PORT +set dedicated 2 +set 
fs_homepath $BIN_PATH $PUNKBUSTER +exec $CONFIG +map_rotate >/dev/null 
2>&1 &
        else
            echo "$SERVERTYPE server started on $PORT, using $CONFIG"
        $BIN_PATH$BINARY +set net_port $PORT +set dedicated 2 +set 
fs_game $FSGAME +set fs_homepath $BIN_PATH $PUNKBUSTER +exec $CONFIG 
+map_rotate >/dev/null 2>&1 &
        fi
       fi
   fi
  
;;

stop)
    ps aux | grep $SERVERTYPE | grep -v grep | grep $PORT | awk '{print 
$2}' | xargs -t kill $2;
;;

   
status)
    if ps aux | grep $SERVERTYPE | grep -v grep | grep $PORT > /dev/null
    then       
        echo " "
        echo "$SERVERTYPE server running on port $PORT with config $CONFIG"
        echo " "
    else
        echo " "
        echo "no $SERVERTYPE server running on port $PORT"
        echo " "
    fi
;;

*)
    echo "Usage: `basename $0` { start | stop | status }"
    exit 64
;;

esac

exit 0



More information about the cod mailing list