diff --git a/.editorconfig b/.editorconfig index f20e02e1c..da6e5f2ca 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,28 +1,17 @@ # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. -# Atom: Please assure your Atom's config setting Tab Type is set to auto, otherwise Atom-EditorConfig may not work as expected. Also disable whitespace package. # http://editorconfig.org/ root = true [*] charset = utf-8 -indent_style = tab -indent_size = 4 -trim_trailing_whitespace = true end_of_line = lf -insert_final_newline = true - -# YAML Files -[*.{yml,yaml}] -indent_size = 2 -indent_style = space - -# JSON Files -[*.{json,json5,webmanifest}] indent_size = 2 indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true # BASH Files [*.{.sh}] -indent_style = tab indent_size = 4 +indent_style = tab diff --git a/.github/workflows/details-check.yml b/.github/workflows/details-check.yml index 748a77991..f52d12c5a 100644 --- a/.github/workflows/details-check.yml +++ b/.github/workflows/details-check.yml @@ -68,6 +68,10 @@ jobs: else curl -f -o config "https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/main/${{ matrix.shortname }}/${{ steps.sets-servercfgname.outputs.servercfgname }}" fi + + - name: Pre-load LinuxGSM + run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server details + - name: Display config run: | if [ "${{ steps.sets-servercfgname.outputs.servercfgname }}" == "" ]; then diff --git a/.github/workflows/update-check.yml b/.github/workflows/update-check.yml index 932e3ea2a..2f2f7babc 100644 --- a/.github/workflows/update-check.yml +++ b/.github/workflows/update-check.yml @@ -13,12 +13,12 @@ concurrency: jobs: update-check: if: github.repository_owner == 'GameServerManagers' - continue-on-error: true runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - shortname: [css, fctr, jk2, mc, mcb, mta, pmc, ts3, ut99, vints] + shortname: [css, fctr, jk2, mc, mcb, mta, pmc, ts3, ut99, vints, xnt] steps: - name: Download linuxgsm.sh diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 000000000..026ee646c --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2154 diff --git a/lgsm/config-default/config-lgsm/hl2dmserver/_default.cfg b/lgsm/config-default/config-lgsm/hl2dmserver/_default.cfg index c429a6c8e..7ce4dd073 100644 --- a/lgsm/config-default/config-lgsm/hl2dmserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/hl2dmserver/_default.cfg @@ -9,6 +9,8 @@ #### Game Server Settings #### ## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters +# Note that for HL2DM, maxplayers > 33 must be specified like so: +# maxplayers="101 -unrestricted_maxplayers" ip="0.0.0.0" port="27015" clientport="27005" diff --git a/lgsm/config-default/config-lgsm/tf2server/_default.cfg b/lgsm/config-default/config-lgsm/tf2server/_default.cfg index 600249013..74fd359ab 100644 --- a/lgsm/config-default/config-lgsm/tf2server/_default.cfg +++ b/lgsm/config-default/config-lgsm/tf2server/_default.cfg @@ -9,6 +9,8 @@ #### Game Server Settings #### ## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters +# Note that for TF2, maxplayers > 33 must be specified like so: +# maxplayers="101 -unrestricted_maxplayers" ip="0.0.0.0" port="27015" clientport="27005" diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 1ed3da441..1440b6a96 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -46,6 +46,11 @@ json=$( "name": "Server Time", "value": "$(date)", "inline": true + }, + { + "name": "More info", + "value": "${alerturl}", + "inline": true } EOF ) @@ -63,7 +68,7 @@ EOF ) fi -if [ -n "{alerturl}" ]; then +if [ -n "${alerturl}" ]; then json+=$( cat << EOF , diff --git a/lgsm/modules/alert_email.sh b/lgsm/modules/alert_email.sh index aa13494d1..81c01e25b 100644 --- a/lgsm/modules/alert_email.sh +++ b/lgsm/modules/alert_email.sh @@ -15,7 +15,7 @@ else mail -s "${alerttitle}" "${email}" < "${alertlog}" fi exitcode=$? -if [ "${exitcode}" -ne 0 ]; then +if [ "${exitcode}" -eq 0 ]; then fn_print_ok_nl "Sending Email alert: ${email}" fn_script_log_pass "Sending Email alert: ${email}" else diff --git a/lgsm/modules/check.sh b/lgsm/modules/check.sh index 59ac2a329..3922aec21 100644 --- a/lgsm/modules/check.sh +++ b/lgsm/modules/check.sh @@ -31,7 +31,7 @@ if [ "${commandname}" != "INSTALL" ] && [ "${commandname}" != "UPDATE-LGSM" ] && check_system_dir.sh fi -allowed_commands_array=(START DEBUG) +allowed_commands_array=(DEBUG RESTART START) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_executable.sh @@ -39,7 +39,7 @@ for allowed_command in "${allowed_commands_array[@]}"; do done if [ "$(whoami)" != "root" ]; then - allowed_commands_array=(DEBUG START INSTALL) + allowed_commands_array=(DEBUG RESTART START INSTALL) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_glibc.sh @@ -54,21 +54,21 @@ for allowed_command in "${allowed_commands_array[@]}"; do fi done -allowed_commands_array=(BACKUP DEBUG DETAILS START UPDATE) +allowed_commands_array=(BACKUP DEBUG DETAILS RESTART START UPDATE) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_deps.sh fi done -allowed_commands_array=(CONSOLE DEBUG MONITOR START STOP) +allowed_commands_array=(CONSOLE DEBUG MONITOR RESTART START STOP) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_config.sh fi done -allowed_commands_array=(DEBUG DETAILS DEV-QUERY-RAW MONITOR POST_DETAILS START STOP POST-DETAILS) +allowed_commands_array=(DEBUG DETAILS DEV-QUERY-RAW MONITOR POST_DETAILS RESTART START STOP POST-DETAILS) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then if [ -z "${installflag}" ]; then @@ -77,7 +77,7 @@ for allowed_command in "${allowed_commands_array[@]}"; do fi done -allowed_commands_array=(DEBUG START UPDATE VALIDATE CHECK-UPDATE) +allowed_commands_array=(DEBUG RESTART START UPDATE VALIDATE CHECK-UPDATE) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then if [ "${appid}" ]; then @@ -86,21 +86,21 @@ for allowed_command in "${allowed_commands_array[@]}"; do fi done -allowed_commands_array=(CHANGE-PASSWORD DETAILS MONITOR START STOP UPDATE VALIDATE POST-DETAILS) +allowed_commands_array=(CHANGE-PASSWORD DETAILS MONITOR RESTART START STOP UPDATE VALIDATE POST-DETAILS) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_status.sh fi done -allowed_commands_array=(DEBUG START INSTALL) +allowed_commands_array=(DEBUG RESTART START INSTALL) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_system_requirements.sh fi done -allowed_commands_array=(DETAILS MONITOR START STOP UPDATE VALIDATE POST-DETAILS) +allowed_commands_array=(DETAILS MONITOR RESTART START STOP UPDATE VALIDATE POST-DETAILS) for allowed_command in "${allowed_commands_array[@]}"; do if [ "${allowed_command}" == "${commandname}" ]; then check_gamedig.sh diff --git a/lgsm/modules/command_backup.sh b/lgsm/modules/command_backup.sh index f427e8b00..5892a81eb 100644 --- a/lgsm/modules/command_backup.sh +++ b/lgsm/modules/command_backup.sh @@ -13,13 +13,13 @@ fn_firstcommand_set # Trap to remove lockfile on quit. fn_backup_trap() { echo -e "" - echo -en "backup ${backupname}.tar.gz..." + echo -en "backup ${backupname}.${compressext}..." fn_print_canceled_eol_nl - fn_script_log_info "Backup ${backupname}.tar.gz: CANCELED" - rm -f "${backupdir:?}/${backupname}.tar.gz" | tee -a "${lgsmlog}" - echo -en "backup ${backupname}.tar.gz..." + fn_script_log_info "Backup ${backupname}.${compressext}: CANCELED" + rm -f "${backupdir:?}/${backupname}.${compressext}" | tee -a "${lgsmlog}" + echo -en "backup ${backupname}.${compressext}..." fn_print_removed_eol_nl - fn_script_log_info "Backup ${backupname}.tar.gz: REMOVED" + fn_script_log_info "Backup ${backupname}.${compressext}: REMOVED" # Remove backup lockfile. rm -f "${lockdir:?}/backup.lock" fn_backup_start_server @@ -110,23 +110,47 @@ fn_backup_create_lockfile() { trap fn_backup_trap INT } +fn_select_compression() { + if command -v zstd > /dev/null 2>&1; then + compressprog="zstd" + compressext="tar.zst" + compressflag="--zstd" + elif command -v pigz > /dev/null 2>&1; then + compressprog="pigz" + compressext="tar.gz" + compressflag="--use-compress-program=pigz" + elif command -v gzip > /dev/null 2>&1; then + compressprog="gzip" + compressext="tar.gz" + compressflag="--gzip" + else + compressprog="" + compressext="tar" + compressflag="" + fi +} + # Compressing files. fn_backup_compression() { - # Tells how much will be compressed using rootdirduexbackup value from info_distro and prompt for continue. + fn_print_info "A total of ${rootdirduexbackup} will be compressed." - fn_script_log_info "A total of ${rootdirduexbackup} will be compressed: ${backupdir}/${backupname}.tar.gz" - fn_print_dots "Backup (${rootdirduexbackup}) ${backupname}.tar.gz, in progress ..." - fn_script_log_info "Backup ${rootdirduexbackup} ${backupname}.tar.gz, in progress" + fn_script_log_info "A total of ${rootdirduexbackup} will be compressed: ${backupdir}/${backupname}.${compressext}" + fn_print_dots "Backup (${rootdirduexbackup}) ${backupname}.${compressext}, in progress ..." + fn_script_log_info "Backup ${rootdirduexbackup} ${backupname}.${compressext}, in progress" excludedir=$(fn_backup_relpath) - # Check that excludedir is a valid path. if [ ! -d "${excludedir}" ]; then fn_print_fail_nl "Problem identifying the previous backup directory for exclusion." fn_script_log_fail "Problem identifying the previous backup directory for exclusion" core_exit.sh fi - tar --use-compress-program=pigz -cf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" --exclude "${tmpdir}" ./. + if [ -n "${compressflag}" ]; then + tar ${compressflag} -hcf "${backupdir}/${backupname}.${compressext}" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" --exclude "${tmpdir}" ./. + else + tar -hcf "${backupdir}/${backupname}.${compressext}" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" --exclude "${tmpdir}" ./. + fi + exitcode=$? if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol @@ -136,8 +160,8 @@ fn_backup_compression() { fn_script_log_fail "Starting backup" else fn_print_ok_eol - fn_print_ok_nl "Completed: ${italic}${backupname}.tar.gz${default}, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" - fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" + fn_print_ok "Completed: ${italic}${backupname}.${compressext}${default}, total size $(du -sh "${backupdir}/${backupname}.${compressext}" | awk '{print $1}')" + fn_script_log_pass "Backup created: ${backupname}.${compressext}, total size $(du -sh "${backupdir}/${backupname}.${compressext}" | awk '{print $1}')" alert="backup" alert.sh fi @@ -152,7 +176,7 @@ fn_backup_prune() { # How many backups exceed maxbackups. backupquotadiff=$((backupcount - maxbackups)) # How many backups exceed maxbackupdays. - backupsoudatedcount=$(find "${backupdir}"/ -type f -name "*.tar.gz" -mtime +"${maxbackupdays}" | wc -l) + backupsoudatedcount=$(find "${backupdir}"/ -type f -name "*.tar.*" -mtime +"${maxbackupdays}" | wc -l) # If anything can be cleared. if [ "${backupquotadiff}" -gt "0" ] || [ "${backupsoudatedcount}" -gt "0" ]; then fn_print_dots "Pruning" @@ -167,7 +191,7 @@ fn_backup_prune() { fn_print_dots "Pruning: Clearing ${backupquotadiff} backup(s)" fn_script_log_info "Pruning: Clearing ${backupquotadiff} backup(s)" # Clear backups over quota. - find "${backupdir}"/ -type f -name "*.tar.gz" -printf '%T@ %p\n' | sort -rn | tail -${backupquotadiff} | cut -f2- -d" " | xargs rm + find "${backupdir}"/ -type f -name "*.tar.*" -printf '%T@ %p\n' | sort -rn | tail -${backupquotadiff} | cut -f2- -d" " | xargs rm fn_print_ok_nl "Pruning: Clearing ${backupquotadiff} backup(s)" fn_script_log_pass "Pruning: Cleared ${backupquotadiff} backup(s)" # If maxbackupdays is used over maxbackups. @@ -190,7 +214,7 @@ fn_backup_prune() { fn_backup_relpath() { # Written by CedarLUG as a "realpath --relative-to" alternative in bash. # Populate an array of tokens initialized from the rootdir components. - declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g")) + mapfile -t rdirtoks < <(readlink -f "${rootdir}" | sed "s/\//\n/g") if [ ${#rdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing rootdir during relative path assessment" fn_script_log_fail "Problem assessing rootdir during relative path assessment: ${rootdir}" @@ -198,7 +222,7 @@ fn_backup_relpath() { fi # Populate an array of tokens initialized from the backupdir components. - declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g")) + mapfile -t bdirtoks < <(readlink -f "${backupdir}" | sed "s/\//\n/g") if [ ${#bdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing backupdir during relative path assessment" fn_script_log_fail "Problem assessing backupdir during relative path assessment: ${rootdir}" @@ -243,12 +267,12 @@ fn_backup_start_server() { fn_print_dots "" check.sh core_logs.sh - +fn_select_compression fn_backup_check_lockfile +fn_backup_create_lockfile fn_backup_init fn_backup_stop_server fn_backup_dir -fn_backup_create_lockfile fn_backup_compression fn_backup_prune fn_backup_start_server diff --git a/lgsm/modules/command_check_update.sh b/lgsm/modules/command_check_update.sh index ee4c8ccb3..38f8b4ddc 100644 --- a/lgsm/modules/command_check_update.sh +++ b/lgsm/modules/command_check_update.sh @@ -32,6 +32,8 @@ elif [ "${shortname}" == "vints" ]; then update_vints.sh elif [ "${shortname}" == "ut99" ]; then update_ut99.sh +elif [ "${shortname}" == "xnt" ]; then + update_xnt.sh else update_steamcmd.sh fi diff --git a/lgsm/modules/command_fastdl.sh b/lgsm/modules/command_fastdl.sh index e3437bc1f..3b8165444 100644 --- a/lgsm/modules/command_fastdl.sh +++ b/lgsm/modules/command_fastdl.sh @@ -21,13 +21,6 @@ luasvautorundir="${systemdir}/lua/autorun/server" luafastdlfile="lgsm_cl_force_fastdl.lua" luafastdlfullpath="${luasvautorundir}/${luafastdlfile}" -# Check if bzip2 is installed. -if [ ! "$(command -v bzip2 2> /dev/null)" ]; then - fn_print_fail "bzip2 is not installed" - fn_script_log_fail "bzip2 is not installed" - core_exit.sh -fi - # Header fn_print_header fn_print_nl "More info: ${italic}https://docs.linuxgsm.com/commands/fastdl" @@ -112,13 +105,13 @@ fn_fastdl_dirs() { # Using this gist https://gist.github.com/agunnerson-ibm/efca449565a3e7356906 fn_human_readable_file_size() { local abbrevs=( - $((1 << 60)):ZB - $((1 << 50)):EB - $((1 << 40)):TB - $((1 << 30)):GB - $((1 << 20)):MB - $((1 << 10)):KB - $((1)):bytes + "1152921504606846976:ZB" + "1125899906842624:EB" + "1099511627776:TB" + "1073741824:GB" + "1048576:MB" + "1024:KB" + "1:bytes" ) local bytes="${1}" @@ -225,11 +218,17 @@ fn_fastdl_preview() { fn_script_log_fail "Generating file list." core_exit.sh fi - fn_print_nl "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" + + if [ "${engine}" == "source" ]; then + echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" + elif [ "${engine}" == "goldsrc" ]; then + echo -e "about to copy ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" + fi + fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" rm -f "${tmpdir:?}/fastdl_files_to_compress.txt" if ! fn_prompt_yn "Continue?" Y; then - fn_script_log "User exited" + exitcode=0 core_exit.sh fi } @@ -431,7 +430,9 @@ fn_fastdl_preview fn_clear_old_fastdl fn_fastdl_dirs fn_fastdl_build -fn_fastdl_bzip2 +if [ "${engine}" == "source" ]; then + fn_fastdl_bzip2 +fi # Finished message. fn_print_nl "Fastdl files are located in:" fn_print_nl "${fastdldir}" diff --git a/lgsm/modules/command_mods_install.sh b/lgsm/modules/command_mods_install.sh index 4401e2c56..e76f3f1fa 100644 --- a/lgsm/modules/command_mods_install.sh +++ b/lgsm/modules/command_mods_install.sh @@ -88,6 +88,7 @@ if [ -f "${modsinstalledlistfullpath}" ]; then fn_script_log_warn "${modprettyname} is already installed" echo -e " * Any configs may be overwritten." if ! fn_prompt_yn "Continue?" Y; then + exitcode=0 core_exit.sh fi fn_script_log_info "User selected to continue" diff --git a/lgsm/modules/command_mods_remove.sh b/lgsm/modules/command_mods_remove.sh index 6dc52d95f..589046b11 100644 --- a/lgsm/modules/command_mods_remove.sh +++ b/lgsm/modules/command_mods_remove.sh @@ -47,6 +47,7 @@ done fn_print_warning_nl "You are about to remove ${cyan}${usermodselect}${default}." echo -e " * Any custom files/configuration will be removed." if ! fn_prompt_yn "Continue?" Y; then + exitcode=0 core_exit.sh fi diff --git a/lgsm/modules/command_send.sh b/lgsm/modules/command_send.sh index de021599d..20ef188e3 100644 --- a/lgsm/modules/command_send.sh +++ b/lgsm/modules/command_send.sh @@ -30,12 +30,8 @@ if [ "${status}" != "0" ]; then tmux -L "${socketname}" send-keys -t "${sessionname}" "${commandtosend}" ENTER fn_script_log_pass "Command \"${commandtosend}\" sent to console" else - fn_print_error_nl "Server not running" - fn_script_log_error "Failed to access: Server not running" - if fn_prompt_yn "Do you want to start the server?" Y; then - exitbypass=1 - command_start.sh - fi + fn_print_error_nl "Unable to send command to console. Server not running" + fn_script_log_error "Unable to send command to console. Server not running" fi core_exit.sh diff --git a/lgsm/modules/compress_unreal2_maps.sh b/lgsm/modules/compress_unreal2_maps.sh deleted file mode 100644 index 58824cbc7..000000000 --- a/lgsm/modules/compress_unreal2_maps.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# LinuxGSM compress_unreal2_maps.sh module -# Author: Daniel Gibbs -# Contributors: https://linuxgsm.com/contrib -# Website: https://linuxgsm.com -# Description: Compresses unreal maps. - -commandname="MAP-COMPRESSOR" -commandaction="Compressing Maps" -moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -fn_firstcommand_set - -check.sh -fn_print_header -echo -e "Will compress all maps in:" -echo -e "" -pwd -echo -e "" -echo -e "Compressed maps saved to:" -echo -e "" -echo -e "${compressedmapsdir}" -echo -e "" -if ! fn_prompt_yn "Start compression?" Y; then - exitcode=0 - core_exit.sh -fi -mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 -rm -rfv "${serverfiles:?}/Maps/"*.ut2.uz2 -cd "${systemdir}" || exit -for map in "${serverfiles}/Maps/"*; do - ./ucc-bin compress "${map}" --nohomedir -done -mv -fv "${serverfiles}/Maps/"*.ut2.uz2 "${compressedmapsdir}" - -core_exit.sh diff --git a/lgsm/modules/compress_unreal_maps.sh b/lgsm/modules/compress_unreal_maps.sh new file mode 100644 index 000000000..6b97e03d9 --- /dev/null +++ b/lgsm/modules/compress_unreal_maps.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# LinuxGSM compress_unreal_maps.sh module +# Author: Daniel Gibbs +# Contributors: https://linuxgsm.com/contrib +# Website: https://linuxgsm.com +# Description: Compresses unreal and unreal2 resources. + +commandname="MAP-COMPRESSOR" +commandaction="Compressing Maps" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set + +check.sh +fn_print_header +echo -e "Will compress all maps in:" +echo -e "" +pwd +echo -e "" +echo -e "Compressed maps saved to:" +echo -e "" +echo -e "${compressedmapsdir}" +echo -e "" +totalseconds=3 +for seconds in {3..1}; do + fn_print_warn "map compression starting in: ${totalseconds}" + totalseconds=$((totalseconds - 1)) + fn_sleep_time_1 + if [ "${seconds}" == "0" ]; then + break + fi +done +fn_print_nl +mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 + +# List of extensions to compress +exts=(ut2 kfm rom u ucl upl int utx uax ukx usx unr umx umod uzx) + +# Remove old compressed files using find +for ext in "${exts[@]}"; do + mapfile -t oldfiles < <(find "${serverfiles}" -name "*.${ext}.uz2" -type f) + if [ ${#oldfiles[@]} -gt 0 ]; then + echo -e "found ${#oldfiles[@]} old compressed file(s) to remove for extension: ${ext}" + fi + for file in "${oldfiles[@]}"; do + if rm -f "$file"; then + echo -en "removing file [ ${italic}$(basename "$file")${default} ]\c" + fn_print_ok_eol_nl + else + echo -en "removing file [ ${italic}$(basename "$file")${default} ]\c" + fn_print_fail_eol_nl + fi + done +done + +cd "${systemdir}" || exit + +# Find and compress files, then move .uz2 to compressedmapsdir +for ext in "${exts[@]}"; do + # Collect all files with the current extension into an array + mapfile -t files < <(find "${serverfiles}" -name "*.${ext}" -type f) + for file in "${files[@]}"; do + echo -en "compressing file [ ${italic}$(basename "$file") -> $(basename "$file").uz2${default} ]\c" + if ! ./ucc-bin compress "${file}" --nohomedir > /dev/null 2>&1; then + fn_print_fail_eol_nl + core_exit.sh + else + fn_print_ok_eol_nl + fi + + if ! mv -f "${file}.uz2" "${compressedmapsdir}" > /dev/null 2>&1; then + echo -en "moving compressed file [ ${italic}$(basename "$file").uz2 -> ${compressedmapsdir}/$(basename "$file").uz2${default} ]\c" + fn_print_fail_eol_nl + core_exit.sh + fi + done +done + +fn_print_ok_nl "Compression complete: All compressed files moved to: ${compressedmapsdir}" + +core_exit.sh diff --git a/lgsm/modules/compress_ut99_maps.sh b/lgsm/modules/compress_ut99_maps.sh deleted file mode 100644 index 885c32d9a..000000000 --- a/lgsm/modules/compress_ut99_maps.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# LinuxGSM compress_ut99_maps.sh module -# Author: Daniel Gibbs -# Contributors: https://linuxgsm.com/contrib -# Website: https://linuxgsm.com -# Description: Compresses unreal maps. - -commandname="MAP-COMPRESSOR" -commandaction="Compressing Maps" -moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -fn_firstcommand_set - -check.sh -fn_print_header -echo -e "Will compress all maps in:" -echo -e "" -pwd -echo -e "" -echo -e "Compressed maps saved to:" -echo -e "" -echo -e "${compressedmapsdir}" -echo -e "" -if ! fn_prompt_yn "Start compression?" Y; then - exitcode=0 - core_exit.sh -fi -mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 -rm -rfv "${serverfiles:?}/Maps/"*.unr.uz -cd "${systemdir}" || exit -for map in "${serverfiles}/Maps/"*; do - ./ucc-bin compress "${map}" --nohomedir -done -mv -fv "${serverfiles}/Maps/"*.unr.uz "${compressedmapsdir}" - -core_exit.sh diff --git a/lgsm/modules/core_exit.sh b/lgsm/modules/core_exit.sh index 5f55dfcd1..1dd6e2f46 100644 --- a/lgsm/modules/core_exit.sh +++ b/lgsm/modules/core_exit.sh @@ -13,8 +13,8 @@ fn_exit_dev_debug() { echo -e "${moduleselfname} exiting with code: ${exitcode}" if [ -f "${rootdir}/dev-debug.log" ]; then grep -a "modulefile=" "${rootdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" - elif [ -f "${lgsmlogdir}/dev-debug.log" ]; then - grep -a "modulefile=" "${lgsmlogdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" + elif [ -f "${logdir}/dev-debug.log" ]; then + grep -a "modulefile=" "${logdir}/dev-debug.log" | sed 's/modulefile=//g' > "${logdir}/dev-debug-module-order.log" fi fi } diff --git a/lgsm/modules/core_getopt.sh b/lgsm/modules/core_getopt.sh index 9a5704663..295f9900b 100644 --- a/lgsm/modules/core_getopt.sh +++ b/lgsm/modules/core_getopt.sh @@ -42,8 +42,7 @@ cmd_change_password=("pw;change-password" "command_ts3_server_pass.sh" "Change T cmd_install_default_resources=("ir;install-default-resources" "command_install_resources_mta.sh" "Install the MTA default resources.") cmd_fullwipe=("fw;full-wipe;wa;wipeall" "serverwipe=1; command_wipe.sh" "Reset the map and remove blueprint data.") cmd_mapwipe=("mw;map-wipe;w;wipe;wi" "mapwipe=1; command_wipe.sh" "Reset the map and keep blueprint 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_map_compressor_unreal=("mc;map-compressor" "compress_unreal_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_install_squad_license=("li;license" "install_squad_license.sh" "Add your Squad server license.") @@ -96,7 +95,7 @@ fi ## Game server exclusive commands. # FastDL command. -if [ "${engine}" == "source" ]; then +if [ "${engine}" == "source" ] || [ "${engine}" == "goldsrc" ]; then currentopt+=("${cmd_fastdl[@]}") fi @@ -113,13 +112,13 @@ fi # Unreal exclusive. if [ "${engine}" == "unreal2" ]; then if [ "${shortname}" == "ut2k4" ]; then - currentopt+=("${cmd_install_cdkey[@]}" "${cmd_map_compressor_u2[@]}") + currentopt+=("${cmd_install_cdkey[@]}" "${cmd_map_compressor_unreal[@]}") else - currentopt+=("${cmd_map_compressor_u2[@]}") + currentopt+=("${cmd_map_compressor_unreal[@]}") fi fi if [ "${engine}" == "unreal" ]; then - currentopt+=("${cmd_map_compressor_u99[@]}") + currentopt+=("${cmd_map_compressor_unreal[@]}") fi # DST exclusive. diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index e5e6d1e5d..2116e5366 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -275,11 +275,6 @@ compress_unreal2_maps.sh() { fn_fetch_module } -compress_ut99_maps.sh() { - modulefile="${FUNCNAME[0]}" - fn_fetch_module -} - # Mods mods_list.sh() { diff --git a/lgsm/modules/info_distro.sh b/lgsm/modules/info_distro.sh index 67a9fd5df..a986edf1f 100644 --- a/lgsm/modules/info_distro.sh +++ b/lgsm/modules/info_distro.sh @@ -252,11 +252,11 @@ if [ -d "${backupdir}" ]; then backupcount=0 # If there are backups in backup dir. - if [ "$(find "${backupdir}" -name "*.tar.gz" | wc -l)" -ne "0" ]; then + if [ "$(find "${backupdir}" -name "*.tar.*" | wc -l)" -ne "0" ]; then # number of backups. - backupcount="$(find "${backupdir}"/*.tar.gz | wc -l)" # integer + backupcount="$(find "${backupdir}"/*.tar.* | wc -l)" # integer # most recent backup. - lastbackup="$(ls -1t "${backupdir}"/*.tar.gz | head -1)" # string + lastbackup="$(ls -1t "${backupdir}"/*.tar.* | head -1)" # string # date of most recent backup. lastbackupdate="$(date -r "${lastbackup}")" # string # no of days since last backup. diff --git a/lgsm/modules/install_config.sh b/lgsm/modules/install_config.sh index db6b1e5cf..b73e7b4b2 100644 --- a/lgsm/modules/install_config.sh +++ b/lgsm/modules/install_config.sh @@ -289,7 +289,6 @@ elif [ "${shortname}" == "bt" ]; then elif [ "${shortname}" == "btl" ]; then fn_check_cfgdir array_configs+=(Game.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -370,7 +369,6 @@ elif [ "${shortname}" == "cs" ]; then fn_list_config_locations elif [ "${shortname}" == "cs2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -483,7 +481,6 @@ elif [ "${shortname}" == "hldms" ]; then fn_list_config_locations elif [ "${shortname}" == "ohd" ]; then array_configs+=(Admins.cfg Engine.ini Game.ini MapCycle.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -585,7 +582,6 @@ elif [ "${shortname}" == "pvkii" ]; then fn_list_config_locations elif [ "${shortname}" == "pw" ]; then array_configs+=(PalWorldSettings.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -614,13 +610,11 @@ elif [ "${shortname}" == "q2" ]; then fn_list_config_locations elif [ "${shortname}" == "q3" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "q4" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -783,8 +777,8 @@ elif [ "${shortname}" == "wmc" ]; then fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "xnt" ]; then + fix_xnt.sh array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations diff --git a/lgsm/modules/install_ut2k4_key.sh b/lgsm/modules/install_ut2k4_key.sh index 2829da8d6..963a52f10 100644 --- a/lgsm/modules/install_ut2k4_key.sh +++ b/lgsm/modules/install_ut2k4_key.sh @@ -27,3 +27,4 @@ else echo -e "./${selfname} server-cd-key" fi echo -e "" +core_exit.sh diff --git a/lgsm/modules/mods_list.sh b/lgsm/modules/mods_list.sh index f6f8301bd..bbefc5ea2 100644 --- a/lgsm/modules/mods_list.sh +++ b/lgsm/modules/mods_list.sh @@ -55,13 +55,13 @@ amxxtslatestfile="amxmodx-${amxxtsversion}-${amxxtsmod}-linux.tar.gz" amxxtsdownloadurl="https://www.amxmodx.org/release/${amxxtslatestfile}" amxxtsurl="${amxxtsdownloadurl}" # Metamod:Source -metamodsourceversion="1.11" +metamodsourceversion="1.12" metamodsourcescrapeurl="https://mms.alliedmods.net/mmsdrop/${metamodsourceversion}/mmsource-latest-linux" metamodsourcelatestfile=$(wget "${metamodsourcescrapeurl}" -q -O -) metamodsourcedownloadurl="https://www.metamodsource.net/latest.php?os=linux&version=${metamodsourceversion}" metamodsourceurl="${metamodsourcedownloadurl}" # Sourcemod -sourcemodversion="1.11" +sourcemodversion="1.13" sourcemodscrapeurl="https://sm.alliedmods.net/smdrop/${sourcemodversion}/sourcemod-latest-linux" sourcemodlatestfile=$(wget "${sourcemodscrapeurl}" -q -O -) sourcemoddownloadurl="https://www.sourcemod.net/latest.php?os=linux&version=${sourcemodversion}" diff --git a/lgsm/modules/update_xnt.sh b/lgsm/modules/update_xnt.sh index f043a4227..c00233aa7 100644 --- a/lgsm/modules/update_xnt.sh +++ b/lgsm/modules/update_xnt.sh @@ -1,9 +1,9 @@ #!/bin/bash -# LinuxGSM command_ut99.sh module +# LinuxGSM command_xnt.sh module # Author: Daniel Gibbs # Contributors: https://linuxgsm.com/contrib # Website: https://linuxgsm.com -# Description: Handles updating of Unreal Tournament 99 servers. +# Description: Handles updating of Xontic servers. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" @@ -17,10 +17,21 @@ fn_update_dl() { fn_update_localbuild() { # Gets local build info. fn_print_dots "Checking local build: ${remotelocation}" - + check_status.sh # Send version command to Xonotic server. - tmux -L "${socketname}" send-keys -t "${sessionname}" "version\r" > /dev/null 2>&1 - fn_sleep_time_1 + if [ "${status}" != "0" ]; then + tmux -L "${socketname}" send-keys -t "${sessionname}" "version" C-m > /dev/null 2>&1 + fn_sleep_time_1 + else + exitbypass=1 + command_start.sh + fn_firstcommand_reset + exitbypass=1 + fn_sleep_time_5 + tmux -L "${socketname}" send-keys -t "${sessionname}" "version" C-m > /dev/null 2>&1 + command_stop.sh + fn_firstcommand_reset + fi # Uses log file to get local build. localbuild=$(grep "SVQC version: xonotic-v" "${consolelogdir}"/* 2> /dev/null | tail -1 | sed 's/.*SVQC version: \(xonotic-v[0-9.]*\).*/\1/' | tr -d '\000-\011\013-\037') diff --git a/linuxgsm.sh b/linuxgsm.sh index 6d6f7251f..2be308d9c 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -32,7 +32,8 @@ rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") lgsmdir="${rootdir}/lgsm" [ -n "${LGSM_LOGDIR}" ] && logdir="${LGSM_LOGDIR}" || logdir="${rootdir}/log" -lgsmlogdir="${logdir}/lgsm" +lgsmlogdir="${logdir}/script" +lgsmlog="${lgsmlogdir}/${selfname}-script.log" steamcmddir="${HOME}/.steam/steamcmd" [ -n "${LGSM_SERVERFILES}" ] && serverfiles="${LGSM_SERVERFILES}" || serverfiles="${rootdir}/serverfiles" modulesdir="${lgsmdir}/modules"