This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
62 lines (54 loc) · 1.58 KB
/
start.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
#!/bin/bash
DATA_PATH="/data"
function update_cfg()
{
sed -i -r "s/^($1)\s+(.+)$/\1 \"$2\"/" "$DATA_PATH/csgo/cfg/server.cfg"
}
# Install CSGO when is not installed
if [ ! -f "./srcds_run" ] || [ -f "./.force_update" ]
then
/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +login anonymous +force_install_dir $DATA_PATH +app_update 740 validate +quit
rc=$?
# Check the exit code of steamcmd
if [[ $rc != 0 ]]
then
(>&2 echo "SteamCMD exited with error code: $rc")
exit $rc
fi
# If the configuration of the server is not present, create new one
if [ ! -f "./csgo/cfg/server.cfg"]
then
cat <<SERVERCFG > ./csgo/cfg/server.cfg
hostname "$SERVER_HOSTNAME"
rcon_password "$SERVER_RCON_PASSWORD"
sv_password "$SERVER_PASSWORD"
sv_lan 0
sv_cheats 0
SERVERCFG
chmod 755 ./csgo/cfg/server.cfg
fi
# If everything ok, delete the file
rm -f .force_update
fi
# Make backup of the configuration
cp ./csgo/cfg/server.cfg ./csgo/cfg/server-`date --iso`.cfg.bak
# Update configuration
update_cfg 'hostname' "$SERVER_HOSTNAME"
update_cfg 'rcon_password' "$SERVER_RCON_PASSWORD"
update_cfg 'sv_password' "$SERVER_PASSWORD"
# Start the server
./srcds_run \
-console \
-usercon \
-game csgo \
-secure \
-autoupdate \
-tickrate $SERVER_TICKRATE \
-port $SERVER_PORT \
-maxplayers_override $SERVER_MAX_PLAYERS \
+game_type $SERVER_GAME_TYPE \
+game_mode $SERVER_GAME_MODE \
+mapgroup $SERVER_MAP_GROUP \
+map $SERVER_MAP \
+ip $SERVER_SERVER_IP \
+sv_setsteamaccount $STEAM_ACCOUNT