Skip to content

Instantly share code, notes, and snippets.

@YoSoyPhil
Last active July 24, 2024 12:44
Show Gist options
  • Save YoSoyPhil/102f9e73deea7227db7ea9f413e1ce5a to your computer and use it in GitHub Desktop.
Save YoSoyPhil/102f9e73deea7227db7ea9f413e1ce5a to your computer and use it in GitHub Desktop.
Install CSGO server (with Soucemod, mmsource and PugSetup) on CentOS 7
50 6 * * * /usr/bin/systemctl stop csgo-USERNAME >/dev/null 2>&1
30 7 * * * /usr/bin/systemctl start csgo-USERNAME >/dev/null 2>&1
0 7 * * * /home/USERNAME/steamcmd.sh +runscript /home/USERNAME/update_csgo.txt > /home/USERNAME/update_csgo.log
[Service]
Type=simple
User=USERNAME
Group=USERNAME
Environment="LD_LIBRARY_PATH=/home/USERNAME/gamedir:/home/USERNAME/gamedir/bin"
ExecStart=/home/USERNAME/gamedir/srcds_linux -autoupdate -game csgo -usercon -tickrate 128 -port PORT \
+game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +sv_setsteamaccount TOKEN
TimeoutStartSec=0
Restart=always
[Install]
WantedBy=multi-user.target
#!/bin/bash
USERNAME="$1"
TOKEN="$2"
PORT="$3"
if [ -n "$1" ]; then
echo "" > /dev/null
else
echo "First parameter not supplied. Should be username!"
exit 1
fi
if [ -n "$2" ]; then
echo "" > /dev/null
else
echo "Second parameter not supplied. Should be token!"
exit 1
fi
if [ -n "$3" ]; then
echo "Installation about to begin.."
else
echo "Third parameter not supplied. Should be port!"
exit 1
fi
# Install dependencies
yum update
yum upgrade -y
yum install -y glibc.i686 libstdc++.i686 bsdtar unzip -y
adduser $USERNAME
su - $USERNAME -c "wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz"
su - $USERNAME -c "tar xf steamcmd_linux.tar.gz"
su - $USERNAME -c "rm -rf steamcmd_linux.tar.gz"
# Create update (and install) file for steamcmd.sh
cp update_csgo.txt /home/$USERNAME/update_csgo.txt
# Create Systemd service for CSGO
cp csgo.service /usr/lib/systemd/system/csgo-$USERNAME.service
cat cronjob.user >> /var/spool/cron/$USERNAME
cat cronjob.root >> /var/spool/cron/root
sed -i "s/USERNAME/$USERNAME/g" /var/spool/cron/root
sed -i "s/USERNAME/$USERNAME/g" /var/spool/cron/$USERNAME
sed -i "s/USERNAME/$USERNAME/g" /usr/lib/systemd/system/csgo-$USERNAME.service
sed -i "s/PORT/$PORT/g" /usr/lib/systemd/system/csgo-$USERNAME.service
sed -i "s/TOKEN/$TOKEN/g" /usr/lib/systemd/system/csgo-$USERNAME.service
# Update CSGO server
su - $USERNAME -c './steamcmd.sh +runscript update_csgo.txt'
# Install sourcemod
su - $USERNAME -c 'wget https://sm.alliedmods.net/smdrop/1.9/sourcemod-1.9.0-git6261-linux.tar.gz'
su - $USERNAME -c 'tar xf sourcemod-1.9.0-git6261-linux.tar.gz -C gamedir/csgo/'
su - $USERNAME -c 'rm -rf sourcemod-1.9.0-git6261-linux.tar.gz'
# Install mmsource
su - $USERNAME -c 'wget https://mms.alliedmods.net/mmsdrop/1.10/mmsource-1.10.7-git966-linux.tar.gz'
su - $USERNAME -c 'tar xf mmsource-1.10.7-git966-linux.tar.gz -C gamedir/csgo/'
su - $USERNAME -c 'rm -rf mmsource-1.10.7-git966-linux.tar.gz'
# Install csgo pug setup
su - $USERNAME -c 'wget https://github.com/splewis/csgo-pug-setup/releases/download/2.0.5/pugsetup_2.0.5.zip'
su - $USERNAME -c 'mv pugsetup_2.0.5.zip gamedir/csgo/'
su - $USERNAME -c 'cd gamedir/csgo/ && unzip pugsetup_2.0.5.zip'
su - $USERNAME -c 'rm -rf gamedir/csgo/pugsetup_2.0.5.zip'
# Install server.cfg
cp server.cfg /home/$USERNAME/gamedir/csgo/cfg/server.cfg
chown $USERNAME:$USERNAME /home/$USERNAME/gamedir/csgo/cfg/server.cfg
sed -i "s/USERNAME/$USERNAME/g" /home/$USERNAME/gamedir/csgo/cfg/server.cfg
# Enable and start CSGO server
systemctl enable csgo-$USERNAME.service
systemctl start csgo-$USERNAME.service
# Setup filewall rules
firewall-cmd --zone=public --add-port=$PORT/tcp --permanent
firewall-cmd --zone=public --add-port=$PORT/udp --permanent
firewall-cmd --reload
hostname "USERNAME | Pug server"
sv_password "letsgotowar"
rcon_password 9977
sv_tags "USERNAME Pug"
writeid
writeip
exec banned_user.cfg
exec banned_ip.cfg
sv_competitive_official_5v5 1
login anonymous
force_install_dir ./gamedir
app_update 740 validate
quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment