-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDayZServerLauncher
More file actions
executable file
·214 lines (193 loc) · 7.47 KB
/
DayZServerLauncher
File metadata and controls
executable file
·214 lines (193 loc) · 7.47 KB
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
#!/bin/bash
source DayZLauncherUtil
dir=$serverDir
exe=$serverExe
##
# 0 = no output
# 1 = mod list | windows output
# 2 = mod list | windows output | arguments
# 3 = mod list | windows output | arguments | executables
# 4 = mod list | windows output | arguments | executables | final command
verbosity=0
useExperimental=false
useDiag=false
args=()
mods=()
serverMods=()
##
# Kill all Dayz related processes (exe and diagnostic exe)
function killAllProcesses() {
printf "%s\n" "> KILLING PROCESSES"
killServer "$verbosity"
killServerDiag "$verbosity"
}
##
# Specify to use experimental executable
function useExperimental() {
useExperimental=true
}
##
# Use the diagnostic executable
function useDiag() {
useDiag=true
args+=("-server")
}
##
# Specify to use file patching (diagnostic exe will be used)
function useFilePatching() {
useDiag
args+=("-filePatching")
}
##
# Print information on parameters used when executing the command
function printLaunchParameters() {
printf "%s\n" "> LAUNCHING SERVER"
if [[ $verbosity -ge 3 ]]; then
printf "\t%s\n" "- DIR: $dir"
printf "\t%s\n" "- EXE: $exe"
fi
if [[ $verbosity -ge 2 ]]; then
printf "\t%s\n" "- ARGUMENTS:"
for arg in "${args[@]}"; do
printf "\t\t%s\n" "$arg"
done
fi
if [[ ${#mods[*]} -gt 0 ]]; then
printf "\t%s\n" "- MODS:"
for mod in "${mods[@]}"; do
printf "\t\t%s\n" "$(printf "%s" "$mod" | sed 's/;/\n\t\t/g')"
done
fi
if [[ ${#serverMods[*]} -gt 0 ]]; then
printf "\t%s\n" "- SERVER MODS:"
for serverMod in "${serverMods[@]}"; do
printf "\t\t%s\n" "$(printf "%s" "$serverMod" | sed 's/;/\n\t\t/g')"
done
fi
}
##
# Setup directory and executables based on the flag given
function setupExecutables() {
if [[ $useExperimental == true ]]; then
if [[ $useDiag == true ]]; then
dir="$clientDirExp" # diagnostic executable is shipped only with client
exe="$clientExeDiag"
else
dir="$serverDirExp"
exe="$serverExe"
fi
else
if [[ $useDiag == true ]]; then
dir="$clientDir" # diagnostic executable is shipped only with client
exe="$clientExeDiag"
else
dir="$serverDir"
exe="$serverExe"
fi
fi
}
options=(
"h,help ?Print this page and exit"
"v,verbose ?Be verbose. Can be repeated for more verbosity"
"k,kill ?Kill active processes before starting a new one"
"e,experimental ?Use experimental executable."
"d,diagnostic ?Use diagnostic executable."
"f,file-patching ?Ensures that only PBOs are loaded and NO unpacked data."
"l,do-logs ?Enables all log messages in the server RPT file."
"a,admin-log ?Enables the admin log."
"n,net-log ?Enables the network traffic logging."
"F,freeze-check ?Stops the server when frozen for more than 5 min and create a dump file."
"m,mods:mods ?Loads the specified sub-folders for different mods.
Separated by semi-colons.
Absolute path and multiple stacked folders are possible."
"s,server-mods:mods ?Loads the specified sub-folders for different server-side (not broadcasted to clients) mods.
Separated by semi-colons.
Absolute path and multiple stacked folders are possible."
"p,port:port ?Port to have dedicated server listen on."
"c,cpu-count:cores-number ?Sets the number of logical CPU cores to use for parallel tasks processing.
It should be less or equal than the numbers of available cores."
"L,limit-fps:max-fps ?Limits server FPS to specified value (current max is 200) to lower CPU usage of low population servers."
"D,dir:exe-directory ?Selects where the executables are found"
"X,exe:exe-file ?Selects what executable file to be used"
"C,config:config ?Selects the Server Config File."
"M,mission:mission ?Selects what mission to use."
"P,profile-folder:profile ?Path to the folder containing server profile.
By default, server logs are written to server profile folder.
Logs/dumps/etc will be created there, along with BattlEye/BEC/Rcon related files.
Windows Environment variables are supported. E.g. &userprofile&"
"B,battleye-path:path ?Sets a custom path to the Battleye files"
"script-define:define ?Specify to load a script preprocessor define.
Can be repeated to define more."
"ignore-new-errors ?Newly added game / script errors are treated as warning."
)
_options=$(declare -p options)
function printUsage() {
mangen \
--name "${0##*/}" \
--options "$_options" \
--command-width 35 \
--description-width 80 \
--new-line-indent 4
}
function parseArgs() {
local parsedArgs
parsedArgs=$(getopt -n "${0##*/}" -o "$(mangen -so "$_options")" --long "$(mangen -lo "$_options")" -- "$@")
[[ "$?" != "0" ]] && exit 1
eval set -- "$parsedArgs"
while true; do
case $1 in
-h | --help) printUsage; exit 1 ;;
-v | --verbose) ((verbosity++)) ;;
-k | --kill) requestedKillProcess=true ;;
-d | --diagnostic) useDiag ;;
-e | --experimental) useExperimental ;;
-f | --file-patching) useFilePatching ;;
-l | --do-logs) args+=("-doLogs") ;;
-a | --admin-log) args+=("-adminLog") ;;
-n | --net-log) args+=("-netLog") ;;
-F | --freeze-check) args+=("-freezeCheck") ;;
-m | --mods) mods+=("$2") ; shift ;;
-s | --server-mods) serverMods+=("$2") ; shift ;;
-p | --port) args+=("-port=$2") ; shift ;;
-c | --cpu-count) args+=("-cpuCount=$2") ; shift ;;
-L | --limit-fps) args+=("-limitFPS=$2") ; shift ;;
-D | --dir) dir="$2" ; shift ;;
-X | --exe) exe="$2" ; shift ;;
-C | --config) args+=("-config=$2") ; shift ;;
-M | --mission) args+=("-mission=$2") ; shift ;;
-P | --profile-folder) args+=("-profiles=$2") ; shift ;;
-B | --battleye-path) args+=("-BEpath=$2") ; shift ;;
--script-define) args+=("-scrDef=$2") ; shift ;;
--ignore-new-errors) args+=("-newErrorsAreWarnings=1") ;;
--)
shift
break
;;
*)
echo "Invalid option: $1"
exit 1
;;
esac
shift #go to next arg
done
local modsArg=""
for mod in "${mods[@]}"; do
[[ -z "$modsArg" ]] && modsArg="-mod=$mod" || modsArg="$modsArg;$mod"
done
[[ -n "$modsArg" ]] && args+=("$modsArg")
local serverModsArg=""
for mod in "${serverMods[@]}"; do
[[ -z "$serverModsArg" ]] && serverModsArg="-serverMod=$mod" || serverModsArg="$serverModsArg;$mod"
done
[[ -n "$serverModsArg" ]] && args+=("$serverModsArg")
}
###############################################################################
parseArgs "$@"
setupExecutables
[[ $requestedKillProcess == true ]] && killAllProcesses
[[ $verbosity -ge 1 ]] && printLaunchParameters
if [[ $verbosity -ge 4 ]]; then
printf "\t%s" "> COMMAND: "
echo cmd.exe /c "cd" "/d" "$dir" "&&" "START" "$exe" "${args[@]}"
fi
cmd.exe /c "cd" "/d" "$dir" "&&" "START" "$exe" "${args[@]}" &