Просмотр исходного кода

Merged feature/cod4 into develop

Daniel Gibbs 9 лет назад
Родитель
Сommit
70773dea8d

+ 188 - 0
CallOfDuty4/cod4server

@@ -0,0 +1,188 @@
+#!/bin/bash
+# Project: Game Server Managers - LinuxGSM
+# Author: Daniel Gibbs
+# License: MIT License, Copyright (c) 2016 Daniel Gibbs
+# Purpose: Call of Duty 4 | Server Management Script
+# Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors
+# Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki
+# Website: https://gameservermanagers.com
+
+# Debugging
+if [ -f ".dev-debug" ]; then
+	exec 5>dev-debug.log
+	BASH_XTRACEFD="5"
+	set -x
+fi
+
+version="161125"
+
+##########################
+######## Settings ########
+##########################
+
+#### Server Settings ####
+
+## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
+
+defaultmap="mp_crossfire"
+maxclients="32"
+port="28960"
+ip="138.68.147.159"
+
+## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
+fn_parms(){
+parms="+set sv_punkbuster 0 +set fs_basepath ${filesdir} +set dedicated 1 +set net_ip ${ip} +set net_port ${port} +set sv_maxclients ${maxclients} +exec ${servercfg} +map ${defaultmap}"
+}
+
+#### LinuxGSM Settings ####
+
+## Notification Alerts
+# (on|off)
+# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
+consolelogging="on"
+logdays="7"
+
+#### Advanced Variables ####
+
+## Github Branch Select
+# Allows for the use of different function files
+# from a different repo and/or branch.
+githubuser="GameServerManagers"
+githubrepo="LinuxGSM"
+githubbranch="master"
+
+## LinuxGSM Server Details
+# Do not edit
+gamename="Call of Duty 4"
+engine="iw3.0"
+
+## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
+servicename="cod4-server"
+
+#### Directories ####
+# Edit with care
+
+## Work Directories
+rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
+selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+lockselfname=".${servicename}.lock"
+lgsmdir="${rootdir}/lgsm"
+functionsdir="${lgsmdir}/functions"
+libdir="${lgsmdir}/lib"
+tmpdir="${lgsmdir}/tmp"
+filesdir="${rootdir}/serverfiles"
+
+## Server Specific Directories
+systemdir="${filesdir}"
+executabledir="${filesdir}"
+executable="./cod4x18_dedrun"
+servercfg="${servicename}.cfg"
+servercfgdefault="server.cfg"
+servercfgdir="${systemdir}/main"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${rootdir}/backups"
+
+## Logging Directories
+gamelogdir="${filesdir}/Logs"
+scriptlogdir="${rootdir}/log/script"
+consolelogdir="${rootdir}/log/console"
+scriptlog="${scriptlogdir}/${servicename}-script.log"
+consolelog="${consolelogdir}/${servicename}-console.log"
+emaillog="${scriptlogdir}/${servicename}-email.log"
+
+## Logs Naming
+scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
+
+########################
+######## Script ########
+###### Do not edit #####
+########################
+
+# Fetches core_dl for file downloads
+fn_fetch_core_dl(){
+github_file_url_dir="lgsm/functions"
+github_file_url_name="${functionfile}"
+filedir="${functionsdir}"
+filename="${github_file_url_name}"
+githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
+# If the file is missing, then download
+if [ ! -f "${filedir}/${filename}" ]; then
+	if [ ! -d "${filedir}" ]; then
+		mkdir -p "${filedir}"
+	fi
+	echo -e "    fetching ${filename}...\c"
+	# Check curl exists and use available path
+	curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
+	for curlcmd in ${curlpaths}
+	do
+		if [ -x "${curlcmd}" ]; then
+			break
+		fi
+	done
+	# If curl exists download file
+	if [ "$(basename ${curlcmd})" == "curl" ]; then
+		curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
+		if [ $? -ne 0 ]; then
+			echo -e "\e[0;31mFAIL\e[0m\n"
+			echo "${curlfetch}"
+			echo -e "${githuburl}\n"
+			exit 1
+		else
+			echo -e "\e[0;32mOK\e[0m"
+		fi
+	else
+		echo -e "\e[0;31mFAIL\e[0m\n"
+		echo "Curl is not installed!"
+		echo -e ""
+		exit 1
+	fi
+	chmod +x "${filedir}/${filename}"
+fi
+source "${filedir}/${filename}"
+}
+
+core_dl.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_fetch_core_dl
+}
+
+core_functions.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_fetch_core_dl
+}
+
+# Prevent from running this script as root.
+if [ "$(whoami)" = "root" ]; then
+	if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
+		echo "[ FAIL ] Do NOT run this script as root!"
+		exit 1
+	else
+		core_functions.sh
+		check_root.sh
+	fi
+fi
+
+core_dl.sh
+core_functions.sh
+getopt=$1
+core_getopt.sh

+ 13 - 2
lgsm/functions/command_details.sh

@@ -152,12 +152,12 @@ fn_details_gameserver(){
 		if [ -n "${tickrate}" ]; then
 			echo -e "${blue}Tick rate:\t${default}${tickrate}"
 		fi
-				
+
 		# Cluster (Don't Starve Together)
 		if [ -n "${cluster}" ]; then
 			echo -e "${blue}Cluster:\t${default}${cluster}"
 		fi
-		
+
 		# Shard (Don't Starve Together)
 		if [ -n "${shard}" ]; then
 			echo -e "${blue}Shard:\t${default}${shard}"
@@ -378,6 +378,15 @@ fn_details_cod2(){
 	} | column -s $'\t' -t
 }
 
+fn_details_cod4(){
+	echo -e "netstat -atunp"
+	echo -e ""
+	{
+		echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
+		echo -e "> Game\tINBOUND\t${port}\tudp"
+	} | column -s $'\t' -t
+}
+
 fn_details_codwaw(){
 	echo -e "netstat -atunp | grep codwaw_lnxded"
 	echo -e ""
@@ -752,6 +761,8 @@ fn_display_details() {
 		fn_details_coduo
 	elif [ "${gamename}" == "Call of Duty 2" ]; then
 		fn_details_cod2
+	elif [ "${gamename}" == "Call of Duty 4" ]; then
+		fn_details_cod4
 	elif [ "${gamename}" == "Call of Duty: World at War" ]; then
 		fn_details_codwaw
 	elif [ "${gamename}" == "Hurtworld" ]; then

+ 1 - 1
lgsm/functions/command_install.sh

@@ -18,7 +18,7 @@ check_deps.sh
 if [ "${gamename}" == "Unreal Tournament 2004" ]; then
 	install_server_files.sh
 	install_ut2k4_key.sh
-elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
+elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty 4" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
 	installer=1
 	install_server_files.sh
 elif [ -n "${appid}" ]; then

+ 1 - 1
lgsm/functions/core_getopt.sh

@@ -699,7 +699,7 @@ case "${getopt}" in
 
 if [ "${gamename}" == "Mumble" ]; then
 	fn_getopt_mumble
-elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
+elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty 4" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
 	fn_getopt_generic_no_update
 elif [ "${engine}" == "lwjgl2" ]; then
 	fn_getopt_minecraft

+ 19 - 3
lgsm/functions/info_config.sh

@@ -94,6 +94,20 @@ fn_info_config_cod2(){
 	fi
 }
 
+fn_info_config_cod4(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		servername="${unavailable}"
+		rconpassword="${unavailable}"
+	else
+		servername=$(grep "sv_hostname " "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set sv_hostname //g' | tr -d '=\";,:' | xargs)
+		rconpassword=$(grep "rconpassword" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set rconpassword //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
+
+		# Not Set
+		servername=${servername:-"NOT SET"}
+		rconpassword=${rconpassword=:-"NOT SET"}
+	fi
+}
+
 fn_info_config_codwaw(){
 	if [ ! -f "${servercfgfullpath}" ]; then
 		servername="${unavailable}"
@@ -123,7 +137,6 @@ fn_info_config_dontstarve(){
 		gamemode=$(grep "game_mode" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/game_mode//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
 		tickrate=$(grep "tick_rate" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
 		masterport=$(grep "master_port" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
-		
 		ip=$(grep "bind_ip" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/bind_ip//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
 		ipsetinconfig=1
 		ipinconfigvar="bind_ip"
@@ -136,7 +149,7 @@ fn_info_config_dontstarve(){
 		tickrate=${tickrate:-"0"}
 		masterport=${masterport:-"0"}
 	fi
-	
+
 	if [ ! -f "${servercfgfullpath}" ]; then
 		port="${zero}"
 		steamauthenticationport="${zero}"
@@ -145,7 +158,7 @@ fn_info_config_dontstarve(){
 		port=$(grep "server_port" "${servercfgfullpath}" | grep "^server_port" | grep -v "#" | tr -cd '[:digit:]')
 		steamauthenticationport=$(grep "authentication_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
 		steammasterserverport=$(grep "master_server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
-		
+
 		# Not Set
 		port=${port:-"0"}
 		steamauthenticationport=${steamauthenticationport:-"0"}
@@ -575,6 +588,9 @@ elif [ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: Unit
 # Call of Duty 2
 elif [ "${gamename}" == "Call of Duty 2" ]; then
 	fn_info_config_cod2
+# Call of Duty 4
+elif [ "${gamename}" == "Call of Duty 4" ]; then
+	fn_info_config_cod4
 # Call of Duty: World at War
 elif [ "${gamename}" == "Call of Duty: World at War" ]; then
 	fn_info_config_codwaw

+ 3 - 0
lgsm/functions/info_glibc.sh

@@ -23,6 +23,9 @@ elif [ "${gamename}" == "Call of Duty 2" ]; then
 elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
 	glibcrequired="2.1"
 	glibcfix="no"
+elif [ "${gamename}" == "Call of Duty 4" ]; then
+	glibcrequired="2.3"
+	glibcfix="no"
 elif [ "${gamename}" == "Call of Duty: World at War" ]; then
 	glibcrequired="2.3.2"
 	glibcfix="no"

+ 12 - 6
lgsm/functions/install_config.sh

@@ -83,20 +83,20 @@ fn_set_dst_config_vars(){
 		randomkey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
 		sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
 		sleep 1
-	else	
+	else
 		echo "${clustercfg} is already configured."
 		fn_script_log_info "${clustercfg} is already configured."
 	fi
-	
+
 	## server.ini
 	# removing unnecessary options (dependent on sharding & shard type)
-	if [ "${sharding}" == "false" ]; then 
+	if [ "${sharding}" == "false" ]; then
 		sed -i "s/ISMASTER//g" "${servercfgfullpath}"
 		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
 	elif [ "${master}" == "true" ]; then
 		sed -i "/SHARDNAME/d" "${servercfgfullpath}"
 	fi
-	
+
 	echo "changing shard name."
 	fn_script_log_info "changing shard name."
 	sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
@@ -105,7 +105,7 @@ fn_set_dst_config_vars(){
 	fn_script_log_info "changing master setting."
 	sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
 	sleep 1
-	
+
 	## worldgenoverride.lua
 	if [ "${cave}" == "true" ]; then
 		echo "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
@@ -177,7 +177,13 @@ elif [ "${gamename}" == "Call of Duty: United Offensive" ]; then
 	fn_default_config_remote
 	fn_set_config_vars
 elif [ "${gamename}" == "Call of Duty 2" ]; then
-	gamedirname="CallofDuty2"
+	gamedirname="CallOfDuty2"
+	array_configs+=( server.cfg )
+	fn_fetch_default_config
+	fn_default_config_remote
+	fn_set_config_vars
+elif [ "${gamename}" == "Call of Duty 4" ]; then
+	gamedirname="CallOfDuty4"
 	array_configs+=( server.cfg )
 	fn_fetch_default_config
 	fn_default_config_remote

+ 2 - 0
lgsm/functions/install_server_files.sh

@@ -17,6 +17,8 @@ fn_install_server_files(){
 		fileurl="http://files.gameservermanagers.com/CallOfDutyUnitedOffensive/coduo-lnxded-1.51b-full.tar.bz2"; filedir="${tmpdir}"; filename="coduo-lnxded-1.51b-full.tar.bz2";  executecmd="noexecute" run="norun"; force="noforce"; md5="f1804ef13036e2b4ab535db000b19e97"
 	elif [ "${gamename}" == "Call of Duty 2" ]; then
 		fileurl="http://files.gameservermanagers.com/CallOfDuty2/cod2-lnxded-1.3-full.tar.bz2"; filedir="${tmpdir}"; filename="cod2-lnxded-1.3-full.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="078128f83d06dc3d7699428dc2870214"
+	elif [ "${gamename}" == "Call of Duty 4" ]; then
+		fileurl="http://files.gameservermanagers.com/CallOfDuty4/cod4x18_dedrun.tar.bz2"; filedir="${tmpdir}"; filename="cod4x18_dedrun.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="bebdfc1755626462bdaad49f6f926c08"
 	elif [ "${gamename}" == "Call of Duty: World at War" ]; then
 		fileurl="http://files.gameservermanagers.com/CallOfDutyWorldAtWar/codwaw-lnxded-1.7-full.tar.bz2"; filedir="${tmpdir}"; filename="codwaw-lnxded-1.7-full.tar.bz2";  executecmd="noexecute" run="norun"; force="noforce"; md5="0489697ff3bf678c109bfb377d1b7895"
 	elif [ "${gamename}" == "GoldenEye: Source" ]; then