[cod] bash script
Albert D. Lawson
wb7awl at lawsonpc.com
Tue Jun 16 09:33:20 EDT 2009
Here's another one. I'd use it as a more of a guide than an actual
script because flavors
of Linux vary...but it should give you an idea or two. Note that
depending on how you call the
script, you can invoke different commands and/or config files...
#!/bin/bash
#
# /root/scripts/cod5
#
# Starts the Call of Duty 5 server daemon
# To start the daemon at runtime, put the
# script command "cod5 start" in your
# /etc/rc.d/rc.local file.
#
HOME="/root/cod5"
BIN="/root/cod5/codwaw_lnxded-bin"
BATCH="/root/cod5/codwaw_lnxded"
CLOSED="+set dedicated 2 +exec closed-server.cfg +map_rotate +set
sv_punkbuster 0"
OPEN="+set fs_localAppData $HOME +set dedicated 2 +exec server.cfg
+map_rotate +set sv_punkbuster 1"
#MOD="+set fs_basepath $HOME +set fs_homepath $HOME +set fs_localAppData
$HOME +set fs_game mods/war +set dedicated 2 +exec custom.cfg
+map_rotate +set sv_punkbuster 0"
MOD="+set fs_basepath $HOME +set fs_homepath $HOME +set dedicated 2 +set
fs_game mods/x5 +exec x5.cfg +map_rotate +set sv_punkbuster 1"
LOCKFILE="/var/lock/subsys/cod5"
NETIP="+set net_ip 192.168.0.253"
RETVAL=0
PROG="CoD5 WaW Server"
up() {
cd $HOME
if test -f $LOCKFILE
then
echo -n "The $PROG is already running!"
echo
else
echo -n $"Starting $PROG in the CLOSED configuration!"
$BIN $CLOSED >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
fi
}
open() {
cd $HOME
if test -f $LOCKFILE
then
echo -n "The $PROG is already running!"
echo
else
echo -n $"Starting $PROG in the OPEN configuration!"
$BIN $OPEN >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
fi
}
war() {
cd $HOME
if test -f $LOCKFILE
then
echo -n "The $PROG is already running!"
echo
else
echo -n $"Starting $PROG in the WAR Configuration!"
$BIN $WAR >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
fi
}
start() {
cd $HOME
if test -f $LOCKFILE
then
echo -n "The $PROG is already running!"
echo
else
echo -n $"Starting $PROG in the Modified Game
Configuration!"
$BIN $MOD >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
fi
}
stop() {
echo -n $"Stopping $PROG"
killall -9 $BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
echo
}
clearpid() {
echo -n $"Clearing PID Lockfile"
rm -f $LOCKFILE
echo
}
#
# See how we were called.
#
case "$1" in
start)
start
;;
stop)
stop
;;
open)
open
;;
war)
war
;;
clearpid)
clearpid
;;
mod)
mod
;;
reload|restart)
stop
start
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|open}"
exit 1
esac
exit $RETVAL
More information about the cod
mailing list