Przeglądaj źródła

Merge branch 'develop' into feature/config

Daniel Gibbs 9 lat temu
rodzic
commit
f80cb5d7e9

+ 2 - 2
lgsm/config-default/config-lgsm/hwserver/_default.cfg

@@ -14,7 +14,7 @@ ip="0.0.0.0"
 port="12871"
 queryport="12881"
 maxplayers="20"
-map="" #Optional
+defaultmap="" #Optional
 creativemode="0" #Free Build: creativemode="1"
 logfile="gamelog.txt"
 
@@ -31,7 +31,7 @@ x64mode="0"
 ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
 # Edit with care | http://hurtworld.wikia.com/wiki/Hosting_A_Server
 fn_parms(){
-parms="-batchmode -nographics -exec \"host ${port} ${map} ${loadsave};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode};${admins}\" -logfile \"${logfile}\" "
+parms="-batchmode -nographics -exec \"host ${port} ${defaultmap} ${loadsave};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode};${admins}\" -logfile \"${logfile}\" "
 }
 
 #### LinuxGSM Settings ####

+ 2 - 2
lgsm/config-default/config-lgsm/ns2cserver/_default.cfg

@@ -22,10 +22,10 @@ webadminuser="admin"
 webadminpass="admin"
 webadminport="8080"
 mods=""
-password=""
+serverpassword=""
 # Add the following line to the parms if you want a private server. Ensuring
 # that the password variable above is not left empty.
-# -password \"${password}\"
+# -password \"${serverpassword}\"
 
 ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
 fn_parms(){

+ 2 - 2
lgsm/config-default/config-lgsm/ns2server/_default.cfg

@@ -22,10 +22,10 @@ webadminuser="admin"
 webadminpass="admin"
 webadminport="8080"
 mods=""
-password=""
+serverpassword=""
 # Add the following line to the parms if you want a private server. Ensuring
 # that the password variable above is not left empty.
-# -password \"${password}\"
+# -password \"${serverpassword}\"
 
 ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
 fn_parms(){

+ 1 - 1
lgsm/config-default/config-lgsm/ut3server/_default.cfg

@@ -26,7 +26,7 @@ allowjoininprogress="true"
 ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
 # Edit with care | List of game types and mutators : http://wiki.unrealadmin.org/FAQ:UT3
 fn_parms(){
-parms="server ${defaultmap}?Game=${game}?bIsDedicated=${isdedicated}?bIsLanMatch=${islanmatch}?bUsesStats=${usesstats}?bShouldAdvertise=${shouldadvertise}?PureServer=${pureserver}?bAllowJoinInProgress=${allowjoininprogress}?MaxPlayers=${maxplayers}?Mutator=${mutators} -port=${port} -queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog}"
+parms="server ${defaultmap}?Game=${game}?bIsDedicated=${isdedicated}?bIsLanMatch=${islanmatch}?bUsesStats=${usesstats}?bShouldAdvertise=${shouldadvertise}?PureServer=${pureserver}?bAllowJoinInProgress=${allowjoininprogress}?MaxPlayers=${maxplayers}?Mutator=${mutators} -port=${port} -queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog} -ini=${servercfgfullpath}""
 }
 
 #### LinuxGSM Settings ####

+ 3 - 3
lgsm/functions/README.md

@@ -1,11 +1,11 @@
-<h1>Linux Game Server Manager - Functions</h1>
+# Linux Game Server Manager - Functions
 
 These functions are universal functions that work in all scripts.
 
-<h2>Function Names</h2>
+## Function Names
 Functions have been named to give an idea of what the function does.
 
-* core: Essential functions that are will always run first.
+* core: Essential functions that will always run first.
 * command: Primary command function.
 * check: Runs checks that will either halt on or fix an issue.
 * dev: development functions.

+ 19 - 1
lgsm/functions/command_details.sh

@@ -208,6 +208,11 @@ fn_details_gameserver(){
 			echo -e "${blue}ASE:\t${default}${saveinterval} s"
 		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}"
@@ -225,7 +230,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
@@ -690,6 +695,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 ""
@@ -895,6 +911,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

+ 38 - 8
lgsm/functions/command_stop.sh

@@ -175,7 +175,7 @@ fn_stop_graceful_sdtd(){
 	fn_stop_tmux
 }
 
-# Attempts graceful of source using rcon 'stop' command.
+# Attempts graceful of Minecraft using rcon 'stop' command.
 fn_stop_graceful_minecraft(){
 	fn_print_dots "Graceful: sending \"stop\""
 	fn_script_log_info "Graceful: sending \"stop\""
@@ -231,19 +231,49 @@ fn_stop_graceful_mta(){
 	fn_stop_tmux
 }
 
+# Attempts graceful of Terraria using 'exit' console command.
+fn_stop_graceful_terraria(){
+	fn_print_dots "Graceful: sending \"exit\""
+	fn_script_log_info "Graceful: sending \"exit\""
+	# sends exit
+	tmux send -t "${servicename}" exit ENTER > /dev/null 2>&1
+	# waits up to 30 seconds giving the server time to shutdown gracefuly
+	for seconds in {1..30}; do
+		check_status.sh
+		if [ "${status}" == "0" ]; then
+			fn_print_ok "Graceful: sending \"exit\": ${seconds}: "
+			fn_print_ok_eol_nl
+			fn_script_log_pass "Graceful: sending \"exit\": OK: ${seconds} seconds"
+			break
+		fi
+		sleep 1
+		fn_print_dots "Graceful: sending \"exit\": ${seconds}"
+	done
+	check_status.sh
+	if [ "${status}" != "0" ]; then
+		fn_print_error "Graceful: sending \"exit\": "
+		fn_print_fail_eol_nl
+		fn_script_log_error "Graceful: sending \"exit\": FAIL"
+	fi
+	sleep 1
+	fn_stop_tmux
+}
+
 fn_stop_graceful_select(){
 	if [ "${gamename}" == "7 Days To Die" ]; then
 		fn_stop_graceful_sdtd
-	elif [ "${gamename}" == "Factorio" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Multi Theft Auto" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal4" ]||[ "${engine}" == "unreal3" ]||[ "${engine}" == "unreal2" ]||[ "${engine}" == "unreal" ]||[ "${gamename}" == "Mumble" ]; then
+	elif [ "${gamename}" == "Terraria" ]; then
+		fn_stop_graceful_terraria
+	elif [ "${gamename}" == "Minecraft" ]; then
+		fn_stop_graceful_minecraft
+	elif [ "${gamename}" == "Multi Theft Auto" ]; then
+		fn_stop_graceful_mta
+	elif [ "${engine}" == "goldsource" ]; then
+		fn_stop_graceful_goldsource
+	elif [ "${gamename}" == "Factorio" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal4" ]||[ "${engine}" == "unreal3" ]||[ "${engine}" == "unreal2" ]||[ "${engine}" == "unreal" ]||[ "${gamename}" == "Mumble" ]; then
 		fn_stop_graceful_ctrlc
 	elif  [ "${engine}" == "source" ]||[ "${engine}" == "quake" ]||[ "${engine}" == "idtech2" ]||[ "${engine}" == "idtech3" ]||[ "${engine}" == "idtech3_ql" ]||[ "${engine}" == "Just Cause 2" ]; then
 		fn_stop_graceful_quit
-	elif [ "${engine}" == "goldsource" ]; then
-		fn_stop_graceful_goldsource
-	elif [ "${engine}" == "lwjgl2" ]; then
-		fn_stop_graceful_minecraft
-	elif [ "${engine}" == "renderware" ]; then
-		fn_stop_graceful_mta
 	else
 		fn_stop_tmux
 	fi

+ 3 - 1
lgsm/functions/core_dl.sh

@@ -61,7 +61,9 @@ fn_dl_extract(){
 	if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
 		extractcmd=$(tar -zxf "${local_filedir}/${local_filename}" -C "${extractdir}")
 	elif [ "${mime}" == "application/x-bzip2" ]; then
-		extractcmd=$(tar -jxf "${local_filedir}/${local_filename}" -C "${extractdir}")
+		tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}")
+	elif [ "${mime}" == "application/x-xz" ]; then
+		tarcmd=$(tar -xf "${filedir}/${filename}" -C "${extractdir}")
 	elif [ "${mime}" == "application/zip" ]; then
 		extractcmd=$(unzip -d "${extractdir}" "${local_filedir}/${local_filename}")
 	fi

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -118,6 +118,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." )
@@ -113,6 +114,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

@@ -734,6 +734,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
@@ -824,4 +845,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 ""

+ 3 - 3
lgsm/functions/update_factorio.sh

@@ -49,7 +49,7 @@ fn_update_factorio_currentbuild(){
 	fi
 
 	# Get current build from logs
-	currentbuild=$(grep "Loading mod base" "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null|awk '{print $5}')
+	currentbuild=$(grep "Loading mod base" "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null|awk '{print $5}'|tail -1)
 	if [ -z "${currentbuild}" ]; then
 		fn_print_error_nl "Checking for update: factorio.com: Current build version not found"
 		fn_script_log_error "Checking for update: factorio.com: Current build version not found"
@@ -60,7 +60,7 @@ fn_update_factorio_currentbuild(){
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		currentbuild=$(grep "Loading mod base" "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null|awk '{print $5}')
+		currentbuild=$(grep "Loading mod base" "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null|awk '{print $5}'|tail -1)
 		if [ -z "${currentbuild}" ]; then
 			fn_print_fail_nl "Checking for update: factorio.com: Current build version still not found"
 			fn_script_log_fatal "Checking for update: factorio.com: Current build version still not found"
@@ -76,7 +76,7 @@ fn_update_factorio_arch(){
 
 fn_update_factorio_availablebuild(){
 	# Gets latest build info.
-	availablebuild=$(${curlpath} -s https://www.factorio.com/download-headless/stable | grep 'headless/linux64' | head -n 1 | grep -oP '(?<=get-download/).*?(?=/)')
+	availablebuild=$(curl -s https://www.factorio.com/download-headless/"${branch}" | grep 'headless/linux64' | head -n 1 | grep -oP '(?<=get-download/).*?(?=/)')
 	sleep 1
 
 	# Checks if availablebuild variable has been set