source: scripts/usr/local/lib/7dtd/serverconfig.sh@ 354

Last change on this file since 354 was 353, checked in by alloc, 6 years ago

Scripts 112

File size: 27.3 KB
RevLine 
[19]1#!/bin/bash
2
[258]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
[19]18# Provides functions to query and validate values for serverconfig.xml
19
[23]20#################################
21## Definition of options
22
[19]23serverconfig_ServerPort_QueryName() {
24 echo "Base Port"
25}
26serverconfig_ServerPort_Type() {
27 echo "number"
28}
29serverconfig_ServerPort_Default() {
[303]30 echo "26900"
[19]31}
32serverconfig_ServerPort_Range() {
33 echo "1024-65533"
34}
35serverconfig_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}
43serverconfig_ServerPort_ErrorMessage() {
44 echo "Illegal port number or port already in use by another instance."
45}
46
47
[303]48serverconfig_ServerDisabledNetworkProtocols_QueryName() {
49 echo "Disabled network protocols"
50}
51serverconfig_ServerDisabledNetworkProtocols_Type() {
52 echo "enum"
53}
54serverconfig_ServerDisabledNetworkProtocols_Default() {
55 echo "1"
56}
57serverconfig_ServerDisabledNetworkProtocols_Values() {
[344]58 config_allowed_values=("None" "SteamNetworking" "SteamNetworking,LiteNetLib" "LiteNetLib")
[303]59}
[19]60
[303]61
[344]62serverconfig_ServerVisibility_QueryName() {
[19]63 echo "Public server"
64}
[344]65serverconfig_ServerVisibility_Type() {
66 echo "number"
[19]67}
[344]68serverconfig_ServerVisibility_Default() {
69 echo "2"
[19]70}
[344]71serverconfig_ServerVisibility_Range() {
72 echo "0-2"
[19]73}
[344]74serverconfig_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}
[19]77
78
79serverconfig_ServerName_QueryName() {
80 echo "Server name"
81}
82serverconfig_ServerName_Type() {
83 echo "string"
84}
85serverconfig_ServerName_Validate() {
86 if [ ! -z "$1" ]; then
87 echo "1"
88 else
89 echo "0"
90 fi
91}
92serverconfig_ServerName_ErrorMessage() {
93 echo "Server name cannot be empty."
94}
95
96
97
[204]98serverconfig_ServerDescription_QueryName() {
99 echo "Server description"
100}
101serverconfig_ServerDescription_Type() {
102 echo "string"
103}
104
105
106
107serverconfig_ServerWebsiteURL_QueryName() {
108 echo "Server website URL"
109}
110serverconfig_ServerWebsiteURL_Type() {
111 echo "string"
112}
113
114
115
[19]116serverconfig_ServerPassword_QueryName() {
117 echo "Server password"
118}
119serverconfig_ServerPassword_Type() {
120 echo "string"
121}
122
123
124
[302]125serverconfig_MaxUncoveredMapChunksPerPlayer_QueryName() {
126 echo "Max uncovered chunks per player"
127}
128serverconfig_MaxUncoveredMapChunksPerPlayer_Type() {
129 echo "number"
130}
131serverconfig_MaxUncoveredMapChunksPerPlayer_Default() {
132 echo "131072"
133}
134
135
136serverconfig_HideCommandExecutionLog_QueryName() {
137 echo "Hide command execution in log"
138}
139serverconfig_HideCommandExecutionLog_Type() {
140 echo "number"
141}
142serverconfig_HideCommandExecutionLog_Default() {
143 echo "0"
144}
145serverconfig_HideCommandExecutionLog_Range() {
146 echo "0-3"
147}
148serverconfig_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
[19]155serverconfig_ServerMaxPlayerCount_QueryName() {
[302]156 echo "Max players"
[19]157}
158serverconfig_ServerMaxPlayerCount_Type() {
[302]159 echo "number"
[19]160}
161serverconfig_ServerMaxPlayerCount_Default() {
162 echo "4"
163}
164serverconfig_ServerMaxPlayerCount_Range() {
165 echo "1-64"
166}
167
168
[302]169serverconfig_ServerReservedSlots_QueryName() {
170 echo "Reserved VIP slots"
171}
172serverconfig_ServerReservedSlots_Type() {
173 echo "number"
174}
175serverconfig_ServerReservedSlots_Default() {
176 echo "0"
177}
178serverconfig_ServerReservedSlots_Range() {
[303]179 echo "0-64"
[302]180}
[19]181
[302]182
183serverconfig_ServerReservedSlotsPermission_QueryName() {
184 echo "Permission level required for VIP slots"
185}
186serverconfig_ServerReservedSlotsPermission_Type() {
187 echo "number"
188}
189serverconfig_ServerReservedSlotsPermission_Default() {
190 echo "100"
191}
192serverconfig_ServerReservedSlotsPermission_Range() {
193 echo "0-2000"
194}
195
196
197serverconfig_ServerAdminSlots_QueryName() {
198 echo "Admin slots"
199}
200serverconfig_ServerAdminSlots_Type() {
201 echo "number"
202}
203serverconfig_ServerAdminSlots_Default() {
204 echo "0"
205}
206serverconfig_ServerAdminSlots_Range() {
[303]207 echo "0-64"
[302]208}
209
210
211serverconfig_ServerAdminSlotsPermission_QueryName() {
212 echo "Permission level required for admin slots"
213}
214serverconfig_ServerAdminSlotsPermission_Type() {
215 echo "number"
216}
217serverconfig_ServerAdminSlotsPermission_Default() {
218 echo "0"
219}
220serverconfig_ServerAdminSlotsPermission_Range() {
221 echo "0-2000"
222}
223
224
225
226
[19]227serverconfig_GameWorld_QueryName() {
228 echo "World name"
229}
230serverconfig_GameWorld_Type() {
231 echo "enum"
232}
233serverconfig_GameWorld_Default() {
234 echo "1"
235}
236serverconfig_GameWorld_Values() {
[344]237 config_allowed_values=("RWG" "Navezgane") # "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War"
[19]238}
239
240
241
[344]242serverconfig_WorldGenSeed_QueryName() {
243 echo "Random generation seed (if world RWG)"
244}
245serverconfig_WorldGenSeed_Type() {
246 echo "string"
247}
248serverconfig_WorldGenSeed_Validate() {
249 if [ ! -z "$1" ]; then
250 echo "1"
251 else
252 echo "0"
253 fi
254}
255serverconfig_WorldGenSeed_ErrorMessage() {
256 echo "Seed cannot be empty."
257}
258
259
260
261serverconfig_WorldGenSize_QueryName() {
262 echo "Random generation map size (if world RWG)"
263}
264serverconfig_WorldGenSize_Type() {
265 echo "number"
266}
267serverconfig_WorldGenSize_Default() {
268 echo "6144"
269}
270serverconfig_WorldGenSize_Range() {
271 echo "2048-16384"
272}
273
274
275
[19]276serverconfig_GameName_QueryName() {
[344]277 echo "World decoration seed"
[19]278}
279serverconfig_GameName_Type() {
280 echo "string"
281}
282serverconfig_GameName_Validate() {
283 if [ ! -z "$1" ]; then
284 echo "1"
285 else
286 echo "0"
287 fi
288}
289serverconfig_GameName_ErrorMessage() {
[204]290 echo "Seed cannot be empty."
[19]291}
292
293
294
295serverconfig_GameDifficulty_QueryName() {
[204]296 echo "Difficulty (+ damage given / received)"
[19]297}
298serverconfig_GameDifficulty_Type() {
299 echo "number"
300}
301serverconfig_GameDifficulty_Default() {
302 echo "2"
303}
304serverconfig_GameDifficulty_Range() {
[204]305 echo "0-5"
[19]306}
307serverconfig_GameDifficulty_Values() {
[204]308 config_allowed_values=("Scavenger (200% / 50%)" "Adventurer (150% / 75%)" "Nomad (100% / 100%)" "Warrior (75% / 150%)" "Survivalist (50% / 200%)" "Insane (25% / 250%)")
[19]309}
310
311
312
313serverconfig_GameMode_QueryName() {
314 echo "Game mode"
315}
316serverconfig_GameMode_Type() {
317 echo "enum"
318}
319serverconfig_GameMode_Default() {
320 echo "1"
321}
322serverconfig_GameMode_Values() {
[344]323 config_allowed_values=("GameModeSurvival")
[19]324}
325
326
327
[344]328serverconfig_ZombieMove_QueryName() {
329 echo "Zombie speed, regular"
[19]330}
[344]331serverconfig_ZombieMove_Type() {
[19]332 echo "number"
333}
[344]334serverconfig_ZombieMove_Default() {
[19]335 echo "0"
336}
[344]337serverconfig_ZombieMove_Range() {
338 echo "0-4"
[19]339}
[344]340serverconfig_ZombieMove_Values() {
341 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
[19]342}
343
344
345
[344]346serverconfig_ZombieMoveNight_QueryName() {
347 echo "Zombie speed, night"
348}
349serverconfig_ZombieMoveNight_Type() {
350 echo "number"
351}
352serverconfig_ZombieMoveNight_Default() {
353 echo "3"
354}
355serverconfig_ZombieMoveNight_Range() {
356 echo "0-4"
357}
358serverconfig_ZombieMoveNight_Values() {
359 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
360}
361
362
363
364serverconfig_ZombieFeralMove_QueryName() {
365 echo "Zombie speed, ferals"
366}
367serverconfig_ZombieFeralMove_Type() {
368 echo "number"
369}
370serverconfig_ZombieFeralMove_Default() {
371 echo "3"
372}
373serverconfig_ZombieFeralMove_Range() {
374 echo "0-4"
375}
376serverconfig_ZombieFeralMove_Values() {
377 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
378}
379
380
381
382serverconfig_ZombieBMMove_QueryName() {
383 echo "Zombie speed, bloodmoons"
384}
385serverconfig_ZombieBMMove_Type() {
386 echo "number"
387}
388serverconfig_ZombieBMMove_Default() {
389 echo "3"
390}
391serverconfig_ZombieBMMove_Range() {
392 echo "0-4"
393}
394serverconfig_ZombieBMMove_Values() {
395 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
396}
397
398
399
400
[19]401serverconfig_BuildCreate_QueryName() {
402 echo "Item spawn menu"
403}
404serverconfig_BuildCreate_Type() {
405 echo "boolean"
406}
407serverconfig_BuildCreate_Default() {
[204]408 echo "false"
[19]409}
410serverconfig_BuildCreate_ErrorMessage() {
411 echo "Not a valid boolean given (true/false or yes/no or y/n)."
412}
413
414
415
416serverconfig_DayNightLength_QueryName() {
417 echo "Length of one day"
418}
419serverconfig_DayNightLength_Type() {
420 echo "number"
421}
422serverconfig_DayNightLength_Default() {
[308]423 echo "60"
[19]424}
425
426
427
[294]428serverconfig_DayLightLength_QueryName() {
429 echo "Duration of daylight (in ingame hours)"
[19]430}
[294]431serverconfig_DayLightLength_Type() {
432 echo "number"
433}
434serverconfig_DayLightLength_Default() {
435 echo "18"
436}
437serverconfig_DayLightLength_Range() {
438 echo "0-24"
439}
440
441
442
[353]443
444serverconfig_XPMultiplier_QueryName() {
445 echo "XP gain multiplier (%)"
446}
447serverconfig_XPMultiplier_Type() {
448 echo "number"
449}
450serverconfig_XPMultiplier_Default() {
451 echo "100"
452}
453
454
[344]455serverconfig_PartySharedKillRange_QueryName() {
456 echo "Party range to share kill / quest XP rewards"
457}
458serverconfig_PartySharedKillRange_Type() {
459 echo "number"
460}
461serverconfig_PartySharedKillRange_Default() {
462 echo "100"
463}
464
465
466
[294]467serverconfig_PlayerKillingMode_QueryName() {
468 echo "Player killing"
469}
470serverconfig_PlayerKillingMode_Type() {
[296]471 echo "number"
[294]472}
473serverconfig_PlayerKillingMode_Default() {
474 echo "3"
475}
[296]476serverconfig_PlayerKillingMode_Range() {
477 echo "0-3"
478}
[294]479serverconfig_PlayerKillingMode_Values() {
480 config_allowed_values=("No player killing" "Kill allies only" "Kill strangers only" "Kill everyone")
481}
482
483
484
485serverconfig_PersistentPlayerProfiles_QueryName() {
486 echo "Persistent player profiles"
487}
488serverconfig_PersistentPlayerProfiles_Type() {
[19]489 echo "boolean"
490}
[294]491serverconfig_PersistentPlayerProfiles_Default() {
[19]492 echo "false"
493}
[294]494serverconfig_PersistentPlayerProfiles_ErrorMessage() {
[19]495 echo "Not a valid boolean given (true/false or yes/no or y/n)."
496}
497
498
499
[294]500serverconfig_PlayerSafeZoneLevel_QueryName() {
501 echo "Safe zone up to player level"
502}
503serverconfig_PlayerSafeZoneLevel_Type() {
504 echo "number"
505}
506serverconfig_PlayerSafeZoneLevel_Default() {
507 echo "5"
508}
509
510
511serverconfig_PlayerSafeZoneHours_QueryName() {
512 echo "Safe zone up to played hours"
513}
514serverconfig_PlayerSafeZoneHours_Type() {
515 echo "number"
516}
517serverconfig_PlayerSafeZoneHours_Default() {
518 echo "5"
519}
520
521
[19]522serverconfig_ControlPanelEnabled_QueryName() {
523 echo "Enable control panel"
524}
525serverconfig_ControlPanelEnabled_Type() {
526 echo "boolean"
527}
528serverconfig_ControlPanelEnabled_Default() {
529 echo "false"
530}
531serverconfig_ControlPanelEnabled_ErrorMessage() {
532 echo "Not a valid boolean given (true/false or yes/no or y/n)."
533}
534
535
536
537serverconfig_ControlPanelPort_QueryName() {
538 echo "Control panel port"
539}
540serverconfig_ControlPanelPort_Type() {
541 echo "number"
542}
543serverconfig_ControlPanelPort_Default() {
544 echo "8080"
545}
546serverconfig_ControlPanelPort_Range() {
547 echo "1024-65535"
548}
549serverconfig_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}
557serverconfig_ControlPanelPort_ErrorMessage() {
558 echo "Illegal port number or port already in use by another instance."
559}
560
561
562
563serverconfig_ControlPanelPassword_QueryName() {
564 echo "Control panel password"
565}
566serverconfig_ControlPanelPassword_Type() {
567 echo "string"
568}
569
570
571
572serverconfig_TelnetPort_QueryName() {
573 echo "Telnet port"
574}
575serverconfig_TelnetPort_Type() {
576 echo "number"
577}
578serverconfig_TelnetPort_Default() {
579 echo "8081"
580}
581serverconfig_TelnetPort_Range() {
582 echo "1024-65535"
583}
584serverconfig_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}
592serverconfig_TelnetPort_ErrorMessage() {
593 echo "Illegal port number or port already in use by another instance."
594}
595
596
597
598serverconfig_TelnetPassword_QueryName() {
599 echo "Telnet password"
600}
601serverconfig_TelnetPassword_Type() {
602 echo "string"
603}
604
605
606
[344]607serverconfig_TelnetFailedLoginLimit_QueryName() {
608 echo "Max failed login attempts (0 to disable)"
609}
610serverconfig_TelnetFailedLoginLimit_Type() {
611 echo "number"
612}
613serverconfig_TelnetFailedLoginLimit_Default() {
614 echo "10"
615}
616
617
618
619serverconfig_TelnetFailedLoginsBlocktime_QueryName() {
620 echo "Telnet login blocktime after failed logins (seconds)"
621}
622serverconfig_TelnetFailedLoginsBlocktime_Type() {
623 echo "number"
624}
625serverconfig_TelnetFailedLoginsBlocktime_Default() {
626 echo "10"
627}
628
629
630
[19]631serverconfig_DropOnDeath_QueryName() {
632 echo "Drop on Death"
633}
634serverconfig_DropOnDeath_Type() {
635 echo "number"
636}
637serverconfig_DropOnDeath_Default() {
638 echo "0"
639}
640serverconfig_DropOnDeath_Range() {
641 echo "0-3"
642}
643serverconfig_DropOnDeath_Values() {
644 config_allowed_values=("Everything" "Toolbelt only" "Backpack only" "Delete all")
645}
646
647
648serverconfig_DropOnQuit_QueryName() {
649 echo "Drop on Quit"
650}
651serverconfig_DropOnQuit_Type() {
652 echo "number"
653}
654serverconfig_DropOnQuit_Default() {
[204]655 echo "1"
[19]656}
657serverconfig_DropOnQuit_Range() {
658 echo "0-3"
659}
660serverconfig_DropOnQuit_Values() {
661 config_allowed_values=("Nothing" "Everything" "Toolbelt only" "Backpack only")
662}
663
664
665
666
667serverconfig_EnemySpawnMode_QueryName() {
668 echo "Spawn mode"
669}
670serverconfig_EnemySpawnMode_Type() {
[302]671 echo "boolean"
[19]672}
673serverconfig_EnemySpawnMode_Default() {
[302]674 echo "true"
[19]675}
[302]676serverconfig_EnemySpawnMode_ErrorMessage() {
677 echo "Not a valid boolean given (true/false or yes/no or y/n)."
[19]678}
679
680
681serverconfig_EnemyDifficulty_QueryName() {
682 echo "Enemy difficulty"
683}
684serverconfig_EnemyDifficulty_Type() {
685 echo "number"
686}
687serverconfig_EnemyDifficulty_Default() {
688 echo "0"
689}
690serverconfig_EnemyDifficulty_Range() {
691 echo "0-1"
692}
693serverconfig_EnemyDifficulty_Values() {
694 config_allowed_values=("Normal" "Feral")
695}
696
697
[302]698serverconfig_BloodMoonEnemyCount_QueryName() {
699 echo "Enemies per Player on Blood moons"
700}
701serverconfig_BloodMoonEnemyCount_Type() {
702 echo "number"
703}
704serverconfig_BloodMoonEnemyCount_Default() {
705 echo "8"
706}
707serverconfig_BloodMoonEnemyCount_Range() {
708 echo "0-64"
709}
[19]710
711
[302]712
713
[353]714serverconfig_BlockDamagePlayer_QueryName() {
715 echo "Block damage modifier for players (%)"
[19]716}
[353]717serverconfig_BlockDamagePlayer_Type() {
[19]718 echo "number"
719}
[353]720serverconfig_BlockDamagePlayer_Default() {
[19]721 echo "100"
722}
723
724
[353]725serverconfig_BlockDamageAI_QueryName() {
726 echo "Block damage modifier for AIs (%)"
727}
728serverconfig_BlockDamageAI_Type() {
729 echo "number"
730}
731serverconfig_BlockDamageAI_Default() {
732 echo "100"
733}
[19]734
735
[353]736serverconfig_BlockDamageAIBM_QueryName() {
737 echo "Block damage modifier for AIs during blood moons (%)"
738}
739serverconfig_BlockDamageAIBM_Type() {
740 echo "number"
741}
742serverconfig_BlockDamageAIBM_Default() {
743 echo "100"
744}
745
746
747
748
749
[19]750serverconfig_LootAbundance_QueryName() {
751 echo "Loot abundance (%)"
752}
753serverconfig_LootAbundance_Type() {
754 echo "number"
755}
756serverconfig_LootAbundance_Default() {
757 echo "100"
758}
759
760
761serverconfig_LootRespawnDays_QueryName() {
762 echo "Loot respawn delay (days)"
763}
764serverconfig_LootRespawnDays_Type() {
765 echo "number"
766}
767serverconfig_LootRespawnDays_Default() {
768 echo "7"
769}
770
[302]771serverconfig_BedrollDeadZoneSize_QueryName() {
772 echo "Bedroll deadzone size"
773}
774serverconfig_BedrollDeadZoneSize_Type() {
775 echo "number"
776}
777serverconfig_BedrollDeadZoneSize_Default() {
778 echo "15"
779}
[19]780
781
782
[302]783
[19]784serverconfig_LandClaimSize_QueryName() {
785 echo "Land claim size"
786}
787serverconfig_LandClaimSize_Type() {
788 echo "number"
789}
790serverconfig_LandClaimSize_Default() {
791 echo "7"
792}
793
794
795serverconfig_LandClaimDeadZone_QueryName() {
796 echo "Minimum keystone distance"
797}
798serverconfig_LandClaimDeadZone_Type() {
799 echo "number"
800}
801serverconfig_LandClaimDeadZone_Default() {
802 echo "30"
803}
804
805
806serverconfig_LandClaimExpiryTime_QueryName() {
807 echo "Claim expiry time (days)"
808}
809serverconfig_LandClaimExpiryTime_Type() {
810 echo "number"
811}
812serverconfig_LandClaimExpiryTime_Default() {
813 echo "3"
814}
815
816
817serverconfig_LandClaimDecayMode_QueryName() {
818 echo "Claim decay mode"
819}
820serverconfig_LandClaimDecayMode_Type() {
821 echo "number"
822}
823serverconfig_LandClaimDecayMode_Default() {
824 echo "0"
825}
826serverconfig_LandClaimDecayMode_Range() {
827 echo "0-2"
828}
829serverconfig_LandClaimDecayMode_Values() {
830 config_allowed_values=("Linear" "Exponential" "Full protection")
831}
832
833
834serverconfig_LandClaimOnlineDurabilityModifier_QueryName() {
835 echo "Claim durability modifier - online"
836}
837serverconfig_LandClaimOnlineDurabilityModifier_Type() {
838 echo "number"
839}
840serverconfig_LandClaimOnlineDurabilityModifier_Default() {
841 echo "4"
842}
843
844
845serverconfig_LandClaimOfflineDurabilityModifier_QueryName() {
846 echo "Claim durability modifier - offline"
847}
848serverconfig_LandClaimOfflineDurabilityModifier_Type() {
849 echo "number"
850}
851serverconfig_LandClaimOfflineDurabilityModifier_Default() {
852 echo "4"
853}
854
855
856
857
858serverconfig_AirDropFrequency_QueryName() {
859 echo "Airdrop delay (hours)"
860}
861serverconfig_AirDropFrequency_Type() {
862 echo "number"
863}
864serverconfig_AirDropFrequency_Default() {
[204]865 echo "72"
[19]866}
867
868
[294]869serverconfig_AirDropMarker_QueryName() {
870 echo "Enable AirDrop markers"
871}
872serverconfig_AirDropMarker_Type() {
873 echo "boolean"
874}
875serverconfig_AirDropMarker_Default() {
876 echo "false"
877}
878serverconfig_AirDropMarker_ErrorMessage() {
879 echo "Not a valid boolean given (true/false or yes/no or y/n)."
880}
881
882
883
[67]884serverconfig_MaxSpawnedZombies_QueryName() {
885 echo "Maximum number of concurrent zombies"
886}
887serverconfig_MaxSpawnedZombies_Type() {
888 echo "number"
889}
890serverconfig_MaxSpawnedZombies_Default() {
891 echo "60"
892}
[19]893
894
[294]895serverconfig_MaxSpawnedAnimals_QueryName() {
896 echo "Maximum number of concurrent animals"
897}
898serverconfig_MaxSpawnedAnimals_Type() {
899 echo "number"
900}
901serverconfig_MaxSpawnedAnimals_Default() {
902 echo "50"
903}
904
905
[204]906serverconfig_EACEnabled_QueryName() {
907 echo "Enable EasyAntiCheat"
[67]908}
[204]909serverconfig_EACEnabled_Type() {
[67]910 echo "boolean"
911}
[204]912serverconfig_EACEnabled_Default() {
[67]913 echo "true"
914}
[204]915serverconfig_EACEnabled_ErrorMessage() {
[67]916 echo "Not a valid boolean given (true/false or yes/no or y/n)."
917}
918
919
920
921
[23]922#################################
923## Edit option functions
924
925configEditServer() {
926 local CV
927
928 echo "Server"
929 echo "--------------------------------"
930 for CV in \
[344]931 ServerName ServerPassword ServerVisibility ServerPort ServerDisabledNetworkProtocols ServerDescription ServerWebsiteURL \
[302]932 HideCommandExecutionLog MaxUncoveredMapChunksPerPlayer EACEnabled MaxSpawnedZombies MaxSpawnedAnimals \
[23]933 ; do
[24]934 $1 $CV
[23]935 done
936 echo
937}
938
[302]939configEditSlots() {
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
[23]952configEditRemoteControl() {
953 local CV
954
955 echo "Remote control"
956 echo "--------------------------------"
957 for CV in \
958 ControlPanelEnabled ControlPanelPort ControlPanelPassword \
[344]959 TelnetPort TelnetPassword TelnetFailedLoginLimit TelnetFailedLoginsBlocktime \
[23]960 ; do
961 if [ "$CV" = "TelnetPort" ]; then
962 echo
963 echo "NOTE: Telnet will always be enabled for management purposes!"
[88]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!"
[23]966 echo
967 fi
[24]968 $1 $CV
[23]969 done
970 echo
971}
972
973configEditGameType() {
974 local CV
975
976 echo "Game type"
977 echo "--------------------------------"
978 for CV in \
[344]979 GameName GameWorld WorldGenSeed WorldGenSize GameMode \
[23]980 ; do
[24]981 $1 $CV
[23]982 done
983 echo
984}
985
986configEditGeneric() {
987 local CV
988
989 echo "Generic options"
990 echo "--------------------------------"
991 for CV in \
[353]992 XPMultiplier \
[344]993 PartySharedKillRange PlayerKillingMode PersistentPlayerProfiles \
[294]994 PlayerSafeZoneLevel PlayerSafeZoneHours \
995 BuildCreate \
[353]996 BlockDamagePlayer BlockDamageAI BlockDamageAIBM \
[23]997 ; do
[24]998 $1 $CV
[23]999 done
1000 echo
1001}
1002
1003configEditDropLoot() {
1004 local CV
1005
1006 echo "Drop and Loot"
1007 echo "--------------------------------"
1008 for CV in \
1009 DropOnDeath DropOnQuit \
[294]1010 LootAbundance LootRespawnDays \
1011 AirDropFrequency AirDropMarker \
[23]1012 ; do
[24]1013 $1 $CV
[23]1014 done
1015 echo
1016}
1017
1018configEditTimes() {
1019 local CV
1020
1021 echo "Times / Durations"
1022 echo "--------------------------------"
1023 for CV in \
[239]1024 DayNightLength DayLightLength \
[23]1025 ; do
[24]1026 $1 $CV
[23]1027 done
1028 echo
1029}
1030
1031configEditDifficulty() {
1032 local CV
1033
1034 echo "Difficulty"
1035 echo "--------------------------------"
1036 for CV in \
[344]1037 GameDifficulty ZombieMove ZombieMoveNight ZombieFeralMove ZombieBMMove \
[302]1038 EnemySpawnMode EnemyDifficulty \
1039 BloodMoonEnemyCount BedrollDeadZoneSize \
[23]1040 ; do
[24]1041 $1 $CV
[23]1042 done
1043 echo
1044}
1045
1046configEditLandClaim() {
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
[24]1055 $1 $CV
[23]1056 done
1057 echo
1058}
1059
1060configEditAll() {
[24]1061 configEditServer "$1"
[303]1062 configEditSlots "$1"
[24]1063 configEditRemoteControl "$1"
1064 configEditGameType "$1"
1065 configEditGeneric "$1"
1066 configEditDropLoot "$1"
1067 configEditTimes "$1"
1068 configEditDifficulty "$1"
1069 configEditLandClaim "$1"
[23]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
1083listConfigEditFuncs() {
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
[19]1095listConfigValues() {
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
[23]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
[19]1111isValidOptionValue() {
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
[23]1161# Query for the value of a single config option
1162# Will be stored in $configCurrent_$1
1163# Params:
1164# 1: Option name
[19]1165configQueryValue() {
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")
[24]1222 prompt=$(printf "%-*s " 40 "$prompt")
[19]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
[45]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
[19]1242 if [ "$TYPE" = "enum" ]; then
1243 export $currentValName="${config_allowed_values[$currentValName-1]}"
1244 fi
[24]1245 echo
[19]1246}
1247
[23]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
[353]1252# - UserDataFolder (for GeneratedWorlds) is made to point to the <user home directory>/serverdata/
[23]1253# Params:
[19]1254# 1: Instance name
1255configSetAutoParameters() {
1256 configCurrent_TelnetEnabled=true
1257 configCurrent_AdminFileName=admins.xml
[35]1258 configCurrent_SaveGameFolder="$(getInstancePath "$1")"
[353]1259 configCurrent_UserDataFolder=$SDTD_BASE/serverdata
[19]1260}
1261
1262
[24]1263# Print defined config value
1264# Params:
1265# 1: Config option
1266printConfigValue() {
1267 local currentValName=configCurrent_$1
1268 printf "%-25s = %s\n" "$(serverconfig_$1_QueryName)" "${!currentValName}"
[19]1269}
1270
[23]1271# Query for an instance name (will be saved in $INSTANCE)
[19]1272readInstanceName() {
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
[23]1285# Undefine the current config values
[19]1286unsetAllConfigValues() {
1287 local CV
1288 for CV in $(listConfigValues); do
1289 local currentValName=configCurrent_$CV
1290 export $currentValName=
1291 done
1292}
1293
[23]1294# Load all config values from the config.xml of the given instance
1295# Params:
[19]1296# 1: Instance name
1297loadCurrentConfigValues() {
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
[23]1310# Save all config values to the config.xml of the given instance
1311# Params:
[19]1312# 1: Instance name
1313saveCurrentConfigValues() {
1314 local CV
[353]1315 for CV in $(listConfigValues) TelnetEnabled AdminFileName SaveGameFolder UserDataFolder; do
[19]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
[23]1336# Check if the config template exists
1337# Returns:
1338# 0/1: no/yes
[19]1339configTemplateExists() {
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
1353getConfigValue() {
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
1363setConfigValue() {
1364 local CONF=$(getInstancePath $1)/config.xml
1365 $XMLSTARLET ed -L -u "/ServerSettings/property[@name='$2']/@value" -v "$3" $CONF
1366}
1367
Note: See TracBrowser for help on using the repository browser.