From 6f085b28c376d1edb028aede2603ec8d8419f116 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 02:58:15 +0100 Subject: [PATCH 01/46] Global source engine FastDL & remove non bz2 files Fixes #1322 and #721 --- lgsm/functions/command_fastdl.sh | 159 +++++++++++++++++++++++++------ 1 file changed, 129 insertions(+), 30 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 9fe7ca68b..28e4b53f5 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -6,11 +6,18 @@ # Description: Creates a FastDL directory. local commandname="FASTDL" -local commandaction="FastDL" +local commandaction="FastDL Generator" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh +# Only Source supports FastDL +if [ "${engine}" != "source" ]; then + fn_print_error "${gamename} does not support FastDL" + fn_script_log_error "${gamename} does not support FastDL" + core_exit.sh +fi + # Directories webdir="${rootdir}/public_html" fastdldir="${webdir}/fastdl" @@ -24,25 +31,27 @@ fn_check_bzip2(){ # Returns true if not installed if [ -z "$(command -v bzip2)" ]; then bzip2installed="0" - fn_print_info "bzip2 is not installed !" - fn_script_log_info "bzip2 is not installed" + fn_print_info "bzip2 is not installed! Install it to enable file compression" + fn_script_log_info "bzip2 is not installed. Install it to enable file compression." + fn_script_log_info "https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" echo -en "\n" sleep 1 - echo "We advise using it" - echo "For more information, see https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" + echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" sleep 2 + echo "" else bzip2installed="1" fi } fn_fastdl_init(){ - # User confirmation - fn_print_ok "Welcome to LGSM's FastDL generator" + fn_print_header + fn_script_log "Started FastDL Generator" sleep 1 echo -en "\n" - fn_script_log "Started FastDL creation" - if ! fn_prompt_yn "Continue?" Y; then + fn_check_bzip2 + # User confirmation + if ! fn_prompt_yn "Build FastDL directory?" Y; then exit fi fn_script_log "Initiating FastDL creation" @@ -105,7 +114,7 @@ fn_fastdl_config(){ fi } -fn_fastdl_gmod_config(){ +fn_fastdl_gmod_luaenforcer(){ # Prompt for download enforcer, that is using a .lua addfile resource generator fn_print_dots if fn_prompt_yn "Use client download enforcer?" Y; then @@ -130,7 +139,7 @@ fn_clear_old_fastdl(){ fi } -fn_gmod_fastdl(){ +fn_fastdl_gmod(){ # Copy all needed files for FastDL echo "" fn_print_dots "Starting gathering all needed files" @@ -213,7 +222,7 @@ fn_gmod_fastdl(){ fn_script_log "Adjusting addon's file structure" sleep 1 cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" - #Don't remove yet rm -R "${fastdldir:?}/addons" + # Don't remove yet rm -R "${fastdldir:?}/addons" fn_print_ok "Adjusted addon's file structure" sleep 1 echo -en "\n" @@ -221,7 +230,7 @@ fn_gmod_fastdl(){ # Correct content that may be into a lua directory by mistake like some darkrpmodification addons if [ -d "${fastdldir}/lua" ]; then - fn_print_dots "Typical DarkRP shit detected, fixing" + fn_print_dots "Typical DarkRP files detected, fixing" sleep 2 cp -Rf "${fastdldir}/lua/"* "${fastdldir}" fn_print_ok "Stupid DarkRP file structure fixed" @@ -230,8 +239,80 @@ fn_gmod_fastdl(){ fi } +fn_fastdl_source(){ + # Copy all needed files for FastDL + echo "" + fn_print_dots "Starting gathering all needed files" + fn_script_log "Starting gathering all needed files" + sleep 1 + echo -en "\n" + + # Map Files + fn_print_dots "Copying map files..." + fn_script_log "Copying map files" + sleep 0.5 + mkdir "${fastdldir}/maps" + find "${systemdir}/maps" -name '*.bsp' -exec cp {} "${fastdldir}/maps" \; + find "${systemdir}/maps" -name '*.ain' -exec cp {} "${fastdldir}/maps" \; + find "${systemdir}/maps" -name '*.nav' -exec cp {} "${fastdldir}/maps" \; + find "${systemdir}/maps" -name '*.jpg' -exec cp {} "${fastdldir}/maps" \; + find "${systemdir}/maps" -name '*.txt' -exec cp {} "${fastdldir}/maps" \; + fn_print_ok "Map files copied" + sleep 0.5 + echo -en "\n" + + # Materials + fn_print_dots "Copying materials..." + fn_script_log "Copying materials" + sleep 0.5 + mkdir "${fastdldir}/materials" + find "${systemdir}/materials" -name '*.vtf' -exec cp {} "${fastdldir}/materials" \; + find "${systemdir}/materials" -name '*.vmt' -exec cp {} "${fastdldir}/materials" \; + find "${systemdir}/materials" -name '*.vbf' -exec cp {} "${fastdldir}/materials" \; + fn_print_ok "Materials copied" + sleep 0.5 + echo -en "\n" + + # Models + fn_print_dots "Copying models..." + fn_script_log "Copying models" + sleep 1 + mkdir "${fastdldir}/models" + find "${systemdir}/models" -name '*.vtx' -exec cp {} "${fastdldir}/models" \; + find "${systemdir}/models" -name '*.vvd' -exec cp {} "${fastdldir}/models" \; + find "${systemdir}/models" -name '*.mdl' -exec cp {} "${fastdldir}/models" \; + find "${systemdir}/models" -name '*.phy' -exec cp {} "${fastdldir}/models" \; + find "${systemdir}/models" -name '*.jpg' -exec cp {} "${fastdldir}/models" \; + find "${systemdir}/models" -name '*.png' -exec cp {} "${fastdldir}/models" \; + fn_print_ok "Models copied" + sleep 0.5 + echo -en "\n" + + # Particles + fn_print_dots "Copying particles..." + fn_script_log "Copying particles" + sleep 0.5 + mkdir "${fastdldir}/particles" + find "${systemdir}" -name '*.pcf' -exec cp {} "${fastdldir}/particles" \; + fn_print_ok "Particles copied" + sleep 0.5 + echo -en "\n" + + # Sounds + fn_print_dots "Copying sounds..." + fn_script_log "Copying sounds" + sleep 0.5 + mkdir "${fastdldir}/sound" + find "${systemdir}" -name '*.wav' -exec cp {} "${fastdldir}/sound" \; + find "${systemdir}" -name '*.mp3' -exec cp {} "${fastdldir}/sound" \; + find "${systemdir}" -name '*.ogg' -exec cp {} "${fastdldir}/sound" \; + fn_print_ok "Sounds copied" + sleep 0.5 + echo -en "\n" +} + # Generate lua file that will force download any file into the FastDL directory -fn_lua_fastdl(){ +fn_fastdl_gmod_lua(){ # Remove lua file if luaressource is turned off and file exists echo "" if [ "${luaressource}" == "off" ]; then @@ -286,36 +367,54 @@ fn_fastdl_bzip2(){ fn_script_log "bzip2 compression done" sleep 1 echo -en "\n" + # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod + fn_print_dots + if [ "${gamename}" == "Garry's Mod" ]; then + if fn_prompt_yn "Keep original/uncompressed FastDL files?" N; then + fn_print_info "Keeping uncompressed FastDL files"; fn_script_log fn_print_info "Keeping uncompressed FastDL files" + else + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \; fn_print_dots "Clearing uncompressed FastDL files..."; sleep 1; fn_print_ok "Cleared uncompressed FastDL files"; fn_script_log "Cleared uncompressed FastDL files." + fi + echo -en "\n" + else + fn_print_dots "Clearing uncompressed FastDL files..." + sleep 1 + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \ + fn_print_ok "Cleared uncompressed FastDL files." + fn_script_log "Cleared uncompressed FastDL files." + fi fi } fn_fastdl_completed(){ # Finished message echo "" - fn_print_ok "Congratulations, it's done!" + fn_print_ok "FastDL created!" fn_script_log "FastDL job done" sleep 2 echo -en "\n" echo "" - fn_print_info "Need more documentation? See https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL" + fn_print_info_nl "Need more documentation? + echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL" echo -en "\n" if [ "$bzip2installed" == "0" ]; then - echo "By the way, you'd better install bzip2 and re-run this command!" + echo "By the way, you'd better install bzip2 and re-run this command!" fi - echo "Credits : UltimateByte" + echo "Credits: UltimateByte" } -# Game checking and functions running -# Garry's Mod +# Run functions +fn_check_bzip2 +fn_fastdl_init +fn_fastdl_config +fn_clear_old_fastdl if [ "${gamename}" == "Garry's Mod" ]; then - fn_check_bzip2 - fn_fastdl_init - fn_fastdl_config - fn_fastdl_gmod_config - fn_clear_old_fastdl - fn_gmod_fastdl - fn_lua_fastdl - fn_fastdl_bzip2 - fn_fastdl_completed - exit + fn_fastdl_gmod_luaenforcer + fn_fastdl_gmod + fn_fastdl_gmod_lua +else + fn_fastdl_source fi +fn_fastdl_bzip2 +fn_fastdl_completed +core_exit.sh From 2ac7d096a3176a7a4d52fdc790513c37e01ad5bd Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 03:02:12 +0100 Subject: [PATCH 02/46] added fastdl #721 Added to fn_getopt_generic for now, will need to remove from non-source games when core_getopt.sh rework comes out. --- lgsm/functions/core_getopt.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index bcecc6c2d..1d91f9bc8 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -43,6 +43,8 @@ case "${getopt}" in command_install.sh;; ai|auto-install) fn_autoinstall;; + fd|fastdl) + command_fastdl.sh;; mi|mods-install) command_mods_install.sh;; mu|mods-update) @@ -82,6 +84,7 @@ case "${getopt}" in 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." + echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL directory for your server." echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." From cdba3114a24e63e599dac9487bc30b83f0c4938a Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 03:05:52 +0100 Subject: [PATCH 03/46] woops double quote --- lgsm/functions/command_fastdl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 28e4b53f5..4b7584079 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -394,7 +394,7 @@ fn_fastdl_completed(){ sleep 2 echo -en "\n" echo "" - fn_print_info_nl "Need more documentation? + fn_print_info_nl "Need more documentation?" echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL" echo -en "\n" if [ "$bzip2installed" == "0" ]; then From 3a4266b9f149daa27465e3ee5feb248bd37f0c09 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 03:16:16 +0100 Subject: [PATCH 04/46] missing ";", attempt for fix --- lgsm/functions/command_fastdl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 4b7584079..0f7c034cd 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -373,13 +373,13 @@ fn_fastdl_bzip2(){ if fn_prompt_yn "Keep original/uncompressed FastDL files?" N; then fn_print_info "Keeping uncompressed FastDL files"; fn_script_log fn_print_info "Keeping uncompressed FastDL files" else - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \; fn_print_dots "Clearing uncompressed FastDL files..."; sleep 1; fn_print_ok "Cleared uncompressed FastDL files"; fn_script_log "Cleared uncompressed FastDL files." + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \;;fn_print_dots "Clearing uncompressed FastDL files..."; sleep 1; fn_print_ok "Cleared uncompressed FastDL files"; fn_script_log "Cleared uncompressed FastDL files." fi echo -en "\n" else fn_print_dots "Clearing uncompressed FastDL files..." sleep 1 - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \ + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \; fn_print_ok "Cleared uncompressed FastDL files." fn_script_log "Cleared uncompressed FastDL files." fi From c9329a02fab2f0b3e38d1b85b1892eb366384697 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 03:20:38 +0100 Subject: [PATCH 05/46] no dots in user messages --- lgsm/functions/command_fastdl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 0f7c034cd..edac9e494 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -380,7 +380,7 @@ fn_fastdl_bzip2(){ fn_print_dots "Clearing uncompressed FastDL files..." sleep 1 find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \; - fn_print_ok "Cleared uncompressed FastDL files." + fn_print_ok "Cleared uncompressed FastDL files" fn_script_log "Cleared uncompressed FastDL files." fi fi From 7693392c5823774014ebbd3f63ada749ef652cd5 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 03:25:35 +0100 Subject: [PATCH 06/46] addons' --- lgsm/functions/command_fastdl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index edac9e494..ac16d5e64 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -219,11 +219,11 @@ fn_fastdl_gmod(){ # Correct addons directory structure for FastDL if [ -d "${fastdldir}/addons" ]; then fn_print_info "Adjusting addons' file structure" - fn_script_log "Adjusting addon's file structure" + fn_script_log "Adjusting addons' file structure" sleep 1 cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" # Don't remove yet rm -R "${fastdldir:?}/addons" - fn_print_ok "Adjusted addon's file structure" + fn_print_ok "Adjusted addons' file structure" sleep 1 echo -en "\n" fi From b4da7c532bbc234db9d236a280910f03f3fda11e Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 04:20:12 +0100 Subject: [PATCH 07/46] various improvements to code logic --- lgsm/functions/command_fastdl.sh | 82 ++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index ac16d5e64..1659a0a21 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -44,11 +44,11 @@ fn_check_bzip2(){ fi } +# Initiates FastDL fn_fastdl_init(){ fn_print_header fn_script_log "Started FastDL Generator" sleep 1 - echo -en "\n" fn_check_bzip2 # User confirmation if ! fn_prompt_yn "Build FastDL directory?" Y; then @@ -72,28 +72,30 @@ fn_fastdl_init(){ fi if [ ! -d "${fastdldir}" ]; then # No directory, won't ask for removing old ones - newfastdl=1 + newfastdl="true" fn_print_dots "Creating fastdl directory" sleep 0.5 mkdir "${fastdldir}" fn_print_ok "Created fastdl directory" - fn_script_log "FastDL created fastdl directory" + fn_script_log "Created fastdl directory" sleep 1 echo -en "\n" clearoldfastdl="off" # Nothing to clear elif [ "$(ls -A "${fastdldir}")" ]; then - newfastdl=0 + newfastdl="false" + else + newfastdl="true" fi } +# Prompts user for FastDL creation settings fn_fastdl_config(){ - # Global settings for FastDL creation fn_print_info "Entering configuration" fn_script_log "Configuration" sleep 2 echo -en "\n" # Prompt for clearing old files if directory was already here - if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then + if [ "${newfastdl}" == "false" ]; then fn_print_dots if fn_prompt_yn "Clear old FastDL files?" Y; then clearoldfastdl="on"; fn_script_log "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled" @@ -102,27 +104,42 @@ fn_fastdl_config(){ fi echo -en "\n" fi - # Prompt for using bzip2 if it's installed + # Settings for bzip2 users if [ ${bzip2installed} == 1 ]; then + # Prompt for using bzip2 if it's installed fn_print_dots - if fn_prompt_yn "Enable file compression using bzip2?" Y; then + if fn_prompt_yn "Enable bzip2 file compression?" Y; then bzip2enable="on"; fn_script_log "bzip2 enabled"; fn_print_ok "bzip2 Enabled" else bzip2enable="off"; fn_script_log "bzip2 disabled"; fn_print_ok "bzip2 Disabled" fi echo -en "\n" + if [ "${gamename}" == "Garry's Mod" ]&&[ "${bzip2enable}" == "on" ]; then + # Prompt for removing uncompressed FastDL files + fn_print_dots + if fn_prompt_yn "Keep original uncompressed FastDL files?" N; then + clearnonbzip2="on"; fn_script_log "Original uncompressed fastDL files won't be kept."; fn_print_ok "Original uncompressed fastDL files won't be kept" + else + clearnonbzip2="off"; fn_script_log "Original uncompressed fastDL files will be kept."; fn_print_ok "Original uncompressed fastDL files will be kept" + fi + echo -en "\n" + else + # Other games default remove non bzip2 files + clearnonbzip2="on" + fn_script_log "Original uncompressed fastDL files won't be kept." + fi fi -} - -fn_fastdl_gmod_luaenforcer(){ - # Prompt for download enforcer, that is using a .lua addfile resource generator - fn_print_dots - if fn_prompt_yn "Use client download enforcer?" Y; then - luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled" - else - luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled" + # Garry's Mod Specific + if [ "${gamename}" == "Garry's Mod" ]; then + # Prompt for download enforcer, which is using a .lua addfile resource generator + fn_print_dots + if fn_prompt_yn "Use client download enforcer?" Y; then + luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled" + else + luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled" + fi + echo -en "\n" fi - echo -en "\n" } fn_clear_old_fastdl(){ @@ -148,8 +165,8 @@ fn_fastdl_gmod(){ echo -en "\n" # No choice to cd to the directory, as find can't then display relative directory - cd "${systemdir}" - + cd "${systemdir}" || exit + # Map Files fn_print_dots "Copying map files..." fn_script_log "Copying map files" @@ -312,7 +329,7 @@ fn_fastdl_source(){ } # Generate lua file that will force download any file into the FastDL directory -fn_fastdl_gmod_lua(){ +fn_fastdl_gmod_lua_enforcer(){ # Remove lua file if luaressource is turned off and file exists echo "" if [ "${luaressource}" == "off" ]; then @@ -341,8 +358,8 @@ fn_fastdl_gmod_lua(){ fn_script_log "Generating new download enforcer" sleep 1 # Read all filenames and put them into a lua file at the right path - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do - echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath} + find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do + echo "resource.AddFile( "\""${line}"\"" )" >> "${luafastdlfullpath}" done fn_print_ok "Download enforcer generated" fn_script_log "Download enforcer generated" @@ -362,24 +379,18 @@ fn_fastdl_bzip2(){ fn_print_dots "Compressing files using bzip2..." fn_script_log "Compressing files using bzip2..." # bzip2 all files that are not already compressed (keeping original files) - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; + find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; fn_print_ok "bzip2 compression done" fn_script_log "bzip2 compression done" sleep 1 echo -en "\n" # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod fn_print_dots - if [ "${gamename}" == "Garry's Mod" ]; then - if fn_prompt_yn "Keep original/uncompressed FastDL files?" N; then - fn_print_info "Keeping uncompressed FastDL files"; fn_script_log fn_print_info "Keeping uncompressed FastDL files" - else - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \;;fn_print_dots "Clearing uncompressed FastDL files..."; sleep 1; fn_print_ok "Cleared uncompressed FastDL files"; fn_script_log "Cleared uncompressed FastDL files." - fi - echo -en "\n" - else - fn_print_dots "Clearing uncompressed FastDL files..." + # Clear non compressed FastDL files + if [ "${clearnonbzip2}" == "on" ]; then + fn_print_dots "Clearing original uncompressed FastDL files..." sleep 1 - find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec rm {} \; + find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -exec rm {} \; fn_print_ok "Cleared uncompressed FastDL files" fn_script_log "Cleared uncompressed FastDL files." fi @@ -409,9 +420,8 @@ fn_fastdl_init fn_fastdl_config fn_clear_old_fastdl if [ "${gamename}" == "Garry's Mod" ]; then - fn_fastdl_gmod_luaenforcer fn_fastdl_gmod - fn_fastdl_gmod_lua + fn_fastdl_gmod_lua_enforcer else fn_fastdl_source fi From b94bb9a29352412e3bc2357f9628e7ee2ee23705 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 04:30:07 +0100 Subject: [PATCH 08/46] useless print_dots --- lgsm/functions/command_fastdl.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 1659a0a21..a79aeb5e9 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -115,7 +115,7 @@ fn_fastdl_config(){ fi echo -en "\n" if [ "${gamename}" == "Garry's Mod" ]&&[ "${bzip2enable}" == "on" ]; then - # Prompt for removing uncompressed FastDL files + # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod fn_print_dots if fn_prompt_yn "Keep original uncompressed FastDL files?" N; then clearnonbzip2="on"; fn_script_log "Original uncompressed fastDL files won't be kept."; fn_print_ok "Original uncompressed fastDL files won't be kept" @@ -384,8 +384,6 @@ fn_fastdl_bzip2(){ fn_script_log "bzip2 compression done" sleep 1 echo -en "\n" - # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod - fn_print_dots # Clear non compressed FastDL files if [ "${clearnonbzip2}" == "on" ]; then fn_print_dots "Clearing original uncompressed FastDL files..." From c517b4624bc7a1190609d4423b03c74f6f63acf9 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 04:40:15 +0100 Subject: [PATCH 09/46] Inverted gmod clearnonbzip2 --- lgsm/functions/command_fastdl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index a79aeb5e9..2c12ded38 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -118,9 +118,9 @@ fn_fastdl_config(){ # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod fn_print_dots if fn_prompt_yn "Keep original uncompressed FastDL files?" N; then - clearnonbzip2="on"; fn_script_log "Original uncompressed fastDL files won't be kept."; fn_print_ok "Original uncompressed fastDL files won't be kept" - else clearnonbzip2="off"; fn_script_log "Original uncompressed fastDL files will be kept."; fn_print_ok "Original uncompressed fastDL files will be kept" + else + clearnonbzip2="on"; fn_script_log "Original uncompressed fastDL files won't be kept."; fn_print_ok "Original uncompressed fastDL files won't be kept" fi echo -en "\n" else From 828a9831b5a765c107c6a3ab1e7c3238bc485df7 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 05:55:29 +0100 Subject: [PATCH 10/46] chivalry init --- ChivalryMedievalWarfare/chivalrymwserver | 199 +++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 ChivalryMedievalWarfare/chivalrymwserver diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver new file mode 100644 index 000000000..2f4179304 --- /dev/null +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -0,0 +1,199 @@ +#!/bin/bash +# Project: Game Server Managers - LinuxGSM +# Author: Daniel Gibbs +# License: MIT License, Copyright (c) 2017 Daniel Gibbs +# Purpose: Chivalry: Medieval Warfare | Server Management Script +# Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors +# Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki +# Website: https://gameservermanagers.com + +# Debugging +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + +version="170219" + +########################## +######## Settings ######## +########################## + +#### Server Settings #### + +## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters +ip="0.0.0.0" +port=7000" +queryport="7010" +adminpassword="CHANGE_ME" + +## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters +fn_parms(){ +parms="aocffa-moor_p\?steamsockets\?adminpassword=${adminpassword}\?port=${port}\?queryport=${queryport} -seekfreeloadingserver" +} + +#### LinuxGSM Settings #### + +## Notification Alerts +# (on|off) +# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email +emailalert="off" +email="email@example.com" +emailfrom="" + +# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet +pushbulletalert="off" +pushbullettoken="accesstoken" +channeltag="" + +## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update +updateonstart="off" + +## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup +maxbackups="4" +maxbackupdays="30" +stoponbackup="on" + +## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging +consolelogging="on" +logdays="7" + +#### LinuxGSM Advanced Settings #### + +## SteamCMD Settings +# Server appid +appid="220070" +# Steam App Branch Select +# Allows to opt into the various Steam app branches. Default branch is "". +# Example: "-beta latest_experimental" +branch="" + +## Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="GameServerManagers" +githubrepo="LinuxGSM" +githubbranch="master" + +## LinuxGSM Server Details +# Do not edit +gamename="Chivalry: Medieval Warfare" +engine="unreal3" + +## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers +servicename="chivalrymw-server" + +#### Directories #### +# Edit with care + +## Work Directories +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +libdir="${lgsmdir}/lib" +tmpdir="${lgsmdir}/tmp" +filesdir="${rootdir}/serverfiles" + +## Server Specific Directories +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="./UDKGameServer-Linux" +servercfg="unknown" +servercfgdefault="unknown" +servercfgdir="${systemdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" + +## Backup Directory +backupdir="${rootdir}/backups" + +## Logging Directories +gamelogdir="${rootdir}/log/server" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" +gamelog="${gamelogdir}/${servicename}-game.log" +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +## Logs Naming +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" + +######################## +######## Script ######## +###### Do not edit ##### +######################## + +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + echo -e " fetching ${filename}...\c" + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_functions.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +# Prevent from running this script as root. +if [ "$(whoami)" = "root" ]; then + if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then + echo "[ FAIL ] Do NOT run this script as root!" + exit 1 + else + core_functions.sh + check_root.sh + fi +fi + +core_dl.sh +core_functions.sh +getopt=$1 +core_getopt.sh From 51542d311f7d6378dbb8ae7713fb0bf3ffd3c5fa Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 05:56:39 +0100 Subject: [PATCH 11/46] double quote --- ChivalryMedievalWarfare/chivalrymwserver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver index 2f4179304..0192710fd 100644 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -24,7 +24,7 @@ version="170219" ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters ip="0.0.0.0" -port=7000" +port="7000" queryport="7010" adminpassword="CHANGE_ME" From 8f0e4c07a0e04318c5af26733db57b83e0fc1f10 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 06:05:11 +0100 Subject: [PATCH 12/46] execdir --- ChivalryMedievalWarfare/chivalrymwserver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver index 0192710fd..ad1a83d94 100644 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -99,7 +99,7 @@ filesdir="${rootdir}/serverfiles" ## Server Specific Directories systemdir="${filesdir}" -executabledir="${filesdir}" +executabledir="${filesdir}/Binaries/Linux/" executable="./UDKGameServer-Linux" servercfg="unknown" servercfgdefault="unknown" From 5f53f4c22b12e37bc42774ada7088c0adec75670 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 06:19:43 +0100 Subject: [PATCH 13/46] cfg files --- ChivalryMedievalWarfare/chivalrymwserver | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver index ad1a83d94..6315fc2e3 100644 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -101,9 +101,9 @@ filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" executabledir="${filesdir}/Binaries/Linux/" executable="./UDKGameServer-Linux" -servercfg="unknown" -servercfgdefault="unknown" -servercfgdir="${systemdir}" +servercfg="PCServer-UDKGame.ini" +servercfgdefault="PCServer-UDKGame.ini" +servercfgdir="${systemdir}/UDKGame/Config" servercfgfullpath="${servercfgdir}/${servercfg}" ## Backup Directory From a2a21a1e73e2b6125e08cf84ef2ae752ef8aa516 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 06:27:22 +0100 Subject: [PATCH 14/46] gamelog & multihome --- ChivalryMedievalWarfare/chivalrymwserver | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver index 6315fc2e3..fab972b91 100644 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -30,7 +30,7 @@ adminpassword="CHANGE_ME" ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters fn_parms(){ -parms="aocffa-moor_p\?steamsockets\?adminpassword=${adminpassword}\?port=${port}\?queryport=${queryport} -seekfreeloadingserver" +parms="aocffa-moor_p\?steamsockets\?adminpassword=${adminpassword}\?port=${port}\?queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog} -seekfreeloadingserver" } #### LinuxGSM Settings #### @@ -121,6 +121,7 @@ emaillog="${scriptlogdir}/${servicename}-email.log" ## Logs Naming scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" +gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%Y-%m-%d-%H:%M:%S').log" ######################## ######## Script ######## From ec30a155cef3f6e1d695c94654dc2f0095e74823 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 06:41:47 +0100 Subject: [PATCH 15/46] New default ports & password through cfg file --- ChivalryMedievalWarfare/chivalrymwserver | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver index fab972b91..6fd0d8ff0 100644 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ b/ChivalryMedievalWarfare/chivalrymwserver @@ -24,13 +24,12 @@ version="170219" ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters ip="0.0.0.0" -port="7000" -queryport="7010" -adminpassword="CHANGE_ME" +port="7777" +queryport="27960" ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters fn_parms(){ -parms="aocffa-moor_p\?steamsockets\?adminpassword=${adminpassword}\?port=${port}\?queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog} -seekfreeloadingserver" +parms="aocffa-moor_p\?steamsockets\?port=${port}\?queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog} -seekfreeloadingserver" } #### LinuxGSM Settings #### From ac0390719f940ba989fb9a5af7ae1986cd611fdf Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 19:17:57 +0100 Subject: [PATCH 16/46] fit changes to master --- lgsm/functions/install_logs.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index 2019fdb13..3feb0feea 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -14,7 +14,7 @@ if [ "${checklogs}" != "1" ]; then echo "=================================" fi sleep 1 -# Create dir's for the script and console logs +# Create script and console log directories mkdir -v "${rootdir}/log" mkdir -v "${scriptlogdir}" touch "${scriptlog}" @@ -23,23 +23,23 @@ if [ -n "${consolelogdir}" ]; then touch "${consolelog}" fi -# If a server is source or goldsource, TeamSpeak 3, Starbound, Project Zomhoid create a symbolic link to the game server logs. -if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ]||[ "${engine}" == "unreal" ]; then +# Create gamelogdir if variable exists but directory does not +if [ -n "${gamelogdir}" ]&&[ ! -d "${gamelogdir}" ]; then + mkdir -pv "${gamelogdir}" +fi + +# Symlink gamelogdir to lgsm logs if variable exists +if [ -n "${gamelogdir}" ]; then if [ ! -h "${rootdir}/log/server" ]; then ln -nfsv "${gamelogdir}" "${rootdir}/log/server" fi fi -# If a server is unreal2 or unity3d create a dir. -if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" == "Teeworlds" ]||[ "${gamename}" == "seriousengine35" ]; then - mkdir -pv "${gamelogdir}" -fi - -# If server uses SteamCMD create a symbolic link to the Steam logs. +# If server uses SteamCMD create a symbolic link to the Steam logs if [ -d "${rootdir}/Steam/logs" ]; then if [ ! -h "${rootdir}/log/steamcmd" ]; then ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd" fi fi sleep 1 -fn_script_log_info "Logs installed" \ No newline at end of file +fn_script_log_info "Logs installed" From 0c94a78f908228984f3448ee68feb776fea7850c Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 19:18:23 +0100 Subject: [PATCH 17/46] Fit changes to master --- lgsm/functions/command_console.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 98ddcae11..0a93a94fb 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -16,7 +16,6 @@ echo "" if ! fn_prompt_yn "Continue?" Y; then echo Exiting; return fi -done fn_print_dots "Accessing console" sleep 1 check_status.sh From 418fb6b9ea19870e03737b901a32b6228c2e0e19 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 19:55:21 +0100 Subject: [PATCH 18/46] allow addons clear + more logic output --- lgsm/functions/command_fastdl.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 2c12ded38..8a02f90a4 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -117,10 +117,10 @@ fn_fastdl_config(){ if [ "${gamename}" == "Garry's Mod" ]&&[ "${bzip2enable}" == "on" ]; then # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod fn_print_dots - if fn_prompt_yn "Keep original uncompressed FastDL files?" N; then - clearnonbzip2="off"; fn_script_log "Original uncompressed fastDL files will be kept."; fn_print_ok "Original uncompressed fastDL files will be kept" + if fn_prompt_yn "Clear non-bzip2 FastDL files?" Y; then + clearnonbzip2="on"; fn_script_log "Clearing non-bzip2 files Enabled."; fn_print_ok "Clearing non-bzip2 files Enabled" else - clearnonbzip2="on"; fn_script_log "Original uncompressed fastDL files won't be kept."; fn_print_ok "Original uncompressed fastDL files won't be kept" + clearnonbzip2="off"; fn_script_log "Clearing non-bzip2 files Disabled."; fn_print_ok "Clearing non-bzip2 files Disabled" fi echo -en "\n" else @@ -131,12 +131,18 @@ fn_fastdl_config(){ fi # Garry's Mod Specific if [ "${gamename}" == "Garry's Mod" ]; then + if fn_prompt_yn "Clear addons dir from fastdl dir?" Y; then + cleargmodaddons="on"; fn_script_log "Addons clearing Enabled."; fn_print_ok "Addons clearing Enabled" + else + cleargmodaddons="off"; fn_script_log "Addons clearing Disabled."; fn_print_ok "Addons clearing Disabled" + fi + echo -en "\n" # Prompt for download enforcer, which is using a .lua addfile resource generator fn_print_dots if fn_prompt_yn "Use client download enforcer?" Y; then - luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled" + luaressource="on"; fn_script_log "DL enforcer Enabled."; fn_print_ok "Enforcer Enabled" else - luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled" + luaressource="off"; fn_script_log "DL enforcer Disabled."; fn_print_ok "Enforcer Disabled" fi echo -en "\n" fi @@ -239,10 +245,19 @@ fn_fastdl_gmod(){ fn_script_log "Adjusting addons' file structure" sleep 1 cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" - # Don't remove yet rm -R "${fastdldir:?}/addons" fn_print_ok "Adjusted addons' file structure" sleep 1 echo -en "\n" + # Clear addons directory in fastdl + if [ "${cleargmodaddons}" == "on" ]; then + fn_print_info "Clearing addons dir from fastdl dir" + fn_script_log "Clearing addons dir from fastdl dir" + sleep 1 + rm -R "${fastdldir:?}/addons" + fn_print_ok "Cleared addons dir from fastdl dir" + sleep 1 + echo -en "\n" + fi fi # Correct content that may be into a lua directory by mistake like some darkrpmodification addons From 184396a5ebc333218c0580f00cfdf0d66e14a9d2 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 19:58:59 +0100 Subject: [PATCH 19/46] print dots --- lgsm/functions/command_fastdl.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 8a02f90a4..5d20df759 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -131,6 +131,8 @@ fn_fastdl_config(){ fi # Garry's Mod Specific if [ "${gamename}" == "Garry's Mod" ]; then + # Prompt to clear addons dir from fastdl, can use unnecessary space or be required depending on addon's file structures + fn_print_dots if fn_prompt_yn "Clear addons dir from fastdl dir?" Y; then cleargmodaddons="on"; fn_script_log "Addons clearing Enabled."; fn_print_ok "Addons clearing Enabled" else From b6a708fcd97c54c5a6bb6c54e27002f0ae3b900a Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 23:34:52 +0100 Subject: [PATCH 20/46] Attempt for new op --- lgsm/functions/core_getopt.sh | 1090 ++++----------------------------- 1 file changed, 128 insertions(+), 962 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 1d91f9bc8..f87b55a0e 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -6,980 +6,146 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_getopt_generic(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.sh;; - uf|update-functions) - command_update_functions.sh;; - v|validate) - command_validate.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;; - fd|fastdl) - command_fastdl.sh;; - mi|mods-install) - command_mods_install.sh;; - mu|mods-update) - command_mods_update.sh;; - mr|mods-remove) - command_mods_remove.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." - echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." - echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." - 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." - echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL directory for your server." - echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." - echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." - echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." - } | column -s $'\t' -t - esac -} - -fn_getopt_generic_update_no_steam(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.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;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates." - 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 -} - -fn_getopt_generic_no_update(){ -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;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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 infomation 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 -} - -fn_getopt_teamspeak3(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.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;; - pw|change-password) - command_ts3_server_pass.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;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from teamspeak.com." - 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}change-password\t${default}pw |Changes TS3 serveradmin password." - echo -e "${blue}backup\t${default}b |Create archive of the server." - 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 -} - -fn_getopt_minecraft(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.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;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from mojang.com." - 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 infomation 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 -} - -fn_getopt_mta(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.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;; - ir|install-default-resources) - command_install_resources_mta.sh;; - ai|auto-install) - fn_autoinstall;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from linux.mtasa.com." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from linux.mtasa.com." - 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 infomation 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." - echo -e "${blue}install-default-resources\t${default}ir |Install the MTA default resources." - } | column -s $'\t' -t - esac -} - -fn_getopt_mumble(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.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;; - dev|dev-debug) - command_dev_debug.sh;; - c|console) - command_console.sh;; - i|install) - command_install.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from GitHub." - 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}debug\t${default}d |See the output of the server directly to your terminal." - echo -e "${blue}install\t${default}i |Install the server." - } | column -s $'\t' -t - esac -} - -fn_getopt_dstserver(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.sh;; - uf|update-functions) - command_update_functions.sh;; - v|validate) - command_validate.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;; - ct|cluster-token) - install_dst_token.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." - echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." - echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." - 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." - echo -e "${blue}cluster-token\t${default}ct |Configure cluster token." - } | column -s $'\t' -t - esac -} - -fn_getopt_gmodserver(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.sh;; - uf|update-functions) - command_update_functions.sh;; - v|validate) - command_validate.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;; - fd|fastdl) - command_fastdl.sh;; - mi|mods-install) - command_mods_install.sh;; - mu|mods-update) - command_mods_update.sh;; - mr|mods-remove) - command_mods_remove.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." - echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." - echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." - 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}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." - echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL directory for your server." - echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." - echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." - echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." - } | column -s $'\t' -t - esac -} - -fn_getopt_rustserver(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.sh;; - uf|update-functions) - command_update_functions.sh;; - v|validate) - command_validate.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;; - mi|mods-install) - command_mods_install.sh;; - mu|mods-update) - command_mods_update.sh;; - mr|mods-remove) - command_mods_remove.sh;; - wi|wipe) - command_wipe.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." - echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." - echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." - 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." - echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." - echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." - echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." - echo -e "${blue}wipe\t${default}wi |Wipe your Rust server." - } | column -s $'\t' -t - esac -} - -fn_getopt_unreal(){ -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;; - 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;; - mc|map-compressor) - compress_ut99_maps.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.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}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." - echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." - } | column -s $'\t' -t - esac -} +### Define all commands here ### +## User commands | Trigger commands | Description +# Standard commands +cmd_install=( "i;install" "command_install.sh" "Install the server." ) +cmd_auto_install=( "ai;auto-install" "command_autoinstall.sh" "Install the server without prompts." ) +cmd_start=( "st;start" "command_start.sh" "Start the server." ) +cmd_stop=( "sp;stop" "command_stop.sh" "Stop the server." ) +cmd_restart=( "r;restart" "command_restart.sh" "Restart the server." ) +cmd_details=( "dt;details" "command_details.sh" "Display relevant server information." ) +cmd_postdetails=( "pd;postdetails" "command_postdetails.sh" "Post stripped details to pastebin for support." ) +cmd_backup=( "b;backup;" "command_backup.sh" "Create archives of the server." ) +cmd_update_functions=( "uf;update-functions" "command_update_functions.sh" "Update LinuxGSM functions." ) +cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." ) +cmd_monitor=( "m;monitor" "command_monitor.sh" "Check server status and restart it if crashed." ) +# Console servers only +cmd_console=( "c;console" "command_console.sh" "Access server console." ) +cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." ) +# Update servers only +cmd_update=( "u;update" "command_update.sh" "Check for updates and apply if available." ) +cmd_force_update=( "fu;force-update;update-restart;ur" "forceupdate=1; command_update.sh" "Unconditionally update the server." ) +# SteamCMD servers only +cmd_validate=( "v;validate" "command_validate.sh" "Validate server files with SteamCMD." ) +# Server with mods-install +cmd_mods_install=( "mi;mods-install" "command_mods_install.sh" "View and install available mods/addons." ) +cmd_mods_remove=( "mr;mods-remove" "command_mods_remove.sh" "View and remove an installed mod/addon." ) +cmd_mods_update=( "mu;mods-update" "command_mods_update.sh" "Update installed mods/addons." ) +# Server specific +cmd_change_password=( "pw;change-password" "command_ts3_server_pass.sh" "Change TS3 serveradmin password." ) +cmd_install_default_ressources=( "ir;install-default-ressources" "command_install_resources_mta.sh" "Install the MTA default resources." ) +cmd_wipe=( "wi;wipe" "command_wipe.sh" "Wipe your server data." ) +cmd_map_compressor_u99=( "mc;map-compressor" "compress_ut99_maps.sh" "Compresses all ${gamename} server maps." ) +cmd_map_compressor_u2=( "mc;map-compressor" "compress_unreal2_maps.sh" "Compresses all ${gamename} server maps." ) +cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server cd key." ) +cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) +# Dev commands +cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "Detect server dependencies." ) +cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect server glibc requirements." ) +cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "Detect server ldd requirements." ) + +### Set specific opt here ### + +## Common opt to all servers + +currentopt=( "${cmd_install[@]}" "${cmd_auto_install[@]}" "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_details[@]}" ) +currentopt+=( "${cmd_backup[@]}" "${cmd_update_functions[@]}" "${cmd_test_alert[@]}" "${cmd_monitor[@]}" ) + +## Servers that do not have a feature + +# Exclude games without a console +if [ "${gamename}" != "TeamSpeak 3" ]; then + currentopt+=( "${cmd_console[@]}" ) +fi +# Exclude noupdated games here +if [ "${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 + currentopt+=( "${cmd_update[@]}" ) +fi +## Include games that have access to specific commands +# Validate command +if [ -n "${appid}" ]; then + currentopt+=( "${cmd_validate[@]}" ) +fi +# FastDL command +if [ "${engine}" == "source" ]; then + currentopt+=( "${cmd_fastdl[@]}" ) +fi +# Wipe command +if [ "${gamename}" == "Rust" ]; then + currentopt+=( "${cmd_wipe[@]}" ) +fi +# Mods commands +if [ "${engine}" == "source" ]||[ "${gamename}" == "Rust" ]|[ "${gamename}" == "Hurtworld" ]|[ "${gamename}" == "7 Days To Die" ]; then + currentopt+=( "${cmd_mods_install[@]}" "${cmd_mods_remove[@]}" "${cmd_mods_update[@]}" ) +fi -fn_getopt_unreal2(){ -case "${getopt}" in - st|start) - command_start.sh;; - sp|stop) - command_stop.sh;; - r|restart) - command_restart.sh;; - u|update) - command_update.sh;; - fu|force-update|update-restart) - forceupdate=1; - command_update.sh;; - uf|update-functions) - command_update_functions.sh;; - v|validate) - command_validate.sh;; - m|monitor) - command_monitor.sh;; - ta|test-alert) - command_test_alert.sh;; - dt|details) - command_details.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;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.sh;; - mc|map-compressor) - compress_unreal2_maps.sh;; - *) - if [ -n "${getopt}" ]; then - echo -e "${red}Unknown command${default}: $0 ${getopt}" - exitcode=2 +## Game server exclusive commands +# TeamSpeak exclusive +if [ "${gamename}" == "TeamSpeak 3" ]; then + currentopt+=( "${cmd_change_password[@]}" ) +fi +# Unreal exclusive +if [ "${engine}" == "unreal2" ]; then + if [ "${gamename}" == "Unreal Tournament 2004" ]; then + currentopt+=( "${cmd_install_cdkey[@]}" "${cmd_map_compressor_u2[@]}" ) + else + currentopt+=( "${cmd_map_compressor_u2[@]}" ) 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\t${default}Checks and applies updates from SteamCMD." - echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." - echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." - echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." - 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}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." - echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." - } | column -s $'\t' -t - esac -} +fi +if [ "${engine}" == "unreal" ]; then + currentopt+=( "${cmd_map_compressor_u99[@]}" ) +fi +# DST exclusive +if [ "${gamename}" == "Don't Starve Together" ]; then + currentopt+=( "${cmd_install_dst_token[@]}" ) +fi +# MTA exclusive +if [ "${gamename}" == "Multi Theft Auto" ]; then + currentopt+=( "${cmd_install_default_ressources[@]}" ) +fi -fn_getopt_ut2k4(){ -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;; - 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;; - cd|server-cd-key) - install_ut2k4_key.sh;; - mc|map-compressor) - compress_unreal2_maps.sh;; - dd|detect-deps) - command_dev_detect_deps.sh;; - dg|detect-glibc) - command_dev_detect_glibc.sh;; - dl|detect-ldd) - command_dev_detect_ldd.sh;; - *) - if [ -n "${getopt}" ]; then - echo -e "${red}Unknown command${default}: $0 ${getopt}" - exitcode=2 - fi +### Build list of available commands +optcommands=() +index="0" +for ((index="0"; index <= ${#currentopt[@]}; index+3)); do + cmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" + for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do + optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' '{ print $cmdindex }')" ) + done +done + +### Check if user command exists or run the command +if [ ! " ${optcommands[@]} " =~ "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" echo -e "${lightyellow}Commands${default}" + # Display available commands + index="0" { - 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}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." - echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key" - echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." + for ((index="0"; index <= ${#currentopt[@]}; index++)); do + echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }') |"${currentopt[index+2]}" + done } | column -s $'\t' -t - esac -} - -# Don't Starve Together -if [ "${gamename}" == "Don't Starve Together" ]; then - fn_getopt_dstserver -# Garry's Mod -elif [ "${gamename}" == "Garry's Mod" ]; then - fn_getopt_gmodserver -# Minecraft -elif [ "${engine}" == "lwjgl2" ]; then - fn_getopt_minecraft -# Multi Theft Auto -elif [ "${gamename}" == "Multi Theft Auto" ]; then - fn_getopt_mta -# Mumble -elif [ "${gamename}" == "Mumble" ]; then - fn_getopt_mumble -# Teamspeak 3 -elif [ "${gamename}" == "TeamSpeak 3" ]; then - fn_getopt_teamspeak3 -elif [ "${gamename}" == "Rust" ]; then - fn_getopt_rustserver -# Unreal 2 Engine -elif [ "${engine}" == "unreal2" ]; then - if [ "${gamename}" == "Unreal Tournament 2004" ]; then - fn_getopt_ut2k4 - else - fn_getopt_unreal2 - fi -# Unreal Engine -elif [ "${engine}" == "unreal" ]; then - fn_getopt_unreal -# Generic -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 - fn_getopt_generic_no_update -elif [ "${gamename}" == "Factorio" ]; then - fn_getopt_generic_update_no_steam else - fn_getopt_generic + # Seek and run command + index="0" + for ((index="0"; index <= ${#currentopt[@]}; index+3)); do + currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" + for ((currcmdindex=1; cmdindex <= ${currcmdamount}; currcmdindex++)); do + if [ "$(echo "${currentopt[index]}"| awk -F ';' '{ print $cmdindex }')" == "${getopt}" ]; then + # Run command + ${currentopt[index+1]} + break + fi + done + done fi + core_exit.sh From 2dc25226ed7592b0fd6ad7ab29ef0ca3caee2f20 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Mon, 20 Feb 2017 23:40:58 +0100 Subject: [PATCH 21/46] new opt test --- lgsm/functions/core_getopt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index f87b55a0e..94024ff79 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -118,7 +118,7 @@ for ((index="0"; index <= ${#currentopt[@]}; index+3)); do done ### Check if user command exists or run the command -if [ ! " ${optcommands[@]} " =~ "${getopt}" ]; then +if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 echo "Usage: $0 [option]" @@ -130,7 +130,7 @@ if [ ! " ${optcommands[@]} " =~ "${getopt}" ]; then index="0" { for ((index="0"; index <= ${#currentopt[@]}; index++)); do - echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }') |"${currentopt[index+2]}" + echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }') |${currentopt[index+2]}" done } | column -s $'\t' -t else From 75547557a8a4e8085a3556de5df16abeaf43ba99 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 00:29:17 +0100 Subject: [PATCH 22/46] fixing awk, probably not infinite loop --- lgsm/functions/core_getopt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 94024ff79..ad5ee730d 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -113,7 +113,7 @@ index="0" for ((index="0"; index <= ${#currentopt[@]}; index+3)); do cmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do - optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' '{ print $cmdindex }')" ) + optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" ) done done @@ -139,7 +139,7 @@ else for ((index="0"; index <= ${#currentopt[@]}; index+3)); do currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" for ((currcmdindex=1; cmdindex <= ${currcmdamount}; currcmdindex++)); do - if [ "$(echo "${currentopt[index]}"| awk -F ';' '{ print $cmdindex }')" == "${getopt}" ]; then + if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" == "${getopt}" ]; then # Run command ${currentopt[index+1]} break From 1be3076dba3fcd9f7ffd5ea77127db277022190e Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 00:41:14 +0100 Subject: [PATCH 23/46] first loop fixes --- lgsm/functions/core_getopt.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index ad5ee730d..9a2695c86 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -110,9 +110,9 @@ fi ### Build list of available commands optcommands=() index="0" -for ((index="0"; index <= ${#currentopt[@]}; index+3)); do +for ((index="0"; index < ${#currentopt[@]}; index+=3)); do cmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do + for ((cmdindex=1; cmdindex < ${cmdamount}; cmdindex++)); do optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" ) done done @@ -136,9 +136,9 @@ if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then else # Seek and run command index="0" - for ((index="0"; index <= ${#currentopt[@]}; index+3)); do + for ((index="0"; index < ${#currentopt[@]}; index+=3)); do currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((currcmdindex=1; cmdindex <= ${currcmdamount}; currcmdindex++)); do + for ((currcmdindex=1; cmdindex < ${currcmdamount}; currcmdindex++)); do if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" == "${getopt}" ]; then # Run command ${currentopt[index+1]} From d125a72b0732ed3b457f2edcfcf249ea06151986 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 00:58:14 +0100 Subject: [PATCH 24/46] fix --- lgsm/functions/core_getopt.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 9a2695c86..c651f105d 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -16,7 +16,7 @@ cmd_stop=( "sp;stop" "command_stop.sh" "Stop the server." ) cmd_restart=( "r;restart" "command_restart.sh" "Restart the server." ) cmd_details=( "dt;details" "command_details.sh" "Display relevant server information." ) cmd_postdetails=( "pd;postdetails" "command_postdetails.sh" "Post stripped details to pastebin for support." ) -cmd_backup=( "b;backup;" "command_backup.sh" "Create archives of the server." ) +cmd_backup=( "b;backup" "command_backup.sh" "Create archives of the server." ) cmd_update_functions=( "uf;update-functions" "command_update_functions.sh" "Update LinuxGSM functions." ) cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." ) cmd_monitor=( "m;monitor" "command_monitor.sh" "Check server status and restart it if crashed." ) @@ -112,16 +112,18 @@ optcommands=() index="0" for ((index="0"; index < ${#currentopt[@]}; index+=3)); do cmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((cmdindex=1; cmdindex < ${cmdamount}; cmdindex++)); do + for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" ) done done ### Check if user command exists or run the command -if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then - echo -e "${red}Unknown command${default}: $0 ${getopt}" - exitcode=2 - echo "Usage: $0 [option]" +if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]||[ -z "${getopt}" ]; then + if [ -z "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 + echo "Usage: $0 [option]" + fi echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" @@ -129,7 +131,7 @@ if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then # Display available commands index="0" { - for ((index="0"; index <= ${#currentopt[@]}; index++)); do + for ((index="0"; index <= ${#currentopt[@]}; index+=3)); do echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }') |${currentopt[index+2]}" done } | column -s $'\t' -t From 3cafcc0e684a2a3f58cd6b825f697243fa3dbe21 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 01:11:07 +0100 Subject: [PATCH 25/46] fixes --- lgsm/functions/core_getopt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index c651f105d..22adbb52d 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -131,8 +131,8 @@ if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]||[ -z "${getopt}" ]; then # Display available commands index="0" { - for ((index="0"; index <= ${#currentopt[@]}; index+=3)); do - echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }') |${currentopt[index+2]}" + for ((index="0"; index < ${#currentopt[@]}; index+=3)); do + echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t|${currentopt[index+2]}" done } | column -s $'\t' -t else @@ -141,7 +141,7 @@ else for ((index="0"; index < ${#currentopt[@]}; index+=3)); do currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" for ((currcmdindex=1; cmdindex < ${currcmdamount}; currcmdindex++)); do - if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" == "${getopt}" ]; then + if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then # Run command ${currentopt[index+1]} break From cfc5bf75fc19eff39c6c3afabffb1cc3462deb17 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 01:16:42 +0100 Subject: [PATCH 26/46] fixes --- lgsm/functions/core_getopt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 22adbb52d..6b230b5f8 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -118,8 +118,8 @@ for ((index="0"; index < ${#currentopt[@]}; index+=3)); do done ### Check if user command exists or run the command -if [[ ! "${optcommands[@]}" =~ "${getopt}" ]]||[ -z "${getopt}" ]; then - if [ -z "${getopt}" ]; then +if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then + if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 echo "Usage: $0 [option]" @@ -140,7 +140,7 @@ else index="0" for ((index="0"; index < ${#currentopt[@]}; index+=3)); do currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((currcmdindex=1; cmdindex < ${currcmdamount}; currcmdindex++)); do + for ((currcmdindex=1; currcmdindex < ${currcmdamount}; currcmdindex++)); do if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then # Run command ${currentopt[index+1]} From 007a373d5d7205a30fcdfe29e90b87101b22849b Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 01:19:11 +0100 Subject: [PATCH 27/46] appearance --- lgsm/functions/core_getopt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 6b230b5f8..7e02b584a 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -122,17 +122,17 @@ if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then if [ -n "${getopt}" ]; then echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 - echo "Usage: $0 [option]" fi echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" + echo "Usage: $0 [option]" echo -e "" echo -e "${lightyellow}Commands${default}" # Display available commands index="0" { for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - echo -e "${blue}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t|${currentopt[index+2]}" + echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t|${currentopt[index+2]}" done } | column -s $'\t' -t else From 021a86c737b925f8e412214d8e1ecf7ad882235b Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 01:35:21 +0100 Subject: [PATCH 28/46] missing commands --- lgsm/functions/core_getopt.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 7e02b584a..884a0f9c9 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -40,6 +40,7 @@ cmd_map_compressor_u99=( "mc;map-compressor" "compress_ut99_maps.sh" "Compresses cmd_map_compressor_u2=( "mc;map-compressor" "compress_unreal2_maps.sh" "Compresses all ${gamename} server maps." ) cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server cd key." ) cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) +cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." # Dev commands cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "Detect server dependencies." ) cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect server glibc requirements." ) @@ -56,11 +57,11 @@ currentopt+=( "${cmd_backup[@]}" "${cmd_update_functions[@]}" "${cmd_test_alert[ # Exclude games without a console if [ "${gamename}" != "TeamSpeak 3" ]; then - currentopt+=( "${cmd_console[@]}" ) + currentopt+=( "${cmd_console[@]}" "${cmd_debug[@]}" ) fi # Exclude noupdated games here if [ "${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 - currentopt+=( "${cmd_update[@]}" ) + currentopt+=( "${cmd_update[@]}" "${cmd_force_update[@]}") fi ## Include games that have access to specific commands @@ -123,9 +124,9 @@ if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${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 "Usage: $0 [option]" echo -e "" echo -e "${lightyellow}Commands${default}" # Display available commands From b9162f1c69079d4508f710a3c4f9f5529351940d Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 01:36:30 +0100 Subject: [PATCH 29/46] hm ) --- lgsm/functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 884a0f9c9..914ab0790 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -40,7 +40,7 @@ cmd_map_compressor_u99=( "mc;map-compressor" "compress_ut99_maps.sh" "Compresses cmd_map_compressor_u2=( "mc;map-compressor" "compress_unreal2_maps.sh" "Compresses all ${gamename} server maps." ) cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server cd key." ) cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) -cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." +cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." ) # Dev commands cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "Detect server dependencies." ) cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect server glibc requirements." ) From edf5b787a941699620d40e79a291cfb8446ab4bf Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 02:36:08 +0100 Subject: [PATCH 30/46] fix for full commands to work --- lgsm/functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 914ab0790..52f72dfaa 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -141,7 +141,7 @@ else index="0" for ((index="0"; index < ${#currentopt[@]}; index+=3)); do currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((currcmdindex=1; currcmdindex < ${currcmdamount}; currcmdindex++)); do + for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then # Run command ${currentopt[index+1]} From 6e8afb5e2a01b0545eb19b1330def039a6dd3ef0 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 02:53:09 +0100 Subject: [PATCH 31/46] dev commands --- lgsm/functions/core_getopt.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 52f72dfaa..a8374493f 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -42,9 +42,10 @@ cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server c cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." ) # Dev commands -cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "Detect server dependencies." ) -cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect server glibc requirements." ) -cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "Detect server ldd requirements." ) +cmd_dev_debug=( "dev;dev-debug" "command_dev_debug.sh" "DEVCOMMAND" +cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "DEVCOMMAND" ) +cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "DEVCOMMAND" ) +cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "DEVCOMMAND" ) ### Set specific opt here ### @@ -107,6 +108,9 @@ if [ "${gamename}" == "Multi Theft Auto" ]; then currentopt+=( "${cmd_install_default_ressources[@]}" ) fi +## Developer commands +currentopt+=( "${cmd_dev_debug[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" ) + ### Build list of available commands optcommands=() @@ -133,7 +137,10 @@ if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then index="0" { for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t|${currentopt[index+2]}" + # Hide developer commands + if [ "${currentopt[index+3]}" != "DEVCOMMAND" ]; then + echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t| ${currentopt[index+2]}" + fi done } | column -s $'\t' -t else From 73be10ffa08ab3ba04519724e4740f263ecac257 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 02:54:22 +0100 Subject: [PATCH 32/46] typo + missing ) --- lgsm/functions/core_getopt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index a8374493f..a8ddc89b0 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -42,8 +42,8 @@ cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server c cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." ) # Dev commands -cmd_dev_debug=( "dev;dev-debug" "command_dev_debug.sh" "DEVCOMMAND" -cmd_dev_detect_deps=( "dd;detect-depts" "command_dev_detect_deps.sh" "DEVCOMMAND" ) +cmd_dev_debug=( "dev;dev-debug" "command_dev_debug.sh" "DEVCOMMAND" ) +cmd_dev_detect_deps=( "dd;detect-deps" "command_dev_detect_deps.sh" "DEVCOMMAND" ) cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "DEVCOMMAND" ) cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "DEVCOMMAND" ) From a49de6bcbd878e3233b5026cfa4efe54da1527e5 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 03:21:05 +0100 Subject: [PATCH 33/46] new algorithm to find commands --- lgsm/functions/core_getopt.sh | 51 ++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index a8ddc89b0..55f4c3beb 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -122,13 +122,10 @@ for ((index="0"; index < ${#currentopt[@]}; index+=3)); do done done -### Check if user command exists or run the command -if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then - if [ -n "${getopt}" ]; then - echo -e "${red}Unknown command${default}: $0 ${getopt}" - exitcode=2 - fi +# Shows LinuxGSM usage +fn_opt_usage(){ echo "Usage: $0 [option]" + echo -e "" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" @@ -143,19 +140,35 @@ if [ -z "${getopt}" ]||[[ ! "${optcommands[@]}" =~ "${getopt}" ]]; then fi done } | column -s $'\t' -t -else - # Seek and run command - index="0" - for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do - if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then - # Run command - ${currentopt[index+1]} - break - fi - done - done + core_exit.sh +} + +### Check if user commands exist and run corresponding scripts, or display script usage +if [ -z "${getopt}" ]; then + fn_opt_usage fi +# Command exists +for i in "${optcommands[@]}"; do + if [ "${i}" == "${getopt}" ] ; then + # Seek and run command + index="0" + for ((index="0"; index < ${#currentopt[@]}; index+=3)); do + currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" + for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do + if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then + # Run command + ${currentopt[index+1]} + break + fi + done + done + break + core_exit.sh + fi +done +# If we're executing this, it means command was not found +echo -e "${red}Unknown command${default}: $0 ${getopt}" +exitcode=2 +fn_opt_usage core_exit.sh From f126f52de9e83918b8066351b7d91e08586d2ed2 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 21 Feb 2017 03:23:50 +0100 Subject: [PATCH 34/46] hide "DEVCOMMAND" description commands --- lgsm/functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 55f4c3beb..78b097398 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -135,7 +135,7 @@ fn_opt_usage(){ { for ((index="0"; index < ${#currentopt[@]}; index+=3)); do # Hide developer commands - if [ "${currentopt[index+3]}" != "DEVCOMMAND" ]; then + if [ "${currentopt[index+2]}" != "DEVCOMMAND" ]; then echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t| ${currentopt[index+2]}" fi done From 9b62ec9fd454e9b62ced634bd0650657eec6f91f Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Wed, 22 Feb 2017 18:06:38 +0100 Subject: [PATCH 35/46] Removed chivalry for now --- ChivalryMedievalWarfare/chivalrymwserver | 199 ----------------------- 1 file changed, 199 deletions(-) delete mode 100644 ChivalryMedievalWarfare/chivalrymwserver diff --git a/ChivalryMedievalWarfare/chivalrymwserver b/ChivalryMedievalWarfare/chivalrymwserver deleted file mode 100644 index 6fd0d8ff0..000000000 --- a/ChivalryMedievalWarfare/chivalrymwserver +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/bash -# Project: Game Server Managers - LinuxGSM -# Author: Daniel Gibbs -# License: MIT License, Copyright (c) 2017 Daniel Gibbs -# Purpose: Chivalry: Medieval Warfare | Server Management Script -# Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors -# Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki -# Website: https://gameservermanagers.com - -# Debugging -if [ -f ".dev-debug" ]; then - exec 5>dev-debug.log - BASH_XTRACEFD="5" - set -x -fi - -version="170219" - -########################## -######## Settings ######## -########################## - -#### Server Settings #### - -## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters -ip="0.0.0.0" -port="7777" -queryport="27960" - -## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters -fn_parms(){ -parms="aocffa-moor_p\?steamsockets\?port=${port}\?queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog} -seekfreeloadingserver" -} - -#### LinuxGSM Settings #### - -## Notification Alerts -# (on|off) -# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email -emailalert="off" -email="email@example.com" -emailfrom="" - -# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet -pushbulletalert="off" -pushbullettoken="accesstoken" -channeltag="" - -## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update -updateonstart="off" - -## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup -maxbackups="4" -maxbackupdays="30" -stoponbackup="on" - -## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging -consolelogging="on" -logdays="7" - -#### LinuxGSM Advanced Settings #### - -## SteamCMD Settings -# Server appid -appid="220070" -# Steam App Branch Select -# Allows to opt into the various Steam app branches. Default branch is "". -# Example: "-beta latest_experimental" -branch="" - -## Github Branch Select -# Allows for the use of different function files -# from a different repo and/or branch. -githubuser="GameServerManagers" -githubrepo="LinuxGSM" -githubbranch="master" - -## LinuxGSM Server Details -# Do not edit -gamename="Chivalry: Medieval Warfare" -engine="unreal3" - -## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers -servicename="chivalrymw-server" - -#### Directories #### -# Edit with care - -## Work Directories -rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" -selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -lockselfname=".${servicename}.lock" -lgsmdir="${rootdir}/lgsm" -functionsdir="${lgsmdir}/functions" -libdir="${lgsmdir}/lib" -tmpdir="${lgsmdir}/tmp" -filesdir="${rootdir}/serverfiles" - -## Server Specific Directories -systemdir="${filesdir}" -executabledir="${filesdir}/Binaries/Linux/" -executable="./UDKGameServer-Linux" -servercfg="PCServer-UDKGame.ini" -servercfgdefault="PCServer-UDKGame.ini" -servercfgdir="${systemdir}/UDKGame/Config" -servercfgfullpath="${servercfgdir}/${servercfg}" - -## Backup Directory -backupdir="${rootdir}/backups" - -## Logging Directories -gamelogdir="${rootdir}/log/server" -scriptlogdir="${rootdir}/log/script" -consolelogdir="${rootdir}/log/console" -gamelog="${gamelogdir}/${servicename}-game.log" -scriptlog="${scriptlogdir}/${servicename}-script.log" -consolelog="${consolelogdir}/${servicename}-console.log" -emaillog="${scriptlogdir}/${servicename}-email.log" - -## Logs Naming -scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" -consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" -gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%Y-%m-%d-%H:%M:%S').log" - -######################## -######## Script ######## -###### Do not edit ##### -######################## - -# Fetches core_dl for file downloads -fn_fetch_core_dl(){ -github_file_url_dir="lgsm/functions" -github_file_url_name="${functionfile}" -filedir="${functionsdir}" -filename="${github_file_url_name}" -githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" -# If the file is missing, then download -if [ ! -f "${filedir}/${filename}" ]; then - if [ ! -d "${filedir}" ]; then - mkdir -p "${filedir}" - fi - echo -e " fetching ${filename}...\c" - # Check curl exists and use available path - curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" - for curlcmd in ${curlpaths} - do - if [ -x "${curlcmd}" ]; then - break - fi - done - # If curl exists download file - if [ "$(basename ${curlcmd})" == "curl" ]; then - curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curlfetch}" - echo -e "${githuburl}\n" - exit 1 - else - echo -e "\e[0;32mOK\e[0m" - fi - else - echo -e "\e[0;31mFAIL\e[0m\n" - echo "Curl is not installed!" - echo -e "" - exit 1 - fi - chmod +x "${filedir}/${filename}" -fi -source "${filedir}/${filename}" -} - -core_dl.sh(){ -# Functions are defined in core_functions.sh. -functionfile="${FUNCNAME}" -fn_fetch_core_dl -} - -core_functions.sh(){ -# Functions are defined in core_functions.sh. -functionfile="${FUNCNAME}" -fn_fetch_core_dl -} - -# Prevent from running this script as root. -if [ "$(whoami)" = "root" ]; then - if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then - echo "[ FAIL ] Do NOT run this script as root!" - exit 1 - else - core_functions.sh - check_root.sh - fi -fi - -core_dl.sh -core_functions.sh -getopt=$1 -core_getopt.sh From 3f9eeb42192993f221b8a16fd4add7fd43b09d54 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 02:55:40 +0100 Subject: [PATCH 36/46] Slight improvement to Rust Wipe feature More safety with rm -r "${var:?}" instead of rm -r "${var}" even though there is an if [ -d "${var}" ] check before And now also removes map file, not only map save. --- lgsm/functions/command_wipe.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_wipe.sh b/lgsm/functions/command_wipe.sh index 67ea65164..27ccfbf2f 100644 --- a/lgsm/functions/command_wipe.sh +++ b/lgsm/functions/command_wipe.sh @@ -45,11 +45,24 @@ fn_wipe_server_remove_files(){ # Rust Wipe if [ "${gamename}" == "Rust" ]; then if [ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.sav")" ]; then - currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.sav" - echo -en "Removing map proceduralmap.*.sav file(s)..." + currentaction="Removing map save(s): ${serveridentitydir}/proceduralmap.*.sav" + echo -en "Removing map saves proceduralmap.*.sav file(s)..." sleep 1 fn_script_log "${currentaction}" - find "${serveridentitydir}" -type f -name "proceduralmap.*.sav" -delete + find "${serveridentitydir:?}" -type f -name "proceduralmap.*.sav" -delete + fn_wipe_exit_code + sleep 0.5 + else + fn_print_information_nl "No map save to remove" + fn_script_log_info "No map save to remove." + sleep 0.5 + fi + if [ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.map")" ]; then + currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.map" + echo -en "Removing map proceduralmap.*.map file(s)..." + sleep 1 + fn_script_log "${currentaction}" + find "${serveridentitydir:?}" -type f -name "proceduralmap.*.map" -delete fn_wipe_exit_code sleep 0.5 else @@ -62,7 +75,7 @@ fn_wipe_server_remove_files(){ echo -en "Removing user directory..." sleep 1 fn_script_log "${currentaction}" - rm -rf "${serveridentitydir}/user" + rm -rf "${serveridentitydir:?}/user" fn_wipe_exit_code sleep 0.5 else @@ -75,7 +88,7 @@ fn_wipe_server_remove_files(){ echo -en "Removing storage directory..." sleep 1 fn_script_log "${currentaction}" - rm -rf "${serveridentitydir}/storage" + rm -rf "${serveridentitydir:?}/storage" fn_wipe_exit_code sleep 0.5 else @@ -88,7 +101,7 @@ fn_wipe_server_remove_files(){ echo -en "Removing Log files..." sleep 1 fn_script_log "${currentaction}" - find "${serveridentitydir}" -type f -name "Log.*.txt" -delete + find "${serveridentitydir:?}" -type f -name "Log.*.txt" -delete fn_wipe_exit_code sleep 0.5 else From 99aeb89b8594b065bc5d7bc3784e3ff23ed26aec Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 03:39:13 +0100 Subject: [PATCH 37/46] fn_print_header As per #1035 --- lgsm/functions/compress_ut99_maps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index 2a3b6a71f..e74ec727c 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -8,9 +8,7 @@ local commandaction="Unreal Map Compressor" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh -clear -echo "${gamename} Map Compressor" -echo "=================================" +fn_print_header echo "Will compress all maps in:" echo "" pwd From a45412c175100721b0470d69a5fb72d69f87dd77 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 03:39:15 +0100 Subject: [PATCH 38/46] fn_print_header As per #1035 --- lgsm/functions/compress_unreal2_maps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 9e0488095..7ef8bfeea 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -8,9 +8,7 @@ local commandaction="Unreal Map Compressor" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh -clear -echo "${gamename} Map Compressor" -echo "=================================" +fn_print_header echo "Will compress all maps in:" echo "" pwd From dd55ccf979689812fa6e5d8f17ed7bb94a340597 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 03:41:53 +0100 Subject: [PATCH 39/46] fn_print_header As per #1035 --- lgsm/functions/command_ts3_server_pass.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 5cdb59e6c..964b93211 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -6,15 +6,12 @@ # Description: Changes TS3 serveradmin password. local commandname="TS3-CHANGE-PASS" -local commandaction="TS3 Change Password" +local commandaction="ServerAdmin Password Change" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_serveradmin_password_prompt(){ - echo "" - echo "${gamename} ServerAdmin Password Change" - echo "=================================" - echo "" + fn_print_header echo "Press \"CTRL+b d\" to exit console." fn_print_information_nl "You are about to change the ${gamename} ServerAdmin password." fn_print_warning_nl "${gamename} will restart during this process." From 10396a233478bd6c3b50aaddbf3d224c37253ae3 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 03:54:03 +0100 Subject: [PATCH 40/46] Minor log issue fix Fixes #1307 --- lgsm/functions/command_start.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 39dc363cf..c544dd9cf 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -85,15 +85,15 @@ fn_start_tmux(){ # tmux pipe-pane not supported in tmux versions < 1.6 if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then - echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" + echo "Console logging disabled: Tmux => 1.6 required + https://gameservermanagers.com/tmux-upgrade + Currently installed: $(tmux -V)" > "${consolelog}" # Console logging disabled: Bug in tmux 1.8 breaks logging elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then - echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" + echo "Console logging disabled: Bug in tmux 1.8 breaks logging + https://gameservermanagers.com/tmux-upgrade + Currently installed: $(tmux -V)" > "${consolelog}" # Console logging enable or not set elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then From 9dae232b4af4e27003f0f99986435a89881cd38a Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 09:02:19 +0100 Subject: [PATCH 41/46] Try reverting changes to check why travis fails --- lgsm/functions/command_start.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index c544dd9cf..39dc363cf 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -85,15 +85,15 @@ fn_start_tmux(){ # tmux pipe-pane not supported in tmux versions < 1.6 if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then - echo "Console logging disabled: Tmux => 1.6 required - https://gameservermanagers.com/tmux-upgrade - Currently installed: $(tmux -V)" > "${consolelog}" + echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" # Console logging disabled: Bug in tmux 1.8 breaks logging elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then - echo "Console logging disabled: Bug in tmux 1.8 breaks logging - https://gameservermanagers.com/tmux-upgrade - Currently installed: $(tmux -V)" > "${consolelog}" + echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" # Console logging enable or not set elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then From ed51b44818a070f2c8289af4050572538cbe60d4 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Thu, 23 Feb 2017 09:21:18 +0100 Subject: [PATCH 42/46] Minor log issue fix (again) Trying to re-add the commit to see if it was just a temporary Travis bug or not. Fixes #1307 (again) --- lgsm/functions/command_start.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 39dc363cf..c544dd9cf 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -85,15 +85,15 @@ fn_start_tmux(){ # tmux pipe-pane not supported in tmux versions < 1.6 if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then - echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" + echo "Console logging disabled: Tmux => 1.6 required + https://gameservermanagers.com/tmux-upgrade + Currently installed: $(tmux -V)" > "${consolelog}" # Console logging disabled: Bug in tmux 1.8 breaks logging elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then - echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" + echo "Console logging disabled: Bug in tmux 1.8 breaks logging + https://gameservermanagers.com/tmux-upgrade + Currently installed: $(tmux -V)" > "${consolelog}" # Console logging enable or not set elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then From 98854eacffbff62e01891d57cde7d5e32f7e6d67 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Sat, 25 Feb 2017 01:03:23 +0100 Subject: [PATCH 43/46] Fixed function syntax breaking Ark stop Fixes #1335 --- lgsm/functions/command_stop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 341ad4d95..ccb7dbbf0 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -272,7 +272,7 @@ fn_stop_ark(){ pid=${pid//[!0-9]/} let pid+=0 # turns an empty string into a valid number, '0', # and a valid numeric pid remains unchanged. - if [ "${pid}" -gt 1 && "${pid}" -le $(cat /proc/sys/kernel/pid_max) ]; then + if [ "${pid}" -gt 1 ]&&[ "${pid}" -le $(cat /proc/sys/kernel/pid_max) ]; then fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}" sleep 1 else From 5ac52b631d38f9fc3bd3768676091206aa880554 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 25 Feb 2017 11:39:02 +0000 Subject: [PATCH 44/46] removed white spaces --- lgsm/functions/command_fastdl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 5d20df759..3d39f49ea 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -122,7 +122,7 @@ fn_fastdl_config(){ else clearnonbzip2="off"; fn_script_log "Clearing non-bzip2 files Disabled."; fn_print_ok "Clearing non-bzip2 files Disabled" fi - echo -en "\n" + echo -en "\n" else # Other games default remove non bzip2 files clearnonbzip2="on" @@ -174,7 +174,7 @@ fn_fastdl_gmod(){ # No choice to cd to the directory, as find can't then display relative directory cd "${systemdir}" || exit - + # Map Files fn_print_dots "Copying map files..." fn_script_log "Copying map files" @@ -408,7 +408,7 @@ fn_fastdl_bzip2(){ find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -exec rm {} \; fn_print_ok "Cleared uncompressed FastDL files" fn_script_log "Cleared uncompressed FastDL files." - fi + fi fi } From 1e81f72b66b2040dd9cb60ccb64f48305a625df2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 4 Mar 2017 14:38:01 +0000 Subject: [PATCH 45/46] Reverted to master version of fastdl to allow merging to develop fast dl is being worked on in ultimatebyte-0220 --- lgsm/functions/command_fastdl.sh | 230 +++++++------------------------ 1 file changed, 53 insertions(+), 177 deletions(-) diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 3d39f49ea..9fe7ca68b 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -6,18 +6,11 @@ # Description: Creates a FastDL directory. local commandname="FASTDL" -local commandaction="FastDL Generator" +local commandaction="FastDL" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh -# Only Source supports FastDL -if [ "${engine}" != "source" ]; then - fn_print_error "${gamename} does not support FastDL" - fn_script_log_error "${gamename} does not support FastDL" - core_exit.sh -fi - # Directories webdir="${rootdir}/public_html" fastdldir="${webdir}/fastdl" @@ -31,27 +24,25 @@ fn_check_bzip2(){ # Returns true if not installed if [ -z "$(command -v bzip2)" ]; then bzip2installed="0" - fn_print_info "bzip2 is not installed! Install it to enable file compression" - fn_script_log_info "bzip2 is not installed. Install it to enable file compression." - fn_script_log_info "https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" + fn_print_info "bzip2 is not installed !" + fn_script_log_info "bzip2 is not installed" echo -en "\n" sleep 1 - echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" + echo "We advise using it" + echo "For more information, see https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL#bzip2-compression" sleep 2 - echo "" else bzip2installed="1" fi } -# Initiates FastDL fn_fastdl_init(){ - fn_print_header - fn_script_log "Started FastDL Generator" - sleep 1 - fn_check_bzip2 # User confirmation - if ! fn_prompt_yn "Build FastDL directory?" Y; then + fn_print_ok "Welcome to LGSM's FastDL generator" + sleep 1 + echo -en "\n" + fn_script_log "Started FastDL creation" + if ! fn_prompt_yn "Continue?" Y; then exit fi fn_script_log "Initiating FastDL creation" @@ -72,30 +63,28 @@ fn_fastdl_init(){ fi if [ ! -d "${fastdldir}" ]; then # No directory, won't ask for removing old ones - newfastdl="true" + newfastdl=1 fn_print_dots "Creating fastdl directory" sleep 0.5 mkdir "${fastdldir}" fn_print_ok "Created fastdl directory" - fn_script_log "Created fastdl directory" + fn_script_log "FastDL created fastdl directory" sleep 1 echo -en "\n" clearoldfastdl="off" # Nothing to clear elif [ "$(ls -A "${fastdldir}")" ]; then - newfastdl="false" - else - newfastdl="true" + newfastdl=0 fi } -# Prompts user for FastDL creation settings fn_fastdl_config(){ + # Global settings for FastDL creation fn_print_info "Entering configuration" fn_script_log "Configuration" sleep 2 echo -en "\n" # Prompt for clearing old files if directory was already here - if [ "${newfastdl}" == "false" ]; then + if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then fn_print_dots if fn_prompt_yn "Clear old FastDL files?" Y; then clearoldfastdl="on"; fn_script_log "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled" @@ -104,50 +93,27 @@ fn_fastdl_config(){ fi echo -en "\n" fi - # Settings for bzip2 users + # Prompt for using bzip2 if it's installed if [ ${bzip2installed} == 1 ]; then - # Prompt for using bzip2 if it's installed fn_print_dots - if fn_prompt_yn "Enable bzip2 file compression?" Y; then + if fn_prompt_yn "Enable file compression using bzip2?" Y; then bzip2enable="on"; fn_script_log "bzip2 enabled"; fn_print_ok "bzip2 Enabled" else bzip2enable="off"; fn_script_log "bzip2 disabled"; fn_print_ok "bzip2 Disabled" fi echo -en "\n" - if [ "${gamename}" == "Garry's Mod" ]&&[ "${bzip2enable}" == "on" ]; then - # Prompt for clearing uncompressed files, can save some space but might cause issues for gmod - fn_print_dots - if fn_prompt_yn "Clear non-bzip2 FastDL files?" Y; then - clearnonbzip2="on"; fn_script_log "Clearing non-bzip2 files Enabled."; fn_print_ok "Clearing non-bzip2 files Enabled" - else - clearnonbzip2="off"; fn_script_log "Clearing non-bzip2 files Disabled."; fn_print_ok "Clearing non-bzip2 files Disabled" - fi - echo -en "\n" - else - # Other games default remove non bzip2 files - clearnonbzip2="on" - fn_script_log "Original uncompressed fastDL files won't be kept." - fi fi - # Garry's Mod Specific - if [ "${gamename}" == "Garry's Mod" ]; then - # Prompt to clear addons dir from fastdl, can use unnecessary space or be required depending on addon's file structures - fn_print_dots - if fn_prompt_yn "Clear addons dir from fastdl dir?" Y; then - cleargmodaddons="on"; fn_script_log "Addons clearing Enabled."; fn_print_ok "Addons clearing Enabled" - else - cleargmodaddons="off"; fn_script_log "Addons clearing Disabled."; fn_print_ok "Addons clearing Disabled" - fi - echo -en "\n" - # Prompt for download enforcer, which is using a .lua addfile resource generator - fn_print_dots - if fn_prompt_yn "Use client download enforcer?" Y; then - luaressource="on"; fn_script_log "DL enforcer Enabled."; fn_print_ok "Enforcer Enabled" - else - luaressource="off"; fn_script_log "DL enforcer Disabled."; fn_print_ok "Enforcer Disabled" - fi - echo -en "\n" +} + +fn_fastdl_gmod_config(){ + # Prompt for download enforcer, that is using a .lua addfile resource generator + fn_print_dots + if fn_prompt_yn "Use client download enforcer?" Y; then + luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled" + else + luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled" fi + echo -en "\n" } fn_clear_old_fastdl(){ @@ -164,7 +130,7 @@ fn_clear_old_fastdl(){ fi } -fn_fastdl_gmod(){ +fn_gmod_fastdl(){ # Copy all needed files for FastDL echo "" fn_print_dots "Starting gathering all needed files" @@ -173,7 +139,7 @@ fn_fastdl_gmod(){ echo -en "\n" # No choice to cd to the directory, as find can't then display relative directory - cd "${systemdir}" || exit + cd "${systemdir}" # Map Files fn_print_dots "Copying map files..." @@ -244,27 +210,18 @@ fn_fastdl_gmod(){ # Correct addons directory structure for FastDL if [ -d "${fastdldir}/addons" ]; then fn_print_info "Adjusting addons' file structure" - fn_script_log "Adjusting addons' file structure" + fn_script_log "Adjusting addon's file structure" sleep 1 cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" - fn_print_ok "Adjusted addons' file structure" + #Don't remove yet rm -R "${fastdldir:?}/addons" + fn_print_ok "Adjusted addon's file structure" sleep 1 echo -en "\n" - # Clear addons directory in fastdl - if [ "${cleargmodaddons}" == "on" ]; then - fn_print_info "Clearing addons dir from fastdl dir" - fn_script_log "Clearing addons dir from fastdl dir" - sleep 1 - rm -R "${fastdldir:?}/addons" - fn_print_ok "Cleared addons dir from fastdl dir" - sleep 1 - echo -en "\n" - fi fi # Correct content that may be into a lua directory by mistake like some darkrpmodification addons if [ -d "${fastdldir}/lua" ]; then - fn_print_dots "Typical DarkRP files detected, fixing" + fn_print_dots "Typical DarkRP shit detected, fixing" sleep 2 cp -Rf "${fastdldir}/lua/"* "${fastdldir}" fn_print_ok "Stupid DarkRP file structure fixed" @@ -273,80 +230,8 @@ fn_fastdl_gmod(){ fi } -fn_fastdl_source(){ - # Copy all needed files for FastDL - echo "" - fn_print_dots "Starting gathering all needed files" - fn_script_log "Starting gathering all needed files" - sleep 1 - echo -en "\n" - - # Map Files - fn_print_dots "Copying map files..." - fn_script_log "Copying map files" - sleep 0.5 - mkdir "${fastdldir}/maps" - find "${systemdir}/maps" -name '*.bsp' -exec cp {} "${fastdldir}/maps" \; - find "${systemdir}/maps" -name '*.ain' -exec cp {} "${fastdldir}/maps" \; - find "${systemdir}/maps" -name '*.nav' -exec cp {} "${fastdldir}/maps" \; - find "${systemdir}/maps" -name '*.jpg' -exec cp {} "${fastdldir}/maps" \; - find "${systemdir}/maps" -name '*.txt' -exec cp {} "${fastdldir}/maps" \; - fn_print_ok "Map files copied" - sleep 0.5 - echo -en "\n" - - # Materials - fn_print_dots "Copying materials..." - fn_script_log "Copying materials" - sleep 0.5 - mkdir "${fastdldir}/materials" - find "${systemdir}/materials" -name '*.vtf' -exec cp {} "${fastdldir}/materials" \; - find "${systemdir}/materials" -name '*.vmt' -exec cp {} "${fastdldir}/materials" \; - find "${systemdir}/materials" -name '*.vbf' -exec cp {} "${fastdldir}/materials" \; - fn_print_ok "Materials copied" - sleep 0.5 - echo -en "\n" - - # Models - fn_print_dots "Copying models..." - fn_script_log "Copying models" - sleep 1 - mkdir "${fastdldir}/models" - find "${systemdir}/models" -name '*.vtx' -exec cp {} "${fastdldir}/models" \; - find "${systemdir}/models" -name '*.vvd' -exec cp {} "${fastdldir}/models" \; - find "${systemdir}/models" -name '*.mdl' -exec cp {} "${fastdldir}/models" \; - find "${systemdir}/models" -name '*.phy' -exec cp {} "${fastdldir}/models" \; - find "${systemdir}/models" -name '*.jpg' -exec cp {} "${fastdldir}/models" \; - find "${systemdir}/models" -name '*.png' -exec cp {} "${fastdldir}/models" \; - fn_print_ok "Models copied" - sleep 0.5 - echo -en "\n" - - # Particles - fn_print_dots "Copying particles..." - fn_script_log "Copying particles" - sleep 0.5 - mkdir "${fastdldir}/particles" - find "${systemdir}" -name '*.pcf' -exec cp {} "${fastdldir}/particles" \; - fn_print_ok "Particles copied" - sleep 0.5 - echo -en "\n" - - # Sounds - fn_print_dots "Copying sounds..." - fn_script_log "Copying sounds" - sleep 0.5 - mkdir "${fastdldir}/sound" - find "${systemdir}" -name '*.wav' -exec cp {} "${fastdldir}/sound" \; - find "${systemdir}" -name '*.mp3' -exec cp {} "${fastdldir}/sound" \; - find "${systemdir}" -name '*.ogg' -exec cp {} "${fastdldir}/sound" \; - fn_print_ok "Sounds copied" - sleep 0.5 - echo -en "\n" -} - # Generate lua file that will force download any file into the FastDL directory -fn_fastdl_gmod_lua_enforcer(){ +fn_lua_fastdl(){ # Remove lua file if luaressource is turned off and file exists echo "" if [ "${luaressource}" == "off" ]; then @@ -375,8 +260,8 @@ fn_fastdl_gmod_lua_enforcer(){ fn_script_log "Generating new download enforcer" sleep 1 # Read all filenames and put them into a lua file at the right path - find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do - echo "resource.AddFile( "\""${line}"\"" )" >> "${luafastdlfullpath}" + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do + echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath} done fn_print_ok "Download enforcer generated" fn_script_log "Download enforcer generated" @@ -396,50 +281,41 @@ fn_fastdl_bzip2(){ fn_print_dots "Compressing files using bzip2..." fn_script_log "Compressing files using bzip2..." # bzip2 all files that are not already compressed (keeping original files) - find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; + find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; fn_print_ok "bzip2 compression done" fn_script_log "bzip2 compression done" sleep 1 echo -en "\n" - # Clear non compressed FastDL files - if [ "${clearnonbzip2}" == "on" ]; then - fn_print_dots "Clearing original uncompressed FastDL files..." - sleep 1 - find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -exec rm {} \; - fn_print_ok "Cleared uncompressed FastDL files" - fn_script_log "Cleared uncompressed FastDL files." - fi fi } fn_fastdl_completed(){ # Finished message echo "" - fn_print_ok "FastDL created!" + fn_print_ok "Congratulations, it's done!" fn_script_log "FastDL job done" sleep 2 echo -en "\n" echo "" - fn_print_info_nl "Need more documentation?" - echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL" + fn_print_info "Need more documentation? See https://github.com/GameServerManagers/LinuxGSM/wiki/FastDL" echo -en "\n" if [ "$bzip2installed" == "0" ]; then - echo "By the way, you'd better install bzip2 and re-run this command!" + echo "By the way, you'd better install bzip2 and re-run this command!" fi - echo "Credits: UltimateByte" + echo "Credits : UltimateByte" } -# Run functions -fn_check_bzip2 -fn_fastdl_init -fn_fastdl_config -fn_clear_old_fastdl +# Game checking and functions running +# Garry's Mod if [ "${gamename}" == "Garry's Mod" ]; then - fn_fastdl_gmod - fn_fastdl_gmod_lua_enforcer -else - fn_fastdl_source + fn_check_bzip2 + fn_fastdl_init + fn_fastdl_config + fn_fastdl_gmod_config + fn_clear_old_fastdl + fn_gmod_fastdl + fn_lua_fastdl + fn_fastdl_bzip2 + fn_fastdl_completed + exit fi -fn_fastdl_bzip2 -fn_fastdl_completed -core_exit.sh From f013f96c4ebe97f0a07f807906dab5b188e1e77d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 4 Mar 2017 14:39:57 +0000 Subject: [PATCH 46/46] Also reverted getopt as well being worked on in ultimatebyte-0220 branch --- lgsm/functions/core_getopt.sh | 1100 ++++++++++++++++++++++++++++----- 1 file changed, 954 insertions(+), 146 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 78b097398..bcecc6c2d 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -6,169 +6,977 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -### Define all commands here ### -## User commands | Trigger commands | Description -# Standard commands -cmd_install=( "i;install" "command_install.sh" "Install the server." ) -cmd_auto_install=( "ai;auto-install" "command_autoinstall.sh" "Install the server without prompts." ) -cmd_start=( "st;start" "command_start.sh" "Start the server." ) -cmd_stop=( "sp;stop" "command_stop.sh" "Stop the server." ) -cmd_restart=( "r;restart" "command_restart.sh" "Restart the server." ) -cmd_details=( "dt;details" "command_details.sh" "Display relevant server information." ) -cmd_postdetails=( "pd;postdetails" "command_postdetails.sh" "Post stripped details to pastebin for support." ) -cmd_backup=( "b;backup" "command_backup.sh" "Create archives of the server." ) -cmd_update_functions=( "uf;update-functions" "command_update_functions.sh" "Update LinuxGSM functions." ) -cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." ) -cmd_monitor=( "m;monitor" "command_monitor.sh" "Check server status and restart it if crashed." ) -# Console servers only -cmd_console=( "c;console" "command_console.sh" "Access server console." ) -cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." ) -# Update servers only -cmd_update=( "u;update" "command_update.sh" "Check for updates and apply if available." ) -cmd_force_update=( "fu;force-update;update-restart;ur" "forceupdate=1; command_update.sh" "Unconditionally update the server." ) -# SteamCMD servers only -cmd_validate=( "v;validate" "command_validate.sh" "Validate server files with SteamCMD." ) -# Server with mods-install -cmd_mods_install=( "mi;mods-install" "command_mods_install.sh" "View and install available mods/addons." ) -cmd_mods_remove=( "mr;mods-remove" "command_mods_remove.sh" "View and remove an installed mod/addon." ) -cmd_mods_update=( "mu;mods-update" "command_mods_update.sh" "Update installed mods/addons." ) -# Server specific -cmd_change_password=( "pw;change-password" "command_ts3_server_pass.sh" "Change TS3 serveradmin password." ) -cmd_install_default_ressources=( "ir;install-default-ressources" "command_install_resources_mta.sh" "Install the MTA default resources." ) -cmd_wipe=( "wi;wipe" "command_wipe.sh" "Wipe your server data." ) -cmd_map_compressor_u99=( "mc;map-compressor" "compress_ut99_maps.sh" "Compresses all ${gamename} server maps." ) -cmd_map_compressor_u2=( "mc;map-compressor" "compress_unreal2_maps.sh" "Compresses all ${gamename} server maps." ) -cmd_install_cdkey=( "cd;server-cd-key" "install_ut2k4_key.sh" "Add your server cd key." ) -cmd_install_dst_token=( "ct;cluster-token" "install_dst_token.sh" "Configure cluster token." ) -cmd_fastdl=( "fd;fastdl" "command_fastdl.sh" "Build a FastDL directory." ) -# Dev commands -cmd_dev_debug=( "dev;dev-debug" "command_dev_debug.sh" "DEVCOMMAND" ) -cmd_dev_detect_deps=( "dd;detect-deps" "command_dev_detect_deps.sh" "DEVCOMMAND" ) -cmd_dev_detect_glibc=( "dg;detect-glibc" "command_dev_detect_glibc.sh" "DEVCOMMAND" ) -cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "DEVCOMMAND" ) - -### Set specific opt here ### - -## Common opt to all servers - -currentopt=( "${cmd_install[@]}" "${cmd_auto_install[@]}" "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_details[@]}" ) -currentopt+=( "${cmd_backup[@]}" "${cmd_update_functions[@]}" "${cmd_test_alert[@]}" "${cmd_monitor[@]}" ) - -## Servers that do not have a feature - -# Exclude games without a console -if [ "${gamename}" != "TeamSpeak 3" ]; then - currentopt+=( "${cmd_console[@]}" "${cmd_debug[@]}" ) -fi -# Exclude noupdated games here -if [ "${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 - currentopt+=( "${cmd_update[@]}" "${cmd_force_update[@]}") -fi +fn_getopt_generic(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + v|validate) + command_validate.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;; + mi|mods-install) + command_mods_install.sh;; + mu|mods-update) + command_mods_update.sh;; + mr|mods-remove) + command_mods_remove.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + 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." + echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." + echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." + echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." + } | column -s $'\t' -t + esac +} -## Include games that have access to specific commands -# Validate command -if [ -n "${appid}" ]; then - currentopt+=( "${cmd_validate[@]}" ) -fi -# FastDL command -if [ "${engine}" == "source" ]; then - currentopt+=( "${cmd_fastdl[@]}" ) -fi -# Wipe command -if [ "${gamename}" == "Rust" ]; then - currentopt+=( "${cmd_wipe[@]}" ) -fi -# Mods commands -if [ "${engine}" == "source" ]||[ "${gamename}" == "Rust" ]|[ "${gamename}" == "Hurtworld" ]|[ "${gamename}" == "7 Days To Die" ]; then - currentopt+=( "${cmd_mods_install[@]}" "${cmd_mods_remove[@]}" "${cmd_mods_update[@]}" ) -fi +fn_getopt_generic_update_no_steam(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.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;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates." + 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 +} -## Game server exclusive commands -# TeamSpeak exclusive -if [ "${gamename}" == "TeamSpeak 3" ]; then - currentopt+=( "${cmd_change_password[@]}" ) -fi -# Unreal exclusive -if [ "${engine}" == "unreal2" ]; then - if [ "${gamename}" == "Unreal Tournament 2004" ]; then - currentopt+=( "${cmd_install_cdkey[@]}" "${cmd_map_compressor_u2[@]}" ) - else - currentopt+=( "${cmd_map_compressor_u2[@]}" ) +fn_getopt_generic_no_update(){ +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;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.sh;; + *) + if [ -n "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 fi -fi -if [ "${engine}" == "unreal" ]; then - currentopt+=( "${cmd_map_compressor_u99[@]}" ) -fi -# DST exclusive -if [ "${gamename}" == "Don't Starve Together" ]; then - currentopt+=( "${cmd_install_dst_token[@]}" ) -fi -# MTA exclusive -if [ "${gamename}" == "Multi Theft Auto" ]; then - currentopt+=( "${cmd_install_default_ressources[@]}" ) -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 infomation 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 +} -## Developer commands -currentopt+=( "${cmd_dev_debug[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" ) +fn_getopt_teamspeak3(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.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;; + pw|change-password) + command_ts3_server_pass.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;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from teamspeak.com." + 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}change-password\t${default}pw |Changes TS3 serveradmin password." + echo -e "${blue}backup\t${default}b |Create archive of the server." + 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 +} +fn_getopt_minecraft(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.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;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from mojang.com." + 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 infomation 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 +} -### Build list of available commands -optcommands=() -index="0" -for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - cmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do - optcommands+=( "$(echo "${currentopt[index]}"| awk -F ';' -v x=${cmdindex} '{ print $x }')" ) - done -done +fn_getopt_mta(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.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;; + ir|install-default-resources) + command_install_resources_mta.sh;; + ai|auto-install) + fn_autoinstall;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from linux.mtasa.com." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from linux.mtasa.com." + 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 infomation 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." + echo -e "${blue}install-default-resources\t${default}ir |Install the MTA default resources." + } | column -s $'\t' -t + esac +} -# Shows LinuxGSM usage -fn_opt_usage(){ +fn_getopt_mumble(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.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;; + dev|dev-debug) + command_dev_debug.sh;; + c|console) + command_console.sh;; + i|install) + command_install.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from GitHub." + 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}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + } | column -s $'\t' -t + esac +} + +fn_getopt_dstserver(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + v|validate) + command_validate.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;; + ct|cluster-token) + install_dst_token.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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}" - # Display available commands - index="0" { - for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - # Hide developer commands - if [ "${currentopt[index+2]}" != "DEVCOMMAND" ]; then - echo -e "${cyan}$(echo "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t| ${currentopt[index+2]}" - fi - done + 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\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + 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." + echo -e "${blue}cluster-token\t${default}ct |Configure cluster token." } | column -s $'\t' -t - core_exit.sh + esac } -### Check if user commands exist and run corresponding scripts, or display script usage -if [ -z "${getopt}" ]; then - fn_opt_usage -fi -# Command exists -for i in "${optcommands[@]}"; do - if [ "${i}" == "${getopt}" ] ; then - # Seek and run command - index="0" - for ((index="0"; index < ${#currentopt[@]}; index+=3)); do - currcmdamount="$(echo "${currentopt[index]}"| awk -F ';' '{ print NF }')" - for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do - if [ "$(echo "${currentopt[index]}"| awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then - # Run command - ${currentopt[index+1]} - break - fi - done - done - break - core_exit.sh +fn_getopt_gmodserver(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + v|validate) + command_validate.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;; + fd|fastdl) + command_fastdl.sh;; + mi|mods-install) + command_mods_install.sh;; + mu|mods-update) + command_mods_update.sh;; + mr|mods-remove) + command_mods_remove.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + 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}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." + echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL directory for your server." + echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." + echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." + echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." + } | column -s $'\t' -t + esac +} + +fn_getopt_rustserver(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + v|validate) + command_validate.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;; + mi|mods-install) + command_mods_install.sh;; + mu|mods-update) + command_mods_update.sh;; + mr|mods-remove) + command_mods_remove.sh;; + wi|wipe) + command_wipe.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + 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." + echo -e "${blue}mods-install\t${default}mi |View and install available mods/addons." + echo -e "${blue}mods-update\t${default}mu |Update installed mods/addons." + echo -e "${blue}mods-remove\t${default}mr |Remove installed mods/addons." + echo -e "${blue}wipe\t${default}wi |Wipe your Rust server." + } | column -s $'\t' -t + esac +} + +fn_getopt_unreal(){ +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;; + 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;; + mc|map-compressor) + compress_ut99_maps.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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}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." + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." + } | column -s $'\t' -t + esac +} + + +fn_getopt_unreal2(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + fu|force-update|update-restart) + forceupdate=1; + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + v|validate) + command_validate.sh;; + m|monitor) + command_monitor.sh;; + ta|test-alert) + command_test_alert.sh;; + dt|details) + command_details.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;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.sh;; + mc|map-compressor) + compress_unreal2_maps.sh;; + *) + if [ -n "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 fi -done + 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\t${default}Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + 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}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." + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." + } | column -s $'\t' -t + esac +} -# If we're executing this, it means command was not found -echo -e "${red}Unknown command${default}: $0 ${getopt}" -exitcode=2 -fn_opt_usage + +fn_getopt_ut2k4(){ +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;; + 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;; + cd|server-cd-key) + install_ut2k4_key.sh;; + mc|map-compressor) + compress_unreal2_maps.sh;; + dd|detect-deps) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + dl|detect-ldd) + command_dev_detect_ldd.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}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." + echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key" + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." + } | column -s $'\t' -t + esac +} + +# Don't Starve Together +if [ "${gamename}" == "Don't Starve Together" ]; then + fn_getopt_dstserver +# Garry's Mod +elif [ "${gamename}" == "Garry's Mod" ]; then + fn_getopt_gmodserver +# Minecraft +elif [ "${engine}" == "lwjgl2" ]; then + fn_getopt_minecraft +# Multi Theft Auto +elif [ "${gamename}" == "Multi Theft Auto" ]; then + fn_getopt_mta +# Mumble +elif [ "${gamename}" == "Mumble" ]; then + fn_getopt_mumble +# Teamspeak 3 +elif [ "${gamename}" == "TeamSpeak 3" ]; then + fn_getopt_teamspeak3 +elif [ "${gamename}" == "Rust" ]; then + fn_getopt_rustserver +# Unreal 2 Engine +elif [ "${engine}" == "unreal2" ]; then + if [ "${gamename}" == "Unreal Tournament 2004" ]; then + fn_getopt_ut2k4 + else + fn_getopt_unreal2 + fi +# Unreal Engine +elif [ "${engine}" == "unreal" ]; then + fn_getopt_unreal +# Generic +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 + fn_getopt_generic_no_update +elif [ "${gamename}" == "Factorio" ]; then + fn_getopt_generic_update_no_steam +else + fn_getopt_generic +fi core_exit.sh