This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.sh
executable file
·110 lines (78 loc) · 3.16 KB
/
server.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
#!/bin/bash
if [[ $(id -u) -ne ${STEAMCMD_UID} ]]; then
exec gosu steamcmd ${0} $@
fi
source /usr/local/lib/steamcmd/server-common.sh srcds
# Define SRCDS-specific functions
_server_requires_hibernation_hooks() {
local hibernation_hooks_appids="730 346680" # CS2, BMS
for hibernation_hooks_appid in ${hibernation_hooks_appids}; do
test "${STEAMCMD_SERVER_APPID}" = "${hibernation_hooks_appid}" && return 0
done
return 1
}
_enable_tickrate() {
if [ ${STEAMCMD_SERVER_TICKRATE} -gt 64 ]; then
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "sv_minupdaterate ${STEAMCMD_SERVER_TICKRATE}" "Enter"
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "sv_mincmdrate ${STEAMCMD_SERVER_TICKRATE}" "Enter"
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "sv_minrate ${STEAMCMD_SERVER_MINRATE}" "Enter"
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "sv_maxrate ${STEAMCMD_SERVER_MAXRATE:-0}" "Enter"
fi
}
_setup_hibernation_hook_attached() {
${TMUX_CMD} set-hook -t ${STEAMCMD_SERVER_SESSION_NAME} -u client-attached
${TMUX_CMD} set-hook -t ${STEAMCMD_SERVER_SESSION_NAME} client-attached 'send-keys "sv_hibernate_when_empty 0" "Enter"'
}
_setup_hibernation_hook_detached() {
${TMUX_CMD} set-hook -t ${STEAMCMD_SERVER_SESSION_NAME} -u client-detached
${TMUX_CMD} set-hook -t ${STEAMCMD_SERVER_SESSION_NAME} client-detached 'send-keys "sv_hibernate_when_empty 1" "Enter"'
}
_setup_hibernation_hooks() {
if _is_attached; then
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "sv_hibernate_when_empty 0" "Enter"
fi
_setup_hibernation_hook_detached
_setup_hibernation_hook_attached
}
attach() {
_attach
}
update() {
_update
}
run() {
pre_exit_code=$(_run_pre)
if ! $pre_exit_code; then
return $pre_exit_code
fi
echo ${MESSAGE_STEAMCMD_SERVER_STARTED}
if [[ "${STEAMCMD_SERVER_APPID}" = "730" ]]; then
ln -sf ${STEAMCMD_SERVER_HOME}/game/bin/linuxsteamrt64/cs2 ${STEAMCMD_SERVER_HOME}/game/bin/linuxsteamrt64/srcds
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "cd ${STEAMCMD_SERVER_HOME}/game/bin/linuxsteamrt64; ./srcds \
-dedicated \
+map ${STEAMCMD_SERVER_MAP} \
+ip 0.0.0.0 \
-port ${STEAMCMD_SERVER_PORT} \
-maxplayers ${STEAMCMD_SERVER_MAXPLAYERS} \
+fps_max ${STEAMCMD_SERVER_FPSMAX}" "Enter"
else
${TMUX_CMD} send-keys -t ${STEAMCMD_SERVER_SESSION_NAME} "cd ${STEAMCMD_SERVER_HOME}; bash ./srcds_run \
-console \
-game ${STEAMCMD_SERVER_GAME} \
+ip 0.0.0.0 \
-port ${STEAMCMD_SERVER_PORT} \
+maxplayers ${STEAMCMD_SERVER_MAXPLAYERS} \
+map ${STEAMCMD_SERVER_MAP} \
-tickrate ${STEAMCMD_SERVER_TICKRATE} \
-threads ${STEAMCMD_SERVER_THREADS} \
+fps_max ${STEAMCMD_SERVER_FPSMAX} \
-nodev" "Enter"
fi
_run_post
if _server_requires_hibernation_hooks; then
_setup_hibernation_hooks
fi
test "${STEAMCMD_SERVER_APPID}" != "730" && _enable_tickrate
return 0
}
${@}