From eb9e5a940f221fb7cb654095892dc9473c8ad3a9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 10 Aug 2020 20:15:39 +0100 Subject: [PATCH] feat(newserver): Jedi Knight II: Jedi Outcast (#3002) Co-authored-by: Nate Berkopec Co-authored-by: Frisasky --- .../config-lgsm/jk2server/_default.cfg | 172 ++++++++++++++++++ lgsm/data/serverlist.csv | 3 +- lgsm/functions/command_install.sh | 1 - lgsm/functions/command_start.sh | 9 + lgsm/functions/command_update.sh | 2 + lgsm/functions/core_dl.sh | 2 +- lgsm/functions/core_functions.sh | 5 + lgsm/functions/core_getopt.sh | 12 +- lgsm/functions/info_config.sh | 24 +++ lgsm/functions/info_messages.sh | 16 ++ lgsm/functions/info_parms.sh | 7 +- lgsm/functions/install_config.sh | 6 + lgsm/functions/install_server_files.sh | 2 + lgsm/functions/update_factorio.sh | 4 +- lgsm/functions/update_jediknight2.sh | 171 +++++++++++++++++ lgsm/functions/update_minecraft.sh | 51 ++---- lgsm/functions/update_minecraft_bedrock.sh | 6 +- lgsm/functions/update_mta.sh | 4 +- lgsm/functions/update_mumble.sh | 4 +- lgsm/functions/update_steamcmd.sh | 2 +- lgsm/functions/update_ts3.sh | 4 +- 21 files changed, 447 insertions(+), 60 deletions(-) create mode 100644 lgsm/config-default/config-lgsm/jk2server/_default.cfg create mode 100644 lgsm/functions/update_jediknight2.sh diff --git a/lgsm/config-default/config-lgsm/jk2server/_default.cfg b/lgsm/config-default/config-lgsm/jk2server/_default.cfg new file mode 100644 index 000000000..b7bc6b307 --- /dev/null +++ b/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" diff --git a/lgsm/data/serverlist.csv b/lgsm/data/serverlist.csv index d85a68011..8a71858fe 100644 --- a/lgsm/data/serverlist.csv +++ b/lgsm/data/serverlist.csv @@ -48,6 +48,7 @@ inss,inssserver,Insurgency: Sandstorm ios,iosserver,IOSoccer jc2,jc2server,Just Cause 2 jc3,jc3server,Just Cause 3 +jk2,jk2server,Jedi Knight II: Jedi Outcast kf,kfserver,Killing Floor kf2,kf2server,Killing Floor 2 l4d,l4dserver,Left 4 Dead @@ -107,4 +108,4 @@ wet,wetserver,Wolfenstein: Enemy Territory wf,wfserver,Warfork wurm,wurmserver,Wurm Unlimited zmr,zmrserver,Zombie Master: Reborn -zps,zpsserver,Zombie Panic! Source \ No newline at end of file +zps,zpsserver,Zombie Panic! Source diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 2437116d3..3e5d27872 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -24,7 +24,6 @@ else install_server_files.sh install_ut2k4_key.sh elif [ -z "${appid}" ]; then - installer=1 install_server_files.sh elif [ "${appid}" ]; then install_steamcmd.sh diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 48cb02e12..62160e187 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -32,6 +32,13 @@ fn_start_teamspeak3(){ 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(){ if [ "${parmsbypass}" ]; then parms="" @@ -196,6 +203,8 @@ fn_print_dots "${servername}" if [ "${shortname}" == "ts3" ]; then fn_start_teamspeak3 +elif [ "${shortname}" == "jk2" ]; then + fn_start_jk2 else fn_start_tmux fi diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 2a6c23d57..d4804edef 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -26,6 +26,8 @@ elif [ "${shortname}" == "fctr" ]; then update_factorio.sh elif [ "${shortname}" == "mta" ]; then update_mta.sh +elif [ "${shortname}" == "jk2" ]; then + update_jediknight2.sh else update_steamcmd.sh fi diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index ae11c4156..a5c187df3 100644 --- a/lgsm/functions/core_dl.sh +++ b/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}" fi # Force Windows Platform type. - elif [ "${shortname}" == "ac" ]; then + elif [ "${shortname}" == "ac" ]||[ "${shortname}" == "jk2" ]; 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}" elif [ -n "${branch}" ]; then diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 08b21f8c0..2057caf94 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -614,6 +614,11 @@ functionfile="${FUNCNAME[0]}" fn_fetch_function } +update_jediknight2.sh(){ +functionfile="${FUNCNAME[0]}" +fn_fetch_function +} + update_steamcmd.sh(){ functionfile="${FUNCNAME[0]}" fn_fetch_function diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index bca60d5d9..47071bc24 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -61,11 +61,13 @@ currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monit currentopt+=( "${cmd_update_linuxgsm[@]}" ) # 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 diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index f07293ae3..25984997d 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -680,6 +680,27 @@ fn_info_config_quake3(){ 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(){ if [ ! -f "${servercfgfullpath}" ]; then rconpassword="${unavailable}" @@ -1570,6 +1591,9 @@ elif [ "${shortname}" == "q3" ]; then # Quake Live elif [ "${shortname}" == "ql" ]; then fn_info_config_quakelive +# Jedi Knight II: Jedi Outcast +elif [ "${shortname}" == "jk2" ]; then + fn_info_config_jk2 # Minecraft elif [ "${shortname}" == "mc" ]; then fn_info_config_minecraft diff --git a/lgsm/functions/info_messages.sh b/lgsm/functions/info_messages.sh index 4dcd5aae3..d82462314 100644 --- a/lgsm/functions/info_messages.sh +++ b/lgsm/functions/info_messages.sh @@ -377,6 +377,11 @@ fn_info_message_gameserver(){ echo -e "${lightblue}Map rotation:\t${default}${randommap}" 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 if [ -n "${displaymasterserver}" ]; then if [ "${displaymasterserver}" == "true" ]; then @@ -820,6 +825,15 @@ fn_info_message_inss(){ } | 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(){ echo -e "netstat -atunp | grep Jcmp-Server" echo -e "" @@ -1456,6 +1470,8 @@ fn_info_message_select_engine(){ fn_info_message_hurtworld elif [ "${shortname}" == "inss" ]; then fn_info_message_inss + elif [ "${shortname}" == "jk2" ]; then + fn_info_message_jk2 elif [ "${shortname}" == "jc2" ]; then fn_info_message_justcause2 elif [ "${shortname}" == "jc3" ]; then diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index f30d90020..809d2cfc6 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -67,12 +67,15 @@ fn_info_parms_inss(){ maxplayers=${maxplayers:-"0"} } +fn_info_parms_jk2(){ + queryport=${port} +} + fn_info_parms_kf2(){ queryport=${queryport:-"0"} defaultmap=${defaultmap:-"NOT SET"} } - fn_info_parms_mordhau(){ port=${port:-"0"} queryport=${queryport:-"0"} @@ -246,6 +249,8 @@ elif [ "${shortname}" == "fctr" ]; then fn_info_parms_factorio elif [ "${shortname}" == "inss" ]; then fn_info_parms_inss +elif [ "${shortname}" == "jk2" ]; then + fn_info_parms_jk2 elif [ "${shortname}" == "kf2" ]; then fn_info_parms_kf2 elif [ "${shortname}" == "mohaa" ]; then diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index e57b2daac..63589b81c 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -626,6 +626,12 @@ elif [ "${shortname}" == "ql" ]; then fn_default_config_remote fn_set_config_vars 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 gamedirname="QuakeWorld" array_configs+=( server.cfg ) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 4f651c2e1..979a32805 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -91,6 +91,8 @@ elif [ "${shortname}" == "mta" ]; then elif [ "${shortname}" == "fctr" ]; then update_factorio.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 if [ "${shortname}" == "ut" ]; then install_eula.sh diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index ae4bdbaa5..ded4d8206 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -43,7 +43,7 @@ fn_update_factorio_localbuild(){ fn_update_factorio_remotebuild(){ # 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) - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -148,7 +148,7 @@ else downloadbranch="${branch}" fi -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_factorio_remotebuild fn_update_factorio_dl else diff --git a/lgsm/functions/update_jediknight2.sh b/lgsm/functions/update_jediknight2.sh new file mode 100644 index 000000000..c2bdca1b6 --- /dev/null +++ b/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 diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index b74b71aab..9915f39b3 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -35,8 +35,8 @@ fn_update_minecraft_localbuild(){ # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" # 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_nl "Checking local build: ${remotelocation}: no log files containing version info" fn_print_info_nl "Checking local build: ${remotelocation}: forcing server restart" @@ -49,8 +49,8 @@ fn_update_minecraft_localbuild(){ command_start.sh fn_firstcommand_reset 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 fn_print_info "Checking local build: ${remotelocation}: waiting for log file: ${totalseconds}" if [ -v "${loopignore}" ]; then @@ -58,45 +58,18 @@ fn_update_minecraft_localbuild(){ fn_script_log_info "Waiting for log file to generate" fi + localbuild=$(grep Version "$(ls -tr "${consolelogdir}"/* 2>/dev/null)" | tail -1 | sed 's/.*Version //') if [ "${totalseconds}" -gt "120" ]; then 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 - sleep 1 totalseconds=$((totalseconds + 1)) done 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_script_log_pass "Checking local build" 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') fi - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -197,7 +170,7 @@ fn_update_minecraft_compare(){ # The location where the builds are checked and downloaded. remotelocation="mojang.com" -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_minecraft_remotebuild fn_update_minecraft_dl else diff --git a/lgsm/functions/update_minecraft_bedrock.sh b/lgsm/functions/update_minecraft_bedrock.sh index 8c90d5efb..925e85635 100644 --- a/lgsm/functions/update_minecraft_bedrock.sh +++ b/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') fn_fetch_file "${latestmcbuildurl}" "" "" "" "${tmpdir}" "bedrock_server.${remotebuild}.zip" 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}" else 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(){ # 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]") - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -158,7 +158,7 @@ fn_update_minecraft_compare(){ # The location where the builds are checked and downloaded. remotelocation="minecraft.net" -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_minecraft_remotebuild fn_update_minecraft_dl else diff --git a/lgsm/functions/update_mta.sh b/lgsm/functions/update_mta.sh index d15d9457b..bb5f744ea 100644 --- a/lgsm/functions/update_mta.sh +++ b/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') 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}" - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -187,7 +187,7 @@ fn_update_mta_compare(){ # The location where the builds are checked and downloaded. remotelocation="linux.mtasa.com" -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_mta_remotebuild fn_update_mta_dl else diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh index 6b3fd19d0..dfe8b317a 100644 --- a/lgsm/functions/update_mumble.sh +++ b/lgsm/functions/update_mumble.sh @@ -43,7 +43,7 @@ fn_update_mumble_localbuild(){ fn_update_mumble_remotebuild(){ # 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 }') - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -126,7 +126,7 @@ remotelocation="mumble.info" # Game server architecture. mumblearch="x86" -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_mumble_remotebuild fn_update_mumble_dl else diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 348147b03..11ad0598c 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/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:]') fi - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 290ddf4d0..b4fc5d692 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -106,7 +106,7 @@ fn_update_ts3_remotebuild(){ elif [ "${arch}" == "x86" ]; then remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version') fi - if [ "${installer}" != "1" ]; then + if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuild variable has been set. if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then @@ -197,7 +197,7 @@ fi # The location where the builds are checked and downloaded. remotelocation="teamspeak.com" -if [ "${installer}" == "1" ]; then +if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_ts3_remotebuild fn_update_ts3_dl else