Browse Source
* Removed `compress_ut99_maps.sh` and integrated its functionality into `compress_unreal_maps.sh`. * Updated `core_getopt.sh` to reference the new unified compression script. * Cleaned up `core_modules.sh` by removing the obsolete function for `compress_ut99_maps.sh`. * Added `core_exit.sh` call to `install_ut2k4_key.sh` for consistent exit handling.pull/4805/head
7 changed files with 86 additions and 104 deletions
@ -0,0 +1 @@ |
|||||
|
disable=SC2154 |
@ -1,59 +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 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 "" |
|
||||
if ! fn_prompt_yn "Start compression?" Y; then |
|
||||
exitcode=0 |
|
||||
core_exit.sh |
|
||||
fi |
|
||||
mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 |
|
||||
|
|
||||
# Remove old compressed files using find |
|
||||
echo -e "Removing old compressed .uz2 files..." |
|
||||
find "${serverfiles}" \( -name "*.ut2.uz2" -o -name "*.rom.uz2" -o -name "*.utx.uz2" -o -name "*.uax.uz2" -o -name "*.usx.uz2" -o -name "*.ukx.uz2" -o -name "*.u.uz2" -o -name "*.ogg.uz2" -o -name "*.int.uz2" \) -type f -exec rm -fv {} \; |
|
||||
|
|
||||
echo -e "Searching for Unreal Engine files to compress..." |
|
||||
echo -e "Look in game config file for maps" |
|
||||
|
|
||||
# List of extensions to compress (excluding .ogg) |
|
||||
exts="ut2 kfm rom u ucl upl ini int utx uax ukx usx" |
|
||||
|
|
||||
# Remove any old compressed files for these extensions |
|
||||
for ext in $exts; do |
|
||||
find "${serverfiles}" -name "*.${ext}.uz2" -type f -exec rm -fv {} \; |
|
||||
done |
|
||||
|
|
||||
cd "${systemdir}" || exit |
|
||||
|
|
||||
# Find and compress files, then move .uz2 to compressedmapsdir |
|
||||
find "${serverfiles}" \( "$(for ext in $exts; do echo -name "*.${ext}" -o; done | sed 's/ -o$//')" \) -type f \ |
|
||||
-exec sh -c ' |
|
||||
compressedmapsdir="$1" |
|
||||
file="$2" |
|
||||
printf "Compressing: %s\n" "$file" |
|
||||
./ucc-bin compress "$file" --nohomedir && \ |
|
||||
printf "Moving: %s -> %s\n" "$file.uz2" "$compressedmapsdir" && \ |
|
||||
mv -fv "$file.uz2" "$compressedmapsdir" |
|
||||
' _ "${compressedmapsdir}" {} \; |
|
||||
|
|
||||
echo -e "Compression complete. All .uz2 files moved to: ${compressedmapsdir}" |
|
||||
|
|
||||
core_exit.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 |
@ -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 |
|
Loading…
Reference in new issue