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