@ -22,8 +22,8 @@ luafastdlfile="lgsm_cl_force_fastdl.lua"
luafastdlfullpath = " ${ luasvautorundir } / ${ luafastdlfile } "
luafastdlfullpath = " ${ luasvautorundir } / ${ luafastdlfile } "
fn_check_bzip2( ) {
fn_check_bzip2( ) {
# Returns true if not installed
# Returns true if not installed
if [ -z " $( command -v bzip2) " ] ; then
if [ -z " $( command -v bzip2) " ] ; then
bzip2installed = "0"
bzip2installed = "0"
fn_printinfo "bzip2 is not installed !"
fn_printinfo "bzip2 is not installed !"
fn_scriptlog "bzip2 is not installed"
fn_scriptlog "bzip2 is not installed"
@ -32,29 +32,29 @@ if [ -z "$(command -v bzip2)" ]; then
echo "We advise using it"
echo "We advise using it"
echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression"
echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/FastDL#bzip2-compression"
sleep 2
sleep 2
else
else
bzip2installed = "1"
bzip2installed = "1"
fi
fi
}
}
fn_fastdl_init( ) {
fn_fastdl_init( ) {
# User confirmation
# User confirmation
fn_printok "Welcome to LGSM's FastDL generator"
fn_printok "Welcome to LGSM's FastDL generator"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
fn_scriptlog "Started FastDL creation"
fn_scriptlog "Started FastDL creation"
while true; do
while true; do
read -e -i "y" -p "Continue? [Y/n]" yn
read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in
case $yn in
[ Yy] * ) break; ;
[ Yy] * ) break; ;
[ Nn] * ) exit; ;
[ Nn] * ) exit; ;
* ) echo "Please answer yes or no." ; ;
* ) echo "Please answer yes or no." ; ;
esac
esac
done
done
fn_scriptlog "Initiating FastDL creation"
fn_scriptlog "Initiating FastDL creation"
# Check and create folders
# Check and create folders
if [ ! -d " ${ webdir } " ] ; then
if [ ! -d " ${ webdir } " ] ; then
echo ""
echo ""
fn_printinfo "Creating FastDL directories"
fn_printinfo "Creating FastDL directories"
echo -en "\n"
echo -en "\n"
@ -66,8 +66,8 @@ if [ ! -d "${webdir}" ]; then
fn_scriptlog "FastDL created www directory"
fn_scriptlog "FastDL created www directory"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
fi
fi
if [ ! -d " ${ fastdldir } " ] ; then
if [ ! -d " ${ fastdldir } " ] ; then
# No folder, won't ask for removing old ones
# No folder, won't ask for removing old ones
newfastdl = 1
newfastdl = 1
fn_printdots "Creating fastdl directory"
fn_printdots "Creating fastdl directory"
@ -78,19 +78,19 @@ if [ ! -d "${fastdldir}" ]; then
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
clearoldfastdl = "off" # Nothing to clear
clearoldfastdl = "off" # Nothing to clear
elif [ " $( ls -A " ${ fastdldir } " ) " ] ; then
elif [ " $( ls -A " ${ fastdldir } " ) " ] ; then
newfastdl = 0
newfastdl = 0
fi
fi
}
}
fn_fastdl_config( ) {
fn_fastdl_config( ) {
# Global settings for FastDL creation
# Global settings for FastDL creation
fn_printinfo "Entering configuration"
fn_printinfo "Entering configuration"
fn_scriptlog "Configuration"
fn_scriptlog "Configuration"
sleep 2
sleep 2
echo -en "\n"
echo -en "\n"
# Prompt for clearing old files if folder was already here
# Prompt for clearing old files if folder was already here
if [ -n " ${ newfastdl } " ] && [ " ${ newfastdl } " = = "0" ] ; then
if [ -n " ${ newfastdl } " ] && [ " ${ newfastdl } " = = "0" ] ; then
fn_printdots
fn_printdots
while true; do
while true; do
read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
@ -101,9 +101,9 @@ if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then
esac
esac
done
done
echo -en "\n"
echo -en "\n"
fi
fi
# Prompt for using bzip2 if it's installed
# Prompt for using bzip2 if it's installed
if [ ${ bzip2installed } = = 1 ] ; then
if [ ${ bzip2installed } = = 1 ] ; then
fn_printdots
fn_printdots
while true; do
while true; do
read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
@ -114,26 +114,26 @@ if [ ${bzip2installed} == 1 ]; then
esac
esac
done
done
echo -en "\n"
echo -en "\n"
fi
fi
}
}
fn_fastdl_gmod_config( ) {
fn_fastdl_gmod_config( ) {
# Prompt for download enforcer, that is using a .lua addfile resource generator
# Prompt for download enforcer, that is using a .lua addfile resource generator
fn_printdots
fn_printdots
while true; do
while true; do
read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
case $yn in
case $yn in
[ Yy] * ) luaressource = "on" ; fn_scriptlog "DL enforcer Enabled" ; fn_printok "Enforcer Enabled" ; break; ;
[ Yy] * ) luaressource = "on" ; fn_scriptlog "DL enforcer Enabled" ; fn_printok "Enforcer Enabled" ; break; ;
[ Nn] * ) luaressource = "off" ; fn_scriptlog "DL enforcer Disabled" ; fn_printok "Enforcer Disabled" ; break; ;
[ Nn] * ) luaressource = "off" ; fn_scriptlog "DL enforcer Disabled" ; fn_printok "Enforcer Disabled" ; break; ;
* ) echo "Please answer yes or no." ; ;
* ) echo "Please answer yes or no." ; ;
esac
esac
done
done
echo -en "\n"
echo -en "\n"
}
}
fn_clear_old_fastdl( ) {
fn_clear_old_fastdl( ) {
# Clearing old FastDL if user answered yes
# Clearing old FastDL if user answered yes
if [ " ${ clearoldfastdl } " = = "on" ] ; then
if [ " ${ clearoldfastdl } " = = "on" ] ; then
fn_printinfo "Clearing existing FastDL folder"
fn_printinfo "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder"
sleep 0.5
sleep 0.5
@ -142,113 +142,113 @@ if [ "${clearoldfastdl}" == "on" ]; then
fn_scriptlog "Old FastDL folder cleared"
fn_scriptlog "Old FastDL folder cleared"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
fi
fi
}
}
fn_gmod_fastdl( ) {
fn_gmod_fastdl( ) {
# Copy all needed files for FastDL
# Copy all needed files for FastDL
echo ""
echo ""
fn_printdots "Starting gathering all needed files"
fn_printdots "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
# No choice to cd to the directory, as find can't then display relative folder
# No choice to cd to the directory, as find can't then display relative folder
cd " ${ systemdir } "
cd " ${ systemdir } "
# Map Files
# Map Files
fn_printdots "Copying map files..."
fn_printdots "Copying map files..."
fn_scriptlog "Copying map files"
fn_scriptlog "Copying map files"
sleep 0.5
sleep 0.5
find . -name '*.bsp' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.bsp' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Map files copied"
fn_printok "Map files copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Materials
# Materials
fn_printdots "Copying materials..."
fn_printdots "Copying materials..."
fn_scriptlog "Copying materials"
fn_scriptlog "Copying materials"
sleep 0.5
sleep 0.5
find . -name '*.vtf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vtf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vmt' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vmt' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Materials copied"
fn_printok "Materials copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Models
# Models
fn_printdots "Copying models..."
fn_printdots "Copying models..."
fn_scriptlog "Copying models"
fn_scriptlog "Copying models"
sleep 1
sleep 1
find . -name '*.vtx' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vtx' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vvd' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.vvd' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.mdl' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.mdl' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.phy' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.phy' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Models copied"
fn_printok "Models copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Particles
# Particles
fn_printdots "Copying particles..."
fn_printdots "Copying particles..."
fn_scriptlog "Copying particles"
fn_scriptlog "Copying particles"
sleep 0.5
sleep 0.5
find . -name '*.pcf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.pcf' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Particles copied"
fn_printok "Particles copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Sounds
# Sounds
fn_printdots "Copying sounds..."
fn_printdots "Copying sounds..."
fn_scriptlog "Copying sounds"
fn_scriptlog "Copying sounds"
sleep 0.5
sleep 0.5
find . -name '*.wav' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.wav' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.mp3' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.mp3' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.ogg' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.ogg' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Sounds copied"
fn_printok "Sounds copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Resources (mostly fonts)
# Resources (mostly fonts)
fn_printdots "Copying fonts and png..."
fn_printdots "Copying fonts and png..."
fn_scriptlog "Copying fonts and png"
fn_scriptlog "Copying fonts and png"
sleep 1
sleep 1
find . -name '*.otf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.otf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.ttf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.ttf' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.png' | cpio --quiet -updm " ${ fastdldir } "
find . -name '*.png' | cpio --quiet -updm " ${ fastdldir } "
fn_printok "Fonts and png copied"
fn_printok "Fonts and png copied"
sleep 0.5
sleep 0.5
echo -en "\n"
echo -en "\n"
# Going back to rootdir in order to prevent mistakes
# Going back to rootdir in order to prevent mistakes
cd " ${ rootdir } "
cd " ${ rootdir } "
# Correct addons folder structure for FastDL
# Correct addons folder structure for FastDL
if [ -d " ${ fastdldir } /addons " ] ; then
if [ -d " ${ fastdldir } /addons " ] ; then
fn_printinfo "Adjusting addons' file structure"
fn_printinfo "Adjusting addons' file structure"
fn_scriptlog "Adjusting addon's file structure"
fn_scriptlog "Adjusting addon's file structure"
sleep 1
sleep 1
cp -Rf " ${ fastdldir } " /addons/*/* " ${ fastdldir } "
cp -Rf " ${ fastdldir } " /addons/*/* " ${ fastdldir } "
#Don't remove yet rm -R "${fastdldir:?}/addons"
#Don't remove yet rm -R "${fastdldir:?}/addons"
fn_printok "Adjusted addon's file structure"
fn_printok "Adjusted addon's file structure"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
fi
fi
# Correct content that may be into a lua folder by mistake like some darkrpmodification addons
# Correct content that may be into a lua folder by mistake like some darkrpmodification addons
if [ -d " ${ fastdldir } /lua " ] ; then
if [ -d " ${ fastdldir } /lua " ] ; then
fn_printdots "Typical DarkRP shit detected, fixing"
fn_printdots "Typical DarkRP shit detected, fixing"
sleep 2
sleep 2
cp -Rf " ${ fastdldir } /lua/ " * " ${ fastdldir } "
cp -Rf " ${ fastdldir } /lua/ " * " ${ fastdldir } "
fn_printok "Stupid DarkRP file structure fixed"
fn_printok "Stupid DarkRP file structure fixed"
sleep 2
sleep 2
echo -en "\n"
echo -en "\n"
fi
fi
}
}
# Generate lua file that will force download any file into the FastDL folder
# Generate lua file that will force download any file into the FastDL folder
fn_lua_fastdl( ) {
fn_lua_fastdl( ) {
# Remove lua file if luaressource is turned off and file exists
# Remove lua file if luaressource is turned off and file exists
echo ""
echo ""
if [ " ${ luaressource } " = = "off" ] ; then
if [ " ${ luaressource } " = = "off" ] ; then
if [ -f " ${ luafastdlfullpath } " ] ; then
if [ -f " ${ luafastdlfullpath } " ] ; then
fn_printdots "Removing download enforcer"
fn_printdots "Removing download enforcer"
sleep 1
sleep 1
@ -258,9 +258,9 @@ if [ "${luaressource}" == "off" ]; then
echo -en "\n"
echo -en "\n"
sleep 2
sleep 2
fi
fi
fi
fi
# Remove old lua file and generate a new one if user said yes
# Remove old lua file and generate a new one if user said yes
if [ " ${ luaressource } " = = "on" ] ; then
if [ " ${ luaressource } " = = "on" ] ; then
if [ -f " ${ luafastdlfullpath } " ] ; then
if [ -f " ${ luafastdlfullpath } " ] ; then
fn_printdots "Removing old download enforcer"
fn_printdots "Removing old download enforcer"
sleep 1
sleep 1
@ -282,13 +282,13 @@ if [ "${luaressource}" == "on" ]; then
echo -en "\n"
echo -en "\n"
echo ""
echo ""
sleep 2
sleep 2
fi
fi
}
}
fn_fastdl_bzip2( ) {
fn_fastdl_bzip2( ) {
# Compressing using bzip2 if user said yes
# Compressing using bzip2 if user said yes
echo ""
echo ""
if [ ${ bzip2enable } = = "on" ] ; then
if [ ${ bzip2enable } = = "on" ] ; then
fn_printinfo "Have a break, this step could take a while..."
fn_printinfo "Have a break, this step could take a while..."
echo -en "\n"
echo -en "\n"
echo ""
echo ""
@ -300,23 +300,23 @@ if [ ${bzip2enable} == "on" ]; then
fn_scriptlog "bzip2 compression done"
fn_scriptlog "bzip2 compression done"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
fi
fi
}
}
fn_fastdl_completed( ) {
fn_fastdl_completed( ) {
# Finished message
# Finished message
echo ""
echo ""
fn_printok "Congratulations, it's done !"
fn_printok "Congratulations, it's done !"
fn_scriptlog "FastDL job done"
fn_scriptlog "FastDL job done"
sleep 2
sleep 2
echo -en "\n"
echo -en "\n"
echo ""
echo ""
fn_printinfo "Need more doc ? See https://github.com/dgibbs64/linuxgsm/wiki/FastDL"
fn_printinfo "Need more doc ? See https://github.com/dgibbs64/linuxgsm/wiki/FastDL"
echo -en "\n"
echo -en "\n"
if [ " $bzip2installed " = = "0" ] ; then
if [ " $bzip2installed " = = "0" ] ; then
echo "By the way, you'd better install bzip2 an re-run this command !"
echo "By the way, you'd better install bzip2 an re-run this command !"
fi
fi
echo "Credits : UltimateByte"
echo "Credits : UltimateByte"
}
}
# Game checking and functions running
# Game checking and functions running