-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhlds_run.sh
executable file
·86 lines (67 loc) · 2.78 KB
/
hlds_run.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
#!/usr/bin/env bash
set -axe
HLDS="/opt/hlds"
CONFIG_FILE="${HLDS}/startup.cfg"
if [ -r "${CONFIG_FILE}" ]; then
# TODO: make config save/restore mechanism more solid
set +e
# shellcheck source=/dev/null
source "${CONFIG_FILE}"
set -e
fi
EXTRA_OPTIONS=( "$@" )
EXECUTABLE="${HLDS}/hlds_run"
GAME="${GAME:-cstrike}"
MAXPLAYERS="${MAXPLAYERS:-32}"
START_MAP="${START_MAP:-de_dust2}"
SERVER_NAME="${SERVER_NAME:-Counter-Strike 1.6 Server}"
CSDM_MODE="${CSDM_MODE:-0}"
OPTIONS=( "-game" "${GAME}" "+maxplayers" "${MAXPLAYERS}" "+map" "${START_MAP}" "+hostname" "\"${SERVER_NAME}\"")
if [ -z "${RESTART_ON_FAIL}" ]; then
OPTIONS+=('-norestart')
fi
# AMX Admin Users by IP
if [ -n "${ADMIN_IP}" ]; then
for ip in ${ADMIN_IP//,/ }
do
echo "\"${ip}\" \"\" \"abcdefghijklmnopqrstu\" \"de\"" >> "${HLDS}/cstrike/addons/amxmodx/configs/users.ini"
done
fi
# AMX Admin Users by Name
if [ -n "${ADMIN_NAME}" ] && [ -n "${ADMIN_PASSWORD}" ]; then
for name in ${ADMIN_NAME//,/ }
do
echo "\"${name}\" \"${ADMIN_PASSWORD}\" \"abcdefghijklmnopqrstu\" \"a\"" >> "${HLDS}/cstrike/addons/amxmodx/configs/users.ini"
done
echo "rcon_password \"${ADMIN_PASSWORD}\"" >> "${HLDS}/cstrike/server.cfg"
fi
# Set Server Password
if [ -n ${SERVER_PASSWORD} ]; then
echo "sv_password \"${SERVER_PASSWORD}\"" >> "${HLDS}/cstrike/server.cfg"
fi
# Enable AMX Plugins
# echo "restmenu.amxx ; Restrict Weapons" >> "${HLDS}/cstrike/addons/amxmodx/configs/plugins.ini"
# echo "deathbeams.amxx ; Death Beams" >> "${HLDS}/cstrike/addons/amxmodx/configs/plugins.ini"
# echo "hsonly.amxx ; HeadShot Only" >> "${HLDS}/cstrike/addons/amxmodx/configs/plugins.ini"
# Disable AMX Messages
sed -ri 's/(adminhelp|multilingual|adminchat|antiflood|scrollmsg|imessage|adminvote)\.amxx.*//g' "${HLDS}/cstrike/addons/amxmodx/configs/plugins.ini"
# Enable YaPB Bots
if [ "${YAPB_ENABLED}" -eq 1 ];then
YAPB_PASSWORD="${YAPB_PASSWORD:-yapb}"
echo "linux addons/yapb/bin/yapb.so" >> "${HLDS}/cstrike/addons/metamod/plugins.ini"
echo "yb_password \"${YAPB_PASSWORD}\"" >> "${HLDS}/cstrike/addons/yapb/conf/yapb.cfg"
echo "amxx_yapbmenu.amxx ; YAPB Menu" >> "${HLDS}/cstrike/addons/amxmodx/configs/plugins.ini"
fi
# Enable CSDM
if [ "${CSDM_MODE}" -ge 1 ]; then
echo 'csdm_active "1"' >> "${HLDS}/cstrike/server.cfg"
sed -ri 's/^menus =.*/menus = ps/; s/^autoitems =.*/autoitems = g/' "${HLDS}/cstrike/addons/amxmodx/configs/csdm.cfg"
else
echo 'csdm_active "0"' >> "${HLDS}/cstrike/server.cfg"
fi
if [ "${CSDM_MODE}" -ge 2 ]; then
echo 'csdm_ffa_enable "1"' >> "${HLDS}/cstrike/server.cfg"
echo 'mp_freeforall "1"' >> "${HLDS}/cstrike/server.cfg"
fi
set > "${CONFIG_FILE}"
exec "${EXECUTABLE}" "${OPTIONS[@]}" "${EXTRA_OPTIONS[@]}"