From 7760c3a6f4cbffb10597a7bf89c5bf5c88334e4f Mon Sep 17 00:00:00 2001 From: Steve Axtmann Date: Sat, 27 Jan 2024 17:28:17 +0100 Subject: [PATCH 1/3] feat(hldmserver): add support for the fastdl command --- lgsm/modules/command_fastdl.sh | 15 ++++++++++++--- lgsm/modules/core_getopt.sh | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lgsm/modules/command_fastdl.sh b/lgsm/modules/command_fastdl.sh index c1c667797c..3579875f2d 100644 --- a/lgsm/modules/command_fastdl.sh +++ b/lgsm/modules/command_fastdl.sh @@ -20,9 +20,13 @@ addonsdir="${systemdir}/addons" luasvautorundir="${systemdir}/lua/autorun/server" luafastdlfile="lgsm_cl_force_fastdl.lua" luafastdlfullpath="${luasvautorundir}/${luafastdlfile}" +# Only Source supports bzip2 compression. +if [ "${engine}" == "source" ]; then + supportsbzip="" +fi # Check if bzip2 is installed. -if [ ! "$(command -v bzip2 2> /dev/null)" ]; then +if [ -v supportsbzip ] && [ ! "$(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 @@ -225,7 +229,10 @@ fn_fastdl_preview() { fn_script_log_fail "Generating file list." core_exit.sh fi - echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" + if [ -v supportsbzip ]; then + compressionmessage="about to compress ${totalfiles} files, " + fi + echo -e "${compressionmessage}total size $(fn_human_readable_file_size ${filesizetotal} 0)" 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 @@ -431,7 +438,9 @@ fn_fastdl_preview fn_clear_old_fastdl fn_fastdl_dirs fn_fastdl_build -fn_fastdl_bzip2 +if [ -v supportsbzip ]; then + fn_fastdl_bzip2 +fi # Finished message. echo -e "FastDL files are located in:" echo -e "${fastdldir}" diff --git a/lgsm/modules/core_getopt.sh b/lgsm/modules/core_getopt.sh index 685e1ce8b0..913ebef89b 100644 --- a/lgsm/modules/core_getopt.sh +++ b/lgsm/modules/core_getopt.sh @@ -94,7 +94,7 @@ fi ## Game server exclusive commands. # FastDL command. -if [ "${engine}" == "source" ]; then +if [ "${engine}" == "source" ] || [ "${shortname}" == "hldm" ]; then currentopt+=("${cmd_fastdl[@]}") fi From e3a0ee26a3ec35195e7cdd8c4545a2609d803fa7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 21 Jun 2025 21:47:10 +0100 Subject: [PATCH 2/3] fix(mods): set exit code to 0 when user cancels mod installation/removal --- lgsm/modules/command_mods_install.sh | 1 + lgsm/modules/command_mods_remove.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/lgsm/modules/command_mods_install.sh b/lgsm/modules/command_mods_install.sh index 19de72ab04..80c61cb773 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 5f70ac389d..78320ec3e5 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 From ed4dcec0288848cab467c215a03593ebe53f2767 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 21 Jun 2025 21:47:47 +0100 Subject: [PATCH 3/3] fix(fastdl): update bzip2 support check and adjust FastDL command conditions --- lgsm/modules/command_fastdl.sh | 40 ++++++++++++++-------------------- lgsm/modules/core_getopt.sh | 2 +- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/lgsm/modules/command_fastdl.sh b/lgsm/modules/command_fastdl.sh index 3579875f2d..f9e9bd42f2 100644 --- a/lgsm/modules/command_fastdl.sh +++ b/lgsm/modules/command_fastdl.sh @@ -20,17 +20,6 @@ addonsdir="${systemdir}/addons" luasvautorundir="${systemdir}/lua/autorun/server" luafastdlfile="lgsm_cl_force_fastdl.lua" luafastdlfullpath="${luasvautorundir}/${luafastdlfile}" -# Only Source supports bzip2 compression. -if [ "${engine}" == "source" ]; then - supportsbzip="" -fi - -# Check if bzip2 is installed. -if [ -v supportsbzip ] && [ ! "$(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 @@ -116,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}" @@ -229,14 +218,17 @@ fn_fastdl_preview() { fn_script_log_fail "Generating file list." core_exit.sh fi - if [ -v supportsbzip ]; then - compressionmessage="about to compress ${totalfiles} files, " + + 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 - echo -e "${compressionmessage}total size $(fn_human_readable_file_size ${filesizetotal} 0)" - fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" + + 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 } @@ -438,7 +430,7 @@ fn_fastdl_preview fn_clear_old_fastdl fn_fastdl_dirs fn_fastdl_build -if [ -v supportsbzip ]; then +if [ "${engine}" == "source" ]; then fn_fastdl_bzip2 fi # Finished message. diff --git a/lgsm/modules/core_getopt.sh b/lgsm/modules/core_getopt.sh index 913ebef89b..e97eac0e81 100644 --- a/lgsm/modules/core_getopt.sh +++ b/lgsm/modules/core_getopt.sh @@ -94,7 +94,7 @@ fi ## Game server exclusive commands. # FastDL command. -if [ "${engine}" == "source" ] || [ "${shortname}" == "hldm" ]; then +if [ "${engine}" == "source" ] || [ "${engine}" == "goldsrc" ]; then currentopt+=("${cmd_fastdl[@]}") fi