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