#!/bin/sh
# Adapted from Tremulous and Nexuiz launch scripts
BINARY=/usr/lib/games/urbanterror/Quake3-UrT-Ded
BASE_PATH=/usr/share/games/urbanterror
QUIET=0
EXCUSE="\
Urban Terror server wrapper\n\
This script is Debian specific, it is *NOT* part of the source distribution!\n\
Usage: urbanterror-server [OPTION]...\n\
\n\
 -h, --help\t\tDisplay this help\n\
 -q, --quiet\t\tDisable console output\n\
 +<internal command>\tPass commands to the engine\n"

# Urban Terror binaries don't understand "regular" command line parameters. Let's
# catch them here, to avoid accidently launching the binary.

while [ "$1" != "" ]; do {
        if [ "$1" = "+set" -o "$1" = "+connect" ]; then
                break;
        fi
        case "$1" in
                -h|--help)
                        echo ${EXCUSE}
                        exit 0
                        ;;
                -q|--quiet)
                        QUIET=1
                        ;;
        esac
        shift
}; done

# Ready to rumble!

if [ ${QUIET} -eq 1 ]; then
        exec ${BINARY} +set fs_basepath ${BASE_PATH} +set ttycon 0 $* >/dev/null 2>&1
else
        exec ${BINARY} +set fs_basepath ${BASE_PATH} $*
fi

exit $?
