From c739902811551b9b7682ea7b7969f9eeabac6d41 Mon Sep 17 00:00:00 2001 From: Chaos Date: Tue, 3 Jan 2017 13:51:38 -0600 Subject: [PATCH 01/17] Adding Multi Theft Auto Support --- MultiTheftAuto/mtaserver | 161 ++++++++++++++++++++++++ lgsm/functions/command_install.sh | 4 +- lgsm/functions/install_config.sh | 8 +- lgsm/functions/install_mta_resources.sh | 50 ++++++++ lgsm/functions/install_server_files.sh | 2 + 5 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 MultiTheftAuto/mtaserver create mode 100644 lgsm/functions/install_mta_resources.sh diff --git a/MultiTheftAuto/mtaserver b/MultiTheftAuto/mtaserver new file mode 100644 index 000000000..4e49001a2 --- /dev/null +++ b/MultiTheftAuto/mtaserver @@ -0,0 +1,161 @@ +#!/bin/bash +# San Andreas Multiplayer +# Server Management Script +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + +version="210516" + +#### Variables #### + +# Notification Alerts +# (on|off) + +# Email +emailalert="off" +email="email@example.com" +#emailfrom="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" + +# Start Variables +ip="0.0.0.0" +port="22003" + +fn_parms(){ +parms=" " +} + +#### Advanced Variables #### + +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="dgibbs64" +githubrepo="linuxgsm" +githubbranch="mta" + +# Server Details +servicename="mta-server" +gamename="Multi Theft Auto" +engine="RenderWare" + +# 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 +systemdir="${filesdir}" +resourcesdir="${systemdir}/mods/deathmatch/resources" +executabledir="${systemdir}" +executable="./mta-server64" +servercfg="mtaserver.conf" +servercfgdir="${systemdir}/mods/deathmatch" +servercfgfullpath="${servercfgdir}/${servercfg}" + +# Backups +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${filesdir}/mods/deathmatch/logs" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" +consolelogging="on" + +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%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 diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index a840af48a..e58ed8f6a 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -18,7 +18,7 @@ check_deps.sh if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_server_files.sh install_ut2k4_key.sh -elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty 4" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then +elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty 4" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]||[ "${gamename}" == "Multi Theft Auto" ]; then installer=1 install_server_files.sh elif [ -n "${appid}" ]; then @@ -34,6 +34,8 @@ elif [ "${gamename}" == "Don't Starve Together" ]; then install_dst_token.sh elif [ "${gamename}" == "TeamSpeak 3" ]; then install_ts3db.sh +elif [ "${gamename}" == "Multi Theft Auto" ]; then + install_mta_resources.sh fi fix.sh diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index a9a97423f..e32956b3d 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -488,4 +488,10 @@ elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fn_fetch_default_config fn_default_config_remote fn_set_config_vars -fi \ No newline at end of file +elif [ "${gamename}" == "Multi Theft Auto" ]; then + gamedirname="MultiTheftAuto" + array_configs+=( acl.xml mtaserver.conf vehiclecolors.conf ) + fn_fetch_default_config + fn_default_config_remote + fn_set_config_vars +fi diff --git a/lgsm/functions/install_mta_resources.sh b/lgsm/functions/install_mta_resources.sh new file mode 100644 index 000000000..042e7e21c --- /dev/null +++ b/lgsm/functions/install_mta_resources.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# LGSM install_ts3db.sh function +# Author: Daniel Gibbs +# Contributor: PhilPhonic +# Website: https://gameservermanagers.com +# Description: Installs the libmysqlclient for database functions on the server and optionally installs default resources required to run the server + +local commandname="INSTALL" +local commandaction="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +fn_install_libmysqlclient16(){ + echo "" + echo "checking if libmysqlclient16 is installed" + echo "=================================" + sleep 1 + ldd /usr/lib/libmysqlclient.so.16 | grep "libmysqlclient.so.16 => not found" + if [ $? -eq 0 ]; then + echo "libmysqlclient16 not installed. Installing.." + fileurl="https://nightly.mtasa.com/files/modules/64/libmysqlclient.so.16"; filedir="/usr/lib/"; filename="libmysqlclient.so.16"; executecmd="noexecute" run="norun"; force="noforce"; md5="6c188e0f8fb5d7a29f4bc413b9fed6c2" + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" + fi + echo "libmysqlclient16 installed." +} + +fn_install_resources(){ + echo "" + echo "installing default resources" + echo "=================================" + fileurl="http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip"; filedir="${tempdir}"; filename="multitheftauto_resources.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="97a587509698f7f010bcd6e5c6dd9c31" + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" + fn_dl_extract "${filedir}" "${filename}" "${resourcesdir}" + echo "default resources installed." +} + +fn_install_libmysqlclient16 + +if [ -z "${autoinstall}" ]; then + echo "" + while true; do + read -e -i "n" -p "Do you want to have the default resources downloaded? (Server is inoperable without resources!) [y/N]" yn + case $yn in + [Yy]* ) fn_install_resources && break;; + [Nn]* ) break;; + * ) echo "Please answer yes or no.";; + esac + done +else +fn_print_warning_nl "./${selfname} auto-install does not download the default resources. If you require them use ./${selfname} install" +fi diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 330e4fb40..990dca980 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -39,6 +39,8 @@ fn_install_server_files(){ fileurl="http://files.gameservermanagers.com/UnrealTournament3/UT3-linux-server-2.1.tar.bz2"; filedir="${tmpdir}"; filename="UT3-linux-server-2.1.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="2527437b46f1b47f20228d27d72395a6" elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fileurl="http://files.gameservermanagers.com/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; filedir="${tmpdir}"; filename="enemy-territory.260b.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7" + elif [ "${gamename}" == "Multi Theft Auto" ]; then + fileurl="https://linux.mtasa.com/dl/153/multitheftauto_linux_x64-1.5.3.tar.gz"; filedir="${tempdir}"; filename="multitheftauto_linux_x64-1.5.3.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="77caf91fe280877a8d21f8046d5f42ba" fi fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" From cff49d1cb50b5434044ceae1035b62e884372a61 Mon Sep 17 00:00:00 2001 From: Chaos Date: Tue, 3 Jan 2017 14:04:49 -0600 Subject: [PATCH 02/17] Name adjustment --- MultiTheftAuto/mtaserver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiTheftAuto/mtaserver b/MultiTheftAuto/mtaserver index 4e49001a2..c26176d19 100644 --- a/MultiTheftAuto/mtaserver +++ b/MultiTheftAuto/mtaserver @@ -1,5 +1,5 @@ #!/bin/bash -# San Andreas Multiplayer +# Multi Theft Auto # Server Management Script # Author: Daniel Gibbs # Website: https://gameservermanagers.com From 1026922eaa88471723c4ae6c3b2664db9d7fe0c1 Mon Sep 17 00:00:00 2001 From: Chaos Date: Tue, 3 Jan 2017 20:49:50 -0600 Subject: [PATCH 03/17] Updated look of server file to match newer versions, updated version number --- MultiTheftAuto/mtaserver | 67 ++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/MultiTheftAuto/mtaserver b/MultiTheftAuto/mtaserver index c26176d19..7fe082265 100644 --- a/MultiTheftAuto/mtaserver +++ b/MultiTheftAuto/mtaserver @@ -9,32 +9,47 @@ if [ -f ".dev-debug" ]; then set -x fi -version="210516" +version="170103" -#### Variables #### +########################## +######## Settings ######## +########################## -# Notification Alerts -# (on|off) +#### Server Settings #### + +## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters +# None Available + +## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters +# Edit with care +fn_parms(){ +parms=" " +} + +#### LinuxGSM Settings #### -# Email +## Notification Alerts +# (on|off) +# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email emailalert="off" email="email@example.com" -#emailfrom="email@example.com" +emailfrom="" -# Pushbullet -# https://www.pushbullet.com/#settings +# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet pushbulletalert="off" pushbullettoken="accesstoken" +channeltag="" -# Start Variables -ip="0.0.0.0" -port="22003" +## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup +maxbackups="4" +maxbackupdays="30" +stoponbackup="on" -fn_parms(){ -parms=" " -} +## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging +consolelogging="on" +logdays="7" -#### Advanced Variables #### +#### LinuxGSM Advanced Settings #### # Github Branch Select # Allows for the use of different function files @@ -43,12 +58,18 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="mta" -# Server Details -servicename="mta-server" +## LinuxGSM Server Details +# Do not edit gamename="Multi Theft Auto" engine="RenderWare" -# Directories +## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers +servicename="mta-server" + +#### Directories #### +# Edit with care + +## Work Directories rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" @@ -58,7 +79,7 @@ libdir="${lgsmdir}/lib" tmpdir="${lgsmdir}/tmp" filesdir="${rootdir}/serverfiles" -# Server Specific +## Server Specific Directories systemdir="${filesdir}" resourcesdir="${systemdir}/mods/deathmatch/resources" executabledir="${systemdir}" @@ -67,20 +88,18 @@ servercfg="mtaserver.conf" servercfgdir="${systemdir}/mods/deathmatch" servercfgfullpath="${servercfgdir}/${servercfg}" -# Backups +## Backup Directory backupdir="${rootdir}/backups" -# Logging -logdays="7" +## Logging Directories gamelogdir="${filesdir}/mods/deathmatch/logs" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" -consolelogging="on" - scriptlog="${scriptlogdir}/${servicename}-script.log" consolelog="${consolelogdir}/${servicename}-console.log" emaillog="${scriptlogdir}/${servicename}-email.log" +## Logs Naming scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" From d7bcd4bad3408ed0b57258bae029ae8f9b5d44f6 Mon Sep 17 00:00:00 2001 From: Chaos Date: Wed, 4 Jan 2017 22:26:45 -0600 Subject: [PATCH 04/17] Typo in the install file --- lgsm/functions/install_server_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 990dca980..d25b1e451 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -40,7 +40,7 @@ fn_install_server_files(){ elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fileurl="http://files.gameservermanagers.com/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; filedir="${tmpdir}"; filename="enemy-territory.260b.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7" elif [ "${gamename}" == "Multi Theft Auto" ]; then - fileurl="https://linux.mtasa.com/dl/153/multitheftauto_linux_x64-1.5.3.tar.gz"; filedir="${tempdir}"; filename="multitheftauto_linux_x64-1.5.3.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="77caf91fe280877a8d21f8046d5f42ba" + fileurl="https://linux.mtasa.com/dl/153/multitheftauto_linux_x64-1.5.3.tar.gz"; filedir="${tmpdir}"; filename="multitheftauto_linux_x64-1.5.3.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="77caf91fe280877a8d21f8046d5f42ba" fi fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" From c1f781ea18701d22f58906dde25dfd3b06276f14 Mon Sep 17 00:00:00 2001 From: Chaos Date: Wed, 4 Jan 2017 23:08:21 -0600 Subject: [PATCH 05/17] Added the mta resources to the core_functions script --- lgsm/functions/core_functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index ae1b436ea..a7f5e2805 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -554,6 +554,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +install_mta_resources.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + # Calls the global Ctrl-C trap core_trap.sh From 784a6ff26892fb5ab5562de4982fa774be029755 Mon Sep 17 00:00:00 2001 From: Chaos Date: Wed, 4 Jan 2017 23:08:54 -0600 Subject: [PATCH 06/17] Check if configuration directory exists before downloading and moving config files --- lgsm/functions/install_config.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index e32956b3d..724d88aab 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -490,6 +490,7 @@ elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fn_set_config_vars elif [ "${gamename}" == "Multi Theft Auto" ]; then gamedirname="MultiTheftAuto" + fn_check_cfgdir array_configs+=( acl.xml mtaserver.conf vehiclecolors.conf ) fn_fetch_default_config fn_default_config_remote From b6d0888a1b47af542f36aaa8657bfc1325f23fd9 Mon Sep 17 00:00:00 2001 From: Chaos Date: Wed, 4 Jan 2017 23:23:19 -0600 Subject: [PATCH 07/17] Improved formatting of the mta_resource install --- lgsm/functions/install_mta_resources.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/install_mta_resources.sh b/lgsm/functions/install_mta_resources.sh index 042e7e21c..97d17c940 100644 --- a/lgsm/functions/install_mta_resources.sh +++ b/lgsm/functions/install_mta_resources.sh @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM install_ts3db.sh function +# LGSM install_mta_resources.sh function # Author: Daniel Gibbs # Contributor: PhilPhonic # Website: https://gameservermanagers.com @@ -11,11 +11,10 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_libmysqlclient16(){ echo "" - echo "checking if libmysqlclient16 is installed" + echo "Checking if libmysqlclient16 is installed" echo "=================================" sleep 1 - ldd /usr/lib/libmysqlclient.so.16 | grep "libmysqlclient.so.16 => not found" - if [ $? -eq 0 ]; then + if [ ! -f /usr/lib/libmysqlclient.so.16 ]; then echo "libmysqlclient16 not installed. Installing.." fileurl="https://nightly.mtasa.com/files/modules/64/libmysqlclient.so.16"; filedir="/usr/lib/"; filename="libmysqlclient.so.16"; executecmd="noexecute" run="norun"; force="noforce"; md5="6c188e0f8fb5d7a29f4bc413b9fed6c2" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" @@ -25,12 +24,12 @@ fn_install_libmysqlclient16(){ fn_install_resources(){ echo "" - echo "installing default resources" + echo "Installing Default Resources" echo "=================================" - fileurl="http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip"; filedir="${tempdir}"; filename="multitheftauto_resources.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="97a587509698f7f010bcd6e5c6dd9c31" + fileurl="http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip"; filedir="${tmpdir}"; filename="multitheftauto_resources.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="97a587509698f7f010bcd6e5c6dd9c31" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${resourcesdir}" - echo "default resources installed." + echo "Default Resources Installed." } fn_install_libmysqlclient16 From 410530ae1e802c4a85ca970b92b46c3469de82c2 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 00:35:47 -0600 Subject: [PATCH 08/17] Custom opt --- lgsm/functions/core_getopt.sh | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 03aa7359a..86dbdbc73 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -697,6 +697,66 @@ case "${getopt}" in esac } +fn_getopt_renderware(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + uf|update-functions) + command_update_functions.sh;; + m|monitor) + command_monitor.sh;; + ta|test-alert) + command_test_alert.sh;; + dt|details) + command_details.sh;; + pd|postdetails) + command_postdetails.sh;; + b|backup) + command_backup.sh;; + c|console) + command_console.sh;; + d|debug) + command_debug.sh;; + dev|dev-debug) + command_dev_debug.sh;; + i|install) + command_install.sh;; + ai|auto-install) + fn_autoinstall;; + dd|detect-deps) + command_dev_detect_deps.sh;; + *) + if [ -n "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 + fi + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "https://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "${lightyellow}Commands${default}" + { + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." + echo -e "${blue}postdetails\t${default}pd |Post stripped details to pastebin (for support)" + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + } | column -s $'\t' -t + esac +} + if [ "${gamename}" == "Mumble" ]; then fn_getopt_mumble elif [ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Call of Duty" ]||[ "${gamename}" == "Call of Duty: United Offensive" ]||[ "${gamename}" == "Call of Duty 2" ]||[ "${gamename}" == "Call of Duty 4" ]||[ "${gamename}" == "Call of Duty: World at War" ]||[ "${gamename}" == "QuakeWorld" ]||[ "${gamename}" == "Quake 2" ]||[ "${gamename}" == "Quake 3: Arena" ]||[ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then @@ -717,6 +777,8 @@ elif [ "${engine}" == "unreal2" ]; then fi elif [ "${engine}" == "unreal" ]; then fn_getopt_unreal +elif [ "${engine}" == "RenderWare" ]; then + fn_getopt_renderware else fn_getopt_generic fi From 9052fbb13902ac86cd6d3a53365394218d972fe7 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 00:36:45 -0600 Subject: [PATCH 09/17] Changes to how the mysqlclient gets installed, if user cannot use sudo it will warn the user about doing it after the installation --- lgsm/functions/install_mta_resources.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/install_mta_resources.sh b/lgsm/functions/install_mta_resources.sh index 97d17c940..1fc11171a 100644 --- a/lgsm/functions/install_mta_resources.sh +++ b/lgsm/functions/install_mta_resources.sh @@ -15,11 +15,20 @@ fn_install_libmysqlclient16(){ echo "=================================" sleep 1 if [ ! -f /usr/lib/libmysqlclient.so.16 ]; then - echo "libmysqlclient16 not installed. Installing.." - fileurl="https://nightly.mtasa.com/files/modules/64/libmysqlclient.so.16"; filedir="/usr/lib/"; filename="libmysqlclient.so.16"; executecmd="noexecute" run="norun"; force="noforce"; md5="6c188e0f8fb5d7a29f4bc413b9fed6c2" - fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" + fn_print_warn "libmysqlclient16 not installed. Installing.." + sleep 1 + sudo -v > /dev/null 2>&1 + if [ $? -eq 0 ]; then + fileurl="https://nightly.mtasa.com/files/modules/64/libmysqlclient.so.16"; filedir="${tmpdir}"; filename="libmysqlclient.so.16"; executecmd="executecmd" run="norun"; force="noforce"; md5="6c188e0f8fb5d7a29f4bc413b9fed6c2" + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" + sudo mv ${tmpdir}/${filename} /usr/lib/${filename} + else + fn_print_fail_nl "Failed to install libmysqlclient16, $(whoami) does not have sudo access. Download it manually and place it in /usr/lib" + sleep 1 + fi + else + echo "libmysqlclient16 already installed." fi - echo "libmysqlclient16 installed." } fn_install_resources(){ @@ -37,7 +46,7 @@ fn_install_libmysqlclient16 if [ -z "${autoinstall}" ]; then echo "" while true; do - read -e -i "n" -p "Do you want to have the default resources downloaded? (Server is inoperable without resources!) [y/N]" yn + read -e -i "y" -p "Do you want to have the default resources downloaded? (Server is inoperable without resources!) [y/N]" yn case $yn in [Yy]* ) fn_install_resources && break;; [Nn]* ) break;; From f2cccf0bdd832d53102f0dfc08dcd10d655e44d5 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 00:40:16 -0600 Subject: [PATCH 10/17] Appearance change --- lgsm/functions/install_mta_resources.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/install_mta_resources.sh b/lgsm/functions/install_mta_resources.sh index 1fc11171a..8d3074f45 100644 --- a/lgsm/functions/install_mta_resources.sh +++ b/lgsm/functions/install_mta_resources.sh @@ -15,7 +15,7 @@ fn_install_libmysqlclient16(){ echo "=================================" sleep 1 if [ ! -f /usr/lib/libmysqlclient.so.16 ]; then - fn_print_warn "libmysqlclient16 not installed. Installing.." + fn_print_warn_nl "libmysqlclient16 not installed. Installing.." sleep 1 sudo -v > /dev/null 2>&1 if [ $? -eq 0 ]; then From f2d8752de72240e363eb35cc627a99568863553a Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 00:50:52 -0600 Subject: [PATCH 11/17] Dependencies changed for MTA --- lgsm/functions/check_deps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 36e0a8f04..0279a9ede 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -158,8 +158,8 @@ if [ -n "$(command -v dpkg-query)" ]; then fi fi - # All servers except ts3,mumble and minecraft servers require libstdc++6 and lib32gcc1 - if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${engine}" != "lwjgl2" ]; then + # All servers except ts3,mumble,multitheftauto and minecraft servers require libstdc++6 and lib32gcc1 + if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${engine}" != "lwjgl2" ]&&[ "${engine}" != "RenderWare" ]; then if [ "${arch}" == "x86_64" ]; then array_deps_required+=( lib32gcc1 libstdc++6:i386 ) else @@ -238,8 +238,8 @@ elif [ -n "$(command -v yum)" ]; then fi fi - # All servers except ts3,mumble and minecraft servers require glibc.i686 and libstdc++.i686 - if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${engine}" != "lwjgl2" ]; then + # All servers except ts3,mumble,multitheftauto and minecraft servers require glibc.i686 and libstdc++.i686 + if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${engine}" != "lwjgl2" ]&&[ "${engine}" != "RenderWare" ]; then array_deps_required+=( glibc.i686 libstdc++.i686 ) fi From 5ed99c9943788d4be0ad5a78fcbd3a4db8eb336f Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 01:14:46 -0600 Subject: [PATCH 12/17] Strip components flag on the gzip extractions. Required for the way MTA compresses it's archives. --- lgsm/functions/core_dl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 6d971b997..e7f73621c 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -58,7 +58,7 @@ fn_dl_extract(){ mime=$(file -b --mime-type "${filedir}/${filename}") if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then - tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}") + tarcmd=$(tar -zxf "${filedir}/${filename}" -C "${extractdir}" --strip-components=1) elif [ "${mime}" == "application/x-bzip2" ]; then tarcmd=$(tar -jxf "${filedir}/${filename}" -C "${extractdir}") elif [ "${mime}" == "application/zip" ]; then From 8949b3d3de51357a4abeffabfdc58d622c80e9a2 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 11:17:23 -0600 Subject: [PATCH 13/17] Do not require glibc --- lgsm/functions/info_glibc.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index 951adefd7..d9529995b 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -131,6 +131,9 @@ elif [ "${engine}" == "refractor" ]; then elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then glibcrequired="2.2.4" glibcfix="no" +elif [ "${gamename}" == "Multi Theft Auto" ]; then + glibcrequired="NOT REQUIRED" + glibcfix="no" else glibcrequired="UNKNOWN" glibcfix="no" From 631dab60ad375ba153e8aeab1fd3275b17df9955 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 12:35:18 -0600 Subject: [PATCH 14/17] command details --- lgsm/functions/command_details.sh | 24 +++++++++++++++++++-- lgsm/functions/info_config.sh | 36 ++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 9d9d8fddc..3be04f541 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -168,6 +168,11 @@ fn_details_gameserver(){ echo -e "${blue}dbplugin:\t${default}${dbplugin}" fi + # ASE (Multi Theft Auto) + if [ -n "${ase}" ]; then + echo -e "${blue}ASE:\t${default}${ase}" + fi + # Online status if [ "${status}" == "0" ]; then echo -e "${blue}Status:\t${red}OFFLINE${default}" @@ -310,7 +315,7 @@ fn_details_ports(){ parmslocation="${red}UNKNOWN${default}" # engines that require editing in the config file - local ports_edit_array=( "avalanche" "dontstarve" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "projectzomboid" "quake" "refractor" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" ) + local ports_edit_array=( "avalanche" "dontstarve" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "projectzomboid" "quake" "refractor" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" "RenderWare" ) for port_edit in "${ports_edit_array[@]}" do if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]; then @@ -701,6 +706,19 @@ fn_details_ark(){ } | column -s $'\t' -t } +fn_details_mta(){ + echo -e "netstat -atunp | grep mta-server64" + echo -e "" + { + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL\tINI VARIABLE" + echo -e "> Game\tOUTBOUND\t${port}\tudp\tPort=${port}" + echo -e "> HTTP Server\tINBOUND\t${httpport}\ttcp" + if [ "${ase}" == "Enabled" ]; then + echo -e "> ASE Game_Monitor\tOUTBOUND\t$((${port} + 123))\tudp" + fi + } | column -s $'\t' -t +} + # Run checks and gathers details to display. fn_display_details() { @@ -716,7 +734,7 @@ fn_display_details() { fn_details_script fn_details_backup # Some game servers do not have parms. - if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${engine}" != "avalanche" ]&&[ "${engine}" != "dontstarve" ]&&[ "${engine}" != "projectzomboid" ]; then + if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${engine}" != "avalanche" ]&&[ "${engine}" != "dontstarve" ]&&[ "${engine}" != "projectzomboid" ]&&[ "${engine}" != "RenderWare" ]; then fn_parms fn_details_commandlineparms fi @@ -783,6 +801,8 @@ fn_display_details() { fn_details_rust elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fn_details_wolfensteinenemyterritory + elif [ "${gamename}" == "Multi Theft Auto" ]; then + fn_details_mta else fn_print_error_nl "Unable to detect server engine." fi diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 829bba841..a5fbf1a40 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -576,6 +576,38 @@ fn_info_config_sdtd(){ fi } +fn_info_config_mta(){ + if [ ! -f "${servercfgfullpath}" ]; then + port="${unavailable}" + httpport="${unavailable}" + ase="${unavailable}" + servername="${unavailable}" + serverpassword="${unavailable}" + maxplayers="${zero}" + else + port=$(grep -m 1 "serverport" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<" | tr -cd '[:digit:]') + httpport=$(grep -m 1 "httpport" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<" | tr -cd '[:digit:]') + ase=$(grep -m 1 "ase" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<" | tr -cd '[:digit:]') + servername=$(grep -m 1 "servername" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<") + serverpassword=$(grep -m 1 "password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<") + maxplayers=$(grep -m 1 "maxplayers" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's///g' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' | cut -f1 -d "<" | tr -cd '[:digit:]') + + if [ "${ase}" == "1" ]; then + ase="Enabled" + else + ase="Disabled" + fi + + # Not Set + port=${port:-"NOT SET - Defaults to 22003"} + httpport=${httpport:-"NOT SET - Defaults to 22005"} + ase=${ase:-"NOT SET - Defaults to Disabled"} + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET - Defaults to none"} + maxplayers=${maxplayers:-"0"} + fi +} + # Just Cause 2 if [ "${engine}" == "avalanche" ]; then fn_info_config_avalanche @@ -643,4 +675,6 @@ elif [ "${gamename}" == "7 Days To Die" ]; then fn_info_config_sdtd elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then fn_info_config_wolfensteinenemyterritory -fi \ No newline at end of file +elif [ "${gamename}" == "Multi Theft Auto" ]; then + fn_info_config_mta +fi From 0a361905501f42100cb4e32c776b0566c3a40bc4 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 12:35:26 -0600 Subject: [PATCH 15/17] Graceful stop --- lgsm/functions/command_stop.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index c5483a864..4175ee5dd 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -172,6 +172,34 @@ fn_stop_graceful_minecraft(){ fn_stop_tmux } +# Attempts graceful of mta using rcon 'quit' command. +fn_stop_graceful_mta(){ + fn_print_dots "Graceful: console quit" + fn_script_log_info "Graceful: console quit" + # sends quit + tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 + # waits up to 120 seconds giving the server time to shutdown gracefuly, we need a long wait time here as resources are stopped individually and process their own shutdowns + for seconds in {1..120}; do + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_ok "Graceful: console quit: ${seconds}: " + fn_print_ok_eol_nl + fn_script_log_pass "Graceful: console quit: OK: ${seconds} seconds" + break + fi + sleep 1 + fn_print_dots "Graceful: console quit: ${seconds}" + done + check_status.sh + if [ "${status}" != "0" ]; then + fn_print_error "Graceful: console quit: " + fn_print_fail_eol_nl + fn_script_log_error "Graceful: console quit: FAIL" + fi + sleep 1 + fn_stop_tmux +} + fn_stop_graceful_select(){ if [ "${gamename}" == "7 Days To Die" ]; then fn_stop_graceful_sdtd @@ -181,6 +209,8 @@ fn_stop_graceful_select(){ 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 From de2ccb3423e1ce64acfd5b369bd78266412584bc Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 12:35:35 -0600 Subject: [PATCH 16/17] Ready for master! --- MultiTheftAuto/mtaserver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiTheftAuto/mtaserver b/MultiTheftAuto/mtaserver index 7fe082265..07ac899f0 100644 --- a/MultiTheftAuto/mtaserver +++ b/MultiTheftAuto/mtaserver @@ -56,7 +56,7 @@ logdays="7" # from a different repo and/or branch. githubuser="dgibbs64" githubrepo="linuxgsm" -githubbranch="mta" +githubbranch="master" ## LinuxGSM Server Details # Do not edit From a9999f7d36d71ed31e32b87d64dd71a886231a75 Mon Sep 17 00:00:00 2001 From: Chaos Date: Thu, 5 Jan 2017 13:14:38 -0600 Subject: [PATCH 17/17] Header change --- lgsm/functions/install_mta_resources.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/install_mta_resources.sh b/lgsm/functions/install_mta_resources.sh index 8d3074f45..c1f16393a 100644 --- a/lgsm/functions/install_mta_resources.sh +++ b/lgsm/functions/install_mta_resources.sh @@ -1,7 +1,7 @@ #!/bin/bash # LGSM install_mta_resources.sh function # Author: Daniel Gibbs -# Contributor: PhilPhonic +# Contributor: ChaosMTA # Website: https://gameservermanagers.com # Description: Installs the libmysqlclient for database functions on the server and optionally installs default resources required to run the server