Browse Source

merged copy code in to one

pull/1331/head
Daniel Gibbs 8 years ago
parent
commit
96ac99b543
  1. 149
      lgsm/functions/command_fastdl.sh

149
lgsm/functions/command_fastdl.sh

@ -306,168 +306,65 @@ fn_fastdl_source(){
fn_script_log "analyzing required files" fn_script_log "analyzing required files"
fi fi
# Maps local directorys_array_=( "maps" "materials" "particles" "sounds" "*.txt" )
if [ -d "${systemdir}/maps" ]; then for directory in "${directorys_array[@]}"
local allowed_extentions_array_=( "*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt" )
for allowed_extention in "${allowed_extentions_array[@]}"
do do
fileswc=0 if [ -d "${systemdir}/${directory}" ]; then
tput sc if [ "${directory}" == "maps" ]; then
if [ -z "${copyflag}" ]; then local allowed_extentions_array_=( "*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt" )
tput rc; tput el elif [ "${directory}" == "materials" ]; then
printf "gathering maps ${allowed_extention} : ${fileswc}..."
fi
while read -r mapfile; do
((fileswc++))
if [ -n "${copyflag}" ]; then
tput rc; tput el
printf "copying maps ${allowed_extention} : ${fileswc}..."
if [ ! -d "${fastdldir}/maps" ]; then
mkdir "${fastdldir}/maps"
fi
cp "${mapfile}" "${fastdldir}/maps"
else
tput rc; tput el
printf "gathering maps ${allowed_extention} : ${fileswc}..."
sleep 0.01
echo "${mapfile}" >> "${tmpdir}/fastdl_files_to_compress.txt"
fi
done < <(find "${systemdir}/maps" -type f -iname ${allowed_extention})
if [ -z "${copyflag}" ]; then
tput rc; tput el
printf "gathering maps ${allowed_extention} : ${fileswc}..."
fi
if [ ${fileswc} != 0 ]&&[ -n "${copyflag}" ]||[ -z "${copyflag}" ]; then
fn_print_ok_eol_nl
fi
done
fi
# Materials
if [ -d "${systemdir}/materials" ]; then
local allowed_extentions_array=( "*.vtf" "*.vmt" "*.vbf" ) local allowed_extentions_array=( "*.vtf" "*.vmt" "*.vbf" )
for allowed_extention in "${allowed_extentions_array[@]}" elif [ "${directory}" == "particles" ]; then
do
fileswc=0
tput sc
if [ -z "${copyflag}" ]; then
tput rc; tput el
printf "gathering materials ${allowed_extention} : ${fileswc}..."
fi
while read -r mapfile; do
((fileswc++))
if [ -n "${copyflag}" ]; then
tput rc; tput el
printf "copying materials ${allowed_extention} : ${fileswc}..."
if [ ! -d "${fastdldir}/materials" ]; then
mkdir "${fastdldir}/materials"
fi
cp "${mapfile}" "${fastdldir}/materials"
else
tput rc; tput el
printf "gathering materials ${allowed_extention} : ${fileswc}..."
sleep 0.01
echo "${mapfile}" >> "${tmpdir}/fastdl_files_to_compress.txt"
fi
done < <(find "${systemdir}/materials" -type f -iname ${allowed_extention})
if [ -z "${copyflag}" ]; then
tput rc; tput el
printf "gathering materials ${allowed_extention} : ${fileswc}..."
fi
if [ ${fileswc} != 0 ]&&[ -n "${copyflag}" ]||[ -z "${copyflag}" ]; then
fn_print_ok_eol_nl
fi
done
fi
# Particles
if [ -d "${systemdir}/particles" ]; then
local allowed_extentions_array=( "*.pcf" ) local allowed_extentions_array=( "*.pcf" )
for allowed_extention in "${allowed_extentions_array[@]}" elif [ "${directory}" == "sounds" ]; then
do
fileswc=0
tput sc
if [ -z "${copyflag}" ]; then
tput rc; tput el
printf "gathering particles ${allowed_extention} : ${fileswc}..."
fi
while read -r mapfile; do
((fileswc++))
if [ -n "${copyflag}" ]; then
tput rc; tput el
printf "copying particles ${allowed_extention} : ${fileswc}..."
if [ ! -d "${fastdldir}/particles" ]; then
mkdir "${fastdldir}/particles"
fi
cp "${mapfile}" "${fastdldir}/particles"
else
tput rc; tput el
printf "gathering particles ${allowed_extention} : ${fileswc}..."
sleep 0.01
echo "${mapfile}" >> "${tmpdir}/fastdl_files_to_compress.txt"
fi
done < <(find "${systemdir}/particles" -type f -iname ${allowed_extention})
if [ -z "${copyflag}" ]; then
tput rc; tput el
printf "gathering particles ${allowed_extention} : ${fileswc}..."
fi
if [ ${fileswc} != 0 ]&&[ -n "${copyflag}" ]||[ -z "${copyflag}" ]; then
fn_print_ok_eol_nl
fi
done
fi
# Sounds
if [ -d "${systemdir}/sounds" ]; then
local allowed_extentions_array=( "*.vtx" "*.vvd" "*.mdl" "*.mdl" "*.phy" "*.jpg" "*.png" ) local allowed_extentions_array=( "*.vtx" "*.vvd" "*.mdl" "*.mdl" "*.phy" "*.jpg" "*.png" )
fi
for allowed_extention in "${allowed_extentions_array[@]}" for allowed_extention in "${allowed_extentions_array[@]}"
do do
fileswc=0 fileswc=0
tput sc tput sc
if [ -z "${copyflag}" ]; then if [ -z "${copyflag}" ]; then
tput rc; tput el tput rc; tput el
printf "gathering sounds ${allowed_extention} : ${fileswc}..." printf "gathering ${directory} ${allowed_extention} : ${fileswc}..."
fi fi
while read -r mapfile; do while read -r mapfile; do
((fileswc++)) ((fileswc++))
if [ -n "${copyflag}" ]; then if [ -n "${copyflag}" ]; then
tput rc; tput el tput rc; tput el
printf "copying soundss ${allowed_extention} : ${fileswc}..." printf "copying ${directory} ${allowed_extention} : ${fileswc}..."
if [ ! -d "${fastdldir}/sounds" ]; then if [ ! -d "${fastdldir}/${directory}" ]; then
mkdir "${fastdldir}/sounds" mkdir "${fastdldir}/${directory}"
fi fi
cp "${mapfile}" "${fastdldir}/sounds" cp "${mapfile}" "${fastdldir}/${directory}"
else else
tput rc; tput el tput rc; tput el
printf "gathering sounds ${allowed_extention} : ${fileswc}..." printf "gathering ${directory} ${allowed_extention} : ${fileswc}..."
sleep 0.01 sleep 0.01
echo "${mapfile}" >> "${tmpdir}/fastdl_files_to_compress.txt" echo "${mapfile}" >> "${tmpdir}/fastdl_files_to_compress.txt"
fi fi
done < <(find "${systemdir}/sounds" -type f -iname ${allowed_extention}) done < <(find "${systemdir}/${directory}" -type f -iname ${allowed_extention})
if [ -z "${copyflag}" ]; then if [ -z "${copyflag}" ]; then
tput rc; tput el tput rc; tput el
printf "gathering sounds ${allowed_extention} : ${fileswc}..." printf "gathering ${directory} ${allowed_extention} : ${fileswc}..."
fi fi
if [ ${fileswc} != 0 ]&&[ -n "${copyflag}" ]||[ -z "${copyflag}" ]; then if [ ${fileswc} != 0 ]&&[ -n "${copyflag}" ]||[ -z "${copyflag}" ]; then
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi
done done
fi fi
done
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt") totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt")
# Calculates total file size # Calculates total file size
while read dufile; do while read dufile; do
filesize=$(du -b "${dufile}"| awk '{ print $1 }') filesize=$(du -b "${dufile}"| awk '{ print $1 }')
filesizetotal=$(( ${filesizetotal} + ${filesize} )) filesizetotal=$(( ${filesizetotal} + ${filesize} ))
done <"${tmpdir}/fastdl_files_to_compress.txt" done <"${tmpdir}/fastdl_files_to_compress.txt"
fi fi
if [ -z "${copyflag}" ]; then if [ -z "${copyflag}" ]; then
echo "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0) " echo "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0) "
rm "${tmpdir}/fastdl_files_to_compress.txt" rm "${tmpdir}/fastdl_files_to_compress.txt"
if fn_prompt_yn "Continue?" Y; then if fn_prompt_yn "Continue?" Y; then
@ -476,9 +373,9 @@ if [ -z "${copyflag}" ]; then
else else
core_exit.sh core_exit.sh
fi fi
else else
fn_fastdl_bzip2 fn_fastdl_bzip2
fi fi
} }
# Generate lua file that will force download any file into the FastDL directory # Generate lua file that will force download any file into the FastDL directory

Loading…
Cancel
Save