Sfoglia il codice sorgente

feat(newserver): Jedi Knight II: Jedi Outcast (#3002)

Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
Co-authored-by: Frisasky <digimoncn@gmail.com>
Daniel Gibbs 5 anni fa
parent
commit
eb9e5a940f

+ 172 - 0
lgsm/config-default/config-lgsm/jk2server/_default.cfg

@@ -0,0 +1,172 @@
+##################################
+######## Default Settings ########
+##################################
+# DO NOT EDIT WILL BE OVERWRITTEN!
+# Copy settings from here and use them in either
+# common.cfg - applies settings to every instance
+# [instance].cfg - applies settings to a specific instance
+
+#### Server Settings ####
+
+## SteamCMD Login | https://docs.linuxgsm.com/steamcmd#steamcmd-login
+steamuser="username"
+steampass='password'
+
+## Server Start Settings | https://docs.linuxgsm.com/configuration/start-parameters
+ip="0.0.0.0"
+port="27960"
+defaultmap="ffa_bespin"
+
+## Server Start Command | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
+fn_parms(){
+parms="+set sv_punkbuster 0 +set fs_basepath ${serverfiles} +set net_ip ${ip} +set net_port ${port} +exec ${servercfg} +map ${defaultmap}"
+}
+
+#### LinuxGSM Settings ####
+
+## Notification Alerts
+# (on|off)
+
+# Display IP | https://docs.linuxgsm.com/alerts#display-ip
+displayip=""
+
+# More info | https://docs.linuxgsm.com/alerts#more-info
+postalert="off"
+postdays="7"
+posttarget="https://hastebin.com"
+
+# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
+discordalert="off"
+discordwebhook="webhook"
+
+# Slack Alerts | https://docs.linuxgsm.com/alerts/slack
+slackalert="off"
+slackwebhook="webhook"
+
+# Email Alerts | https://docs.linuxgsm.com/alerts/email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt
+iftttalert="off"
+ifttttoken="accesstoken"
+iftttevent="linuxgsm_alert"
+
+# Mailgun Email Alerts | https://docs.linuxgsm.com/alerts/mailgun
+mailgunalert="off"
+mailguntoken="accesstoken"
+mailgundomain="example.com"
+mailgunemailfrom="alert@example.com"
+mailgunemail="email@myemail.com"
+
+# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover
+pushoveralert="off"
+pushovertoken="accesstoken"
+
+# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram
+# You can add a custom cURL string eg proxy (useful in Russia) or else in "curlcustomstring".
+# like a "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help", if you not need
+# any custom string in curl - simple ignore this parameter.
+telegramalert="off"
+telegramtoken="accesstoken"
+telegramchatid=""
+curlcustomstring=""
+
+## Updating | https://docs.linuxgsm.com/commands/update
+updateonstart="off"
+
+## Backup | https://docs.linuxgsm.com/commands/backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://docs.linuxgsm.com/features/logging
+consolelogging="on"
+logdays="7"
+
+## Monitor | https://docs.linuxgsm.com/commands/monitor
+# Query delay time
+querydelay="1"
+
+#### LinuxGSM Advanced Settings ####
+
+# ANSI Colors
+ansi="on"
+
+# Message Display Time
+sleeptime="0.5"
+
+# Stop Mode | https://docs.linuxgsm.com/steamcmd/stopmode
+# 1: tmux kill
+# 2: CTRL+c
+# 3: quit
+# 4: quit 120s
+# 5: stop
+# 6: q
+# 7: exit
+# 8: 7 Days to Die
+# 9: Gold Source
+# 10: Teamspeak 3
+stopmode="3"
+
+## Query mode
+# 1: session only
+# 2: gamedig + gsquery
+# 3: gamedig
+# 4: gsquery
+# 5: tcp
+querymode="2"
+querytype="protocol-quake3"
+
+## Console type
+consoleverbose="yes"
+consoleinteract="yes"
+
+## SteamCMD Settings
+# Server appid
+appid="6030"
+# SteamCMD Branch | https://docs.linuxgsm.com/steamcmd/branch
+branch=""
+# Master Server | https://docs.linuxgsm.com/steamcmd/steam-master-server
+steammaster="true"
+
+## LinuxGSM Server Details
+# Do not edit
+gamename="Jedi Knight II: Jedi Outcast"
+engine="idtech3"
+glibc="2.15"
+
+#### Directories ####
+# Edit with care
+
+## Server Specific Directories
+systemdir="${serverfiles}/GameData"
+executabledir="${systemdir}"
+executable="./jk2mvded"
+servercfg="${selfname}.cfg"
+servercfgdefault="server.cfg"
+servercfgdir="${systemdir}"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${rootdir}/backups"
+
+## Logging Directories
+logdir="${rootdir}/log"
+gamelogdir="${systemdir}/logs"
+lgsmlogdir="${logdir}/script"
+consolelogdir="${logdir}/console"
+lgsmlog="${lgsmlogdir}/${selfname}-script.log"
+consolelog="${consolelogdir}/${selfname}-console.log"
+alertlog="${lgsmlogdir}/${selfname}-alert.log"
+postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
+
+## Logs Naming
+lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"

+ 2 - 1
lgsm/data/serverlist.csv

@@ -48,6 +48,7 @@ inss,inssserver,Insurgency: Sandstorm
 ios,iosserver,IOSoccer
 ios,iosserver,IOSoccer
 jc2,jc2server,Just Cause 2
 jc2,jc2server,Just Cause 2
 jc3,jc3server,Just Cause 3
 jc3,jc3server,Just Cause 3
+jk2,jk2server,Jedi Knight II: Jedi Outcast
 kf,kfserver,Killing Floor
 kf,kfserver,Killing Floor
 kf2,kf2server,Killing Floor 2
 kf2,kf2server,Killing Floor 2
 l4d,l4dserver,Left 4 Dead
 l4d,l4dserver,Left 4 Dead
@@ -107,4 +108,4 @@ wet,wetserver,Wolfenstein: Enemy Territory
 wf,wfserver,Warfork
 wf,wfserver,Warfork
 wurm,wurmserver,Wurm Unlimited
 wurm,wurmserver,Wurm Unlimited
 zmr,zmrserver,Zombie Master: Reborn
 zmr,zmrserver,Zombie Master: Reborn
-zps,zpsserver,Zombie Panic! Source
+zps,zpsserver,Zombie Panic! Source

+ 0 - 1
lgsm/functions/command_install.sh

@@ -24,7 +24,6 @@ else
 		install_server_files.sh
 		install_server_files.sh
 		install_ut2k4_key.sh
 		install_ut2k4_key.sh
 	elif [ -z "${appid}" ]; then
 	elif [ -z "${appid}" ]; then
-		installer=1
 		install_server_files.sh
 		install_server_files.sh
 	elif [ "${appid}" ]; then
 	elif [ "${appid}" ]; then
 		install_steamcmd.sh
 		install_steamcmd.sh

+ 9 - 0
lgsm/functions/command_start.sh

@@ -32,6 +32,13 @@ fn_start_teamspeak3(){
 	fn_start_tmux
 	fn_start_tmux
 }
 }
 
 
+# This will allow the Jedi Knight 2 version to be printed in console on start.
+# Used to allow update to detect JK2MV server version.
+fn_start_jk2(){
+	fn_start_tmux
+	tmux send -t "${sessionname}" version ENTER > /dev/null 2>&1
+}
+
 fn_start_tmux(){
 fn_start_tmux(){
 	if [ "${parmsbypass}" ]; then
 	if [ "${parmsbypass}" ]; then
 		parms=""
 		parms=""
@@ -196,6 +203,8 @@ fn_print_dots "${servername}"
 
 
 if [ "${shortname}" == "ts3" ]; then
 if [ "${shortname}" == "ts3" ]; then
 	fn_start_teamspeak3
 	fn_start_teamspeak3
+elif [ "${shortname}" == "jk2" ]; then
+	fn_start_jk2
 else
 else
 	fn_start_tmux
 	fn_start_tmux
 fi
 fi

+ 2 - 0
lgsm/functions/command_update.sh

@@ -26,6 +26,8 @@ elif [ "${shortname}" == "fctr" ]; then
 	update_factorio.sh
 	update_factorio.sh
 elif [ "${shortname}" == "mta" ]; then
 elif [ "${shortname}" == "mta" ]; then
 	update_mta.sh
 	update_mta.sh
+elif [ "${shortname}" == "jk2" ]; then
+	update_jediknight2.sh	
 else
 else
 	update_steamcmd.sh
 	update_steamcmd.sh
 fi
 fi

+ 1 - 1
lgsm/functions/core_dl.sh

@@ -67,7 +67,7 @@ fn_dl_steamcmd(){
 				${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
 				${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
 			fi
 			fi
 		# Force Windows Platform type.
 		# Force Windows Platform type.
-		elif [ "${shortname}" == "ac" ]; then
+		elif [ "${shortname}" == "ac" ]||[ "${shortname}" == "jk2" ]; then
 			if [ -n "${branch}" ]&&[ -n "${betapassword}" ]; then
 			if [ -n "${branch}" ]&&[ -n "${betapassword}" ]; then
 				${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" -betapassword "${betapassword}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
 				${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" -betapassword "${betapassword}" ${validate} +quit | tee -a "${lgsmlog}" "${steamcmdlog}"
 			elif [ -n "${branch}" ]; then
 			elif [ -n "${branch}" ]; then

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -614,6 +614,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function
 }
 }
 
 
+update_jediknight2.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 update_steamcmd.sh(){
 update_steamcmd.sh(){
 functionfile="${FUNCNAME[0]}"
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function

+ 7 - 5
lgsm/functions/core_getopt.sh

@@ -61,11 +61,13 @@ currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monit
 currentopt+=( "${cmd_update_linuxgsm[@]}" )
 currentopt+=( "${cmd_update_linuxgsm[@]}" )
 
 
 # Exclude noupdate games here.
 # Exclude noupdate games here.
-if [ "${engine}" != "quake" ]&&[ "${engine}" != "idtech2" ]&&[ "${engine}" != "idtech3" ]&&[ "${engine}" != "iw2.0" ]&&[ "${engine}" != "iw3.0" ]&&[ "${shortname}" != "bf1942" ]&&[ "${shortname}" != "bfv" ]&&[ "${shortname}" != "samp" ]; then
-	currentopt+=( "${cmd_update[@]}" )
-	# force update for SteamCMD only or MTA.
-	if [ "${appid}" ]||[ "${shortname}" == "mta" ]; then
-		currentopt+=( "${cmd_force_update[@]}" )
+if [ "${shortname}" == "jk2" ]||[ "${engine}" != "idtech3" ];then
+	if [ "${engine}" != "quake" ]&&[ "${engine}" != "idtech2" ]&&[ "${engine}" != "iw2.0" ]&&[ "${engine}" != "iw3.0" ]&&[ "${shortname}" != "bf1942" ]&&[ "${shortname}" != "bfv" ]&&[ "${shortname}" != "samp" ]; then
+		currentopt+=( "${cmd_update[@]}" )
+		# force update for SteamCMD only or MTA.
+		if [ "${appid}" ]||[ "${shortname}" == "mta" ]; then
+			currentopt+=( "${cmd_force_update[@]}" )
+		fi
 	fi
 	fi
 fi
 fi
 
 

+ 24 - 0
lgsm/functions/info_config.sh

@@ -680,6 +680,27 @@ fn_info_config_quake3(){
 	fi
 	fi
 }
 }
 
 
+fn_info_config_jk2(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		rconpassword="${unavailable}"
+		servername="${unavailable}"
+		serverpassword="${unavailable}"
+		maxplayers="${zero}"
+	else
+		rconpassword=$(grep "seta rconpassword" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/seta rconpassword//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
+		servername=$(grep "seta sv_hostname" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/seta sv_hostname//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
+		serverpassword=$(grep "seta g_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/seta g_password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
+		maxplayers=$(grep "seta sv_maxclients" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
+		serverversion=$(grep "seta mv_serverversion" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/seta mv_serverversion//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
+
+		# Not Set
+		rconpassword=${rconpassword:-"NOT SET"}
+		servername=${servername:-"NOT SET"}
+		serverpassword=${serverpassword:-"NOT SET"}
+		maxplayers=${maxplayers:-"0"}
+	fi
+}
+
 fn_info_config_quakelive(){
 fn_info_config_quakelive(){
 	if [ ! -f "${servercfgfullpath}" ]; then
 	if [ ! -f "${servercfgfullpath}" ]; then
 		rconpassword="${unavailable}"
 		rconpassword="${unavailable}"
@@ -1570,6 +1591,9 @@ elif [ "${shortname}" == "q3" ]; then
 # Quake Live
 # Quake Live
 elif [ "${shortname}" == "ql" ]; then
 elif [ "${shortname}" == "ql" ]; then
 	fn_info_config_quakelive
 	fn_info_config_quakelive
+# Jedi Knight II: Jedi Outcast
+elif [ "${shortname}" == "jk2" ]; then
+	fn_info_config_jk2
 # Minecraft
 # Minecraft
 elif [ "${shortname}" == "mc" ]; then
 elif [ "${shortname}" == "mc" ]; then
 	fn_info_config_minecraft
 	fn_info_config_minecraft

+ 16 - 0
lgsm/functions/info_messages.sh

@@ -377,6 +377,11 @@ fn_info_message_gameserver(){
 			echo -e "${lightblue}Map rotation:\t${default}${randommap}"
 			echo -e "${lightblue}Map rotation:\t${default}${randommap}"
 		fi
 		fi
 
 
+		# Server Version (Jedi Knight II: Jedi Outcast)
+		if [ -n "${serverversion}" ]; then
+			echo -e "${lightblue}Server Version:\t${default}${serverversion}"
+		fi
+
 		# Listed on Master server
 		# Listed on Master server
 		if [ -n "${displaymasterserver}" ]; then
 		if [ -n "${displaymasterserver}" ]; then
 			if [ "${displaymasterserver}" == "true" ]; then
 			if [ "${displaymasterserver}" == "true" ]; then
@@ -820,6 +825,15 @@ fn_info_message_inss(){
 	} | column -s $'\t' -t
 	} | column -s $'\t' -t
 }
 }
 
 
+	fn_info_message_jk2(){
+		echo -e "netstat -atunp | grep jk2mvded"
+		echo -e ""
+		{
+			echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
+			echo -e "> Game\tINBOUND\t${port}\tudp"
+		} | column -s $'\t' -t
+	}
+
 fn_info_message_justcause2(){
 fn_info_message_justcause2(){
 	echo -e "netstat -atunp | grep Jcmp-Server"
 	echo -e "netstat -atunp | grep Jcmp-Server"
 	echo -e ""
 	echo -e ""
@@ -1456,6 +1470,8 @@ fn_info_message_select_engine(){
 		fn_info_message_hurtworld
 		fn_info_message_hurtworld
 	elif [ "${shortname}" == "inss" ]; then
 	elif [ "${shortname}" == "inss" ]; then
 		fn_info_message_inss
 		fn_info_message_inss
+	elif [ "${shortname}" == "jk2" ]; then
+		fn_info_message_jk2
 	elif [ "${shortname}" == "jc2" ]; then
 	elif [ "${shortname}" == "jc2" ]; then
 		fn_info_message_justcause2
 		fn_info_message_justcause2
 	elif [ "${shortname}" == "jc3" ]; then
 	elif [ "${shortname}" == "jc3" ]; then

+ 6 - 1
lgsm/functions/info_parms.sh

@@ -67,12 +67,15 @@ fn_info_parms_inss(){
 	maxplayers=${maxplayers:-"0"}
 	maxplayers=${maxplayers:-"0"}
 }
 }
 
 
+fn_info_parms_jk2(){
+	queryport=${port}
+}
+
 fn_info_parms_kf2(){
 fn_info_parms_kf2(){
 	queryport=${queryport:-"0"}
 	queryport=${queryport:-"0"}
 	defaultmap=${defaultmap:-"NOT SET"}
 	defaultmap=${defaultmap:-"NOT SET"}
 }
 }
 
 
-
 fn_info_parms_mordhau(){
 fn_info_parms_mordhau(){
 	port=${port:-"0"}
 	port=${port:-"0"}
 	queryport=${queryport:-"0"}
 	queryport=${queryport:-"0"}
@@ -246,6 +249,8 @@ elif [ "${shortname}" == "fctr" ]; then
 	fn_info_parms_factorio
 	fn_info_parms_factorio
 elif [ "${shortname}" == "inss" ]; then
 elif [ "${shortname}" == "inss" ]; then
 	fn_info_parms_inss
 	fn_info_parms_inss
+elif [ "${shortname}" == "jk2" ]; then
+	fn_info_parms_jk2	
 elif [ "${shortname}" == "kf2" ]; then
 elif [ "${shortname}" == "kf2" ]; then
 	fn_info_parms_kf2
 	fn_info_parms_kf2
 elif [ "${shortname}" == "mohaa" ]; then
 elif [ "${shortname}" == "mohaa" ]; then

+ 6 - 0
lgsm/functions/install_config.sh

@@ -626,6 +626,12 @@ elif [ "${shortname}" == "ql" ]; then
 	fn_default_config_remote
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_set_config_vars
 	fn_list_config_locations
 	fn_list_config_locations
+elif [ "${shortname}" == "jk2" ]; then
+	gamedirname="JediKnightIIJediOutcast"
+	array_configs+=( server.cfg )
+	fn_fetch_default_config
+	fn_default_config_remote
+	fn_set_config_vars
 elif [ "${shortname}" == "qw" ]; then
 elif [ "${shortname}" == "qw" ]; then
 	gamedirname="QuakeWorld"
 	gamedirname="QuakeWorld"
 	array_configs+=( server.cfg )
 	array_configs+=( server.cfg )

+ 2 - 0
lgsm/functions/install_server_files.sh

@@ -91,6 +91,8 @@ elif [ "${shortname}" == "mta" ]; then
 elif [ "${shortname}" == "fctr" ]; then
 elif [ "${shortname}" == "fctr" ]; then
 	update_factorio.sh
 	update_factorio.sh
 	install_factorio_save.sh
 	install_factorio_save.sh
+elif [ "${shortname}" == "jk2" ]; then
+	update_jediknight2.sh
 elif [ -z "${appid}" ]||[ "${shortname}" == "ahl" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ges" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "sfc" ]||[ "${shortname}" == "ts" ]||[ "${shortname}" == "vs" ]||[ "${shortname}" == "zmr" ]; then
 elif [ -z "${appid}" ]||[ "${shortname}" == "ahl" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ges" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "sfc" ]||[ "${shortname}" == "ts" ]||[ "${shortname}" == "vs" ]||[ "${shortname}" == "zmr" ]; then
 	if [ "${shortname}" == "ut" ]; then
 	if [ "${shortname}" == "ut" ]; then
 		install_eula.sh
 		install_eula.sh

+ 2 - 2
lgsm/functions/update_factorio.sh

@@ -43,7 +43,7 @@ fn_update_factorio_localbuild(){
 fn_update_factorio_remotebuild(){
 fn_update_factorio_remotebuild(){
 	# Gets remote build info.
 	# Gets remote build info.
 	remotebuild=$(curl -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
 	remotebuild=$(curl -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -148,7 +148,7 @@ else
 	downloadbranch="${branch}"
 	downloadbranch="${branch}"
 fi
 fi
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_factorio_remotebuild
 	fn_update_factorio_remotebuild
 	fn_update_factorio_dl
 	fn_update_factorio_dl
 else
 else

+ 171 - 0
lgsm/functions/update_jediknight2.sh

@@ -0,0 +1,171 @@
+#!/bin/bash
+# LinuxGSM update_jk2.sh function
+# Author: Daniel Gibbs
+# Website: https://linuxgsm.com
+# Description: Handles updating of jk2 servers.
+
+local commandname="UPDATE"
+local commandaction="Update"
+local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+fn_update_jk2_dl(){
+	fn_fetch_file "https://github.com/mvdevs/jk2mv/releases/download/${remotebuild}/jk2mv-v${remotebuild}-dedicated.zip" "" "" "" "${tmpdir}" "jk2mv-${remotebuild}-dedicated.zip" "" "norun" "noforce" "nomd5"
+	fn_dl_extract "${tmpdir}" "jk2mv-${remotebuild}-dedicated.zip" "${tmpdir}/jk2mv-v${remotebuild}-dedicated"
+	echo -e "copying to ${serverfiles}...\c"
+	cp -R "${tmpdir}/jk2mv-v${remotebuild}-dedicated/linux-amd64/jk2mvded"* "${serverfiles}/GameData"
+	local exitcode=$?
+	if [ "${exitcode}" == "0" ]; then
+		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		fn_clear_tmp
+	else
+		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
+	fi
+}
+
+fn_update_jk2_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking local build: ${remotelocation}"
+	# Uses log file to gather info.
+	# Log is generated and cleared on startup but filled on shutdown.
+	localbuild=$(grep "\"version\"" "${consolelogdir}"/* 2>/dev/null | sed 's/.*://' | awk '{print $1}' | head -n 1)
+	if [ -z "${localbuild}" ]; then
+		fn_print_error "Checking local build: ${remotelocation}"
+		fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info"
+		fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart"
+		fn_script_log_error "No log files containing version info"
+		fn_script_log_info "Forcing server restart"
+
+		check_status.sh
+		# If server stopped.
+		if [ "${status}" == "0" ]; then
+			exitbypass=1
+			command_start.sh
+			fn_firstcommand_reset
+			sleep 3
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+		# If server started.
+		else
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+		fi
+	fi
+
+	if [ -z "${localbuild}" ]; then
+		localbuild=$(grep Version "$(ls -tr "${consolelogdir}"/* 2>/dev/null)" | tail -1 | sed 's/.*Version //')
+	fi
+
+	if [ -z "${localbuild}" ]; then
+		localbuild="0"
+		fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info"
+		fn_script_log_error "Missing local build info"
+		fn_script_log_error "Set localbuild to 0"
+	else
+		fn_print_ok "Checking local build: ${remotelocation}"
+		fn_script_log_pass "Checking local build"
+	fi
+}
+
+fn_update_jk2_remotebuild(){
+	# Gets remote build info.
+	remotebuild=$(curl -s "https://api.github.com/repos/mvdevs/jk2mv/releases/latest" | grep dedicated.zip | tail -1 | awk -F"/" '{ print $8 }')
+	if [ "${firstcommandname}" != "INSTALL" ]; then
+		fn_print_dots "Checking remote build: ${remotelocation}"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking remote build: ${remotelocation}"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking remote build: ${remotelocation}"
+			fn_script_log_pass "Checking remote build"
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_jk2_compare(){
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	localbuilddigit=$(echo -e "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo -e "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild} ${jk2arch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${jk2arch}${default}"
+		echo -en "\n"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild} ${jk2arch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${jk2arch}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
+
+		unset updateonstart
+		check_status.sh
+		# If server stopped.
+		if [ "${status}" == "0" ]; then
+			exitbypass=1
+			fn_update_jk2_dl
+			exitbypass=1
+			command_start.sh
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+		# If server started.
+		else
+			fn_print_restart_warning
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+			exitbypass=1
+			fn_update_jk2_dl
+			exitbypass=1
+			command_start.sh
+			fn_firstcommand_reset
+		fi
+		date +%s > "${lockdir}/lastupdate.lock"
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild} ${jk2arch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${jk2arch}${default}"
+		echo -en "\n"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild} ${jk2arch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${jk2arch}"
+	fi
+}
+
+# The location where the builds are checked and downloaded.
+remotelocation="jk2mv.org"
+
+# Game server architecture.
+jk2arch="x64"
+
+if [ "${firstcommandname}" == "INSTALL" ]; then
+	fn_update_jk2_remotebuild
+	fn_update_jk2_dl
+else
+	update_steamcmd.sh
+	fn_print_dots "Checking for update"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
+	fn_update_jk2_localbuild
+	fn_update_jk2_remotebuild
+	fn_update_jk2_compare
+fi

+ 12 - 39
lgsm/functions/update_minecraft.sh

@@ -35,8 +35,8 @@ fn_update_minecraft_localbuild(){
 	# Gets local build info.
 	# Gets local build info.
 	fn_print_dots "Checking local build: ${remotelocation}"
 	fn_print_dots "Checking local build: ${remotelocation}"
 	# Uses log file to gather info.
 	# Uses log file to gather info.
-	# Gives time for log file to generate.
-	if [ ! -f "${serverfiles}/logs/latest.log" ]; then
+	localbuild=$(grep Version "${consolelogdir}"/* 2>/dev/null | tail -1 | sed 's/.*Version //')
+	if [ -z "${localbuild}" ]; then
 		fn_print_error "Checking local build: ${remotelocation}"
 		fn_print_error "Checking local build: ${remotelocation}"
 		fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info"
 		fn_print_error_nl "Checking local build: ${remotelocation}: no log files containing version info"
 		fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart"
 		fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart"
@@ -49,8 +49,8 @@ fn_update_minecraft_localbuild(){
 		command_start.sh
 		command_start.sh
 		fn_firstcommand_reset
 		fn_firstcommand_reset
 		totalseconds=0
 		totalseconds=0
-		# Check again, allow time to generate logs.
-		while [ ! -f "${serverfiles}/logs/latest.log" ]; do
+		localbuild=$(grep Version "${consolelogdir}"/* 2>/dev/null | tail -1 | sed 's/.*Version //')
+		while [ -z "${localbuild}" ]; do
 			sleep 1
 			sleep 1
 			fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}"
 			fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}"
 			if [ -v "${loopignore}" ]; then
 			if [ -v "${loopignore}" ]; then
@@ -58,45 +58,18 @@ fn_update_minecraft_localbuild(){
 				fn_script_log_info "Waiting for log file to generate"
 				fn_script_log_info "Waiting for log file to generate"
 			fi
 			fi
 
 
+			localbuild=$(grep Version "$(ls -tr "${consolelogdir}"/* 2>/dev/null)" | tail -1 | sed 's/.*Version //')
 			if [ "${totalseconds}" -gt "120" ]; then
 			if [ "${totalseconds}" -gt "120" ]; then
 				localbuild="0"
 				localbuild="0"
-				fn_print_error "Checking local build: ${remotelocation}: waiting for log file: missing log file"
-				fn_script_log_error "Missing log file"
-				fn_script_log_error "Set localbuild to 0"
-			fi
-
-			totalseconds=$((totalseconds + 1))
-		done
-	fi
-
-	if [ -z "${localbuild}" ]; then
-		localbuild=$(grep version "${serverfiles}/logs/latest.log" | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}(-pre[0-9]+)?|([0-9]+w[0-9]+[a-z])')
-	fi
-
-	if [ -z "${localbuild}" ]; then
-		# Gives time for var to generate.
-		totalseconds=0
-		for seconds in {1..120}; do
-			fn_print_info "Checking local build: ${remotelocation}: waiting for local build: ${totalseconds}"
-			if [ -z "${loopignore}" ]; then
-				loopignore=1
-				fn_script_log_info "Waiting for local build to generate"
-			fi
-			localbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}(-pre[0-9]+)?|([0-9]+w[0-9]+[a-z])')
-			if [ "${localbuild}" ]||[ "${seconds}" == "120" ]; then
-				break
+				fn_print_error "Checking local build: ${remotelocation}: waiting for log file"
+				fn_script_log_error "Local build did not generate"
+				fn_script_log_error "Required log file may be missing"
+				fn_script_log_error "Local build set to 0"
 			fi
 			fi
-			sleep 1
 			totalseconds=$((totalseconds + 1))
 			totalseconds=$((totalseconds + 1))
 		done
 		done
 	fi
 	fi
-
-	if [ -z "${localbuild}" ]; then
-		localbuild="0"
-		fn_print_error "Checking local build: ${remotelocation}: waiting for local build: missing local build info"
-		fn_script_log_error "Missing local build info"
-		fn_script_log_error "Set localbuild to 0"
-	else
+	if [ "${localbuild}" != "0" ]; then
 		fn_print_ok "Checking local build: ${remotelocation}"
 		fn_print_ok "Checking local build: ${remotelocation}"
 		fn_script_log_pass "Checking local build"
 		fn_script_log_pass "Checking local build"
 	fi
 	fi
@@ -110,7 +83,7 @@ fn_update_minecraft_remotebuild(){
 		remotebuild=$(curl -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r '.versions[0].id')
 		remotebuild=$(curl -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r '.versions[0].id')
 	fi
 	fi
 
 
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -197,7 +170,7 @@ fn_update_minecraft_compare(){
 # The location where the builds are checked and downloaded.
 # The location where the builds are checked and downloaded.
 remotelocation="mojang.com"
 remotelocation="mojang.com"
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_minecraft_remotebuild
 	fn_update_minecraft_remotebuild
 	fn_update_minecraft_dl
 	fn_update_minecraft_dl
 else
 else

+ 3 - 3
lgsm/functions/update_minecraft_bedrock.sh

@@ -10,7 +10,7 @@ fn_update_minecraft_dl(){
 	latestmcbuildurl=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*zip')
 	latestmcbuildurl=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*zip')
 	fn_fetch_file "${latestmcbuildurl}" "" "" "" "${tmpdir}" "bedrock_server.${remotebuild}.zip"
 	fn_fetch_file "${latestmcbuildurl}" "" "" "" "${tmpdir}" "bedrock_server.${remotebuild}.zip"
 	echo -e "Extracting to ${serverfiles}...\c"
 	echo -e "Extracting to ${serverfiles}...\c"
-	if [ "${installer}" == "1" ]; then
+	if [ "${firstcommandname}" == "INSTALL" ]; then
 		unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "server.properties" -d "${serverfiles}"
 		unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "server.properties" -d "${serverfiles}"
 	else
 	else
 		unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "permissions.json" "server.properties" "whitelist.json" -d "${serverfiles}"
 		unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "permissions.json" "server.properties" "whitelist.json" -d "${serverfiles}"
@@ -78,7 +78,7 @@ fn_update_minecraft_localbuild(){
 fn_update_minecraft_remotebuild(){
 fn_update_minecraft_remotebuild(){
 	# Gets remote build info.
 	# Gets remote build info.
 	remotebuild=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*' | sed 's/.*\///' | grep -Eo "[.0-9]+[0-9]")
 	remotebuild=$(curl -s "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*' | sed 's/.*\///' | grep -Eo "[.0-9]+[0-9]")
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -158,7 +158,7 @@ fn_update_minecraft_compare(){
 # The location where the builds are checked and downloaded.
 # The location where the builds are checked and downloaded.
 remotelocation="minecraft.net"
 remotelocation="minecraft.net"
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_minecraft_remotebuild
 	fn_update_minecraft_remotebuild
 	fn_update_minecraft_dl
 	fn_update_minecraft_dl
 else
 else

+ 2 - 2
lgsm/functions/update_mta.sh

@@ -101,7 +101,7 @@ fn_update_mta_remotebuild(){
 	minorversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MINOR" | awk '{ print $3 }' | sed 's/\r//g')
 	minorversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MINOR" | awk '{ print $3 }' | sed 's/\r//g')
 	maintenanceversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g')
 	maintenanceversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g')
 	remotebuild="${majorversion}.${minorversion}.${maintenanceversion}"
 	remotebuild="${majorversion}.${minorversion}.${maintenanceversion}"
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -187,7 +187,7 @@ fn_update_mta_compare(){
 # The location where the builds are checked and downloaded.
 # The location where the builds are checked and downloaded.
 remotelocation="linux.mtasa.com"
 remotelocation="linux.mtasa.com"
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_mta_remotebuild
 	fn_update_mta_remotebuild
 	fn_update_mta_dl
 	fn_update_mta_dl
 else
 else

+ 2 - 2
lgsm/functions/update_mumble.sh

@@ -43,7 +43,7 @@ fn_update_mumble_localbuild(){
 fn_update_mumble_remotebuild(){
 fn_update_mumble_remotebuild(){
 	# Gets remote build info.
 	# Gets remote build info.
 	remotebuild=$(curl -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
 	remotebuild=$(curl -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -126,7 +126,7 @@ remotelocation="mumble.info"
 # Game server architecture.
 # Game server architecture.
 mumblearch="x86"
 mumblearch="x86"
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_mumble_remotebuild
 	fn_update_mumble_remotebuild
 	fn_update_mumble_dl
 	fn_update_mumble_dl
 else
 else

+ 1 - 1
lgsm/functions/update_steamcmd.sh

@@ -48,7 +48,7 @@ fn_update_steamcmd_remotebuild(){
 		remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branch}/d" | grep -m 1 buildid | tr -cd '[:digit:]')
 		remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branch}/d" | grep -m 1 buildid | tr -cd '[:digit:]')
 	fi
 	fi
 
 
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then

+ 2 - 2
lgsm/functions/update_ts3.sh

@@ -106,7 +106,7 @@ fn_update_ts3_remotebuild(){
 	elif [ "${arch}" == "x86" ]; then
 	elif [ "${arch}" == "x86" ]; then
 		remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version')
 		remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version')
 	fi
 	fi
-	if [ "${installer}" != "1" ]; then
+	if [ "${firstcommandname}" != "INSTALL" ]; then
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		fn_print_dots "Checking remote build: ${remotelocation}"
 		# Checks if remotebuild variable has been set.
 		# Checks if remotebuild variable has been set.
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
 		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
@@ -197,7 +197,7 @@ fi
 # The location where the builds are checked and downloaded.
 # The location where the builds are checked and downloaded.
 remotelocation="teamspeak.com"
 remotelocation="teamspeak.com"
 
 
-if [ "${installer}" == "1" ]; then
+if [ "${firstcommandname}" == "INSTALL" ]; then
 	fn_update_ts3_remotebuild
 	fn_update_ts3_remotebuild
 	fn_update_ts3_dl
 	fn_update_ts3_dl
 else
 else