Linux bash script for managing quake live servers

Locked
User avatar
DooMer
Posts: 3068
Joined: Thu Dec 23, 1999 8:00 am

Linux bash script for managing quake live servers

Post by DooMer »

I wrote a small bash script last year so i could easily change game types and stuff. I'll post it here, maybe it will come in handy for somebody.

You basically make a config and mappool for each gametype and stick it in baseq3. (configs should be called ctf_server.cfg, mappool_ctf.txt for example.) Replace the baseq3 in the script with the path of your baseq3. It swaps out the server configs for you and kills the qz process. You should use something like supervisord which will restart the qzeroded process automatically if it isn't running. http://supervisord.org/

[root@doomer ~]# ./ql.sh
Usage: ql [gametype(duel/ctf/ca/rr/ft/ad)] [private(0/1)]

So to respawn the server as a private duel server: ./ql.sh duel 1

Code: Select all

#!/bin/bash

baseq3="/home/user/quakelive/baseq3"
gametype=(duel ctf ca rr ft ad)

if [ -z "$1" ];then
	echo "Usage: ql [gametype(duel/ctf/ca/rr/ft/ad)] [private(0/1)]"
	exit 1
fi

if [[ ${gametype[*]} =~ "$1" ]];then
	cp $baseq3/mappool_$1.txt $baseq3/mappool.txt
	cp $baseq3/base_server.cfg $baseq3/server.cfg
	sed -i "1s/^/exec $1_server.cfg /" $baseq3/server.cfg
	for i in `ps aux |grep qz |awk '{ print $2 }'`; do kill -9 $i; done 2>/dev/null

echo "Setting gametype to $1 "

else
	echo "Scuse me? $1? Supported gametypes are ${gametype[*]}"
	exit 1
fi

if [ "$2" == "1"  ];then
        sed -i 's/set sv_master "1"/set sv_master "0"/g' $baseq3/server.cfg
        echo "Private Server"
	exit 1
else
	echo "Public Server"
	exit 1
fi
Don't contact me for troubleshooting.
Locked