Created
September 19, 2019 08:24
-
-
Save nosoop/04dcb8088ad8b5a1114f3bb5c7e900ad to your computer and use it in GitHub Desktop.
ctrl+c, ctrl+v srcds/cs:go but smol and largely untested
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
''' | |
gameinfo cloner for CS:GO | |
takes an existing CS:GO dedicated server installation and an empty directory and links / copies / | |
modifies files in the latter to create a runnable server | |
''' | |
import os | |
import pathlib | |
import platform | |
import re | |
import sys | |
import shutil | |
ENGINE_PATH = pathlib.Path('..', 'core') | |
GAME_PATH = ENGINE_PATH / 'csgo' | |
DEST_ENGINE_PATH = pathlib.Path('.') | |
DEST_GAME_PATH = DEST_ENGINE_PATH / 'csgo' | |
DEST_GAME_PATH.mkdir(exist_ok = True) | |
# support absolute paths on linux, windows must use relative paths | |
# might want to use relative for both, but linux generally avoids spaces in file paths anyways | |
if platform.system() == 'Linux': | |
ENGINE_PATH = ENGINE_PATH.resolve() | |
GAME_PATH = GAME_PATH.resolve() | |
DEST_ENGINE_PATH = DEST_ENGINE_PATH.resolve() | |
DEST_GAME_PATH = DEST_GAME_PATH.resolve() | |
# process gameinfo.txt file, insert a new hardcoded CS:GO path | |
with (GAME_PATH / 'gameinfo.txt').open('rt') as input, (DEST_GAME_PATH / 'gameinfo.txt').open('wt') as output: | |
for line in filter(lambda s: not (s.strip().startswith('//') or len(s.strip()) == 0), input): | |
line = re.sub('Game\\s+csgo$', r'Game\t\t\t\t{gamedir}\n\t\t\tGame\t\t\t\tcsgo'.format(gamedir = GAME_PATH.as_posix()), line) | |
output.write(line) | |
# list of required files / directories | |
ENGINE_LINKS = [ "bin" ] | |
GAME_LINKS = [ "steam.inf" ] | |
GAME_COPIES = [ ] | |
if platform.system() == 'Linux': | |
shutil.copy2(ENGINE_PATH / 'srcds_run', 'srcds_run') | |
ENGINE_LINKS.append("srcds_linux") | |
elif platform.system() == 'Windows': | |
shutil.copy2(ENGINE_PATH / 'srcds.exe', 'srcds.exe') | |
for link in filter(lambda l: not (DEST_ENGINE_PATH / l).exists(), ENGINE_LINKS): | |
os.symlink(ENGINE_PATH / link, DEST_ENGINE_PATH / link) | |
for link in filter(lambda l: not (DEST_GAME_PATH / l).exists(), GAME_LINKS): | |
# get a proper relative path on windows (os.symlink src is relative to target) | |
link_rel = pathlib.Path(os.path.relpath((GAME_PATH / link).resolve(), DEST_GAME_PATH)) | |
os.symlink(link_rel, DEST_GAME_PATH / link) | |
for file in filter(lambda f: not (DEST_GAME_PATH / f).exists(), GAME_COPIES): | |
shutil.copytree(GAME_PATH / file, DEST_GAME_PATH / file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# script to set up a gameinfo-cloning CS:GO server on Linux | |
# cd into your base directory | |
mkdir -p core/steam | |
pushd core | |
# install steam and install game above | |
wget -qO- "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar xzf - -C steam | |
steam/steamcmd.sh +login anonymous +force_install_dir ../ +app_update 740 +quit | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions
cd
yourself into an empty directory where all the files will go (e.g.,/home/me/csgo-servers
)install-csgo-multi.sh
, will install CS:GO game files and SteamCMD intocore
andcore/steam
mkdir
andcd
into a new "server instance" directory, runclone_gameinfo.py
in the new directory to generate the rewritten gameinfo and symlink the necessary files — you'll need Python 3.6 or 3.7 because of pathlib usesrcds_run
(orsrcds_wrapper
) as you normally wouldFor new server instances
cd
into the directory created in step 1 then start from step 3