scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 659c9098ccb6f8d9babf9796decf3b930094cdde
parent 0e68265001ec95177fc7ac609796ea47dcf5139c
Author: sin <sin@2f30.org>
Date:   Mon, 22 Dec 2014 20:34:59 +0000

Add q3d

Diffstat:
Aq3d | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+), 0 deletions(-)

diff --git a/q3d b/q3d @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Written by z3bra + +base="/opt/ioquake3/" +port="25000" + +green='\e[1;32m' +reset='\e[0m' +red='\e[1;31m' + +function usage() { +cat << EOF + usage: `basename $0` <command> + commands: + ffa|tdm|ctf|duel|df - Start the corresponding mod + kill|stop <mod> - Stop the corresponding mod + list - List running servers + help - Display this help +EOF +} + +conf_path=$HOME/.q3a/baseq3 +fifo_path=$HOME/var/q3 + +# Spawn the appropriate game type +function spawn() { + socket=$fifo_path/$1.fifo + + ## Options to add when launching server + opt="" + [[ "$1" == "df" ]] && opt="$opt +set fs_game defrag" + opt="$opt +set dedicated 2" + opt="$opt +set fs_basepath $base" + opt="$opt +set net_port $port" + opt="$opt +exec $1.cfg" + + # If a server exists, attach to it. + if [ -S $socket ]; then + dtach -a $socket + # If not, create a background session + else + dtach -n $socket ioq3ded $opt + echo -e "${green}$1 running through ${reset}${socket}" + fi +} + +case $1 in + ffa|tdm|ctf|duel|df) spawn $1;; + kill|stop) wipe q3 $2;; + list) ls -C --color=auto $fifo_path;; + help) usage;; + *) usage; exit 1;; +esac + +exit 0 +