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