Skip to content

Instantly share code, notes, and snippets.

@magik6k
Last active June 14, 2022 21:29
Show Gist options
  • Save magik6k/d463875423864e6d5273 to your computer and use it in GitHub Desktop.
Save magik6k/d463875423864e6d5273 to your computer and use it in GitHub Desktop.
#!/bin/bash
# FastDL for Garrys Mod setup script - linux
# If you don't have $GMODROOT/bin/gmad_linux get it from gmod client installation(At least linux one)
#
# <!!!> Before use set config varibles <!!!>
#
# After running this script append following to the server.cfg
#
# sv_downloadurl "http://example.com/fastdl"
# sv_allowdownload 0
# sv_allowupload 0
#
# Constier this file to be WTFPL licensed
###
# Config
# Web server path. This directory must exist before running this script!
FASTDLROOT=/var/www/example.com/fastdl
# Gmod install path(one with bin, assets, lua.. directories)
GMODROOT=/home/steam/garrysmod
# Config end
###
# Use pbzip2 for faster compression if installed
BZIP=bzip2
if hash pbzip2 2>/dev/null; then
BZIP=pbzip2
fi
echo -e "\e[32mExtracting addons\e[39m"
find $GMODROOT/addons/ -exec $GMODROOT/bin/gmad_linux extract -file {} -out $FASTDLROOT \;
echo -e "\e[32mCompressing addons\e[39m"
find $FASTDLROOT -type f -not -name "*.bz2" -exec $BZIP -zfkv {} \;
echo -e "\e[32mGenerating fastdl.lua\e[39m"
echo "if (SERVER) then" > $GMODROOT/lua/autorun/fastdl.lua
find $FASTDLROOT -type f -printf '\tresource.AddFile("%P")\n' >> $GMODROOT/lua/autorun/fastdl.lua
echo "end" >> $GMODROOT/lua/autorun/fastdl.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment