Browse Source

lua file resource generator and tweaks

pull/709/head
lrob 9 years ago
parent
commit
4a49c05a5f
  1. 44
      functions/command_fastdl.sh

44
functions/command_fastdl.sh

@ -13,7 +13,8 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
# Directories # Directories
fastdldir="${rootdir}/fastdl" webdir="${rootdir}/www"
fastdldir="${webdir}/fastdl"
# Server lua autorun dir, used to autorun lua on client connect to the server # Server lua autorun dir, used to autorun lua on client connect to the server
luasvautorundir="${systemdir}/lua/audoturn/server" luasvautorundir="${systemdir}/lua/audoturn/server"
luafastdlfile="lgsm_cl_force_fastdl.lua" luafastdlfile="lgsm_cl_force_fastdl.lua"
@ -31,6 +32,10 @@ while true; do
esac esac
done done
# Create FastDL folder if it doesn't exit # Create FastDL folder if it doesn't exit
if [ ! -d "${webdir}" ]; then
echo "Creating www directory"
mkdir -v "${webdir}"
sleep 1
if [ ! -d "${fastdldir}" ]; then if [ ! -d "${fastdldir}" ]; then
echo "Creating FastDL directory" echo "Creating FastDL directory"
mkdir -v "${fastdldir}" mkdir -v "${fastdldir}"
@ -39,13 +44,13 @@ else
echo "Updating FastDL..." echo "Updating FastDL..."
fi fi
# Ask for lua resource add file use # Ask for lua resource add file use
echo "Do you wish to use a lua file to force clients to download FastDL content ?" echo "Do you wish to generate a lua file to force clients to download all FastDL content ?"
echo "It can be necessary for addons devs that forgot about registering their files to be downloaded through FastDL" echo "It is useful for many addons where devs didn't register their files to be downloaded through FastDL."
while true; do while true; do
read -p "Continue? [y/n]" yn read -p "Continue? [y/n]" yn
case $yn in case $yn in
[Yy]* ) luaressource="on"; break;; [Yy]* ) luaressource="on"; break;;
[Nn]* ) luaressource="off"; return 1;; [Nn]* ) luaressource="off"; return 0;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
@ -174,19 +179,40 @@ echo "bzip2 compression done"
sleep 1 sleep 1
} }
# Function to implement # Generate lua file that will force download any file into the FastDL folder
fn_lua_fastdl(){ fn_lua_fastdl(){
if [ luaressource="off" == "on" ]; then # Remove lua file if luaressource is turned off
if [ ${luaressource} == "off" ]; then
if [ -f "${luafastdlfullpath}" ]; then if [ -f "${luafastdlfullpath}" ]; then
echo "Removing " echo "Removing download enforcer"
sleep 1
rm -R "${luafastdlfullpath}"
fi
fi
if [ ${luaressource == "on" ]; then
if [ -f "${luafastdlfullpath}" ]; then
echo "Removing old download enforcer"
sleep 1
rm "${luafastdlfullpath}"
fi
echo "Generating new download enforcer"
sleep 1
find "${fastdldir}" \( -name "." ! -name "*.bz2" \) -printf '%P\n' | while read line; do
echo "resource.AddFile("\""${line}"\"")" >> "${luafastdlfullpath}"
done
echo "Download enforcer generated"
sleep 1
fi
} }
fn_fastdl_completed(){ fn_fastdl_completed(){
echo "----------------------------------" echo "----------------------------------"
echo "Congratulations, it's done" echo "Congratulations, it's done"
echo "Now you should configure your HTTP server to target the fastdl folder that was created" 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 "Or copy files to an external server"
echo "Don't forget to change your sv_downloadurl accordingly in ${servercfgfullpath}" 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"
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
@ -203,7 +229,7 @@ if [ "${gamename}" == "Garry's Mod" ]; then
if [ "${bzip2installed}" == "1" ]; then if [ "${bzip2installed}" == "1" ]; then
fn_fastdl_bzip2 fn_fastdl_bzip2
fi fi
fn_lua_fastdl fn_lua_fastdl
fn_fastdl_completed fn_fastdl_completed
exit exit
fi fi

Loading…
Cancel
Save