forked from Soren90/cs2-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
66 lines (57 loc) · 2.04 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
sleep 1
# Mandatory variables check
: "${STEAM_DIR:?'ERROR: STEAM_DIR IS NOT SET!'}"
: "${STEAMCMD_DIR:?'ERROR: STEAMCMD_DIR IS NOT SET!'}"
: "${CS2_DIR:?'ERROR: CSGO_DIR IS NOT SET!'}"
: "${TOKEN}:?'ERROR: TOKEN IS NOT SET!'}"
# Set defaults
export SERVER_HOSTNAME="${SERVER_HOSTNAME:-cs2server}"
export PORT="${PORT:-27015}"
export GAME_TYPE="${GAME_TYPE:-0}"
export GAME_MODE="${GAME_MODE:-1}"
export MAP="${MAP:-de_dust2}"
export MAPGROUP="${MAPGROUP:-mg_active}"
export MAXPLAYERS="${MAXPLAYERS:-12}"
export IP="${IP:-0.0.0.0}"
export TOKEN="${TOKEN:-token}"
# Copy competitive configs
mkdir -p ${CS2_DIR}/game/csgo/cfg
cp /mnt/cfg/* ${CS2_DIR}/game/csgo/cfg
if [ ! -s "$CS2_DIR/game/csgo/cfg/autoexec.cfg" ]; then
cat << AUTOEXECCFG > "$CS2_DIR/game/csgo/cfg/autoexec.cfg"
log on
hostname "$SERVER_HOSTNAME"
rcon_password "$RCON_PASSWORD"
sv_password "$SERVER_PASSWORD"
sv_cheats 0
tv_delaymapchange 1
tv_delay 30
tv_deltacache 2
tv_dispatchmode 1
tv_maxclients 10
tv_maxrate 0
tv_overridemaster 0
tv_relayvoice 1
tv_snapshotrate 64
tv_timeout 60
tv_transmitall 1
writeid
writeip
exec banned_user.cfg
exec banned_ip.cfg
exec warmup.cfg
AUTOEXECCFG
else
sed -i "s/^hostname.*/hostname \"$SERVER_HOSTNAME\"/" $CS2_DIR/game/csgo/cfg/autoexec.cfg
sed -i "s/^rcon_password.*/rcon_password \"$RCON_PASSWORD\"/" $CS2_DIR/game/csgo/cfg/autoexec.cfg
sed -i "s/^sv_password.*/sv_password \"$SERVER_PASSWORD\"/" $CS2_DIR/game/csgo/cfg/autoexec.cfg
fi
# Install/update game
${STEAMCMD_DIR}/steamcmd.sh +login anonymous +force_install_dir ${CS2_DIR} +app_update 730 +quit
# hacky error fix
mkdir -p ${STEAM_DIR}/.steam/sdk32
mkdir -p ${STEAM_DIR}/.steam/sdk64
cp ${STEAMCMD_DIR}/linux32/steamclient.so ${STEAM_DIR}/.steam/sdk32/steamclient.so
cp ${STEAMCMD_DIR}/linux64/steamclient.so ${STEAM_DIR}/.steam/sdk64/steamclient.so
# Start gameserver
${CS2_DIR}/game/cs2.sh +ip ${IP} -port ${PORT} -dedicated -game csgo -console -usercon +map ${MAP} +game_type ${GAME_TYPE} +game_mode ${GAME_MODE} +exec autoexec.cfg +sv_setsteamaccount "${TOKEN}" -maxplayers_override ${MAXPLAYERS} ${EXTRAARG}