forked from dwurf/docker-kf2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkf2_functions.sh
119 lines (95 loc) · 3.49 KB
/
kf2_functions.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
function require_steamcmd() {
# Download/extract steam
mkdir -p downloads
[[ -f downloads/steamcmd.zip ]] || \
wget http://media.steampowered.com/installer/steamcmd.zip -P downloads
[[ -f steamcmd.exe ]] || unzip -o downloads/steamcmd.zip
# Install/update steam
WINEDEBUG=fixme-all wine steamcmd.exe +exit
}
function require_kf2() {
# Download kf2
[[ -f kf2server/Binaries/Win64/KFServer.exe ]] || \
WINEDEBUG=fixme-all \
wine steamcmd.exe \
+login anonymous \
+force_install_dir ./kf2server \
+app_update 232130 validate \
+exit
}
function require_dlls() {
# Download/extract KF2 DLLs
mkdir -p downloads
[[ -f downloads/KF2_WineDLL.zip ]] || \
wget http://www.redorchestra2.fr/downloads/KF2_WineDLL.zip -P downloads
[[ -f .wine/drive_c/windows/system32/X3DAudio1_7.dll ]] || (
cd $HOME/.wine/drive_c/windows/system32
unzip -o $OLDPWD/downloads/KF2_WineDLL.zip
)
# Install MS Visual C++ runtime
[[ -d $HOME/.wine/drive_c/windows/temp/_vcrun2010 ]] || (
winetricks -q vcrun2010 & sleep 30
)
}
function update() {
export WINEDEBUG=fixme-all
wine steamcmd.exe \
+login anonymous \
+force_install_dir \
./kf2server \
+app_update 232130 \
+exit
}
function validate() {
export WINEDEBUG=fixme-all
wine steamcmd.exe \
+login anonymous \
+force_install_dir \
./kf2server \
+app_update 232130 validate \
+exit
}
function require_config() {
# Generate INI files
if [[ ! -f kf2server/KFGame/Config/PCServer-KFGame.ini ]]; then
wine kf2server/Binaries/Win64/KFServer kf-bioticslab?difficulty=0?adminpassword=secret?gamepassword=secret -port=7777 &
sleep 20
kfpid=$(pgrep -f port=7777)
kill $kfpid
fi
}
function load_config() {
## Load defaults if nothing has been set
# find /path/to/volume -name '*KF-*kfm' | xargs -n 1 basename -s .kfm\n"
[[ -z "$KF_MAP" ]] && export KF_MAP=KF-BioticsLab
# 0 - normal, 1 - hard, 2 - suicidal, 3 - hell on earth
[[ -z "$KF_DIFFICULTY" ]] && export KF_DIFFICULTY=0
# Used for web console and in-game logins
[[ -z "$KF_ADMIN_PASS" ]] && export KF_ADMIN_PASS=secret
# Setting this creates a private server
[[ -z "$KF_GAME_PASS" ]] && export KF_GAME_PASS=''
# 0 - 4 waves, 1 - 7 waves, 2 - 10 waves, default 1
[[ -z "$KF_GAME_LENGTH" ]] && export KF_GAME_LENGTH=1
# Name that appears in the server browser
[[ -z "$KF_SERVER_NAME" ]] && export KF_SERVER_NAME=KF2 Server
# true or false, default false
[[ -z "$KF_ENABLE_WEB" ]] && export KF_ENABLE_WEB=false
## Now we edit the config files to set the config
sed -i "s/^GameLength=.*/GameLength=$KF_GAME_LENGTH\r/" /kf2/kf2server/KFGame/Config/PCServer-KFGame.ini
sed -i "s/^ServerName=.*/ServerName=$KF_SERVER_NAME\r/" /kf2/kf2server/KFGame/Config/PCServer-KFGame.ini
sed -i "s/^bEnabled=.*/bEnabled=$KF_ENABLE_WEB\r/" /kf2/kf2server/KFGame/Config/KFWeb.ini
}
function launch() {
export WINEDEBUG=fixme-all
local cmd
cmd="wine kf2server/Binaries/Win64/KFServer "
cmd+="$KF_MAP"
cmd+="?Difficulty=$KF_DIFFICULTY"
cmd+="?AdminPassword=$KF_ADMIN_PASS"
[[ -z "$KF_GAME_PASS" ]] || cmd+="?GamePassword=$KF_GAME_PASS"
cmd+=" -Port=7777"
cmd+=" -WebAdminPort=8080"
cmd+=" -QueryPort=27015"
echo "Running command: $cmd" > $0-cmd.log
exec $cmd
}