|
@@ -62,6 +62,7 @@ if [ ! -d "${webdir}" ]; then
|
|
|
fn_scriptlog "FastDL created ${webdir}"
|
|
fn_scriptlog "FastDL created ${webdir}"
|
|
|
fi
|
|
fi
|
|
|
if [ ! -d "${fastdldir}" ]; then
|
|
if [ ! -d "${fastdldir}" ]; then
|
|
|
|
|
+ # No folder, won't ask for removing old ones
|
|
|
newfastdl=1
|
|
newfastdl=1
|
|
|
fn_printdots "Creating FastDL directory..."
|
|
fn_printdots "Creating FastDL directory..."
|
|
|
sleep 0.5
|
|
sleep 0.5
|
|
@@ -71,19 +72,22 @@ if [ ! -d "${fastdldir}" ]; then
|
|
|
fn_printok "Folders created"
|
|
fn_printok "Folders created"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
else
|
|
else
|
|
|
|
|
+ # Used to prompt for removing old files
|
|
|
newfastdl=0
|
|
newfastdl=0
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_fastdl_config(){
|
|
fn_fastdl_config(){
|
|
|
|
|
+# Global settings for FastDL creation
|
|
|
fn_printinfo "Entering configuration"
|
|
fn_printinfo "Entering configuration"
|
|
|
fn_scriptlog "Configuration"
|
|
fn_scriptlog "Configuration"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 2
|
|
sleep 2
|
|
|
|
|
+# Prompt for clearing old files if folder was already here
|
|
|
if [ ${newfastdl} == 0 ]; then
|
|
if [ ${newfastdl} == 0 ]; then
|
|
|
fn_printdots
|
|
fn_printdots
|
|
|
while true; do
|
|
while true; do
|
|
|
- read -p "Clear old FastDL files? [y/n]" yn
|
|
|
|
|
|
|
+ read -p "Clear old FastDL files? [y/N]" yN
|
|
|
case $yn in
|
|
case $yn in
|
|
|
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_printok "Clearing Enabled"; break;;
|
|
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_printok "Clearing Enabled"; break;;
|
|
|
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_printok "Clearing Disabled"; break;;
|
|
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_printok "Clearing Disabled"; break;;
|
|
@@ -93,9 +97,9 @@ if [ ${newfastdl} == 0 ]; then
|
|
|
sleep 1
|
|
sleep 1
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
fi
|
|
fi
|
|
|
|
|
+# Prompt for using bzip2 if it's installed
|
|
|
if [ ${bzip2installed} == 1 ]; then
|
|
if [ ${bzip2installed} == 1 ]; then
|
|
|
fn_printdots
|
|
fn_printdots
|
|
|
- sleep 1
|
|
|
|
|
while true; do
|
|
while true; do
|
|
|
read -p "Enable file compression using bzip2? [Y/n]" Yn
|
|
read -p "Enable file compression using bzip2? [Y/n]" Yn
|
|
|
case $yn in
|
|
case $yn in
|
|
@@ -113,7 +117,7 @@ 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 -p "Use client download enforcer? [y/n]" yn
|
|
|
|
|
|
|
+ read -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"; "DL enforcer Disabled"; fn_printok "Enforcer Disabled"; break;;
|
|
[Nn]* ) luaressource="off"; "DL enforcer Disabled"; fn_printok "Enforcer Disabled"; break;;
|
|
@@ -125,6 +129,7 @@ done
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_clear_old_fastdl(){
|
|
fn_clear_old_fastdl(){
|
|
|
|
|
+# 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"
|
|
@@ -138,7 +143,7 @@ fi
|
|
|
|
|
|
|
|
fn_gmod_fastdl(){
|
|
fn_gmod_fastdl(){
|
|
|
# Copy all needed files for fastDL
|
|
# Copy all needed files for fastDL
|
|
|
-fn_printdots "Gathering all needed FastDL files..."
|
|
|
|
|
|
|
+fn_printdots "Gathering all needed files..."
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
@@ -147,95 +152,97 @@ fn_printdots "Copying map files..."
|
|
|
fn_scriptlog "Copying map files"
|
|
fn_scriptlog "Copying map files"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
find "${addonsdir}" -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Map files copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# Materials
|
|
# Materials
|
|
|
-fn_printdots "Copying materials"
|
|
|
|
|
|
|
+fn_printdots "Copying materials..."
|
|
|
fn_scriptlog "Copying materials"
|
|
fn_scriptlog "Copying materials"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
find "${addonsdir}" -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Materials copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# Models
|
|
# Models
|
|
|
-fn_printdots "Copying models"
|
|
|
|
|
|
|
+fn_printdots "Copying models..."
|
|
|
fn_scriptlog "Copying models"
|
|
fn_scriptlog "Copying models"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
find "${addonsdir}" -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.mdl' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.mdl' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.phy' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.phy' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Models copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# Particles
|
|
# Particles
|
|
|
-fn_printdots "Copying particles"
|
|
|
|
|
|
|
+fn_printdots "Copying particles..."
|
|
|
fn_scriptlog "Copying particles"
|
|
fn_scriptlog "Copying particles"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
find "${addonsdir}" -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Particles copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# Sounds
|
|
# Sounds
|
|
|
-fn_printdots "Copying sounds"
|
|
|
|
|
|
|
+fn_printdots "Copying sounds..."
|
|
|
fn_scriptlog "Copying sounds"
|
|
fn_scriptlog "Copying sounds"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
find "${addonsdir}" -name '*.wav' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.wav' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.ogg' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.ogg' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Sounds copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# 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 "${addonsdir}" -name '*.otf' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.otf' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
|
|
|
find "${addonsdir}" -name '*.png' | cpio --quiet -updm "${fastdldir}"
|
|
find "${addonsdir}" -name '*.png' | cpio --quiet -updm "${fastdldir}"
|
|
|
-fn_printok
|
|
|
|
|
|
|
+fn_printok "Fonts and png copied"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
|
|
|
# Correct addons folder structure
|
|
# Correct addons folder structure
|
|
|
if [ -d "${fastdldir}/addons" ]; then
|
|
if [ -d "${fastdldir}/addons" ]; then
|
|
|
- echo "Possible FastDL files found into addons"
|
|
|
|
|
|
|
+ fn_printinfo "Correcting file structure"
|
|
|
|
|
+ fn_scriptlog "Correcting file structure"
|
|
|
|
|
+ sleep 2
|
|
|
echo "Copying those files to their correct folder"
|
|
echo "Copying those files to their correct folder"
|
|
|
sleep 2
|
|
sleep 2
|
|
|
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
|
|
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
|
|
|
-# As we're not sure about the correct file structure, duplicate instead of remove
|
|
|
|
|
-# rm -R "${fastdldir}/addons"
|
|
|
|
|
- fn_printok
|
|
|
|
|
|
|
+ # As we're not sure about the correct file structure, duplicate instead of remove
|
|
|
|
|
+ # rm -R "${fastdldir}/addons"
|
|
|
|
|
+ fn_printok "Corrected file structure"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
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 "Stupid filestructure fix"
|
|
|
|
|
|
|
+ fn_printdots "Stupid file structure fix"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
|
|
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
|
|
|
- fn_printok
|
|
|
|
|
|
|
+ fn_printok "Stupid file structure fixed"
|
|
|
echo -en "\n"
|
|
echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_fastdl_bzip2(){
|
|
fn_fastdl_bzip2(){
|
|
|
-
|
|
|
|
|
|
|
+# Compressing using bzip2 if user said yes
|
|
|
if [ ${bzip2enable} == "on" ]; then
|
|
if [ ${bzip2enable} == "on" ]; then
|
|
|
fn_printinfo "Compressing files using bzip2..."
|
|
fn_printinfo "Compressing files using bzip2..."
|
|
|
fn_scriptlog "Compressing files using bzip2..."
|
|
fn_scriptlog "Compressing files using bzip2..."
|
|
|
sleep 2
|
|
sleep 2
|
|
|
# bzip2 all files that are not already compressed (keeping original files)
|
|
# bzip2 all files that are not already compressed (keeping original files)
|
|
|
- find "${fastdldir}" -not -name \*.bz2 -exec bzip2 -k \{\} \;
|
|
|
|
|
|
|
+ find "${fastdldir}" -not -name \*.bz2 -exec bzip2 -qk \{\} \;
|
|
|
fn_printinfo "bzip2 compression done"
|
|
fn_printinfo "bzip2 compression done"
|
|
|
fn_scriptlog "bzip2 compression done"
|
|
fn_scriptlog "bzip2 compression done"
|
|
|
sleep 1
|
|
sleep 1
|
|
@@ -244,7 +251,7 @@ 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
|
|
|
|
|
|
|
+# Remove lua file if luaressource is turned off and file exists
|
|
|
if [ "${luaressource}" == "off" ]; then
|
|
if [ "${luaressource}" == "off" ]; then
|
|
|
if [ -f "${luafastdlfullpath}" ]; then
|
|
if [ -f "${luafastdlfullpath}" ]; then
|
|
|
echo "Removing download enforcer"
|
|
echo "Removing download enforcer"
|
|
@@ -252,38 +259,43 @@ if [ "${luaressource}" == "off" ]; then
|
|
|
rm -R "${luafastdlfullpath}"
|
|
rm -R "${luafastdlfullpath}"
|
|
|
fi
|
|
fi
|
|
|
fi
|
|
fi
|
|
|
|
|
+# 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
|
|
|
- echo "Removing old download enforcer"
|
|
|
|
|
|
|
+ fn_printdots "Removing old download enforcer"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
rm "${luafastdlfullpath}"
|
|
rm "${luafastdlfullpath}"
|
|
|
|
|
+ fn_printok "Removed old download enforcer"
|
|
|
|
|
+ fn_scriptlog "Removed old download inforcer"
|
|
|
|
|
+ echo -en "\n"
|
|
|
|
|
+ sleep 1
|
|
|
fi
|
|
fi
|
|
|
- echo "Generating new download enforcer"
|
|
|
|
|
|
|
+ fn_printdots "Generating new download enforcer"
|
|
|
|
|
+ fn_scriptlog "Generating new download enforcer"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
|
|
+ # Read all filenames and put them into a lua file at the right path
|
|
|
find "${fastdldir}" \( -name "." ! -name "*.bz2" \) -printf '%P\n' | while read line; do
|
|
find "${fastdldir}" \( -name "." ! -name "*.bz2" \) -printf '%P\n' | while read line; do
|
|
|
echo "resource.AddFile("\""${line}"\"")" >> "${luafastdlfullpath}"
|
|
echo "resource.AddFile("\""${line}"\"")" >> "${luafastdlfullpath}"
|
|
|
done
|
|
done
|
|
|
- echo "Download enforcer generated"
|
|
|
|
|
|
|
+ fn_printok "Download enforcer generated"
|
|
|
|
|
+ fn_scriptlog "Download enforcer generated"
|
|
|
|
|
+ echo -en "\n"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_fastdl_completed(){
|
|
fn_fastdl_completed(){
|
|
|
-echo "----------------------------------"
|
|
|
|
|
-echo "Congratulations, it's done"
|
|
|
|
|
-echo "Now you should configure your HTTP server to target the fastdl folder that was created in ${fastdldir}"
|
|
|
|
|
-echo "Or copy files to an external server"
|
|
|
|
|
-echo "Don't forget to change your sv_downloadurl accordingly in ${servercfgfullpath}"
|
|
|
|
|
-echo "You may want to use the www folder to host a loadingurl too,"
|
|
|
|
|
-echo "for that purpose, just make a loadingurl folder next to the fastdl folder and put your loadingurl in it"
|
|
|
|
|
|
|
+# Finished message
|
|
|
|
|
+fn_printok "Congratulations, it's done"
|
|
|
|
|
+fn_scriptlog "FastDL job done"
|
|
|
|
|
+echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/Fastdl"
|
|
|
|
|
+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 "----------------------------------"
|
|
|
|
|
-echo "For more information, see https://github.com/dgibbs64/linuxgsm/wiki/Fastdl"
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-# Game checking
|
|
|
|
|
|
|
+# Game checking and functions running
|
|
|
# Garry's Mod
|
|
# Garry's Mod
|
|
|
if [ "${gamename}" == "Garry's Mod" ]; then
|
|
if [ "${gamename}" == "Garry's Mod" ]; then
|
|
|
fn_check_bzip2
|
|
fn_check_bzip2
|
|
@@ -292,10 +304,8 @@ if [ "${gamename}" == "Garry's Mod" ]; then
|
|
|
fn_fastdl_gmod_config
|
|
fn_fastdl_gmod_config
|
|
|
fn_clear_old_fastdl
|
|
fn_clear_old_fastdl
|
|
|
fn_gmod_fastdl
|
|
fn_gmod_fastdl
|
|
|
- if [ "${bzip2installed}" == "1" ]; then
|
|
|
|
|
- fn_fastdl_bzip2
|
|
|
|
|
- fi
|
|
|
|
|
fn_lua_fastdl
|
|
fn_lua_fastdl
|
|
|
|
|
+ fn_fastdl_bzip2
|
|
|
fn_fastdl_completed
|
|
fn_fastdl_completed
|
|
|
exit
|
|
exit
|
|
|
fi
|
|
fi
|