1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Provides functions to query and validate values for serverconfig.xml
|
---|
4 |
|
---|
5 | #################################
|
---|
6 | ## Definition of options
|
---|
7 |
|
---|
8 | serverconfig_ServerPort_QueryName() {
|
---|
9 | echo "Base Port"
|
---|
10 | }
|
---|
11 | serverconfig_ServerPort_Type() {
|
---|
12 | echo "number"
|
---|
13 | }
|
---|
14 | serverconfig_ServerPort_Default() {
|
---|
15 | echo "25000"
|
---|
16 | }
|
---|
17 | serverconfig_ServerPort_Range() {
|
---|
18 | echo "1024-65533"
|
---|
19 | }
|
---|
20 | serverconfig_ServerPort_Validate() {
|
---|
21 | local I=${INSTANCE:-!}
|
---|
22 | if [ $(checkGamePortUsed "$1" "$I") -eq 0 ]; then
|
---|
23 | echo "1"
|
---|
24 | else
|
---|
25 | echo "0"
|
---|
26 | fi
|
---|
27 | }
|
---|
28 | serverconfig_ServerPort_ErrorMessage() {
|
---|
29 | echo "Illegal port number or port already in use by another instance."
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 | serverconfig_ServerIsPublic_QueryName() {
|
---|
35 | echo "Public server"
|
---|
36 | }
|
---|
37 | serverconfig_ServerIsPublic_Type() {
|
---|
38 | echo "boolean"
|
---|
39 | }
|
---|
40 | serverconfig_ServerIsPublic_Default() {
|
---|
41 | echo "true"
|
---|
42 | }
|
---|
43 | serverconfig_ServerIsPublic_ErrorMessage() {
|
---|
44 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 | serverconfig_ServerName_QueryName() {
|
---|
50 | echo "Server name"
|
---|
51 | }
|
---|
52 | serverconfig_ServerName_Type() {
|
---|
53 | echo "string"
|
---|
54 | }
|
---|
55 | serverconfig_ServerName_Validate() {
|
---|
56 | if [ ! -z "$1" ]; then
|
---|
57 | echo "1"
|
---|
58 | else
|
---|
59 | echo "0"
|
---|
60 | fi
|
---|
61 | }
|
---|
62 | serverconfig_ServerName_ErrorMessage() {
|
---|
63 | echo "Server name cannot be empty."
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | serverconfig_ServerPassword_QueryName() {
|
---|
69 | echo "Server password"
|
---|
70 | }
|
---|
71 | serverconfig_ServerPassword_Type() {
|
---|
72 | echo "string"
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 | serverconfig_ServerMaxPlayerCount_QueryName() {
|
---|
78 | echo "Max players"
|
---|
79 | }
|
---|
80 | serverconfig_ServerMaxPlayerCount_Type() {
|
---|
81 | echo "number"
|
---|
82 | }
|
---|
83 | serverconfig_ServerMaxPlayerCount_Default() {
|
---|
84 | echo "4"
|
---|
85 | }
|
---|
86 | serverconfig_ServerMaxPlayerCount_Range() {
|
---|
87 | echo "1-64"
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | serverconfig_GameWorld_QueryName() {
|
---|
93 | echo "World name"
|
---|
94 | }
|
---|
95 | serverconfig_GameWorld_Type() {
|
---|
96 | echo "enum"
|
---|
97 | }
|
---|
98 | serverconfig_GameWorld_Default() {
|
---|
99 | echo "1"
|
---|
100 | }
|
---|
101 | serverconfig_GameWorld_Values() {
|
---|
102 | config_allowed_values=("Navezgane" "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War")
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|
107 | serverconfig_GameName_QueryName() {
|
---|
108 | echo "Game name"
|
---|
109 | }
|
---|
110 | serverconfig_GameName_Type() {
|
---|
111 | echo "string"
|
---|
112 | }
|
---|
113 | serverconfig_GameName_Validate() {
|
---|
114 | if [ ! -z "$1" ]; then
|
---|
115 | echo "1"
|
---|
116 | else
|
---|
117 | echo "0"
|
---|
118 | fi
|
---|
119 | }
|
---|
120 | serverconfig_GameName_ErrorMessage() {
|
---|
121 | echo "Game name cannot be empty."
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 | serverconfig_GameDifficulty_QueryName() {
|
---|
127 | echo "Difficulty"
|
---|
128 | }
|
---|
129 | serverconfig_GameDifficulty_Type() {
|
---|
130 | echo "number"
|
---|
131 | }
|
---|
132 | serverconfig_GameDifficulty_Default() {
|
---|
133 | echo "2"
|
---|
134 | }
|
---|
135 | serverconfig_GameDifficulty_Range() {
|
---|
136 | echo "0-4"
|
---|
137 | }
|
---|
138 | serverconfig_GameDifficulty_Values() {
|
---|
139 | config_allowed_values=("Very easy" "Easy" "Medium" "Hard" "Very hard")
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 | serverconfig_GameMode_QueryName() {
|
---|
145 | echo "Game mode"
|
---|
146 | }
|
---|
147 | serverconfig_GameMode_Type() {
|
---|
148 | echo "enum"
|
---|
149 | }
|
---|
150 | serverconfig_GameMode_Default() {
|
---|
151 | echo "1"
|
---|
152 | }
|
---|
153 | serverconfig_GameMode_Values() {
|
---|
154 | config_allowed_values=("GameModeSurvivalMP" "GameModeSurvivalSP")
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 | serverconfig_ZombiesRun_QueryName() {
|
---|
160 | echo "Zombies run"
|
---|
161 | }
|
---|
162 | serverconfig_ZombiesRun_Type() {
|
---|
163 | echo "number"
|
---|
164 | }
|
---|
165 | serverconfig_ZombiesRun_Default() {
|
---|
166 | echo "0"
|
---|
167 | }
|
---|
168 | serverconfig_ZombiesRun_Range() {
|
---|
169 | echo "0-2"
|
---|
170 | }
|
---|
171 | serverconfig_ZombiesRun_Values() {
|
---|
172 | config_allowed_values=("Default day/night walk/run" "Never run" "Always run")
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 |
|
---|
177 | serverconfig_ShowAllPlayersOnMap_QueryName() {
|
---|
178 | echo "Show all players on map"
|
---|
179 | }
|
---|
180 | serverconfig_ShowAllPlayersOnMap_Type() {
|
---|
181 | echo "boolean"
|
---|
182 | }
|
---|
183 | serverconfig_ShowAllPlayersOnMap_Default() {
|
---|
184 | echo "true"
|
---|
185 | }
|
---|
186 | serverconfig_ShowAllPlayersOnMap_ErrorMessage() {
|
---|
187 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
188 | }
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 | serverconfig_BuildCreate_QueryName() {
|
---|
193 | echo "Item spawn menu"
|
---|
194 | }
|
---|
195 | serverconfig_BuildCreate_Type() {
|
---|
196 | echo "boolean"
|
---|
197 | }
|
---|
198 | serverconfig_BuildCreate_Default() {
|
---|
199 | echo "true"
|
---|
200 | }
|
---|
201 | serverconfig_BuildCreate_ErrorMessage() {
|
---|
202 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
203 | }
|
---|
204 |
|
---|
205 |
|
---|
206 |
|
---|
207 | serverconfig_DayNightLength_QueryName() {
|
---|
208 | echo "Length of one day"
|
---|
209 | }
|
---|
210 | serverconfig_DayNightLength_Type() {
|
---|
211 | echo "number"
|
---|
212 | }
|
---|
213 | serverconfig_DayNightLength_Default() {
|
---|
214 | echo "45"
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 |
|
---|
219 | serverconfig_FriendlyFire_QueryName() {
|
---|
220 | echo "Friendly fire"
|
---|
221 | }
|
---|
222 | serverconfig_FriendlyFire_Type() {
|
---|
223 | echo "boolean"
|
---|
224 | }
|
---|
225 | serverconfig_FriendlyFire_Default() {
|
---|
226 | echo "false"
|
---|
227 | }
|
---|
228 | serverconfig_FriendlyFire_ErrorMessage() {
|
---|
229 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 |
|
---|
234 | serverconfig_DayCount_QueryName() {
|
---|
235 | echo "Day Count (Horde)"
|
---|
236 | }
|
---|
237 | serverconfig_DayCount_Type() {
|
---|
238 | echo "number"
|
---|
239 | }
|
---|
240 | serverconfig_DayCount_Default() {
|
---|
241 | echo "3"
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 | serverconfig_FragLimit_QueryName() {
|
---|
247 | echo "Frag limit (DM)"
|
---|
248 | }
|
---|
249 | serverconfig_FragLimit_Type() {
|
---|
250 | echo "number"
|
---|
251 | }
|
---|
252 | serverconfig_FragLimit_Default() {
|
---|
253 | echo "5"
|
---|
254 | }
|
---|
255 |
|
---|
256 |
|
---|
257 |
|
---|
258 | serverconfig_MatchLength_QueryName() {
|
---|
259 | echo "Match length (DM)"
|
---|
260 | }
|
---|
261 | serverconfig_MatchLength_Type() {
|
---|
262 | echo "number"
|
---|
263 | }
|
---|
264 | serverconfig_MatchLength_Default() {
|
---|
265 | echo "15"
|
---|
266 | }
|
---|
267 |
|
---|
268 |
|
---|
269 |
|
---|
270 | serverconfig_RebuildMap_QueryName() {
|
---|
271 | echo "Rebuild map on round restart"
|
---|
272 | }
|
---|
273 | serverconfig_RebuildMap_Type() {
|
---|
274 | echo "boolean"
|
---|
275 | }
|
---|
276 | serverconfig_RebuildMap_Default() {
|
---|
277 | echo "false"
|
---|
278 | }
|
---|
279 | serverconfig_RebuildMap_ErrorMessage() {
|
---|
280 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
281 | }
|
---|
282 |
|
---|
283 |
|
---|
284 |
|
---|
285 | serverconfig_ControlPanelEnabled_QueryName() {
|
---|
286 | echo "Enable control panel"
|
---|
287 | }
|
---|
288 | serverconfig_ControlPanelEnabled_Type() {
|
---|
289 | echo "boolean"
|
---|
290 | }
|
---|
291 | serverconfig_ControlPanelEnabled_Default() {
|
---|
292 | echo "false"
|
---|
293 | }
|
---|
294 | serverconfig_ControlPanelEnabled_ErrorMessage() {
|
---|
295 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
296 | }
|
---|
297 |
|
---|
298 |
|
---|
299 |
|
---|
300 | serverconfig_ControlPanelPort_QueryName() {
|
---|
301 | echo "Control panel port"
|
---|
302 | }
|
---|
303 | serverconfig_ControlPanelPort_Type() {
|
---|
304 | echo "number"
|
---|
305 | }
|
---|
306 | serverconfig_ControlPanelPort_Default() {
|
---|
307 | echo "8080"
|
---|
308 | }
|
---|
309 | serverconfig_ControlPanelPort_Range() {
|
---|
310 | echo "1024-65535"
|
---|
311 | }
|
---|
312 | serverconfig_ControlPanelPort_Validate() {
|
---|
313 | local I=${INSTANCE:-!}
|
---|
314 | if [ $(checkTCPPortUsed "$1" "$I") -eq 0 ]; then
|
---|
315 | echo "1"
|
---|
316 | else
|
---|
317 | echo "0"
|
---|
318 | fi
|
---|
319 | }
|
---|
320 | serverconfig_ControlPanelPort_ErrorMessage() {
|
---|
321 | echo "Illegal port number or port already in use by another instance."
|
---|
322 | }
|
---|
323 |
|
---|
324 |
|
---|
325 |
|
---|
326 | serverconfig_ControlPanelPassword_QueryName() {
|
---|
327 | echo "Control panel password"
|
---|
328 | }
|
---|
329 | serverconfig_ControlPanelPassword_Type() {
|
---|
330 | echo "string"
|
---|
331 | }
|
---|
332 |
|
---|
333 |
|
---|
334 |
|
---|
335 | serverconfig_TelnetPort_QueryName() {
|
---|
336 | echo "Telnet port"
|
---|
337 | }
|
---|
338 | serverconfig_TelnetPort_Type() {
|
---|
339 | echo "number"
|
---|
340 | }
|
---|
341 | serverconfig_TelnetPort_Default() {
|
---|
342 | echo "8081"
|
---|
343 | }
|
---|
344 | serverconfig_TelnetPort_Range() {
|
---|
345 | echo "1024-65535"
|
---|
346 | }
|
---|
347 | serverconfig_TelnetPort_Validate() {
|
---|
348 | local I=${INSTANCE:-!}
|
---|
349 | if [ $(checkTCPPortUsed "$1" "$I") -eq 0 ]; then
|
---|
350 | echo "1"
|
---|
351 | else
|
---|
352 | echo "0"
|
---|
353 | fi
|
---|
354 | }
|
---|
355 | serverconfig_TelnetPort_ErrorMessage() {
|
---|
356 | echo "Illegal port number or port already in use by another instance."
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 |
|
---|
361 | serverconfig_TelnetPassword_QueryName() {
|
---|
362 | echo "Telnet password"
|
---|
363 | }
|
---|
364 | serverconfig_TelnetPassword_Type() {
|
---|
365 | echo "string"
|
---|
366 | }
|
---|
367 | serverconfig_TelnetPassword_Validate() {
|
---|
368 | if [ -z $1 ]; then
|
---|
369 | echo "0"
|
---|
370 | else
|
---|
371 | echo "1"
|
---|
372 | fi
|
---|
373 | }
|
---|
374 | serverconfig_TelnetPassword_ErrorMessage() {
|
---|
375 | echo "Telnet must have a password set to function."
|
---|
376 | }
|
---|
377 |
|
---|
378 |
|
---|
379 |
|
---|
380 | serverconfig_DisableNAT_QueryName() {
|
---|
381 | echo "Disable NAT"
|
---|
382 | }
|
---|
383 | serverconfig_DisableNAT_Type() {
|
---|
384 | echo "boolean"
|
---|
385 | }
|
---|
386 | serverconfig_DisableNAT_Default() {
|
---|
387 | echo "true"
|
---|
388 | }
|
---|
389 | serverconfig_DisableNAT_ErrorMessage() {
|
---|
390 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
391 | }
|
---|
392 |
|
---|
393 |
|
---|
394 |
|
---|
395 |
|
---|
396 | serverconfig_DropOnDeath_QueryName() {
|
---|
397 | echo "Drop on Death"
|
---|
398 | }
|
---|
399 | serverconfig_DropOnDeath_Type() {
|
---|
400 | echo "number"
|
---|
401 | }
|
---|
402 | serverconfig_DropOnDeath_Default() {
|
---|
403 | echo "0"
|
---|
404 | }
|
---|
405 | serverconfig_DropOnDeath_Range() {
|
---|
406 | echo "0-3"
|
---|
407 | }
|
---|
408 | serverconfig_DropOnDeath_Values() {
|
---|
409 | config_allowed_values=("Everything" "Toolbelt only" "Backpack only" "Delete all")
|
---|
410 | }
|
---|
411 |
|
---|
412 |
|
---|
413 | serverconfig_DropOnQuit_QueryName() {
|
---|
414 | echo "Drop on Quit"
|
---|
415 | }
|
---|
416 | serverconfig_DropOnQuit_Type() {
|
---|
417 | echo "number"
|
---|
418 | }
|
---|
419 | serverconfig_DropOnQuit_Default() {
|
---|
420 | echo "0"
|
---|
421 | }
|
---|
422 | serverconfig_DropOnQuit_Range() {
|
---|
423 | echo "0-3"
|
---|
424 | }
|
---|
425 | serverconfig_DropOnQuit_Values() {
|
---|
426 | config_allowed_values=("Nothing" "Everything" "Toolbelt only" "Backpack only")
|
---|
427 | }
|
---|
428 |
|
---|
429 |
|
---|
430 |
|
---|
431 |
|
---|
432 | serverconfig_CraftTimer_QueryName() {
|
---|
433 | echo "Craft speed"
|
---|
434 | }
|
---|
435 | serverconfig_CraftTimer_Type() {
|
---|
436 | echo "number"
|
---|
437 | }
|
---|
438 | serverconfig_CraftTimer_Default() {
|
---|
439 | echo "1"
|
---|
440 | }
|
---|
441 | serverconfig_CraftTimer_Range() {
|
---|
442 | echo "0-2"
|
---|
443 | }
|
---|
444 | serverconfig_CraftTimer_Values() {
|
---|
445 | config_allowed_values=("Instant" "Normal" "Double")
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 | serverconfig_LootTimer_QueryName() {
|
---|
450 | echo "Loot open speed"
|
---|
451 | }
|
---|
452 | serverconfig_LootTimer_Type() {
|
---|
453 | echo "number"
|
---|
454 | }
|
---|
455 | serverconfig_LootTimer_Default() {
|
---|
456 | echo "1"
|
---|
457 | }
|
---|
458 | serverconfig_LootTimer_Range() {
|
---|
459 | echo "0-2"
|
---|
460 | }
|
---|
461 | serverconfig_LootTimer_Values() {
|
---|
462 | config_allowed_values=("Instant" "Normal" "Double")
|
---|
463 | }
|
---|
464 |
|
---|
465 |
|
---|
466 |
|
---|
467 |
|
---|
468 | serverconfig_PlayerDamageGiven_QueryName() {
|
---|
469 | echo "Damage Player->Zombies"
|
---|
470 | }
|
---|
471 | serverconfig_PlayerDamageGiven_Type() {
|
---|
472 | echo "number"
|
---|
473 | }
|
---|
474 | serverconfig_PlayerDamageGiven_Default() {
|
---|
475 | echo "2"
|
---|
476 | }
|
---|
477 | serverconfig_PlayerDamageGiven_Range() {
|
---|
478 | echo "0-4"
|
---|
479 | }
|
---|
480 | serverconfig_PlayerDamageGiven_Values() {
|
---|
481 | config_allowed_values=("50%" "75%" "100%" "150%" "200%")
|
---|
482 | }
|
---|
483 |
|
---|
484 |
|
---|
485 | serverconfig_PlayerDamageRecieved_QueryName() {
|
---|
486 | echo "Damage Zombies->Player"
|
---|
487 | }
|
---|
488 | serverconfig_PlayerDamageRecieved_Type() {
|
---|
489 | echo "number"
|
---|
490 | }
|
---|
491 | serverconfig_PlayerDamageRecieved_Default() {
|
---|
492 | echo "2"
|
---|
493 | }
|
---|
494 | serverconfig_PlayerDamageRecieved_Range() {
|
---|
495 | echo "0-4"
|
---|
496 | }
|
---|
497 | serverconfig_PlayerDamageRecieved_Values() {
|
---|
498 | config_allowed_values=("50%" "75%" "100%" "150%" "200%")
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | serverconfig_EnemySenseMemory_QueryName() {
|
---|
503 | echo "Sense memory (seconds)"
|
---|
504 | }
|
---|
505 | serverconfig_EnemySenseMemory_Type() {
|
---|
506 | echo "number"
|
---|
507 | }
|
---|
508 | serverconfig_EnemySenseMemory_Default() {
|
---|
509 | echo "60"
|
---|
510 | }
|
---|
511 |
|
---|
512 |
|
---|
513 | serverconfig_EnemySpawnMode_QueryName() {
|
---|
514 | echo "Spawn mode"
|
---|
515 | }
|
---|
516 | serverconfig_EnemySpawnMode_Type() {
|
---|
517 | echo "number"
|
---|
518 | }
|
---|
519 | serverconfig_EnemySpawnMode_Default() {
|
---|
520 | echo "3"
|
---|
521 | }
|
---|
522 | serverconfig_EnemySpawnMode_Range() {
|
---|
523 | echo "0-5"
|
---|
524 | }
|
---|
525 | serverconfig_EnemySpawnMode_Values() {
|
---|
526 | config_allowed_values=("Disabled" "50%" "75%" "100%" "125%" "150%")
|
---|
527 | }
|
---|
528 |
|
---|
529 |
|
---|
530 | serverconfig_EnemyDifficulty_QueryName() {
|
---|
531 | echo "Enemy difficulty"
|
---|
532 | }
|
---|
533 | serverconfig_EnemyDifficulty_Type() {
|
---|
534 | echo "number"
|
---|
535 | }
|
---|
536 | serverconfig_EnemyDifficulty_Default() {
|
---|
537 | echo "0"
|
---|
538 | }
|
---|
539 | serverconfig_EnemyDifficulty_Range() {
|
---|
540 | echo "0-1"
|
---|
541 | }
|
---|
542 | serverconfig_EnemyDifficulty_Values() {
|
---|
543 | config_allowed_values=("Normal" "Feral")
|
---|
544 | }
|
---|
545 |
|
---|
546 |
|
---|
547 |
|
---|
548 |
|
---|
549 | serverconfig_NightPercentage_QueryName() {
|
---|
550 | echo "Night percentage"
|
---|
551 | }
|
---|
552 | serverconfig_NightPercentage_Type() {
|
---|
553 | echo "number"
|
---|
554 | }
|
---|
555 | serverconfig_NightPercentage_Default() {
|
---|
556 | echo "35"
|
---|
557 | }
|
---|
558 | serverconfig_NightPercentage_Range() {
|
---|
559 | echo "10-90"
|
---|
560 | }
|
---|
561 |
|
---|
562 |
|
---|
563 |
|
---|
564 | serverconfig_BlockDurabilityModifier_QueryName() {
|
---|
565 | echo "Block durability (%)"
|
---|
566 | }
|
---|
567 | serverconfig_BlockDurabilityModifier_Type() {
|
---|
568 | echo "number"
|
---|
569 | }
|
---|
570 | serverconfig_BlockDurabilityModifier_Default() {
|
---|
571 | echo "100"
|
---|
572 | }
|
---|
573 |
|
---|
574 |
|
---|
575 |
|
---|
576 |
|
---|
577 | serverconfig_LootAbundance_QueryName() {
|
---|
578 | echo "Loot abundance (%)"
|
---|
579 | }
|
---|
580 | serverconfig_LootAbundance_Type() {
|
---|
581 | echo "number"
|
---|
582 | }
|
---|
583 | serverconfig_LootAbundance_Default() {
|
---|
584 | echo "100"
|
---|
585 | }
|
---|
586 |
|
---|
587 |
|
---|
588 | serverconfig_LootRespawnDays_QueryName() {
|
---|
589 | echo "Loot respawn delay (days)"
|
---|
590 | }
|
---|
591 | serverconfig_LootRespawnDays_Type() {
|
---|
592 | echo "number"
|
---|
593 | }
|
---|
594 | serverconfig_LootRespawnDays_Default() {
|
---|
595 | echo "7"
|
---|
596 | }
|
---|
597 |
|
---|
598 |
|
---|
599 |
|
---|
600 |
|
---|
601 | serverconfig_LandClaimSize_QueryName() {
|
---|
602 | echo "Land claim size"
|
---|
603 | }
|
---|
604 | serverconfig_LandClaimSize_Type() {
|
---|
605 | echo "number"
|
---|
606 | }
|
---|
607 | serverconfig_LandClaimSize_Default() {
|
---|
608 | echo "7"
|
---|
609 | }
|
---|
610 |
|
---|
611 |
|
---|
612 | serverconfig_LandClaimDeadZone_QueryName() {
|
---|
613 | echo "Minimum keystone distance"
|
---|
614 | }
|
---|
615 | serverconfig_LandClaimDeadZone_Type() {
|
---|
616 | echo "number"
|
---|
617 | }
|
---|
618 | serverconfig_LandClaimDeadZone_Default() {
|
---|
619 | echo "30"
|
---|
620 | }
|
---|
621 |
|
---|
622 |
|
---|
623 | serverconfig_LandClaimExpiryTime_QueryName() {
|
---|
624 | echo "Claim expiry time (days)"
|
---|
625 | }
|
---|
626 | serverconfig_LandClaimExpiryTime_Type() {
|
---|
627 | echo "number"
|
---|
628 | }
|
---|
629 | serverconfig_LandClaimExpiryTime_Default() {
|
---|
630 | echo "3"
|
---|
631 | }
|
---|
632 |
|
---|
633 |
|
---|
634 | serverconfig_LandClaimDecayMode_QueryName() {
|
---|
635 | echo "Claim decay mode"
|
---|
636 | }
|
---|
637 | serverconfig_LandClaimDecayMode_Type() {
|
---|
638 | echo "number"
|
---|
639 | }
|
---|
640 | serverconfig_LandClaimDecayMode_Default() {
|
---|
641 | echo "0"
|
---|
642 | }
|
---|
643 | serverconfig_LandClaimDecayMode_Range() {
|
---|
644 | echo "0-2"
|
---|
645 | }
|
---|
646 | serverconfig_LandClaimDecayMode_Values() {
|
---|
647 | config_allowed_values=("Linear" "Exponential" "Full protection")
|
---|
648 | }
|
---|
649 |
|
---|
650 |
|
---|
651 | serverconfig_LandClaimOnlineDurabilityModifier_QueryName() {
|
---|
652 | echo "Claim durability modifier - online"
|
---|
653 | }
|
---|
654 | serverconfig_LandClaimOnlineDurabilityModifier_Type() {
|
---|
655 | echo "number"
|
---|
656 | }
|
---|
657 | serverconfig_LandClaimOnlineDurabilityModifier_Default() {
|
---|
658 | echo "4"
|
---|
659 | }
|
---|
660 |
|
---|
661 |
|
---|
662 | serverconfig_LandClaimOfflineDurabilityModifier_QueryName() {
|
---|
663 | echo "Claim durability modifier - offline"
|
---|
664 | }
|
---|
665 | serverconfig_LandClaimOfflineDurabilityModifier_Type() {
|
---|
666 | echo "number"
|
---|
667 | }
|
---|
668 | serverconfig_LandClaimOfflineDurabilityModifier_Default() {
|
---|
669 | echo "4"
|
---|
670 | }
|
---|
671 |
|
---|
672 |
|
---|
673 |
|
---|
674 |
|
---|
675 | serverconfig_AirDropFrequency_QueryName() {
|
---|
676 | echo "Airdrop delay (hours)"
|
---|
677 | }
|
---|
678 | serverconfig_AirDropFrequency_Type() {
|
---|
679 | echo "number"
|
---|
680 | }
|
---|
681 | serverconfig_AirDropFrequency_Default() {
|
---|
682 | echo "24"
|
---|
683 | }
|
---|
684 |
|
---|
685 |
|
---|
686 |
|
---|
687 |
|
---|
688 | #################################
|
---|
689 | ## Edit option functions
|
---|
690 |
|
---|
691 | configEditServer() {
|
---|
692 | local CV
|
---|
693 |
|
---|
694 | echo "Server"
|
---|
695 | echo "--------------------------------"
|
---|
696 | for CV in \
|
---|
697 | ServerName ServerPassword ServerIsPublic ServerPort ServerMaxPlayerCount \
|
---|
698 | DisableNAT \
|
---|
699 | ; do
|
---|
700 | $1 $CV
|
---|
701 | done
|
---|
702 | echo
|
---|
703 | }
|
---|
704 |
|
---|
705 | configEditRemoteControl() {
|
---|
706 | local CV
|
---|
707 |
|
---|
708 | echo "Remote control"
|
---|
709 | echo "--------------------------------"
|
---|
710 | for CV in \
|
---|
711 | ControlPanelEnabled ControlPanelPort ControlPanelPassword \
|
---|
712 | TelnetPort TelnetPassword \
|
---|
713 | ; do
|
---|
714 | if [ "$CV" = "TelnetPort" ]; then
|
---|
715 | echo
|
---|
716 | echo "NOTE: Telnet will always be enabled for management purposes!"
|
---|
717 | echo "Make sure you block external access to this port!"
|
---|
718 | echo
|
---|
719 | fi
|
---|
720 | $1 $CV
|
---|
721 | done
|
---|
722 | echo
|
---|
723 | }
|
---|
724 |
|
---|
725 | configEditGameType() {
|
---|
726 | local CV
|
---|
727 |
|
---|
728 | echo "Game type"
|
---|
729 | echo "--------------------------------"
|
---|
730 | for CV in \
|
---|
731 | GameName GameWorld GameMode \
|
---|
732 | ; do
|
---|
733 | $1 $CV
|
---|
734 | done
|
---|
735 | echo
|
---|
736 | }
|
---|
737 |
|
---|
738 | configEditGameTypeSpecific() {
|
---|
739 | local CV
|
---|
740 |
|
---|
741 | echo "Options for specific game types"
|
---|
742 | echo "--------------------------------"
|
---|
743 | for CV in \
|
---|
744 | DayCount FragLimit MatchLength RebuildMap \
|
---|
745 | ; do
|
---|
746 | $1 $CV
|
---|
747 | done
|
---|
748 | echo
|
---|
749 | }
|
---|
750 |
|
---|
751 | configEditGeneric() {
|
---|
752 | local CV
|
---|
753 |
|
---|
754 | echo "Generic options"
|
---|
755 | echo "--------------------------------"
|
---|
756 | for CV in \
|
---|
757 | ShowAllPlayersOnMap FriendlyFire BuildCreate \
|
---|
758 | BlockDurabilityModifier \
|
---|
759 | ; do
|
---|
760 | $1 $CV
|
---|
761 | done
|
---|
762 | echo
|
---|
763 | }
|
---|
764 |
|
---|
765 | configEditDropLoot() {
|
---|
766 | local CV
|
---|
767 |
|
---|
768 | echo "Drop and Loot"
|
---|
769 | echo "--------------------------------"
|
---|
770 | for CV in \
|
---|
771 | DropOnDeath DropOnQuit \
|
---|
772 | LootAbundance LootRespawnDays AirDropFrequency \
|
---|
773 | ; do
|
---|
774 | $1 $CV
|
---|
775 | done
|
---|
776 | echo
|
---|
777 | }
|
---|
778 |
|
---|
779 | configEditTimes() {
|
---|
780 | local CV
|
---|
781 |
|
---|
782 | echo "Times / Durations"
|
---|
783 | echo "--------------------------------"
|
---|
784 | for CV in \
|
---|
785 | CraftTimer LootTimer \
|
---|
786 | DayNightLength NightPercentage \
|
---|
787 | ; do
|
---|
788 | $1 $CV
|
---|
789 | done
|
---|
790 | echo
|
---|
791 | }
|
---|
792 |
|
---|
793 | configEditDifficulty() {
|
---|
794 | local CV
|
---|
795 |
|
---|
796 | echo "Difficulty"
|
---|
797 | echo "--------------------------------"
|
---|
798 | for CV in \
|
---|
799 | GameDifficulty ZombiesRun \
|
---|
800 | PlayerDamageGiven PlayerDamageRecieved EnemySenseMemory EnemySpawnMode EnemyDifficulty \
|
---|
801 | ; do
|
---|
802 | $1 $CV
|
---|
803 | done
|
---|
804 | echo
|
---|
805 | }
|
---|
806 |
|
---|
807 | configEditLandClaim() {
|
---|
808 | local CV
|
---|
809 |
|
---|
810 | echo "Land claim options"
|
---|
811 | echo "--------------------------------"
|
---|
812 | for CV in \
|
---|
813 | LandClaimSize LandClaimDeadZone LandClaimExpiryTime LandClaimDecayMode \
|
---|
814 | LandClaimOnlineDurabilityModifier LandClaimOfflineDurabilityModifier \
|
---|
815 | ; do
|
---|
816 | $1 $CV
|
---|
817 | done
|
---|
818 | echo
|
---|
819 | }
|
---|
820 |
|
---|
821 | configEditAll() {
|
---|
822 | configEditServer "$1"
|
---|
823 | configEditRemoteControl "$1"
|
---|
824 | configEditGameType "$1"
|
---|
825 | configEditGameTypeSpecific "$1"
|
---|
826 | configEditGeneric "$1"
|
---|
827 | configEditDropLoot "$1"
|
---|
828 | configEditTimes "$1"
|
---|
829 | configEditDifficulty "$1"
|
---|
830 | configEditLandClaim "$1"
|
---|
831 | }
|
---|
832 |
|
---|
833 |
|
---|
834 |
|
---|
835 |
|
---|
836 |
|
---|
837 | #################################
|
---|
838 | ## Generic worker functions
|
---|
839 |
|
---|
840 |
|
---|
841 | # List all defined config editing parts
|
---|
842 | # Returns:
|
---|
843 | # List of config funcs
|
---|
844 | listConfigEditFuncs() {
|
---|
845 | local CV
|
---|
846 | for CV in $(declare -F | cut -d\ -f3 | grep "^configEdit.*$"); do
|
---|
847 | CV=${CV#configEdit}
|
---|
848 | printf "%s " "$CV"
|
---|
849 | done
|
---|
850 | }
|
---|
851 |
|
---|
852 |
|
---|
853 | # List all defined config options
|
---|
854 | # Returns:
|
---|
855 | # List of defined config options
|
---|
856 | listConfigValues() {
|
---|
857 | local CV
|
---|
858 | for CV in $(declare -F | cut -d\ -f3 | grep "^serverconfig_.*_Type$"); do
|
---|
859 | CV=${CV#serverconfig_}
|
---|
860 | CV=${CV%_Type}
|
---|
861 | printf "%s " "$CV"
|
---|
862 | done
|
---|
863 | }
|
---|
864 |
|
---|
865 |
|
---|
866 | # Validate the given value for the given option
|
---|
867 | # Params:
|
---|
868 | # 1: Option name
|
---|
869 | # 2: Value
|
---|
870 | # Returns:
|
---|
871 | # 0/1: invalid/valid
|
---|
872 | isValidOptionValue() {
|
---|
873 | local TYPE=$(serverconfig_$1_Type)
|
---|
874 | local RANGE=""
|
---|
875 |
|
---|
876 | if [ "$TYPE" = "enum" ]; then
|
---|
877 | TYPE="number"
|
---|
878 | serverconfig_$1_Values
|
---|
879 | RANGE=1-${#config_allowed_values[@]}
|
---|
880 | else
|
---|
881 | if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then
|
---|
882 | RANGE=$(serverconfig_$1_Range)
|
---|
883 | fi
|
---|
884 | fi
|
---|
885 |
|
---|
886 | case "$TYPE" in
|
---|
887 | number)
|
---|
888 | if [ $(isANumber "$2") -eq 0 ]; then
|
---|
889 | echo "0"
|
---|
890 | return
|
---|
891 | fi
|
---|
892 | if [ ! -z "$RANGE" ]; then
|
---|
893 | local MIN=$(cut -d- -f1 <<< "$RANGE")
|
---|
894 | local MAX=$(cut -d- -f2 <<< "$RANGE")
|
---|
895 | if [ $2 -lt $MIN -o $2 -gt $MAX ]; then
|
---|
896 | echo "0"
|
---|
897 | return
|
---|
898 | fi
|
---|
899 | fi
|
---|
900 | ;;
|
---|
901 | boolean)
|
---|
902 | if [ $(isABool "$2") -eq 0 ]; then
|
---|
903 | echo "0"
|
---|
904 | return
|
---|
905 | fi
|
---|
906 | ;;
|
---|
907 | string)
|
---|
908 | ;;
|
---|
909 | esac
|
---|
910 |
|
---|
911 |
|
---|
912 | if [ "$(type -t serverconfig_$1_Validate)" = "function" ]; then
|
---|
913 | if [ $(serverconfig_$1_Validate "$2") -eq 0 ]; then
|
---|
914 | echo "0"
|
---|
915 | return
|
---|
916 | fi
|
---|
917 | fi
|
---|
918 |
|
---|
919 | echo "1"
|
---|
920 | }
|
---|
921 |
|
---|
922 | # Query for the value of a single config option
|
---|
923 | # Will be stored in $configCurrent_$1
|
---|
924 | # Params:
|
---|
925 | # 1: Option name
|
---|
926 | configQueryValue() {
|
---|
927 | local TYPE=$(serverconfig_$1_Type)
|
---|
928 | local NAME=""
|
---|
929 | local RANGE=""
|
---|
930 | local DEFAULT=""
|
---|
931 | local currentValName=configCurrent_$1
|
---|
932 |
|
---|
933 | if [ "$(type -t serverconfig_$1_Values)" = "function" ]; then
|
---|
934 | echo "$(serverconfig_$1_QueryName), options:"
|
---|
935 | serverconfig_$1_Values
|
---|
936 | NAME="Select option"
|
---|
937 | if [ "$TYPE" = "enum" ]; then
|
---|
938 | local OPTOFFSET=1
|
---|
939 | else
|
---|
940 | local OPTOFFSET=0
|
---|
941 | fi
|
---|
942 | for (( i=$OPTOFFSET; i < ${#config_allowed_values[@]}+$OPTOFFSET; i++ )); do
|
---|
943 | printf " %2d: %s\n" $i "${config_allowed_values[$i-$OPTOFFSET]}"
|
---|
944 | done
|
---|
945 | else
|
---|
946 | NAME=$(serverconfig_$1_QueryName)
|
---|
947 | fi
|
---|
948 |
|
---|
949 | if [ "$TYPE" = "enum" ]; then
|
---|
950 | RANGE=1-${#config_allowed_values[@]}
|
---|
951 | if [ ! -z "${!currentValName}" ]; then
|
---|
952 | for (( i=1; i < ${#config_allowed_values[@]}+1; i++ )); do
|
---|
953 | if [ "${!currentValName}" = "${config_allowed_values[$i-1]}" ]; then
|
---|
954 | DEFAULT=$i
|
---|
955 | fi
|
---|
956 | done
|
---|
957 | export $currentValName=
|
---|
958 | fi
|
---|
959 | else
|
---|
960 | if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then
|
---|
961 | RANGE=$(serverconfig_$1_Range)
|
---|
962 | fi
|
---|
963 | fi
|
---|
964 |
|
---|
965 | if [ -z "$DEFAULT" ]; then
|
---|
966 | if [ ! -z "${!currentValName}" ]; then
|
---|
967 | DEFAULT=${!currentValName}
|
---|
968 | else
|
---|
969 | if [ "$(type -t serverconfig_$1_Default)" = "function" ]; then
|
---|
970 | DEFAULT=$(serverconfig_$1_Default)
|
---|
971 | fi
|
---|
972 | fi
|
---|
973 | fi
|
---|
974 |
|
---|
975 | local prompt=$(printf "%s" "$NAME")
|
---|
976 | if [ ! -z "$RANGE" ]; then
|
---|
977 | prompt=$(printf "%s (%s)" "$prompt" "$RANGE")
|
---|
978 | fi
|
---|
979 | if [ ! -z "$DEFAULT" ]; then
|
---|
980 | prompt=$(printf "%s [%s]" "$prompt" "$DEFAULT")
|
---|
981 | fi
|
---|
982 | prompt=$(printf "%s:" "$prompt")
|
---|
983 | prompt=$(printf "%-*s " 40 "$prompt")
|
---|
984 |
|
---|
985 | while : ; do
|
---|
986 | read -p "$prompt" $currentValName
|
---|
987 | export $currentValName="${!currentValName:-$DEFAULT}"
|
---|
988 | if [ $(isValidOptionValue "$1" "${!currentValName}") -eq 0 ]; then
|
---|
989 | if [ "$(type -t serverconfig_$1_ErrorMessage)" = "function" ]; then
|
---|
990 | serverconfig_$1_ErrorMessage "${!currentValName}"
|
---|
991 | fi
|
---|
992 | fi
|
---|
993 | [ $(isValidOptionValue "$1" "${!currentValName}") -eq 1 ] && break
|
---|
994 | done
|
---|
995 |
|
---|
996 | if [ "$TYPE" = "enum" ]; then
|
---|
997 | export $currentValName="${config_allowed_values[$currentValName-1]}"
|
---|
998 | fi
|
---|
999 | echo
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | # Set parameters for current instance that have forced values:
|
---|
1003 | # - TelnetEnabled must be set so that management scripts can work
|
---|
1004 | # - AdminFileName is made to point to the local instance admins.xml
|
---|
1005 | # - SaveGameFolder is made to point to the instance folder
|
---|
1006 | # Params:
|
---|
1007 | # 1: Instance name
|
---|
1008 | configSetAutoParameters() {
|
---|
1009 | configCurrent_TelnetEnabled=true
|
---|
1010 | configCurrent_AdminFileName=admins.xml
|
---|
1011 | configCurrent_SaveGameFolder="$(winepath -w $(getInstancePath "$1") 2>/dev/null | grep instances)"
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | # Print defined config value
|
---|
1016 | # Params:
|
---|
1017 | # 1: Config option
|
---|
1018 | printConfigValue() {
|
---|
1019 | local currentValName=configCurrent_$1
|
---|
1020 | printf "%-25s = %s\n" "$(serverconfig_$1_QueryName)" "${!currentValName}"
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | # Query for an instance name (will be saved in $INSTANCE)
|
---|
1024 | readInstanceName() {
|
---|
1025 | until [ $(isValidInstanceName "$INSTANCE") -eq 1 ]; do
|
---|
1026 | read -p "Instance name: " INSTANCE
|
---|
1027 | if [ $(isValidInstanceName "$INSTANCE") -eq 0 ]; then
|
---|
1028 | echo "Invalid instance name, may only contain:"
|
---|
1029 | echo " - letters (A-Z / a-z)"
|
---|
1030 | echo " - digits (0-9)"
|
---|
1031 | echo " - underscores (_)"
|
---|
1032 | echo " - hyphens (-)"
|
---|
1033 | fi
|
---|
1034 | done
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | # Undefine the current config values
|
---|
1038 | unsetAllConfigValues() {
|
---|
1039 | local CV
|
---|
1040 | for CV in $(listConfigValues); do
|
---|
1041 | local currentValName=configCurrent_$CV
|
---|
1042 | export $currentValName=
|
---|
1043 | done
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | # Load all config values from the config.xml of the given instance
|
---|
1047 | # Params:
|
---|
1048 | # 1: Instance name
|
---|
1049 | loadCurrentConfigValues() {
|
---|
1050 | local CV
|
---|
1051 | for CV in $(listConfigValues); do
|
---|
1052 | local currentValName=configCurrent_$CV
|
---|
1053 | local cfile=$(getInstancePath "$1")/config.xml
|
---|
1054 | local XPATH="/ServerSettings/property[@name='$CV']/@value"
|
---|
1055 | local VAL=$($XMLSTARLET sel -t -v "$XPATH" $cfile)
|
---|
1056 | if [ ! -z "$VAL" ]; then
|
---|
1057 | export $currentValName="$VAL"
|
---|
1058 | fi
|
---|
1059 | done
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | # Save all config values to the config.xml of the given instance
|
---|
1063 | # Params:
|
---|
1064 | # 1: Instance name
|
---|
1065 | saveCurrentConfigValues() {
|
---|
1066 | local CV
|
---|
1067 | for CV in $(listConfigValues) TelnetEnabled AdminFileName SaveGameFolder; do
|
---|
1068 | local currentValName=configCurrent_$CV
|
---|
1069 | local val="${!currentValName}"
|
---|
1070 | local cfile=$(getInstancePath "$1")/config.xml
|
---|
1071 |
|
---|
1072 | XPATHBASE="/ServerSettings/property[@name='$CV']"
|
---|
1073 |
|
---|
1074 | if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@name" $cfile) ]; then
|
---|
1075 | $XMLSTARLET ed -L \
|
---|
1076 | -s "/ServerSettings" -t elem -n "property" -v "" \
|
---|
1077 | -i "/ServerSettings/property[not(@name)]" -t attr -n "name" -v "$CV" \
|
---|
1078 | -i "$XPATHBASE" -t attr -n "value" -v "$val" \
|
---|
1079 | $cfile
|
---|
1080 | else
|
---|
1081 | $XMLSTARLET ed -L \
|
---|
1082 | -u "$XPATHBASE/@value" -v "$val" \
|
---|
1083 | $cfile
|
---|
1084 | fi
|
---|
1085 | done
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | # Check if the config template exists
|
---|
1089 | # Returns:
|
---|
1090 | # 0/1: no/yes
|
---|
1091 | configTemplateExists() {
|
---|
1092 | if [ -f $SDTD_BASE/templates/config.xml ]; then
|
---|
1093 | echo 1
|
---|
1094 | else
|
---|
1095 | echo 0
|
---|
1096 | fi
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | # Get a single value from a serverconfig
|
---|
1100 | # Params:
|
---|
1101 | # 1: Instance name
|
---|
1102 | # 2: Property name
|
---|
1103 | # Returns:
|
---|
1104 | # Property value
|
---|
1105 | getConfigValue() {
|
---|
1106 | local CONF=$(getInstancePath $1)/config.xml
|
---|
1107 | $XMLSTARLET sel -t -v "/ServerSettings/property[@name='$2']/@value" $CONF
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | # Update a single value in a serverconfig
|
---|
1111 | # Params:
|
---|
1112 | # 1: Instance name
|
---|
1113 | # 2: Property name
|
---|
1114 | # 3: New value
|
---|
1115 | setConfigValue() {
|
---|
1116 | local CONF=$(getInstancePath $1)/config.xml
|
---|
1117 | $XMLSTARLET ed -L -u "/ServerSettings/property[@name='$2']/@value" -v "$3" $CONF
|
---|
1118 | }
|
---|
1119 |
|
---|