Skip to content

Instantly share code, notes, and snippets.

@leobrines
Created April 4, 2020 20:01
Show Gist options
  • Save leobrines/1a169b18ec1ebf1bdf61965760bbc686 to your computer and use it in GitHub Desktop.
Save leobrines/1a169b18ec1ebf1bdf61965760bbc686 to your computer and use it in GitHub Desktop.
Create a directory with fastdl files for cstrike server (Update 2k20)
#!/bin/bash
# SRCDS Server
# FastDL Creator
# Author : Robin Labadie aka UltimateByte
# Website : http://www.lrob.fr for http://www.mesnie.org
# Version : 1.2
# README
# This script is intended to work only for Valve SRCDS (Source) servers using Daniel Gibbs Linux Game Servers Management script
# It's been tested for Debian 8 but other debian and distros should also work
# After running this, you have to setup an HTTP server pointing to the fastdl folder that will be created
# Of course, you will also have to change your server configuration's sv_downloadurl
# If my work helped you, please consider making a donation on www.mesnie.org
# CONFIGURATION
# The SRCDS name of the game
gamename="cstrike"
# SCRIPT
# Directories
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
serverdir="${rootdir}/2/${gamename}"
fastdl="${rootdir}/fastdl"
addons="${serverdir}/addons"
# Welcome message
echo "Welcome to FastDL folder Creator"
echo "Checking configuration..."
sleep 2
# Check if lgsm directories seems to exists and be standard, if not, exit
if [ -d $serverdir ]; then
echo "Good, your lgsm installation and script configuration are fine"
echo "Setup will now copy FastDL files into a new folder"
else
echo "Sorry, your lgsm installation was not found"
echo "Please make sure to read the README at the beginning of the script"
sleep 2
exit
fi
# User confirmation for starting process
while true; do
read -p "Continue? [y/N]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# Check if bzip2 is installed, warning if not
if [ -z "$(command -v bzip2)" ]; then
echo "WARNING bzip2 is not installed"
echo "You can still continue but loading time won't be as best as possible for your players"
while true; do
read -p "Continue? [y/N]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# Create FastDL folder if it doesn't exit
if [ ! -d $fastdl ]; then
mkdir -v "${fastdl}"
sleep 1
fi
# Copy all needed files for fastDL
echo "Gathering all needed FastDL files..."
sleep 2
cd ${serverdir}
# Map Files
echo "Copying map files"
sleep 1
find . -name '*.bsp' | cpio -updm ${fastdl}
find . -name '*.ain' | cpio -updm ${fastdl}
find . -name '*.nav' | cpio -updm ${fastdl}
find . -name '*.txt' | cpio -updm ${fastdl}
find . -name '*.wad' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Materials
echo "Copying Materials"
sleep 1
find . -name '*.vtf' | cpio -updm ${fastdl}
find . -name '*.vmt' | cpio -updm ${fastdl}
find . -name '*.vbf' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Models
echo "Copying Models"
sleep 1
find . -name '*.vtx' | cpio -updm ${fastdl}
find . -name '*.vvd' | cpio -updm ${fastdl}
find . -name '*.mdl' | cpio -updm ${fastdl}
find . -name '*.phy' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Map Files
echo "Copying sprite files"
sleep 1
find . -name '*.spr' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Particles
echo "Copying Particles"
sleep 1
find . -name '*.pcf' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Sounds
echo "Copying Sounds"
sleep 1
find . -name '*.wav' | cpio -updm ${fastdl}
find . -name '*.mp3' | cpio -updm ${fastdl}
find . -name '*.ogg' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Resources (mostly fonts)
echo "Copying fonts"
sleep 1
find . -name '*.otf' | cpio -updm ${fastdl}
find . -name '*.ttf' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Images
echo "Copying fonts and png"
sleep 1
find . -name '*.png' | cpio -updm ${fastdl}
find . -name '*.jpg' | cpio -updm ${fastdl}
find . -name '*.svg' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Models
echo "Copying Models"
sleep 1
find . -name '*.vtx' | cpio -updm ${fastdl}
find . -name '*.vvd' | cpio -updm ${fastdl}
find . -name '*.mdl' | cpio -updm ${fastdl}
find . -name '*.phy' | cpio -updm ${fastdl}
find . -name '*.tga' | cpio -updm ${fastdl}
echo "Done"
sleep 1
# Going back to scriptfolder to avoid mistakes
cd ${rootdir}
# Correct addons folder structure
# Create FastDL folder if it doesn't exit
if [ -d "$fastdl/addons" ]; then
echo "Possible FastDL files found into addons"
echo "Moving those files to their correct folder"
sleep 2
cp -Rf ${fastdl}/addons/*/* ${fastdl}
rm -R ${fastdl}/addons
echo "Done"
sleep 1
fi
# Correct content that may be into a lua folder by mistake like darkrpmodification
if [ -d "$fastdl/lua" ]; then
echo "Possible FastDL files found into a lua folder"
echo "Moving those files to their correct folder"
sleep 2
cp -Rf ${fastdl}/lua/* ${fastdl}
echo "Done"
sleep 1
fi
# bzip2 compression
# End if bzip2 not installed
if [ -z "$(command -v bzip2)" ]; then
echo "----------------------------------"
echo "Congratulations, it's done"
echo "Now you should configure your HTTP server to target the fastdl folder that was created"
echo "Or copy files to an external server"
echo "Don't forget to change your sv_downloadurl in server configuration"
echo "By the way, you'd better install bzip2 an re-run this script"
echo "----------------------------------"
exit
fi
# Files Compression with bzip2
# User confirmation for bzip2
echo "----------------------------------"
echo "FastDL will now compress files using bzip2"
sleep 1
echo "It may take a while..."
sleep 1
while true; do
read -p "Continue? [y/N]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# bzip2 all files that are not already compressed (keeping original files)
find $fastdl -not -name \*.bz2 -exec bzip2 -k \{\} \;
echo "bzip2 compression done"
sleep 1
echo "----------------------------------"
echo "Congratulations, it's done"
echo "Now you should configure your HTTP server to target the fastdl folder that was created"
echo "Or copy files to an external server"
echo "Don't forget to change your sv_downloadurl in server configuration"
echo "----------------------------------"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment