Răsfoiți Sursa

Merge pull request #1449 from GameServerManagers/feature/squadserver

Add squadserver
Daniel Gibbs 9 ani în urmă
părinte
comite
da0fb5d272

+ 199 - 0
Squad/squadserver

@@ -0,0 +1,199 @@
+#!/bin/bash
+# Project: Game Server Managers - LinuxGSM
+# Author: Daniel Gibbs
+# License: MIT License, Copyright (c) 2017 Daniel Gibbs
+# Purpose: Squad | 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="170501"
+
+##########################
+######## Settings ########
+##########################
+
+#### Server Settings ####
+
+## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
+port="7787"
+queryport="27165"
+fixedmaxplayers="80"
+randommapmode="ALWAYS"
+ip="0.0.0.0"
+
+## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
+fn_parms(){
+parms="MULTIHOME=${ip} PORT=${port} QueryPort=${queryport} FIXEDMAXPLAYERS=${fixedmaxplayers} RANDOM=${randommapmode}"
+}
+
+#### 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=""
+
+## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
+updateonstart="off"
+
+## 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"
+
+#### LinuxGSM Advanced Settings ####
+
+## SteamCMD Settings
+# Server appid
+appid="403240"
+# Steam App Branch Select
+# Allows to opt into the various Steam app branches. Default branch is "".
+# Example: "-beta latest_experimental"
+branch=""
+
+## Github Branch Select
+# Allows for the use of different function files
+# from a different repo and/or branch.
+githubuser="GameServerManagers"
+githubrepo="LinuxGSM"
+githubbranch="feature/squadserver"
+
+## LinuxGSM Server Details
+# Do not edit
+gamename="Squad"
+engine="unreal4"
+
+## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
+servicename="squad-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}/Squad"
+executabledir="${filesdir}"
+executable="./SquadServer.sh"
+servercfgdir="${systemdir}/ServerConfig"
+servercfg="Server.cfg"
+servercfgdefault="Server.cfg"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${rootdir}/backups"
+
+## Logging Directories
+gamelogdir="${systemdir}/Saved/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

+ 19 - 1
lgsm/functions/command_details.sh

@@ -173,6 +173,11 @@ fn_details_gameserver(){
 			echo -e "${blue}ASE:\t${default}${ase}"
 		fi
 
+		# Random map rotation mode (Squad)
+		if [ -n "${randommapmode}" ]; then
+			echo -e "${blue}Map rotation:\t${default}${randommapmode}"
+		fi
+
 		# Online status
 		if [ "${status}" == "0" ]; then
 			echo -e "${blue}Status:\t${red}OFFLINE${default}"
@@ -190,7 +195,7 @@ fn_details_script(){
 	# Service name:        ql-server
 	# qlserver version:    150316
 	# User:                lgsm
-	# Email alert:  off
+	# Email alert:         off
 	# Update on start:     off
 	# Location:            /home/lgsm/qlserver
 	# Config file:         /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
@@ -656,6 +661,17 @@ fn_details_spark(){
 	} | column -s $'\t' -t
 }
 
+fn_details_squad(){
+	echo -e "netstat -atunp | grep SquadServer"
+	echo -e ""
+	{
+		echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
+		echo -e "> Game\tINBOUND\t${port}\tudp"
+		echo -e "> Query\tINBOUND\t${queryport}\tudp"
+		echo -e "> RCON\tINBOUND\t${rconport}\ttcp"
+	} | column -s $'\t' -t
+}
+
 fn_details_starbound(){
 	echo -e "netstat -atunp | grep starbound"
 	echo -e ""
@@ -861,6 +877,8 @@ fn_display_details() {
 		fn_details_quake3
 	elif [ "${gamename}" == "Quake Live" ]; then
 		fn_details_quakelive
+	elif [ "${gamename}" == "Squad" ]; then
+		fn_details_squad
 	elif [ "${gamename}" == "TeamSpeak 3" ]; then
 		fn_details_teamspeak3
 	elif [ "${gamename}" == "Tower Unite" ]; then

+ 2 - 0
lgsm/functions/command_install.sh

@@ -32,6 +32,8 @@ if [ "${gamename}" == "BrainBread 2" ]||[ "${gamename}" == "Black Mesa: Deathmat
 	install_gslt.sh
 elif [ "${gamename}" == "Don't Starve Together" ]; then
 	install_dst_token.sh
+elif [ "${gamename}" == "Squad" ]; then
+	install_squad_license.sh
 elif [ "${gamename}" == "TeamSpeak 3" ]; then
 	install_ts3db.sh
 elif [ "${gamename}" == "Multi Theft Auto" ]; then

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -187,6 +187,11 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
+install_squad_license.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_function
+}
+
 command_mods_install.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function

+ 6 - 0
lgsm/functions/core_getopt.sh

@@ -40,6 +40,7 @@ cmd_map_compressor_u99=( "mc;map-compressor" "compress_ut99_maps.sh" "Compresses
 cmd_map_compressor_u2=( "mc;map-compressor" "compress_unreal2_maps.sh" "Compresses all ${gamename} server maps." )
 cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server cd key." )
 cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." )
+cmd_install_squad_license=( "li;license" "install_squad_license.sh" "Add your Squad server license." )
 cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." )
 # Dev commands
 cmd_dev_debug=( "dev;developer" "command_dev_debug.sh" "Enable developer Mode." )
@@ -114,6 +115,11 @@ if [ "${gamename}" == "Multi Theft Auto" ]; then
 	currentopt+=( "${cmd_install_default_resources[@]}" )
 fi
 
+# Squad license exclusive
+if [ "${gamename}" == "Squad" ]; then
+	currentopt+=( "${cmd_install_squad_license[@]}" )
+fi
+
 ## Mods commands
 if [ "${engine}" == "source" ]||[ "${gamename}" == "Rust" ]||[ "${gamename}" == "Hurtworld" ]||[ "${gamename}" == "7 Days To Die" ]; then
 	currentopt+=( "${cmd_mods_install[@]}" "${cmd_mods_remove[@]}" "${cmd_mods_update[@]}" )

+ 23 - 0
lgsm/functions/info_config.sh

@@ -703,6 +703,27 @@ fn_info_config_wolfensteinenemyterritory(){
 	fi
 }
 
+fn_info_config_squad(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		servername="${unavailable}"
+		maxplayers="${unavailable}"
+	else
+		servername="$(cat ${servercfgfullpath} | grep "ServerName=" | cut -c13- | rev | cut -c3- | rev)"
+		maxplayers="$(cat ${servercfgfullpath} | grep "MaxPlayers=" | cut -c12- | tr -cd '[:digit:]')"
+	fi
+
+	if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then
+		rconport=${unavailable}
+		rconpassword=${unavailable}
+	else
+		rconport=$(cat ${servercfgdir}/Rcon.cfg | grep "Port=" | cut -c6- | tr -cd '[:digit:]')
+		rconpassword=$(cat ${servercfgdir}/Rcon.cfg | grep "Password=" | cut -c10-)
+		if [ -z "${rconpassword}" ]||[ ${#rconpassword} == 1 ]; then
+			rconpassword="${yellow}DISABLED${default}"
+		fi
+	fi
+}
+
 # Just Cause 2
 if [ "${engine}" == "avalanche" ]; then
 	fn_info_config_avalanche
@@ -787,4 +808,6 @@ elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then
 	fn_info_config_wolfensteinenemyterritory
 elif [ "${gamename}" == "Multi Theft Auto" ]; then
 	fn_info_config_mta
+elif [ "${gamename}" == "Squad" ]; then
+	fn_info_config_squad
 fi

+ 26 - 0
lgsm/functions/install_squad_license.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+# LinuxGSM install_squad_license.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: Configures the Squad server's license.
+
+local commandname="INSTALL"
+local commandaction="Install"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+echo ""
+echo "Squad Server License"
+echo "================================="
+sleep 1
+echo "Server license is an optional feature for ${gamename} server"
+fn_script_log_info "Server license is an optional feature for ${gamename} server"
+
+echo "Get more info and a server license here:"
+echo "http://forums.joinsquad.com/topic/16519-server-licensing-general-info/"
+fn_script_log_info "Get more info and a server license here:"
+fn_script_log_info "http://forums.joinsquad.com/topic/16519-server-licensing-general-info/"
+echo ""
+sleep 1
+echo "The Squad server license can be changed by editing ${servercfgdir}/License.cfg."
+fn_script_log_info "The Squad server license can be changed by editing ${selfname}."
+echo ""