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