From d3111365aa5993fe0ef580e01bb3fb8a979dec3d Mon Sep 17 00:00:00 2001
From: Alexander Hurd <hurdad@gmail.com>
Date: Tue, 2 Feb 2016 00:46:37 -0500
Subject: [PATCH 1/3] adding Quake Live

Ubuntu 14.04 x64
---
 QuakeLive/cfg/lgsm-default.cfg | 103 ++++++++++++++++++++++++
 QuakeLive/quakeliveserver      | 138 +++++++++++++++++++++++++++++++++
 functions/install_config.sh    |   6 ++
 3 files changed, 247 insertions(+)
 create mode 100644 QuakeLive/cfg/lgsm-default.cfg
 create mode 100644 QuakeLive/quakeliveserver

diff --git a/QuakeLive/cfg/lgsm-default.cfg b/QuakeLive/cfg/lgsm-default.cfg
new file mode 100644
index 000000000..501193a40
--- /dev/null
+++ b/QuakeLive/cfg/lgsm-default.cfg
@@ -0,0 +1,103 @@
+// Servers have the ability to run multiple gametypes, known as "factories." You should not add gameplay related
+// cvars in the server config: they may get overwritten by the factory. For creating your own sets of gameplay rules,
+// create a file ending in ".factories" inside baseq3/scripts, and refer to "Creating custom gametypes" in the
+// server_readme.txt file.
+
+// Be aware that factories can override any cvar, including ones specified in this config file.
+
+set sv_hostname "<hostname>"
+set sv_tags "" // Comma delimited field of server tags to show in server browser.
+               // Will automatically include gametype and some gameplay modifications.
+               // ex. "crouch slide, classic, space"
+set sv_mapPoolFile "mappool.txt"  // Map pool that the server will use. See default mapcycle.txt for format.
+                                  // Built in map pools: mappool.txt, mappool_ca.txt, mappool_ctf.txt, mappool_duel.txt,
+                                  //                     mappool_ffa.txt, mappool_race.txt, mappool_tdm.txt
+set g_accessFile "access.txt"      // Used to determine which 64-bit Steam IDs have admin access, or are banned.
+               
+set sv_maxClients "16"     // How many players can connect at once.
+set g_password ""          // Set a server-wide password, and stop all users from connecting without it.
+set sv_privateClients "0"  // Reserve slots that can be used with sv_privatePassword.
+set sv_privatePassword ""  // Password to use in conjunction with sv_privateClients.
+set com_hunkMegs "60"      // May need to be increased for additional players.
+
+// Flood protection will increment everytime the user sends a client command, ex. dropweapon, changing name, color
+// model, or chatting. Set g_floodprot_maxcount to 0 to disable completely, but this will allow uncontrolled spam.
+set sv_floodprotect "10"       // Kick the player when they reach x commands, decreases by 1 every second
+set g_floodprot_maxcount "10"  // Kick the player when their userinfo flood counter reaches this level.
+set g_floodprot_decay "1000"   // Decrease the userinfo flood counter by 1 this often, in milliseconds.
+
+// Add the below values for which callvotes should be DISABLED:
+// map              1
+// map_restart      2
+// nextmap          4
+// gametype         8 (ex: "/callvote map campgrounds" will be allowed, but "/callvote map campgrounds ca" will fail)
+// kick             16
+// timelimit        32
+// fraglimit        64
+// shuffle          128
+// teamsize         256
+// cointoss/random  512
+// loadouts         1024
+// end-game voting  2048
+// ammo (global)    4096
+// timers (item)    8192
+set g_voteFlags "0"
+set g_allowVote "1"        // Turn off all votes
+set g_voteDelay "0"        // Delay allowing votes for x milliseconds after map load.
+set g_voteLimit "0"        // Limit users to x votes per map.
+set g_allowVoteMidGame "0" // Don't allow callvotes once the map has started
+set g_allowSpecVote "0"    // Allow spectators to call votes
+
+set sv_warmupReadyPercentage "0.51"  // Ratio of players that must be ready before the match starts.
+set g_warmupDelay "15"               // Wait x seconds before allowing match to start to allow all players to connect.
+set g_warmupReadyDelay "0"           // Force the game to start after x seconds after someone readies up.
+set g_warmupReadyDelayAction "1"     // Set to 1 to force players to spectator after g_warmupReady Delay, 2 to force ready up.
+
+set g_inactivity "0"  // Kick players who are inactive for x amount of seconds.
+set g_alltalk "0"     // 0: Limit voice comms to teams during match
+                      // 1: Allow all players to talk to each other always
+                      // 2: 1+ send back your own voice to yourself for testing
+
+// System settings
+
+// Uncomment and set below to use (server.cfg will override commandline!)
+// set net_strict "1"    // Quit out immediately if we can't bind the IP and port.
+// set net_ip ""         // Which IP to bind to. Blank will bind to all interfaces.
+// set net_port "55555"  // Which UDP port to bind to. Blank will start at 27960 and keep going up, if net_strict is 0.
+set sv_serverType "2"    // 0 = Offline, 1 = LAN, 2 = Internet
+set sv_master "1"        // Whether the server should respond to queries. Disable this to stop server from appearing in browser.
+                         // (This will affect the LAN browser!)
+
+set sv_fps "40" // Change how many frames the server runs per second. WARNING: Has not been tested extensively, and
+                // will have a direct impact on CPU and network usage!
+
+// Exit the server if idle (not running a map) for a specified time. This will allow it to automatically restart
+// in the case of a game error or other problem. A value of "1" is recommended, but not default, when you are running
+// the server detached from the terminal.
+
+set sv_idleExit "120"
+
+// Enable remote console, provided through ZeroMQ. See zmq_rcon.py for simple client.
+// ZMQ rcon binds on a separate port from the game server, and uses TCP. It must differ from the stats port if used.
+// Rcon can not be enabled or disabled after launch, nor can the IP and port change. Password can, however.
+
+// Uncomment and set below to use (server.cfg will override commandline!)
+set zmq_rcon_enable "1"
+// set zmq_rcon_ip ""
+// set zmq_rcon_port "28960"
+set zmq_rcon_password "<rconpassword>"
+
+// Enable ZeroMQ stats socket. This will not be much use without a client listening.
+// See zmq_stats_verbose.py for example connect and stats printing.
+// If not specified, the stats socket will default to the same IP and port as the game server, but on TCP.
+
+// Uncomment and set below to use (server.cfg will override commandline!)
+// set zmq_stats_enable "1"
+// set zmq_stats_ip ""
+// set zmq_stats_port ""
+// set zmq_stats_password ""
+
+// The server will run serverstartup when it finishes initializing, so start a random map from the map pool.
+set serverstartup "startRandomMap"
+// Or, start a map of your choosing (factory is required)
+// set serverstartup "map campgrounds ffa"
\ No newline at end of file
diff --git a/QuakeLive/quakeliveserver b/QuakeLive/quakeliveserver
new file mode 100644
index 000000000..38ea360e8
--- /dev/null
+++ b/QuakeLive/quakeliveserver
@@ -0,0 +1,138 @@
+#!/bin/bash
+# Quake Live
+# Server Management Script
+# Author: Daniel Gibbs
+# Website: http://gameservermanagers.com
+if [ -f ".dev-debug" ]; then
+	exec 5>dev-debug.log
+	BASH_XTRACEFD="5"
+	set -x
+fi
+
+version="271215"
+
+#### Variables ####
+arch="x64"
+
+# Notification Email
+# (on|off)
+emailnotification="off"
+email="email@example.com"
+
+# Steam login
+steamuser="anonymous"
+steampass=""
+
+# Start Variables
+gameport="27960"
+rconport="28960"
+ip="0.0.0.0"
+updateonstart="off"
+
+# Install/Config Guide : https://steamcommunity.com/sharedfiles/filedetails/?id=542966946
+# Console Commands : http://www.regurge.at/ql/
+fn_parms(){
+	parms="+set net_strict 1 +set net_ip ${ip} +set net_port ${gameport} +set zmq_rcon_port ${rconport} +set fs_homepath ${filesdir} +exec ${servercfg}"
+}
+
+#### Advanced Variables ####
+
+# Github Branch Select
+# Allows for the use of different function files
+# from a different repo and/or branch.
+githubuser="dgibbs64"
+githubrepo="linuxgsm"
+githubbranch="master"
+
+# Steam
+appid="349090"
+
+# Server Details
+servicename="quakelive-server"
+gamename="Quake Live"
+engine="idtech3"
+
+# Directories
+rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
+selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+lockselfname=".${servicename}.lock"
+filesdir="${rootdir}/serverfiles"
+systemdir="${filesdir}"
+executabledir="${filesdir}"
+executable=$([ "$arch" == 'x64' ] && echo "./run_server_x64.sh" || echo "./run_server_x86.sh")
+servercfg="${servicename}.cfg"
+servercfgdir="${filesdir}/baseq3"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+servercfgdefault="${servercfgdir}/lgsm-default.cfg"
+backupdir="${rootdir}/backups"
+
+# Logging
+logdays="7"
+gamelogdir="${rootdir}/log/server"
+scriptlogdir="${rootdir}/log/script"
+consolelogdir="${rootdir}/log/console"
+
+gamelog="${gamelogdir}/${servicename}-game.log"
+scriptlog="${scriptlogdir}/${servicename}-script.log"
+consolelog="${consolelogdir}/${servicename}-console.log"
+emaillog="${scriptlogdir}/${servicename}-email.log"
+
+scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
+consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
+
+##### Script #####
+# Do not edit
+
+fn_getgithubfile(){
+filename=$1
+exec=$2
+fileurl=${3:-$filename}
+filepath="${rootdir}/${filename}"
+filedir=$(dirname "${filepath}")
+# If the function file is missing, then download
+if [ ! -f "${filepath}" ]; then
+	if [ ! -d "${filedir}" ]; then
+		mkdir "${filedir}"
+	fi
+	githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
+	echo -e "    fetching ${filename}...\c"
+	if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
+		:
+	else	
+		echo -e "\e[0;31mFAIL\e[0m\n"
+		echo "Curl is not installed!"
+		echo -e ""
+		exit
+	fi
+	curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
+	if [ $? -ne 0 ]; then
+		echo -e "\e[0;31mFAIL\e[0m\n"
+		echo "${curl}"
+		echo -e "${githuburl}\n"
+		exit
+	else
+		echo -e "\e[0;32mOK\e[0m"
+	fi	
+	if [ "${exec}" ]; then
+		chmod +x "${filepath}"
+	fi
+fi
+if [ "${exec}" ]; then
+	source "${filepath}"
+fi
+}
+
+fn_runfunction(){
+	fn_getgithubfile "functions/${functionfile}" 1
+}
+
+core_functions.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
+core_functions.sh
+
+getopt=$1
+core_getopt.sh
diff --git a/functions/install_config.sh b/functions/install_config.sh
index 5ccccd80a..635c89f24 100644
--- a/functions/install_config.sh
+++ b/functions/install_config.sh
@@ -273,6 +273,12 @@ elif [ "${gamename}" == "Pirates, Vikings, and Knights II" ]; then
 	wget -N /dev/null ${githuburl}/PiratesVikingandKnightsII/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
 	sleep 1
 	fn_sourceconfig	
+elif [ "${gamename}" == "Quake Live" ]; then
+	echo -e "downloading lgsm-default.cfg...\c"
+	wget -N /dev/null ${githuburl}/QuakeLive/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
+	sleep 1
+	fn_defaultconfig
+	fn_userinputconfig
 elif [ "${gamename}" == "Red Orchestra: Ostfront 41-45" ]; then
 	fn_unreal2config
 elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then

From 492b20de11e62cfbc107e1458e0bb89349b7dde5 Mon Sep 17 00:00:00 2001
From: Alexander Hurd <hurdad@gmail.com>
Date: Wed, 3 Feb 2016 03:54:45 -0500
Subject: [PATCH 2/3] refactor + tested rcon settings

---
 QuakeLive/{quakeliveserver => qlserver} | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
 rename QuakeLive/{quakeliveserver => qlserver} (87%)
 mode change 100644 => 100755

diff --git a/QuakeLive/quakeliveserver b/QuakeLive/qlserver
old mode 100644
new mode 100755
similarity index 87%
rename from QuakeLive/quakeliveserver
rename to QuakeLive/qlserver
index 38ea360e8..de4cc6d68
--- a/QuakeLive/quakeliveserver
+++ b/QuakeLive/qlserver
@@ -26,13 +26,16 @@ steampass=""
 # Start Variables
 gameport="27960"
 rconport="28960"
+rcon_password='ch@ng3me'
+stats_password='ch@ng3me'
+mappool='mappool.txt'
 ip="0.0.0.0"
 updateonstart="off"
 
 # Install/Config Guide : https://steamcommunity.com/sharedfiles/filedetails/?id=542966946
 # Console Commands : http://www.regurge.at/ql/
 fn_parms(){
-	parms="+set net_strict 1 +set net_ip ${ip} +set net_port ${gameport} +set zmq_rcon_port ${rconport} +set fs_homepath ${filesdir} +exec ${servercfg}"
+	parms="+set net_strict 1 +set net_ip 0.0.0.0 +set net_port ${gameport} +set fs_homepath ${filesdir}/${gameport} +set zmq_rcon_enable 1 +set zmq_rcon_port ${rconport} +set zmq_rcon_password ${rcon_password} +set zmq_stats_enable 1 +set zmq_stats_password ${stats_password} +set zmq_stats_port ${gameport} +set sv_mapPoolFile ${mappool} +exec ${servercfg} "
 }
 
 #### Advanced Variables ####
@@ -48,7 +51,7 @@ githubbranch="master"
 appid="349090"
 
 # Server Details
-servicename="quakelive-server"
+servicename="ql-server"
 gamename="Quake Live"
 engine="idtech3"
 

From 7bd42fde161f80f2a9e458d733ebef3aeabffb3f Mon Sep 17 00:00:00 2001
From: Alexander Hurd <hurdad@gmail.com>
Date: Wed, 3 Feb 2016 03:56:52 -0500
Subject: [PATCH 3/3] ip fix

---
 QuakeLive/qlserver | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/QuakeLive/qlserver b/QuakeLive/qlserver
index de4cc6d68..ca7742e26 100755
--- a/QuakeLive/qlserver
+++ b/QuakeLive/qlserver
@@ -35,7 +35,7 @@ updateonstart="off"
 # Install/Config Guide : https://steamcommunity.com/sharedfiles/filedetails/?id=542966946
 # Console Commands : http://www.regurge.at/ql/
 fn_parms(){
-	parms="+set net_strict 1 +set net_ip 0.0.0.0 +set net_port ${gameport} +set fs_homepath ${filesdir}/${gameport} +set zmq_rcon_enable 1 +set zmq_rcon_port ${rconport} +set zmq_rcon_password ${rcon_password} +set zmq_stats_enable 1 +set zmq_stats_password ${stats_password} +set zmq_stats_port ${gameport} +set sv_mapPoolFile ${mappool} +exec ${servercfg} "
+	parms="+set net_strict 1 +set net_ip ${ip} +set net_port ${gameport} +set fs_homepath ${filesdir}/${gameport} +set zmq_rcon_enable 1 +set zmq_rcon_port ${rconport} +set zmq_rcon_password ${rcon_password} +set zmq_stats_enable 1 +set zmq_stats_password ${stats_password} +set zmq_stats_port ${gameport} +set sv_mapPoolFile ${mappool} +exec ${servercfg} "
 }
 
 #### Advanced Variables ####