|
|
@@ -30,18 +30,18 @@ fi
|
|
|
|
|
|
# Header
|
|
|
fn_print_header
|
|
|
-echo -e "More info: ${italic}https://docs.linuxgsm.com/commands/fastdl"
|
|
|
-echo -e ""
|
|
|
+fn_print_nl "More info: ${italic}https://docs.linuxgsm.com/commands/fastdl"
|
|
|
+fn_print_nl ""
|
|
|
|
|
|
# Prompts user for Fastdl creation settings.
|
|
|
-echo -e "${bold}${lightyellow}${commandaction} Setup"
|
|
|
+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."
|
|
|
- echo -e "${fastdldir}"
|
|
|
- echo -e ""
|
|
|
+ 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
|
|
|
@@ -65,7 +65,7 @@ fi
|
|
|
fn_clear_old_fastdl() {
|
|
|
# Clearing old Fastdl.
|
|
|
if [ -d "${fastdldir}" ]; then
|
|
|
- echo -en "clearing existing Fastdl directory ${fastdldir}"
|
|
|
+ fn_print "clearing existing Fastdl directory ${fastdldir}"
|
|
|
rm -rf "${fastdldir:?}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -82,7 +82,7 @@ fn_clear_old_fastdl() {
|
|
|
fn_fastdl_dirs() {
|
|
|
# Check and create directories.
|
|
|
if [ ! -d "${webdir}" ]; then
|
|
|
- echo -en "creating web directory ${webdir}"
|
|
|
+ fn_print "creating web directory ${webdir}"
|
|
|
mkdir -p "${webdir}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -95,7 +95,7 @@ fn_fastdl_dirs() {
|
|
|
fi
|
|
|
fi
|
|
|
if [ ! -d "${fastdldir}" ]; then
|
|
|
- echo -en "creating fastdl directory ${fastdldir}"
|
|
|
+ fn_print "creating fastdl directory ${fastdldir}"
|
|
|
mkdir -p "${fastdldir}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -125,7 +125,7 @@ fn_human_readable_file_size() {
|
|
|
local precision="${2}"
|
|
|
|
|
|
if [[ "${bytes}" == "1" ]]; then
|
|
|
- echo -e "1 byte"
|
|
|
+ fn_print_nl "1 byte"
|
|
|
else
|
|
|
for item in "${abbrevs[@]}"; do
|
|
|
local factor="${item%:*}"
|
|
|
@@ -145,7 +145,7 @@ fn_fastdl_preview() {
|
|
|
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
|
|
|
rm -f "${tmpdir:?}/fastdl_files_to_compress.txt"
|
|
|
fi
|
|
|
- echo -e "analysing required files"
|
|
|
+ fn_print_nl "analysing required files"
|
|
|
fn_script_log_info "Analysing required files"
|
|
|
# Garry's Mod
|
|
|
if [ "${shortname}" == "gmod" ]; then
|
|
|
@@ -158,8 +158,8 @@ fn_fastdl_preview() {
|
|
|
((fileswc++))
|
|
|
tput rc
|
|
|
tput el
|
|
|
- echo -e "gathering ${allowed_extention} : ${fileswc}"
|
|
|
- echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
|
+ fn_print_nl "gathering ${allowed_extention} : ${fileswc}"
|
|
|
+ fn_print_nl "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
|
done < <(find . -type f -iname "${allowed_extention}")
|
|
|
if [ ${fileswc} != 0 ]; then
|
|
|
fn_print_ok_eol_nl
|
|
|
@@ -190,12 +190,12 @@ fn_fastdl_preview() {
|
|
|
((fileswc++))
|
|
|
tput rc
|
|
|
tput el
|
|
|
- echo -e "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
- echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
|
+ fn_print_nl "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
+ fn_print_nl "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
|
|
|
done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
|
|
|
tput rc
|
|
|
tput el
|
|
|
- echo -e "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
+ fn_print_nl "gathering ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
if [ ${fileswc} != 0 ]; then
|
|
|
fn_print_ok_eol_nl
|
|
|
else
|
|
|
@@ -206,7 +206,7 @@ fn_fastdl_preview() {
|
|
|
done
|
|
|
fi
|
|
|
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
|
|
|
- echo -e "calculating total file size..."
|
|
|
+ fn_print_nl "calculating total file size..."
|
|
|
fn_sleep_time_1
|
|
|
totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt")
|
|
|
# Calculates total file size.
|
|
|
@@ -225,7 +225,7 @@ 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)"
|
|
|
+ fn_print_nl "about to compress ${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
|
|
|
@@ -244,7 +244,7 @@ fn_fastdl_gmod() {
|
|
|
((fileswc++))
|
|
|
tput rc
|
|
|
tput el
|
|
|
- echo -e "copying ${allowed_extention} : ${fileswc}"
|
|
|
+ fn_print_nl "copying ${allowed_extention} : ${fileswc}"
|
|
|
cp --parents "${fastdlfile}" "${fastdldir}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -261,7 +261,7 @@ fn_fastdl_gmod() {
|
|
|
done
|
|
|
# Correct addons directory structure for Fastdl.
|
|
|
if [ -d "${fastdldir}/addons" ]; then
|
|
|
- echo -en "updating addons file structure..."
|
|
|
+ fn_print "updating addons file structure..."
|
|
|
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -273,7 +273,7 @@ fn_fastdl_gmod() {
|
|
|
fn_script_log_pass "Updating addons file structure"
|
|
|
fi
|
|
|
# Clear addons directory in fastdl.
|
|
|
- echo -en "clearing addons dir from fastdl dir..."
|
|
|
+ fn_print "clearing addons dir from fastdl dir..."
|
|
|
fn_sleep_time_1
|
|
|
rm -rf "${fastdldir:?}/addons"
|
|
|
exitcode=$?
|
|
|
@@ -288,7 +288,7 @@ fn_fastdl_gmod() {
|
|
|
fi
|
|
|
# Correct content that may be into a lua directory by mistake like some darkrpmodification addons.
|
|
|
if [ -d "${fastdldir}/lua" ]; then
|
|
|
- echo -en "correcting DarkRP files..."
|
|
|
+ fn_print "correcting DarkRP files..."
|
|
|
fn_sleep_time_1
|
|
|
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
|
|
|
exitcode=$?
|
|
|
@@ -332,7 +332,7 @@ fn_fastdl_source() {
|
|
|
((fileswc++))
|
|
|
tput rc
|
|
|
tput el
|
|
|
- echo -e "copying ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
+ fn_print_nl "copying ${directory} ${allowed_extention} : ${fileswc}"
|
|
|
fn_sleep_time_1
|
|
|
# get relative path of file in the dir
|
|
|
tmprelfilepath="${fastdlfile#"${systemdir}/"}"
|
|
|
@@ -362,7 +362,7 @@ fn_fastdl_source() {
|
|
|
# Builds the fastdl directory content.
|
|
|
fn_fastdl_build() {
|
|
|
# Copy all needed files for Fastdl.
|
|
|
- echo -e "copying files to ${fastdldir}"
|
|
|
+ fn_print_nl "copying files to ${fastdldir}"
|
|
|
fn_script_log_info "Copying files to ${fastdldir}"
|
|
|
if [ "${shortname}" == "gmod" ]; then
|
|
|
fn_fastdl_gmod
|
|
|
@@ -376,7 +376,7 @@ fn_fastdl_build() {
|
|
|
fn_fastdl_gmod_dl_enforcer() {
|
|
|
# Clear old lua file.
|
|
|
if [ -f "${luafastdlfullpath}" ]; then
|
|
|
- echo -en "removing existing download enforcer: ${luafastdlfile}"
|
|
|
+ fn_print "removing existing download enforcer: ${luafastdlfile}"
|
|
|
rm -f "${luafastdlfullpath:?}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -390,11 +390,11 @@ fn_fastdl_gmod_dl_enforcer() {
|
|
|
fi
|
|
|
# Generate new one if user said yes.
|
|
|
if [ "${luaresource}" == "on" ]; then
|
|
|
- echo -en "creating new download enforcer: ${luafastdlfile}"
|
|
|
+ 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}"
|
|
|
+ fn_print_nl "resource.AddFile( \"${line}\" )" >> "${luafastdlfullpath}"
|
|
|
done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n')
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -411,7 +411,7 @@ fn_fastdl_gmod_dl_enforcer() {
|
|
|
# Compresses Fastdl files using bzip2.
|
|
|
fn_fastdl_bzip2() {
|
|
|
while read -r filetocompress; do
|
|
|
- echo -en "\r\033[Kcompressing ${filetocompress}"
|
|
|
+ fn_print "\r\033[Kcompressing ${filetocompress}"
|
|
|
bzip2 -f "${filetocompress}"
|
|
|
exitcode=$?
|
|
|
if [ "${exitcode}" != 0 ]; then
|
|
|
@@ -433,9 +433,9 @@ fn_fastdl_dirs
|
|
|
fn_fastdl_build
|
|
|
fn_fastdl_bzip2
|
|
|
# Finished message.
|
|
|
-echo -e "Fastdl files are located in:"
|
|
|
-echo -e "${fastdldir}"
|
|
|
-echo -e "Fastdl completed"
|
|
|
+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
|