-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
217 lines (179 loc) · 5.77 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
set -e
set -x
shopt -s extglob
gokz="https://bitbucket.org/kztimerglobalteam/gokz/downloads/GOKZ-latest.zip"
kztver=($(wget -qO- http://updater.kztimerglobal.com/KZTimerGlobal.txt | grep Latest | awk -F "\"" '{print $4}'))
kztimer="https://bitbucket.org/kztimerglobalteam/kztimerglobal/downloads/${kztver}_Full.zip"
mhudtrackgokz="https://bitbucket.org/Sikarii/movementhud-tracking/downloads/MovementHUD-Tracking-GOKZ-latest.smx"
mhudtrackkzt="https://bitbucket.org/Sikarii/movementhud-tracking/downloads/MovementHUD-Tracking-KZTimer-latest.smx"
mapcycle='https://kzmaps.tangoworldwide.net/mapcycles/gokz.txt'
kztmapcycle='https://kzmaps.tangoworldwide.net/mapcycles/kztimer.txt'
STEAM_DIR=/home/csgo/Steam
SERVER_DIR=/home/csgo/server
SERVER_INSTALLED_LOCK_FILE=/home/csgo/server/installed.lock
CSGO_DIR=/home/csgo/server/csgo
CSGO_CUSTOM_CONFIGS_DIR="${CSGO_CUSTOM_CONFIGS_DIR-/var/csgo}"
syncPlugins() {
echo "> Syncing plugins ..."
rsync -rti /home/csgo/plugins/ /home/csgo/server/csgo/
echo '> Done'
}
installGOKZ() {
echo "> Installing GOKZ ..."
cd $CSGO_DIR/addons/sourcemod/plugins
if [ -f ./KZTimerGlobal.smx ]; then
mv ./KZ*.smx disabled
fi
if [ -f ./MovementHUD-Tracking-KZTimer-latest.smx ]; then
mv ./MovementHUD-Tracking*.smx disabled
fi
if [ -f ./MovementHUD-Tracking-GOKZ-latest.smx ]; then
mv ./MovementHUD-Tracking*.smx disabled
fi
wget -q $mhudtrackgokz
mv ./fun*.smx disabled
mv ./playercommands.smx disabled
cd $CSGO_DIR
wget -q -O plugin.zip $gokz
unzip -qo plugin.zip
rm plugin.zip
wget -q -O mapcycle.txt $mapcycle
cp -p mapcycle.txt $CSGO_DIR/cfg/sourcemod/gokz/gokz-localranks-mappool.cfg
echo '> Done'
}
installKZTimer() {
echo "> Installing KZTimer ..."
cd $CSGO_DIR/addons/sourcemod/plugins
if [ -f ./gokz-core.smx ]; then
mv ./gokz*.smx disabled
fi
if [ -f ./MovementHUD-Tracking-KZTimer-latest.smx ]; then
mv ./MovementHUD-Tracking*.smx disabled
fi
if [ -f ./MovementHUD-Tracking-GOKZ-latest.smx ]; then
mv ./MovementHUD-Tracking*.smx disabled
fi
wget -q $mhudtrackkzt
mv ./fun*.smx disabled
mv ./playercommands.smx disabled
cd $CSGO_DIR
wget -q -O plugin.zip $kztimer
unzip -qo plugin.zip
rm plugin.zip
wget -q -O mapcycle.txt $kztmapcycle
echo '> Done'
}
#downloadMaps() {
# echo "> Downloading maps ..."
# cd /home/csgo/server/csgo/maps/workshop
# /bin/bash /home/csgo/mapsync.sh
# cd /home/csgo/server/csgo
#}
#downloadMapsKZT() {
# echo "> Downloading maps ..."
# cd /home/csgo/server/csgo/maps/workshop
# /bin/bash /home/csgo/mapsynckzt.sh
# cd /home/csgo/server/csgo
#}
installServer() {
echo '> Installing server ...'
$STEAM_DIR/steamcmd.sh \
+login anonymous \
+force_install_dir $SERVER_DIR \
+app_update 740 validate \
+quit
echo '> Done'
touch $SERVER_INSTALLED_LOCK_FILE
}
applyCustomConfigs() {
echo "> Checking for custom configs at \"$CSGO_CUSTOM_CONFIGS_DIR\" ..."
if [ -d "$CSGO_CUSTOM_CONFIGS_DIR" ]; then
echo '> Found custom configs, applying ...'
rsync -rti $CSGO_CUSTOM_CONFIGS_DIR/ $CSGO_DIR
echo '> Done'
else
echo '> No custom configs found to apply'
fi
}
startServer() {
echo '> Starting server ...'
optionalParameters=""
if [ -n "$CSGO_GSLT" ]; then
optionalParameters+=" +sv_setsteamaccount $CSGO_GSLT"
else
echo '> Warning: Environment variable "CSGO_GSLT" is not set, but is required to run the server on the internet. Running the server in LAN mode.'
optionalParameters+=" +sv_lan 1"
fi
if [ -n "$CSGO_RCON_PW" ]; then
optionalParameters+=" +rcon_password $CSGO_RCON_PW"
fi
if [ -n "$CSGO_PW" ]; then
optionalParameters+=" +sv_password $CSGO_PW"
fi
if [ -n "$CSGO_HOSTNAME" ]; then
optionalParameters+=" +hostname "'"'"$CSGO_HOSTNAME"'"'
fi
if [ -n "$CSGO_WS_API_KEY" ]; then
optionalParameters+=" -authkey $CSGO_WS_API_KEY +host_workshop_map 1326959512"
else
echo '> Warning: Environment variable "CSGO_WS_API_KEY" is not set, so you need to mount maps and set environment variable "CSGO_CUSTOM_CONFIGS_DIR"'
fi
if [ -n "$KZ_API_KEY" ]; then
echo $KZ_API_KEY > $CSGO_DIR/cfg/sourcemod/globalrecords.cfg
else
echo '> Warning: Environment variable "KZ_API_KEY" is not set, so you need to mount globalrecords.cfg and set environment variable "CSGO_CUSTOM_CONFIGS_DIR" if you intend to make this server "global"'
fi
#if [ "$DLMAPS" == "yes" ]; then
# optionalParameters+=" -nowatchdog"
#fi
$SERVER_DIR/srcds_run \
-game csgo \
-console \
-norestart \
-usercon \
-nobreakpad \
+ip "${CSGO_IP-0.0.0.0}" \
-port "${CSGO_PORT-27015}" \
-tickrate "${CSGO_TICKRATE-128}" \
-maxplayers_override "${CSGO_MAX_PLAYERS-16}" \
+game_type 3 \
+game_mode 0 \
+map de_mirage \
$optionalParameters \
$CSGO_PARAMS
}
updateServer() {
echo '> Checking for server update ...'
$STEAM_DIR/steamcmd.sh \
+login anonymous \
+force_install_dir $HOME/server \
+app_update 740 \
+quit
echo '> Done'
}
if [ -f "$SERVER_INSTALLED_LOCK_FILE" ]; then
updateServer
else
installServer
fi
syncPlugins
if [ "$TIMER" == "kztimer" ]; then
installKZTimer
else
installGOKZ
fi
#if [ "$DLMAPS" == "yes" ]; then
# if [ "$TIMER" == "kztimer" ]; then
# downloadMapsKZT
# else
# downloadMaps
# fi
#fi
if [ "$MAPCHOOSER" == "yes" ]; then
mv $CSGO_DIR/addons/sourcemod/plugins/disabled/mapchooser.smx $CSGO_DIR/addons/sourcemod/plugins/
mv $CSGO_DIR/addons/sourcemod/plugins/disabled/nominations.smx $CSGO_DIR/addons/sourcemod/plugins/
mv $CSGO_DIR/addons/sourcemod/plugins/disabled/rockthevote.smx $CSGO_DIR/addons/sourcemod/plugins/
fi
applyCustomConfigs
startServer