mirror of
https://github.com/GameServerManagers/LinuxGSM
synced 2026-08-18 20:23:04 -04:00
* feat: refactor update comparison output for consistency and clarity - Replaced direct echo statements with fn_print functions for uniformity in output formatting across multiple update scripts. - Ensured lockfile creation uses the correct syntax for variable expansion. - Moved lock file to the same location to ensure monitor doesnt reboot at the wrong time - Updated remote build information display to enhance readability and maintain consistency in logging. - Removed unnecessary echo commands to streamline the output process. * Refactor remote build version handling across multiple modules - Updated variable names from 'remotebuildversion' to 'remotebuild' for consistency. - Adjusted logic to check for remote build availability using the new variable name. - Modified output messages to reflect the change in variable naming. - Ensured all modules (update_mc.sh, update_mcb.sh, update_mta.sh, update_pmc.sh, update_ts3.sh, update_ut99.sh, update_vints.sh, update_xnt.sh) are aligned with the new naming convention for better readability and maintainability. * fix(alert): resolve issue with servername not always being listed in title * Moved `info_distro.sh`, `info_game.sh`, and `info_messages.sh` calls to the top of the `fn_alert_log` function for better clarity. * Updated `alerticon` assignment to maintain consistency in alert information handling. * fix(alert_discord): remove "More info" field from Discord alert JSON * Eliminated the "More info" field to streamline the alert message. * This change enhances the clarity of the alert by focusing on essential information. * fix(alert): improve update alert messaging for clarity * Updated alert messages in `fn_alert_update` and `fn_alert_update_failed` for better readability. * Changed alert action from `update-request` to `update-restart-request` in `fn_monitor_check_update_source`. * remove inline * fix(alert): Correct grammar in update alert message * Changed "an LinuxGSM update" to "a LinuxGSM update" for grammatical accuracy. * typo * fix(alert_discord): Add inline property to "Is my Game Server Online?" field * Ensures proper formatting of the Discord alert message. * Improves the display of the server status information. * fix(pd): increase timeout for termbin.com connection * fix(alert_discord): reorder fields in Discord alert JSON * Changed the order of fields in the Discord alert JSON structure. * Updated the "More info" and "Is my Game Server Online?" fields for better clarity. * revert back to factorio.com Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Standardizes alert messages across platforms Ensures consistency in alert messages across Discord, NTFY, Pushover, Rocketchat, Slack, and Telegram. Updates Discord alerts to include server hostname and time, removes redundant formatting. Standardizes plain-text alert formatting for NTFY. Refactors Pushover messages to use consistent HTML formatting. Streamlines Rocketchat and Slack messages by removing duplicate server info and adding optional link support. * Removes Hostname from alert messages Removes the Hostname field from various alert messages (Discord, Gotify, IFTTT, ntfy, Pushbullet, Pushover, Rocketchat, Slack, Telegram). The hostname was deemed redundant or unnecessary in the context of these alerts. Relates to #4696 * Configures shellcheckrc filename Configures the Super-Linter action to use `.shellcheckrc` as the BASH_FILE_NAME. This ensures that shellcheck uses the correct configuration file for bash script linting. Fixes #4696 * Disables shellcheck errors and removes variable Disables specific shellcheck errors to allow certain coding patterns and removes an unused variable from the super-linter workflow. This improves the linter's signal-to-noise ratio and reduces unnecessary checks. Relates to #4696 * Fixes and improves server list validation scripts Addresses issues in the server list validation scripts: - Fixes potential issues with parsing curl custom arguments in telegram alerts. - Corrects the shortname array generation. - Implements more robust checks for validating game icons. - Ensures the consistency of server counts across different CSV files. * Fixes glibc check and mod selection logic Corrects glibc version comparison to properly handle version strings. Improves mod installation and removal by validating user input against available options, providing a more robust selection process. This prevents errors caused by invalid mod names and enhances the user experience. Updates arithmetic expression syntax for better compatibility. * Fixes cache control for dev-debug mode Updates the handling of cache control headers in dev-debug mode. The `nocache` variable is changed to an array to correctly pass multiple headers to `curl`. This resolves issues with cached versions of files being used when dev-debug is enabled, ensuring that the latest versions are always fetched. Fixes #4696 * Allows spaces in steamcmdcommand variable Parses steamcmdcommand as an array to allow spaces in the variable. This prevents issues when the user wants to pass arguments with spaces to the steamcmd executable. * Addresses various script improvements Addresses multiple improvements across various scripts: - Fixes Valheim unstripped_corlib override by commenting out the lines in the config files. - Improves process identification for source and goldsrc engines using `pgrep`. - Enhances backup file identification using `find` with `-maxdepth 1` and `-type f`. - Fixes glibc version comparison logic in multiple files. - Improves UT2K4 key installation script by using printf for writing the key to the file. - Corrects the mod info extraction logic to correctly identify mod entries. - Improves amxmodx file installation/removal logic to prevent duplicate entries. - Fixes server info retrieval to handle spaces in the server list. Relates to #4696 * Fixes mono repo install exit code check Corrects the mono repo install exit code check to use the dedicated monorepoexitcode variable, ensuring accurate error detection. Updates the exit trap to preserve the original exit status, preventing potential loss of information when handling script termination. * Refactors and reorders core modules Improves module loading by reordering and refactoring the core modules. This change addresses inconsistencies and improves the overall structure of how core modules are handled within the system. Some fix scripts were renamed to match the module name. * Makes scripts executable Changes file permissions to make shell scripts executable. This ensures that the scripts can be run directly. Addresses a pre-existing issue. Related to #4696 * Adds explicit permissions to workflows Specifies explicit permissions for GitHub Actions workflows to enhance security and control access to resources. This ensures that each workflow only has the necessary permissions, following the principle of least privilege. * Fixes output redirection and URL parsing Corrects output redirection in GitHub Actions workflows by enclosing the $GITHUB_OUTPUT variable in quotes, preventing potential issues with variable expansion. Ensures proper URL parsing in workflows by enclosing the URL within quotes, addressing potential parsing errors. Fixes #4696 * Applies code formatting for consistency Applies Prettier formatting to the codebase for improved readability and consistency. Addresses minor code style inconsistencies across several files. * Fixes minor formatting and logic issues Addresses various minor issues including: - Standardizes indentation in `.editorconfig` for different file types. - Simplifies Prettier configuration. - Updates image links in `README.md`. - Ensures newline character at end of `.csv` files. - Corrects a conditional statement in `command_fastdl.sh`. - Corrects a conditional statement in `info_messages.sh`. - Updates server query protocols in `query_gsquery.py`. * Configures and disables linters Adds YAML linting configuration and disables unnecessary linters to streamline the CI/CD process and reduce noise from irrelevant checks. * Improves documentation and linting Updates documentation links to be enclosed in angle brackets, preventing markdown rendering issues. Configures markdownlint to align with repository standards and avoid common false positives. The updated links in the documentation ensure they are correctly interpreted by markdown parsers, improving user experience. The markdownlint configuration fine-tunes linting rules to better match the project's existing style and conventions, reducing noise from irrelevant warnings. * Fixes typos and improves code consistency Addresses various typos and inconsistencies across multiple files, enhancing code readability and maintainability. Adds codespell and flake8 configurations for linting. Relates to #4696 * Excludes workflow files from Prettier formatting Prevents Prettier from formatting workflow files due to GitHub token restrictions, as the token used by the Prettier auto-commit action lacks permissions to update files within the `.github/workflows/` directory. * chore(prettier): format code * Updates Super-Linter configuration Improves Super-Linter's reliability by switching to linting the entire codebase instead of relying on git history. This change also addresses potential transient fetch failures from GitHub. Additionally, this commit expands the ignored paths in codespell and disables some linters to improve performance and reduce false positives. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: dgibbs64 <dgibbs64@users.noreply.github.com>
442 lines
13 KiB
Bash
Executable file
442 lines
13 KiB
Bash
Executable file
#!/bin/bash
|
|
# LinuxGSM command_fastdl.sh module
|
|
# Author: Daniel Gibbs
|
|
# Contributors: https://linuxgsm.com/contrib
|
|
# Website: https://linuxgsm.com
|
|
# Description: Creates a Fastdl directory.
|
|
|
|
commandname="FASTDL"
|
|
commandaction="Fastdl"
|
|
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
fn_firstcommand_set
|
|
|
|
# Directories.
|
|
if [ -z "${webdir}" ]; then
|
|
webdir="${rootdir}/public_html"
|
|
fi
|
|
fastdldir="${webdir}/fastdl"
|
|
addonsdir="${systemdir}/addons"
|
|
# Server lua autorun dir, used to autorun lua on client connect to the server.
|
|
luasvautorundir="${systemdir}/lua/autorun/server"
|
|
luafastdlfile="lgsm_cl_force_fastdl.lua"
|
|
luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
|
|
|
|
# Header
|
|
fn_print_header
|
|
fn_print_nl "More info: ${italic}https://docs.linuxgsm.com/commands/fastdl"
|
|
fn_print_nl ""
|
|
|
|
# Prompts user for Fastdl creation settings.
|
|
fn_print_nl "${bold}${lightyellow}${commandaction} Setup"
|
|
fn_messages_separator
|
|
|
|
# Prompt for clearing old files if directory was already here.
|
|
if [ -d "${fastdldir}" ]; then
|
|
fn_print_warning_nl "Fastdl directory already exists."
|
|
fn_print_nl "${fastdldir}"
|
|
fn_print_nl ""
|
|
if fn_prompt_yn "Overwrite existing directory?" Y; then
|
|
fn_script_log_info "Overwrite existing directory: YES"
|
|
else
|
|
core_exit.sh
|
|
fi
|
|
fi
|
|
|
|
# Garry's Mod Specific.
|
|
if [ "${shortname}" == "gmod" ]; then
|
|
# Prompt for download enforcer, which is using a .lua addfile resource generator.
|
|
if fn_prompt_yn "Force clients to download files?" Y; then
|
|
luaresource="on"
|
|
fn_script_log_info "Force clients to download files: YES"
|
|
else
|
|
luaresource="off"
|
|
fn_script_log_info "Force clients to download filesr: NO"
|
|
fi
|
|
fi
|
|
|
|
# Clears any fastdl directory content.
|
|
fn_clear_old_fastdl() {
|
|
# Clearing old Fastdl.
|
|
if [ -d "${fastdldir}" ]; then
|
|
fn_print "clearing existing Fastdl directory ${fastdldir}"
|
|
rm -rf "${fastdldir:?}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Clearing existing Fastdl directory ${fastdldir}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Clearing existing Fastdl directory ${fastdldir}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
fn_fastdl_dirs() {
|
|
# Check and create directories.
|
|
if [ ! -d "${webdir}" ]; then
|
|
fn_print "creating web directory ${webdir}"
|
|
mkdir -p "${webdir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Creating web directory ${webdir}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Creating web directory ${webdir}"
|
|
fi
|
|
fi
|
|
if [ ! -d "${fastdldir}" ]; then
|
|
fn_print "creating fastdl directory ${fastdldir}"
|
|
mkdir -p "${fastdldir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Creating fastdl directory ${fastdldir}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Creating fastdl directory ${fastdldir}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Using this gist https://gist.github.com/agunnerson-ibm/efca449565a3e7356906
|
|
fn_human_readable_file_size() {
|
|
local abbrevs=(
|
|
"1152921504606846976:ZB"
|
|
"1125899906842624:EB"
|
|
"1099511627776:TB"
|
|
"1073741824:GB"
|
|
"1048576:MB"
|
|
"1024:KB"
|
|
"1:bytes"
|
|
)
|
|
|
|
local bytes="${1}"
|
|
local precision="${2}"
|
|
|
|
if [[ "${bytes}" == "1" ]]; then
|
|
fn_print_nl "1 byte"
|
|
else
|
|
for item in "${abbrevs[@]}"; do
|
|
local factor="${item%:*}"
|
|
local abbrev="${item#*:}"
|
|
if [[ "${bytes}" -ge "${factor}" ]]; then
|
|
size=$(bc -l <<< "${bytes} / ${factor}")
|
|
printf "%.*f %s\n" "${precision}" "${size}" "${abbrev}"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
# Provides info about the fastdl directory content and prompts for confirmation.
|
|
fn_fastdl_preview() {
|
|
# Remove any file list.
|
|
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
|
|
rm -f "${tmpdir:?}/fastdl_files_to_compress.txt"
|
|
fi
|
|
fn_print_nl "analysing required files"
|
|
fn_script_log_info "Analysing required files"
|
|
# Garry's Mod
|
|
if [ "${shortname}" == "gmod" ]; then
|
|
cd "${systemdir}" || exit
|
|
allowed_extentions_array=("*.ain" "*.bsp" "*.mdl" "*.mp3" "*.ogg" "*.otf" "*.pcf" "*.phy" "*.png" "*.svg" "*.vtf" "*.vmt" "*.vtx" "*.vvd" "*.ttf" "*.wav")
|
|
for allowed_extention in "${allowed_extentions_array[@]}"; do
|
|
fileswc=0
|
|
tput sc
|
|
while read -r ext; do
|
|
((fileswc++))
|
|
tput rc
|
|
tput el
|
|
fn_print "gathering ${allowed_extention} : ${fileswc}"
|
|
echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
done < <(find . -type f -iname "${allowed_extention}")
|
|
if [ ${fileswc} != 0 ]; then
|
|
fn_print_ok_eol_nl
|
|
else
|
|
fn_print_skip_eol_nl
|
|
fi
|
|
done
|
|
# Source engine
|
|
else
|
|
fastdl_directories_array=("maps" "materials" "models" "particles" "sound" "resources")
|
|
for directory in "${fastdl_directories_array[@]}"; do
|
|
if [ -d "${systemdir}/${directory}" ]; then
|
|
if [ "${directory}" == "maps" ]; then
|
|
local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
|
|
elif [ "${directory}" == "materials" ]; then
|
|
local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
|
|
elif [ "${directory}" == "models" ]; then
|
|
local allowed_extentions_array=("*.vtx" "*.vvd" "*.mdl" "*.phy" "*.jpg" "*.png" "*.vmt" "*.vtf")
|
|
elif [ "${directory}" == "particles" ]; then
|
|
local allowed_extentions_array=("*.pcf")
|
|
elif [ "${directory}" == "sound" ]; then
|
|
local allowed_extentions_array=("*.wav" "*.mp3" "*.ogg")
|
|
fi
|
|
for allowed_extention in "${allowed_extentions_array[@]}"; do
|
|
fileswc=0
|
|
tput sc
|
|
while read -r ext; do
|
|
((fileswc++))
|
|
tput rc
|
|
tput el
|
|
fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
|
|
tput rc
|
|
tput el
|
|
fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
if [ ${fileswc} != 0 ]; then
|
|
fn_print_ok_eol_nl
|
|
else
|
|
fn_print_info_eol_nl
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
fi
|
|
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
|
|
fn_print_nl "calculating total file size"
|
|
fn_sleep_time_1
|
|
totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt")
|
|
# Calculates total file size.
|
|
while read -r dufile; do
|
|
filesize=$(stat -c %s "${dufile}")
|
|
filesizetotal=$((filesizetotal + filesize))
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Calculating total file size"
|
|
core_exit.sh
|
|
fi
|
|
done < "${tmpdir}/fastdl_files_to_compress.txt"
|
|
else
|
|
fn_print_fail_eol_nl "generating file list"
|
|
fn_script_log_fail "Generating file list."
|
|
core_exit.sh
|
|
fi
|
|
|
|
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
|
|
exitcode=0
|
|
core_exit.sh
|
|
fi
|
|
}
|
|
|
|
# Builds Garry's Mod fastdl directory content.
|
|
fn_fastdl_gmod() {
|
|
cd "${systemdir}" || exit
|
|
for allowed_extention in "${allowed_extentions_array[@]}"; do
|
|
fileswc=0
|
|
tput sc
|
|
while read -r fastdlfile; do
|
|
((fileswc++))
|
|
tput rc
|
|
tput el
|
|
fn_print "copying ${allowed_extention} : ${fileswc}"
|
|
cp --parents "${fastdlfile}" "${fastdldir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}"
|
|
core_exit.sh
|
|
else
|
|
fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}"
|
|
fi
|
|
done < <(find . -type f -iname "${allowed_extention}")
|
|
if [ ${fileswc} != 0 ]; then
|
|
fn_print_ok_eol_nl
|
|
fi
|
|
done
|
|
# Correct addons directory structure for Fastdl.
|
|
if [ -d "${fastdldir}/addons" ]; then
|
|
fn_print "updating addons file structure..."
|
|
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Updating addons file structure"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Updating addons file structure"
|
|
fi
|
|
# Clear addons directory in fastdl.
|
|
fn_print "clearing addons dir from fastdl dir..."
|
|
fn_sleep_time_1
|
|
rm -rf "${fastdldir:?}/addons"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Clearing addons dir from fastdl dir"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Clearing addons dir from fastdl dir"
|
|
fi
|
|
fi
|
|
# Correct content that may be into a lua directory by mistake like some darkrpmodification addons.
|
|
if [ -d "${fastdldir}/lua" ]; then
|
|
fn_print "correcting DarkRP files..."
|
|
fn_sleep_time_1
|
|
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Correcting DarkRP files"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Correcting DarkRP files"
|
|
fi
|
|
fi
|
|
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
|
|
totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt")
|
|
# Calculates total file size.
|
|
while read -r dufile; do
|
|
filesize=$(du -b "${dufile}" | awk '{ print $1 }')
|
|
filesizetotal=$((filesizetotal + filesize))
|
|
done < "${tmpdir}/fastdl_files_to_compress.txt"
|
|
fi
|
|
}
|
|
|
|
fn_fastdl_source() {
|
|
for directory in "${fastdl_directories_array[@]}"; do
|
|
if [ -d "${systemdir}/${directory}" ]; then
|
|
if [ "${directory}" == "maps" ]; then
|
|
local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
|
|
elif [ "${directory}" == "materials" ]; then
|
|
local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
|
|
elif [ "${directory}" == "models" ]; then
|
|
local allowed_extentions_array=("*.vtx" "*.vvd" "*.mdl" "*.phy" "*.jpg" "*.png")
|
|
elif [ "${directory}" == "particles" ]; then
|
|
local allowed_extentions_array=("*.pcf")
|
|
elif [ "${directory}" == "sound" ]; then
|
|
local allowed_extentions_array=("*.wav" "*.mp3" "*.ogg")
|
|
fi
|
|
for allowed_extention in "${allowed_extentions_array[@]}"; do
|
|
fileswc=0
|
|
tput sc
|
|
while read -r fastdlfile; do
|
|
((fileswc++))
|
|
tput rc
|
|
tput el
|
|
fn_print "copying ${directory} ${allowed_extention} : ${fileswc}"
|
|
fn_sleep_time
|
|
# get relative path of file in the dir
|
|
tmprelfilepath="${fastdlfile#"${systemdir}/"}"
|
|
copytodir="${tmprelfilepath%/*}"
|
|
# create relative path for fastdl
|
|
if [ ! -d "${fastdldir}/${copytodir}" ]; then
|
|
mkdir -p "${fastdldir}/${copytodir}"
|
|
fi
|
|
cp "${fastdlfile}" "${fastdldir}/${copytodir}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
|
|
core_exit.sh
|
|
else
|
|
fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
|
|
fi
|
|
done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
|
|
if [ ${fileswc} != 0 ]; then
|
|
fn_print_ok_eol_nl
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Builds the fastdl directory content.
|
|
fn_fastdl_build() {
|
|
# Copy all needed files for Fastdl.
|
|
fn_print_nl "copying files to ${fastdldir}"
|
|
fn_script_log_info "Copying files to ${fastdldir}"
|
|
if [ "${shortname}" == "gmod" ]; then
|
|
fn_fastdl_gmod
|
|
fn_fastdl_gmod_dl_enforcer
|
|
else
|
|
fn_fastdl_source
|
|
fi
|
|
}
|
|
|
|
# Generate lua file that will force download any file into the Fastdl directory.
|
|
fn_fastdl_gmod_dl_enforcer() {
|
|
# Clear old lua file.
|
|
if [ -f "${luafastdlfullpath}" ]; then
|
|
fn_print "removing existing download enforcer: ${luafastdlfile}"
|
|
rm -f "${luafastdlfullpath:?}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Removing existing download enforcer ${luafastdlfullpath}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Removing existing download enforcer ${luafastdlfullpath}"
|
|
fi
|
|
fi
|
|
# Generate new one if user said yes.
|
|
if [ "${luaresource}" == "on" ]; then
|
|
fn_print "creating new download enforcer: ${luafastdlfile}"
|
|
touch "${luafastdlfullpath}"
|
|
# Read all filenames and put them into a lua file at the right path.
|
|
while read -r line; do
|
|
echo -e "resource.AddFile( \"${line}\" )" >> "${luafastdlfullpath}"
|
|
done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n')
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Creating new download enforcer ${luafastdlfullpath}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Creating new download enforcer ${luafastdlfullpath}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Compresses Fastdl files using bzip2.
|
|
fn_fastdl_bzip2() {
|
|
while read -r filetocompress; do
|
|
fn_print "compressing ${filetocompress}"
|
|
bzip2 -f "${filetocompress}"
|
|
exitcode=$?
|
|
if [ "${exitcode}" -ne 0 ]; then
|
|
fn_print_fail_eol_nl
|
|
fn_script_log_fail "Compressing ${filetocompress}"
|
|
core_exit.sh
|
|
else
|
|
fn_print_ok_eol_nl
|
|
fn_script_log_pass "Compressing ${filetocompress}"
|
|
fi
|
|
done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \))
|
|
}
|
|
|
|
check.sh
|
|
# Run functions.
|
|
fn_fastdl_preview
|
|
fn_clear_old_fastdl
|
|
fn_fastdl_dirs
|
|
fn_fastdl_build
|
|
if [ "${engine}" == "source" ]; then
|
|
fn_fastdl_bzip2
|
|
fi
|
|
# Finished message.
|
|
fn_print_nl "Fastdl files are located in:"
|
|
fn_print_nl "${fastdldir}"
|
|
fn_print_nl "Fastdl completed"
|
|
fn_script_log_info "Fastdl completed"
|
|
|
|
core_exit.sh
|