From 39e82d614aa4fa33523d562909be2eb37bb3c77d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 5 Jun 2020 00:57:19 +0100 Subject: [PATCH] fix(log): allow logs to correctly display primary command bug: if a command calls another command then the log file will permanently change to the second command this fix will revert the logs to state the primary command that was run --- lgsm/functions/command_backup.sh | 19 +- lgsm/functions/command_console.sh | 10 +- lgsm/functions/command_debug.sh | 10 +- lgsm/functions/command_install.sh | 3 + lgsm/functions/command_restart.sh | 5 +- lgsm/functions/command_start.sh | 12 +- lgsm/functions/command_update.sh | 9 +- lgsm/functions/command_validate.sh | 33 +- lgsm/functions/command_wipe.sh | 331 +++++++++++---------- lgsm/functions/fix_kf.sh | 4 + lgsm/functions/fix_kf2.sh | 2 + lgsm/functions/fix_ro.sh | 4 + lgsm/functions/fix_ut2k4.sh | 4 + lgsm/functions/fix_ut3.sh | 2 + lgsm/functions/fix_wurm.sh | 2 + lgsm/functions/update_factorio.sh | 12 +- lgsm/functions/update_minecraft.sh | 10 +- lgsm/functions/update_minecraft_bedrock.sh | 11 +- lgsm/functions/update_mta.sh | 10 +- lgsm/functions/update_mumble.sh | 12 +- lgsm/functions/update_steamcmd.sh | 10 +- lgsm/functions/update_ts3.sh | 6 + 22 files changed, 298 insertions(+), 223 deletions(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 537e86f1c..0ab88c231 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -5,9 +5,12 @@ # Website: https://linuxgsm.com # Description: Creates a .tar.gz file in the backup directory. -commandname="BACKUP" -commandaction="Backing up" -functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_commandname(){ + commandname="BACKUP" + commandaction="Backing up" + functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname check.sh @@ -77,6 +80,7 @@ fn_backup_stop_server(){ serverstopped="yes" exitbypass=1 command_stop.sh + fn_commandname fi } @@ -247,18 +251,18 @@ fn_backup_relpath() { } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup" + fn_print_warn "this game server will be stopped during backup" + fn_script_log_warn "this game server will be stopped during backup" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during backup: ${totalseconds}" + fn_print_warn "this game server will be stopped during backup: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during backup" + fn_print_warn_nl "this game server will be stopped during backup" } # Restart the server if it was stopped for the backup. @@ -266,6 +270,7 @@ fn_backup_start_server(){ if [ "${serverstopped}" == "yes" ]; then exitbypass=1 command_start.sh + fn_commandname fi } diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 18e674652..ea0c4af93 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -4,9 +4,12 @@ # Website: https://linuxgsm.com # Description: Gives access to the server tmux console. -commandname="CONSOLE" -commandaction="Access console" -functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_commandname(){} + commandname="CONSOLE" + commandaction="Access console" + functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname check.sh fn_print_header @@ -35,6 +38,7 @@ else if fn_prompt_yn "Do you want to start the server?" Y; then exitbypass=1 command_start.sh + fn_commandname fi fi diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 5aeb0d5e1..4addb86b5 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -4,9 +4,12 @@ # Website: https://linuxgsm.com # Description: Runs the server without tmux and directly from the terminal. -commandname="DEBUG" -commandaction="Debuging" -functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_commandname(){ + commandname="DEBUG" + commandaction="Debuging" + functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname # Trap to remove lockfile on quit. fn_lockfile_trap(){ @@ -88,6 +91,7 @@ fn_print_info_nl "Stopping any running servers" fn_script_log_info "Stopping any running servers" exitbypass=1 command_stop.sh +fn_commandname unset exitbypass fn_print_dots "Starting debug" fn_script_log_info "Starting debug" diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 9a6b64e98..90b40c0e4 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -5,9 +5,12 @@ # Website: https://linuxgsm.com # Description: Overall function for the installer. +fn_commandname(){ commandname="INSTALL" commandaction="Installing" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname check.sh if [ "$(whoami)" = "root" ]; then diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 8a08c04ff..3ccfcbe3d 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -4,13 +4,16 @@ # Website: https://linuxgsm.com # Description: Restarts the server. +fn_commandname(){ commandname="MODS-INSTALL" commandaction="Restarting" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname info_config.sh exitbypass=1 command_stop.sh command_start.sh - +fn_commandname core_exit.sh diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index d0487e5d4..e9ff0734d 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -5,9 +5,12 @@ # Website: https://linuxgsm.com # Description: Starts the server. -commandname="START" -commandaction="Starting" -functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_commandname(){} + commandname="START" + commandaction="Starting" + functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname fn_start_teamspeak3(){ if [ ! -f "${servercfgfullpath}" ]; then @@ -188,8 +191,7 @@ if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateon exitbypass=1 unset updateonstart command_update.sh - commandname="START" - commandaction="Starting" + fn_commandname fi fn_print_dots "${servername}" diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 88109a147..a430ae425 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -4,9 +4,12 @@ # Website: https://linuxgsm.com # Description: Handles updating of servers. -commandname="UPDATE" -commandaction="Updating" -functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_commandname(){} + commandname="UPDATE" + commandaction="Updating" + functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname fn_print_dots "" check.sh diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 276458e48..423756834 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -4,23 +4,26 @@ # Website: https://linuxgsm.com # Description: Runs a server validation. +fn_commandname(){ commandname="VALIDATE" commandaction="Validating" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +} +fn_commandname fn_validate(){ - fn_script_log_warn "Validating server: SteamCMD: Validate might overwrite some customised files" + fn_script_log_warn "SteamCMD: Validate might overwrite some customised files" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Validating server: SteamCMD: Validate might overwrite some customised files: ${totalseconds}" + fn_print_warn "SteamCMD: Validate might overwrite some customised files: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Validating server: SteamCMD: Validate might overwrite some customised files" - fn_print_start_nl "Validating server: SteamCMD" + fn_print_warn_nl "SteamCMD: Validate might overwrite some customised files" + fn_print_start_nl "SteamCMD" fn_script_log_info "Validating server: SteamCMD" if [ -d "${steamcmddir}" ]; then cd "${steamcmddir}" || exit @@ -40,8 +43,7 @@ fn_validate(){ ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" "${branch}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}" fi elif [ "${shortname}" == "ac" ]; then - ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit - local exitcode=$? + ${unbuffer} ${steamcmdcommand} +@sSteamCmdForcePlatformType windows +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" validate +quit | tee -a "${lgsmlog}" # All other servers. elif [ -n "${branch}" ]; then ${unbuffer} ${steamcmdcommand} +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" -beta "${branch}" validate +quit | tee -a "${lgsmlog}" @@ -50,42 +52,43 @@ fn_validate(){ fi exitcode=$? - fn_print_dots "Validating server: SteamCMD" + fn_print_dots "SteamCMD" if [ "${exitcode}" != "0" ]; then - fn_print_fail_nl "Validating server: SteamCMD" + fn_print_fail_nl "SteamCMD" fn_script_log_fatal "Validating server: SteamCMD: FAIL" else - fn_print_ok_nl "Validating server: SteamCMD" + fn_print_ok_nl "SteamCMD" fn_script_log_pass "Validating server: SteamCMD: OK" fi core_exit.sh } fn_stop_warning(){ - fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation" - fn_script_log_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation" + fn_print_warn "this game server will be stopped during validate" + fn_script_log_warn "this game server will be stopped during validate" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Validating server: SteamCMD: ${selfname} will be stopped during validation: ${totalseconds}" + fn_print_warn "this game server will be stopped during validate: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Validating server: SteamCMD: ${selfname} will be stopped during validation" + fn_print_warn_nl "this game server will be stopped during validate" } -fn_print_dots "Validating server" -fn_print_dots "Validating server: SteamCMD" +fn_print_dots "SteamCMD" check.sh if [ "${status}" != "0" ]; then fn_stop_warning exitbypass=1 command_stop.sh + fn_commandname fn_validate exitbypass=1 command_start.sh + fn_commandname else fn_validate fi diff --git a/lgsm/functions/command_wipe.sh b/lgsm/functions/command_wipe.sh index 5b5abf552..880776f99 100644 --- a/lgsm/functions/command_wipe.sh +++ b/lgsm/functions/command_wipe.sh @@ -5,29 +5,12 @@ # Website: https://linuxgsm.com # Description: Wipes server data, useful after updates for some games like Rust +fn_commandname(){ commandname="WIPE" commandaction="Wiping" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" - -check.sh -fn_print_header -fn_script_log "Entering ${gamename} ${commandaction}" - -# Process to server wipe. -fn_wipe_server_process(){ - check_status.sh - if [ "${status}" != "0" ]; then - exitbypass=1 - command_stop.sh - fn_wipe_server_remove_files - exitbypass=1 - command_start.sh - else - fn_wipe_server_remove_files - fi - echo -e "server data wiped" - fn_script_log "server data wiped." } +fn_commandname # Provides an exit code upon error. fn_wipe_exit_code(){ @@ -41,166 +24,190 @@ fn_wipe_exit_code(){ } # Removes files to wipe server. -fn_wipe_server_remove_files(){ - # Rust Wipe. - if [ "${shortname}" == "rust" ]; then - # Wipe pocedural map. - if [ "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.map")" ]; then - currentaction="Removing map file(s): ${serveridentitydir}/proceduralmap.*.map" - echo -en "Removing procedural map proceduralmap.*.map file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "proceduralmap.*.map" -delete - fn_wipe_exit_code - fn_sleep_time - else - fn_print_information_nl "No procedural map file to remove" - fn_script_log_info "No procedural map file to remove." - fi - # Wipe procedural map save. - if [ "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.sav")" ]; then - currentaction="Removing procedural map save(s): ${serveridentitydir}/proceduralmap.*.sav" - echo -en "Removing map saves proceduralmap.*.sav file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "proceduralmap.*.sav" -delete - fn_wipe_exit_code - fn_sleep_time - else - fn_print_information_nl "No procedural map save to remove" - fn_script_log_info "No procedural map save to remove." - fi - # Wipe Barren map. - if [ "$(find "${serveridentitydir}" -type f -name "barren*.map")" ]; then - currentaction="Removing map file(s): ${serveridentitydir}/barren*.map" - echo -en "Removing barren map barren*.map file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "barren*.map" -delete - fn_wipe_exit_code - fn_sleep_time - else - fn_print_information_nl "No barren map file to remove" - fn_script_log_info "No barren map file to remove." - fi - # Wipe barren map save. - if [ "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]; then - currentaction="Removing barren map save(s): ${serveridentitydir}/barren*.sav" - echo -en "Removing barren map saves barren*.sav file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "barren*.sav" -delete - fn_wipe_exit_code - fn_sleep_time - else - fn_print_information_nl "No barren map save to remove" - fn_script_log_info "No barren map save to remove." - fi - # Wipe user dir, might be a legacy thing, maybe to be removed. - if [ -d "${serveridentitydir}/user" ]; then - currentaction="Removing user directory: ${serveridentitydir}/user" - echo -en "Removing user directory..." - fn_sleep_time - fn_script_log "${currentaction}" - rm -rf "${serveridentitydir:?}/user" - fn_wipe_exit_code - fn_sleep_time +fn_wipe_server_files(){ + fn_print_start_nl "Wiping server" + fn_script_log_info "Wiping server" + # Wipe procedural map. + if [ "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.map")" ]; then + echo -en "removing procedural map proceduralmap.*.map file(s)..." + fn_sleep_time + fn_script_log_info "Removing procedural map file(s): ${serveridentitydir}/proceduralmap.*.map" + find "${serveridentitydir:?}" -type f -name "proceduralmap.*.map" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time + else + echo -e "no procedural map file to remove" + fn_sleep_time + fn_script_log_pass "No procedural map file to remove" + fi + # Wipe procedural map save. + if [ "$(find "${serveridentitydir}" -type f -name "proceduralmap.*.sav")" ]; then + echo -en "removing map saves proceduralmap.*.sav file(s)..." + fn_sleep_time + fn_script_log_info "Removing procedural map save(s): ${serveridentitydir}/proceduralmap.*.sav" + find "${serveridentitydir:?}" -type f -name "proceduralmap.*.sav" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time + else + echo -e "no procedural map save to remove" + fn_sleep_time + fn_script_log_pass "No procedural map save to remove" + fi + # Wipe Barren map. + if [ "$(find "${serveridentitydir}" -type f -name "barren*.map")" ]; then + echo -en "removing barren map barren*.map file(s)..." + fn_sleep_time + fn_script_log_info "Removing map file(s): ${serveridentitydir}/barren*.map" + find "${serveridentitydir:?}" -type f -name "barren*.map" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time + else + echo -e "no barren map file to remove" + fn_sleep_time + fn_script_log_pass "No barren map file to remove" + fi + # Wipe barren map save. + if [ "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]; then + echo -en "removing barren map saves barren*.sav file(s)..." + fn_sleep_time + fn_script_log_info "Removing barren map save(s): ${serveridentitydir}/barren*.sav" + find "${serveridentitydir:?}" -type f -name "barren*.sav" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time + else + echo -e "no barren map save to remove" + fn_sleep_time + fn_script_log_pass "No barren map save to remove." + fi + # Wipe user dir, might be a legacy thing, maybe to be removed. + if [ -d "${serveridentitydir}/user" ]; then + echo -en "removing user directory..." + fn_sleep_time + fn_script_log_info "removing user directory: ${serveridentitydir}/user" + rm -rf "${serveridentitydir:?}/user" + fn_wipe_exit_code + fn_sleep_time # We do not print additional information if there is nothing to remove since this might be obsolete. - fi - # Wipe storage dir, might be a legacy thing, maybe to be removed. - if [ -d "${serveridentitydir}/storage" ]; then - currentaction="Removing storage directory: ${serveridentitydir}/storage" - echo -en "Removing storage directory..." - fn_sleep_time - fn_script_log "${currentaction}" - rm -rf "${serveridentitydir:?}/storage" - fn_wipe_exit_code - fn_sleep_time + fi + # Wipe storage dir, might be a legacy thing, maybe to be removed. + if [ -d "${serveridentitydir}/storage" ]; then + echo -en "removing storage directory..." + fn_sleep_time + fn_script_log_info "removing storage directory: ${serveridentitydir}/storage" + rm -rf "${serveridentitydir:?}/storage" + fn_wipe_exit_code + fn_sleep_time # We do not print additional information if there is nothing to remove since this might be obsolete. - fi - # Wipe sv.files. - if [ "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then - currentaction="Removing server misc files: ${serveridentitydir}/sv.files.*.db" - echo -en "Removing server misc srv.files*.db file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "sv.files.*.db" -delete - fn_wipe_exit_code - fn_sleep_time + fi + # Wipe sv.files. + if [ "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then + echo -en "removing server misc srv.files*.db file(s)..." + fn_sleep_time + fn_script_log_info "Removing server misc files: ${serveridentitydir}/sv.files.*.db" + find "${serveridentitydir:?}" -type f -name "sv.files.*.db" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time # No further information if not found because it should I could not get this file showing up. - fi - # Wipe player death files. - if [ "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]; then - currentaction="Removing player death files: ${serveridentitydir}/player.deaths.*.db" - echo -en "Removing player deaths player.deaths.*.db file(s)..." + fi + # Wipe player death files. + if [ "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]; then + echo -en "removing player deaths player.deaths.*.db file(s)..." + fn_sleep_time + fn_script_log_info "Removing player death files: ${serveridentitydir}/player.deaths.*.db" + find "${serveridentitydir:?}" -type f -name "player.deaths.*.db" -delete | tee -a "${lgsmlog}" + fn_wipe_exit_code + fn_sleep_time + else + echo -e "no player death to remove" + fn_sleep_time + fn_script_log_pass "No player death to remove" + fi + # Wipe blueprints only if full-wipe command was used. + if [ "${fullwipe}" == "1" ]; then + if [ "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then + echo -en "removing blueprints player.blueprints.*.db file(s)..." fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "player.deaths.*.db" -delete + fn_script_log_info "Removing blueprint file(s): ${serveridentitydir}/player.blueprints.*.db" + find "${serveridentitydir:?}" -type f -name "player.blueprints.*.db" -delete | tee -a "${lgsmlog}" fn_wipe_exit_code fn_sleep_time else - fn_print_information_nl "No player death to remove" - fn_script_log_info "No player death to remove." - fi - # Wipe blueprints only if wipeall command was used. - if [ "${wipeall}" == "1" ]; then - if [ "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then - currentaction="Removing blueprint file(s): ${serveridentitydir}/player.blueprints.*.db" - echo -en "Removing blueprints player.blueprints.*.db file(s)..." - fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "player.blueprints.*.db" -delete - fn_wipe_exit_code - fn_sleep_time - else - fn_print_information_nl "No blueprint file to remove" - fn_script_log_info "No blueprint file to remove." - fi - elif [ "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then - fn_print_information_nl "Keeping blueprints" - fn_script_log_info "Keeping blueprints." - else - fn_print_information_nl "No blueprints found" - fn_script_log_info "No blueprints found." - fn_sleep_time + echo -e "no blueprint file to remove" + fn_sleep_time + fn_script_log_pass "No blueprint file to remove" fi - # Wipe some logs that might be there. - if [ "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]; then - currentaction="Removing log files: ${serveridentitydir}/Log.*.txt" - echo -en "Removing Log files..." + elif [ "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]; then + echo -e "keeping blueprints" fn_sleep_time - fn_script_log "${currentaction}" - find "${serveridentitydir:?}" -type f -name "Log.*.txt" -delete - fn_wipe_exit_code + fn_script_log_info "Keeping blueprints" + else + echo -e "no blueprints found" fn_sleep_time + fn_script_log_pass "No blueprints found" + fi + # Wipe some logs that might be there. + if [ "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]; then + echo -en "removing Log files..." + fn_sleep_time + fn_script_log_info "Removing log files: ${serveridentitydir}/Log.*.txt" + find "${serveridentitydir:?}" -type f -name "Log.*.txt" -delete + fn_wipe_exit_code + fn_sleep_time # We do not print additional information if there are no logs to remove. - fi - # You can add an "elif" here to add another game or engine. fi } -# Check if there is something to wipe, prompt the user, and call appropriate functions. -# Rust Wipe. -if [ "${shortname}" == "rust" ]; then - if [ -d "${serveridentitydir}/storage" ]||[ -d "${serveridentitydir}/user" ]||[ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then - fn_print_warning_nl "Any user, storage, log and map data from ${serveridentitydir} will be erased." - if ! fn_prompt_yn "Continue?" Y; then - core_exit.sh +fn_stop_warning(){ + fn_print_warn "this game server will be stopped during wipe" + fn_script_log_warn "this game server will be stopped during wipe" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "this game server will be stopped during wipe: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break fi - fn_script_log_info "User selects to erase any user, storage, log and map data from ${serveridentitydir}" - fn_sleep_time - fn_wipe_server_process + done + fn_print_warn_nl "this game server will be stopped during wipe" +} + +fn_wipe_warning(){ + fn_print_warn "wipe is about to start" + fn_script_log_warn "wipe is about to start" + totalseconds=3 + for seconds in {3..1}; do + fn_print_warn "wipe is about to start: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + sleep 1 + if [ "${seconds}" == "0" ]; then + break + fi + done + fn_print_warn "wipe is about to start" +} + +fn_print_dots "" +check.sh + +# Check if there is something to wipe. +if [ -d "${serveridentitydir}/storage" ]||[ -d "${serveridentitydir}/user" ]||[ -n "$(find "${serveridentitydir}" -type f -name "proceduralmap*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "barren*.sav")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "Log.*.txt")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.deaths.*.db")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "player.blueprints.*.db")" ]||[ -n "$(find "${serveridentitydir}" -type f -name "sv.files.*.db")" ]; then + fn_wipe_warning + check_status.sh + if [ "${status}" != "0" ]; then + fn_stop_warning + exitbypass=1 + command_stop.sh + fn_commandname + fn_wipe_server_files + exitbypass=1 + command_start.sh + fn_commandname else - fn_print_information_nl "No data to wipe was found" - fn_script_log_info "No data to wipe was found." - core_exit.sh + fn_wipe_server_files fi -# You can add an "elif" here to add another game or engine. -else - # Game not listed. - fn_print_information_nl "Wipe is not available for this game" - fn_script_log_info "Wipe is not available for this game." - core_exit.sh + fn_print_ok_nl "" + fn_script_log_pass "Wiping server" fi core_exit.sh diff --git a/lgsm/functions/fix_kf.sh b/lgsm/functions/fix_kf.sh index f0c29ee6f..a745094b0 100644 --- a/lgsm/functions/fix_kf.sh +++ b/lgsm/functions/fix_kf.sh @@ -21,11 +21,15 @@ echo -e "forcing server restart..." fn_sleep_time exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname diff --git a/lgsm/functions/fix_kf2.sh b/lgsm/functions/fix_kf2.sh index 77edd77e8..99e96543a 100644 --- a/lgsm/functions/fix_kf2.sh +++ b/lgsm/functions/fix_kf2.sh @@ -14,6 +14,8 @@ fn_print_information "starting ${gamename} server to generate configs." fn_sleep_time exitbypass=1 command_start.sh +fn_commandname sleep 10 exitbypass=1 command_stop.sh +fn_commandname diff --git a/lgsm/functions/fix_ro.sh b/lgsm/functions/fix_ro.sh index 9f08d56d7..902fed7fe 100644 --- a/lgsm/functions/fix_ro.sh +++ b/lgsm/functions/fix_ro.sh @@ -24,11 +24,15 @@ echo -e "forcing server restart..." fn_sleep_time exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname diff --git a/lgsm/functions/fix_ut2k4.sh b/lgsm/functions/fix_ut2k4.sh index fa2d29bf5..07805d42b 100644 --- a/lgsm/functions/fix_ut2k4.sh +++ b/lgsm/functions/fix_ut2k4.sh @@ -21,11 +21,15 @@ echo -e "forcing server restart." fn_sleep_time exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname exitbypass=1 command_start.sh +fn_commandname sleep 5 exitbypass=1 command_stop.sh +fn_commandname diff --git a/lgsm/functions/fix_ut3.sh b/lgsm/functions/fix_ut3.sh index e6c018d00..ad9b3db4e 100644 --- a/lgsm/functions/fix_ut3.sh +++ b/lgsm/functions/fix_ut3.sh @@ -14,6 +14,8 @@ fn_print_information "starting ${gamename} server to generate configs." fn_sleep_time exitbypass=1 command_start.sh +fn_commandname sleep 10 exitbypass=1 command_stop.sh +fn_commandname diff --git a/lgsm/functions/fix_wurm.sh b/lgsm/functions/fix_wurm.sh index 809651d55..40325d729 100644 --- a/lgsm/functions/fix_wurm.sh +++ b/lgsm/functions/fix_wurm.sh @@ -18,8 +18,10 @@ if [ ! -d "${serverfiles}/Creative" ]; then fixbypass=1 exitbypass=1 command_start.sh + fn_commandname sleep 10 exitbypass=1 command_stop.sh + fn_commandname unset parmsbypass fi diff --git a/lgsm/functions/update_factorio.sh b/lgsm/functions/update_factorio.sh index 5ff67c448..869314d60 100644 --- a/lgsm/functions/update_factorio.sh +++ b/lgsm/functions/update_factorio.sh @@ -96,17 +96,21 @@ fn_update_factorio_compare(){ fn_update_factorio_dl exitbypass=1 command_start.sh + fn_commandname exitbypass=1 command_stop.sh + fn_commandname # If server started. else fn_stop_warning exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 fn_update_factorio_dl exitbypass=1 command_start.sh + fn_commandname fi date +%s > "${lockdir}/lastupdate.lock" alert="update" @@ -131,18 +135,18 @@ fn_update_factorio_compare(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh index 556097bd6..bf898ea91 100644 --- a/lgsm/functions/update_minecraft.sh +++ b/lgsm/functions/update_minecraft.sh @@ -44,8 +44,10 @@ fn_update_minecraft_localbuild(){ fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 command_start.sh + fn_commandname totalseconds=0 # Check again, allow time to generate logs. while [ ! -f "${serverfiles}/logs/latest.log" ]; do @@ -190,18 +192,18 @@ fn_update_minecraft_compare(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_minecraft_bedrock.sh b/lgsm/functions/update_minecraft_bedrock.sh index 61cad6854..2966980b0 100644 --- a/lgsm/functions/update_minecraft_bedrock.sh +++ b/lgsm/functions/update_minecraft_bedrock.sh @@ -47,13 +47,16 @@ fn_update_minecraft_localbuild(){ if [ "${status}" == "0" ]; then exitbypass=1 command_start.sh + fn_commandname sleep 3 exitbypass=1 command_stop.sh + fn_commandname # If server started. else exitbypass=1 command_stop.sh + fn_commandname fi fi @@ -150,18 +153,18 @@ fn_update_minecraft_compare(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_mta.sh b/lgsm/functions/update_mta.sh index 5aaecc122..0de1faab9 100644 --- a/lgsm/functions/update_mta.sh +++ b/lgsm/functions/update_mta.sh @@ -38,8 +38,10 @@ fn_update_mta_localbuild(){ fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 command_start.sh + fn_commandname totalseconds=0 # Check again, allow time to generate logs. while [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; do @@ -181,18 +183,18 @@ fn_update_mta_compare(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh index ee6a2b0ad..982b7edb3 100644 --- a/lgsm/functions/update_mumble.sh +++ b/lgsm/functions/update_mumble.sh @@ -89,17 +89,21 @@ fn_update_mumble_compare(){ fn_update_mumble_dl exitbypass=1 command_start.sh + fn_commandname exitbypass=1 command_stop.sh + fn_commandname # If server started. else fn_stop_warning exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 fn_update_mumble_dl exitbypass=1 command_start.sh + fn_commandname fi date +%s > "${lockdir}/lastupdate.lock" alert="update" @@ -118,18 +122,18 @@ fn_update_mumble_compare(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 8a089c7f7..0b2612611 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -128,10 +128,12 @@ fn_update_steamcmd_compare(){ fn_stop_warning exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 fn_update_steamcmd_dl exitbypass=1 command_start.sh + fn_commandname fi date +%s > "${lockdir}/lastupdate.lock" alert="update" @@ -206,18 +208,18 @@ fn_appmanifest_check(){ } fn_stop_warning(){ - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" - fn_script_log_warn "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn "this game server will be stopped during update" + fn_script_log_warn "this game server will be stopped during update" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Updating server: SteamCMD: ${selfname} will be stopped during update: ${totalseconds}" + fn_print_warn "this game server will be stopped during update: ${totalseconds}" totalseconds=$((totalseconds - 1)) sleep 1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Updating server: SteamCMD: ${selfname} will be stopped during update" + fn_print_warn_nl "this game server will be stopped during update" } # The location where the builds are checked and downloaded. diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index a5cc0dd60..889e773e6 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -42,8 +42,10 @@ fn_update_ts3_localbuild(){ fn_script_log_info "Forcing server restart" exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 command_start.sh + fn_commandname totalseconds=0 # Check again, allow time to generate logs. while [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; do @@ -150,17 +152,21 @@ fn_update_ts3_compare(){ fn_update_ts3_dl exitbypass=1 command_start.sh + fn_commandname exitbypass=1 command_stop.sh + fn_commandname # If server started. else fn_stop_warning exitbypass=1 command_stop.sh + fn_commandname exitbypass=1 fn_update_ts3_dl exitbypass=1 command_start.sh + fn_commandname fi date +%s > "${lockdir}/lastupdate.lock" alert="update"