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

Last change on this file since 395 was 357, checked in by alloc, 5 years ago

Scripts v114

File size: 28.2 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
[356]135serverconfig_ServerMaxWorldTransferSpeedKiBs_QueryName() {
136 echo "Max download speed for the world (KiB/s"
137}
138serverconfig_ServerMaxWorldTransferSpeedKiBs_Type() {
139 echo "number"
140}
141serverconfig_ServerMaxWorldTransferSpeedKiBs_Default() {
142 echo "512"
143}
144serverconfig_ServerMaxWorldTransferSpeedKiBs_Range() {
145 echo "64-1300"
146}
[302]147
[356]148serverconfig_ServerMaxAllowedViewDistance_QueryName() {
149 echo "Limit allowed view distance settings of clients"
150}
151serverconfig_ServerMaxAllowedViewDistance_Type() {
152 echo "number"
153}
154serverconfig_ServerMaxAllowedViewDistance_Default() {
155 echo "12"
156}
157serverconfig_ServerMaxAllowedViewDistance_Range() {
158 echo "5-12"
159}
160
[302]161serverconfig_HideCommandExecutionLog_QueryName() {
162 echo "Hide command execution in log"
163}
164serverconfig_HideCommandExecutionLog_Type() {
165 echo "number"
166}
167serverconfig_HideCommandExecutionLog_Default() {
168 echo "0"
169}
170serverconfig_HideCommandExecutionLog_Range() {
171 echo "0-3"
172}
173serverconfig_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
[19]180serverconfig_ServerMaxPlayerCount_QueryName() {
[302]181 echo "Max players"
[19]182}
183serverconfig_ServerMaxPlayerCount_Type() {
[302]184 echo "number"
[19]185}
186serverconfig_ServerMaxPlayerCount_Default() {
187 echo "4"
188}
189serverconfig_ServerMaxPlayerCount_Range() {
190 echo "1-64"
191}
192
193
[302]194serverconfig_ServerReservedSlots_QueryName() {
195 echo "Reserved VIP slots"
196}
197serverconfig_ServerReservedSlots_Type() {
198 echo "number"
199}
200serverconfig_ServerReservedSlots_Default() {
201 echo "0"
202}
203serverconfig_ServerReservedSlots_Range() {
[303]204 echo "0-64"
[302]205}
[19]206
[302]207
208serverconfig_ServerReservedSlotsPermission_QueryName() {
209 echo "Permission level required for VIP slots"
210}
211serverconfig_ServerReservedSlotsPermission_Type() {
212 echo "number"
213}
214serverconfig_ServerReservedSlotsPermission_Default() {
215 echo "100"
216}
217serverconfig_ServerReservedSlotsPermission_Range() {
218 echo "0-2000"
219}
220
221
222serverconfig_ServerAdminSlots_QueryName() {
223 echo "Admin slots"
224}
225serverconfig_ServerAdminSlots_Type() {
226 echo "number"
227}
228serverconfig_ServerAdminSlots_Default() {
229 echo "0"
230}
231serverconfig_ServerAdminSlots_Range() {
[303]232 echo "0-64"
[302]233}
234
235
236serverconfig_ServerAdminSlotsPermission_QueryName() {
237 echo "Permission level required for admin slots"
238}
239serverconfig_ServerAdminSlotsPermission_Type() {
240 echo "number"
241}
242serverconfig_ServerAdminSlotsPermission_Default() {
243 echo "0"
244}
245serverconfig_ServerAdminSlotsPermission_Range() {
246 echo "0-2000"
247}
248
249
250
251
[19]252serverconfig_GameWorld_QueryName() {
253 echo "World name"
254}
255serverconfig_GameWorld_Type() {
256 echo "enum"
257}
258serverconfig_GameWorld_Default() {
259 echo "1"
260}
261serverconfig_GameWorld_Values() {
[344]262 config_allowed_values=("RWG" "Navezgane") # "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War"
[19]263}
264
265
266
[344]267serverconfig_WorldGenSeed_QueryName() {
268 echo "Random generation seed (if world RWG)"
269}
270serverconfig_WorldGenSeed_Type() {
271 echo "string"
272}
273serverconfig_WorldGenSeed_Validate() {
274 if [ ! -z "$1" ]; then
275 echo "1"
276 else
277 echo "0"
278 fi
279}
280serverconfig_WorldGenSeed_ErrorMessage() {
281 echo "Seed cannot be empty."
282}
283
284
285
286serverconfig_WorldGenSize_QueryName() {
287 echo "Random generation map size (if world RWG)"
288}
289serverconfig_WorldGenSize_Type() {
290 echo "number"
291}
292serverconfig_WorldGenSize_Default() {
293 echo "6144"
294}
295serverconfig_WorldGenSize_Range() {
296 echo "2048-16384"
297}
298
299
300
[19]301serverconfig_GameName_QueryName() {
[344]302 echo "World decoration seed"
[19]303}
304serverconfig_GameName_Type() {
305 echo "string"
306}
307serverconfig_GameName_Validate() {
308 if [ ! -z "$1" ]; then
309 echo "1"
310 else
311 echo "0"
312 fi
313}
314serverconfig_GameName_ErrorMessage() {
[204]315 echo "Seed cannot be empty."
[19]316}
317
318
319
320serverconfig_GameDifficulty_QueryName() {
[204]321 echo "Difficulty (+ damage given / received)"
[19]322}
323serverconfig_GameDifficulty_Type() {
324 echo "number"
325}
326serverconfig_GameDifficulty_Default() {
[357]327 echo "1"
[19]328}
329serverconfig_GameDifficulty_Range() {
[204]330 echo "0-5"
[19]331}
332serverconfig_GameDifficulty_Values() {
[204]333 config_allowed_values=("Scavenger (200% / 50%)" "Adventurer (150% / 75%)" "Nomad (100% / 100%)" "Warrior (75% / 150%)" "Survivalist (50% / 200%)" "Insane (25% / 250%)")
[19]334}
335
336
337
338serverconfig_GameMode_QueryName() {
339 echo "Game mode"
340}
341serverconfig_GameMode_Type() {
342 echo "enum"
343}
344serverconfig_GameMode_Default() {
345 echo "1"
346}
347serverconfig_GameMode_Values() {
[344]348 config_allowed_values=("GameModeSurvival")
[19]349}
350
351
352
[344]353serverconfig_ZombieMove_QueryName() {
354 echo "Zombie speed, regular"
[19]355}
[344]356serverconfig_ZombieMove_Type() {
[19]357 echo "number"
358}
[344]359serverconfig_ZombieMove_Default() {
[19]360 echo "0"
361}
[344]362serverconfig_ZombieMove_Range() {
363 echo "0-4"
[19]364}
[344]365serverconfig_ZombieMove_Values() {
366 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
[19]367}
368
369
370
[344]371serverconfig_ZombieMoveNight_QueryName() {
372 echo "Zombie speed, night"
373}
374serverconfig_ZombieMoveNight_Type() {
375 echo "number"
376}
377serverconfig_ZombieMoveNight_Default() {
378 echo "3"
379}
380serverconfig_ZombieMoveNight_Range() {
381 echo "0-4"
382}
383serverconfig_ZombieMoveNight_Values() {
384 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
385}
386
387
388
389serverconfig_ZombieFeralMove_QueryName() {
390 echo "Zombie speed, ferals"
391}
392serverconfig_ZombieFeralMove_Type() {
393 echo "number"
394}
395serverconfig_ZombieFeralMove_Default() {
396 echo "3"
397}
398serverconfig_ZombieFeralMove_Range() {
399 echo "0-4"
400}
401serverconfig_ZombieFeralMove_Values() {
402 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
403}
404
405
406
407serverconfig_ZombieBMMove_QueryName() {
408 echo "Zombie speed, bloodmoons"
409}
410serverconfig_ZombieBMMove_Type() {
411 echo "number"
412}
413serverconfig_ZombieBMMove_Default() {
414 echo "3"
415}
416serverconfig_ZombieBMMove_Range() {
417 echo "0-4"
418}
419serverconfig_ZombieBMMove_Values() {
420 config_allowed_values=("Walk" "Jog" "Run" "Sprint" "Nightmare")
421}
422
423
424
425
[19]426serverconfig_BuildCreate_QueryName() {
427 echo "Item spawn menu"
428}
429serverconfig_BuildCreate_Type() {
430 echo "boolean"
431}
432serverconfig_BuildCreate_Default() {
[204]433 echo "false"
[19]434}
435serverconfig_BuildCreate_ErrorMessage() {
436 echo "Not a valid boolean given (true/false or yes/no or y/n)."
437}
438
439
440
441serverconfig_DayNightLength_QueryName() {
442 echo "Length of one day"
443}
444serverconfig_DayNightLength_Type() {
445 echo "number"
446}
447serverconfig_DayNightLength_Default() {
[308]448 echo "60"
[19]449}
450
451
452
[294]453serverconfig_DayLightLength_QueryName() {
454 echo "Duration of daylight (in ingame hours)"
[19]455}
[294]456serverconfig_DayLightLength_Type() {
457 echo "number"
458}
459serverconfig_DayLightLength_Default() {
460 echo "18"
461}
462serverconfig_DayLightLength_Range() {
463 echo "0-24"
464}
465
466
467
[353]468
469serverconfig_XPMultiplier_QueryName() {
470 echo "XP gain multiplier (%)"
471}
472serverconfig_XPMultiplier_Type() {
473 echo "number"
474}
475serverconfig_XPMultiplier_Default() {
476 echo "100"
477}
478
479
[344]480serverconfig_PartySharedKillRange_QueryName() {
481 echo "Party range to share kill / quest XP rewards"
482}
483serverconfig_PartySharedKillRange_Type() {
484 echo "number"
485}
486serverconfig_PartySharedKillRange_Default() {
487 echo "100"
488}
489
490
491
[294]492serverconfig_PlayerKillingMode_QueryName() {
493 echo "Player killing"
494}
495serverconfig_PlayerKillingMode_Type() {
[296]496 echo "number"
[294]497}
498serverconfig_PlayerKillingMode_Default() {
499 echo "3"
500}
[296]501serverconfig_PlayerKillingMode_Range() {
502 echo "0-3"
503}
[294]504serverconfig_PlayerKillingMode_Values() {
505 config_allowed_values=("No player killing" "Kill allies only" "Kill strangers only" "Kill everyone")
506}
507
508
509
510serverconfig_PersistentPlayerProfiles_QueryName() {
511 echo "Persistent player profiles"
512}
513serverconfig_PersistentPlayerProfiles_Type() {
[19]514 echo "boolean"
515}
[294]516serverconfig_PersistentPlayerProfiles_Default() {
[19]517 echo "false"
518}
[294]519serverconfig_PersistentPlayerProfiles_ErrorMessage() {
[19]520 echo "Not a valid boolean given (true/false or yes/no or y/n)."
521}
522
523
524
[294]525serverconfig_PlayerSafeZoneLevel_QueryName() {
526 echo "Safe zone up to player level"
527}
528serverconfig_PlayerSafeZoneLevel_Type() {
529 echo "number"
530}
531serverconfig_PlayerSafeZoneLevel_Default() {
532 echo "5"
533}
534
535
536serverconfig_PlayerSafeZoneHours_QueryName() {
537 echo "Safe zone up to played hours"
538}
539serverconfig_PlayerSafeZoneHours_Type() {
540 echo "number"
541}
542serverconfig_PlayerSafeZoneHours_Default() {
543 echo "5"
544}
545
546
[19]547serverconfig_ControlPanelEnabled_QueryName() {
548 echo "Enable control panel"
549}
550serverconfig_ControlPanelEnabled_Type() {
551 echo "boolean"
552}
553serverconfig_ControlPanelEnabled_Default() {
554 echo "false"
555}
556serverconfig_ControlPanelEnabled_ErrorMessage() {
557 echo "Not a valid boolean given (true/false or yes/no or y/n)."
558}
559
560
561
562serverconfig_ControlPanelPort_QueryName() {
563 echo "Control panel port"
564}
565serverconfig_ControlPanelPort_Type() {
566 echo "number"
567}
568serverconfig_ControlPanelPort_Default() {
569 echo "8080"
570}
571serverconfig_ControlPanelPort_Range() {
572 echo "1024-65535"
573}
574serverconfig_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}
582serverconfig_ControlPanelPort_ErrorMessage() {
583 echo "Illegal port number or port already in use by another instance."
584}
585
586
587
588serverconfig_ControlPanelPassword_QueryName() {
589 echo "Control panel password"
590}
591serverconfig_ControlPanelPassword_Type() {
592 echo "string"
593}
594
595
596
597serverconfig_TelnetPort_QueryName() {
598 echo "Telnet port"
599}
600serverconfig_TelnetPort_Type() {
601 echo "number"
602}
603serverconfig_TelnetPort_Default() {
604 echo "8081"
605}
606serverconfig_TelnetPort_Range() {
607 echo "1024-65535"
608}
609serverconfig_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}
617serverconfig_TelnetPort_ErrorMessage() {
618 echo "Illegal port number or port already in use by another instance."
619}
620
621
622
623serverconfig_TelnetPassword_QueryName() {
624 echo "Telnet password"
625}
626serverconfig_TelnetPassword_Type() {
627 echo "string"
628}
629
630
631
[344]632serverconfig_TelnetFailedLoginLimit_QueryName() {
633 echo "Max failed login attempts (0 to disable)"
634}
635serverconfig_TelnetFailedLoginLimit_Type() {
636 echo "number"
637}
638serverconfig_TelnetFailedLoginLimit_Default() {
639 echo "10"
640}
641
642
643
644serverconfig_TelnetFailedLoginsBlocktime_QueryName() {
645 echo "Telnet login blocktime after failed logins (seconds)"
646}
647serverconfig_TelnetFailedLoginsBlocktime_Type() {
648 echo "number"
649}
650serverconfig_TelnetFailedLoginsBlocktime_Default() {
651 echo "10"
652}
653
654
655
[19]656serverconfig_DropOnDeath_QueryName() {
657 echo "Drop on Death"
658}
659serverconfig_DropOnDeath_Type() {
660 echo "number"
661}
662serverconfig_DropOnDeath_Default() {
[356]663 echo "1"
[19]664}
665serverconfig_DropOnDeath_Range() {
[356]666 echo "0-4"
[19]667}
668serverconfig_DropOnDeath_Values() {
[356]669 config_allowed_values=("Nothing" "Everything (incl. Equip)" "Toolbelt only" "Backpack only" "Delete all")
[19]670}
671
672
673serverconfig_DropOnQuit_QueryName() {
674 echo "Drop on Quit"
675}
676serverconfig_DropOnQuit_Type() {
677 echo "number"
678}
679serverconfig_DropOnQuit_Default() {
[356]680 echo "0"
[19]681}
682serverconfig_DropOnQuit_Range() {
683 echo "0-3"
684}
685serverconfig_DropOnQuit_Values() {
[356]686 config_allowed_values=("Nothing" "Everything (incl. Equip)" "Toolbelt only" "Backpack only")
[19]687}
688
689
690
691
692serverconfig_EnemySpawnMode_QueryName() {
693 echo "Spawn mode"
694}
695serverconfig_EnemySpawnMode_Type() {
[302]696 echo "boolean"
[19]697}
698serverconfig_EnemySpawnMode_Default() {
[302]699 echo "true"
[19]700}
[302]701serverconfig_EnemySpawnMode_ErrorMessage() {
702 echo "Not a valid boolean given (true/false or yes/no or y/n)."
[19]703}
704
705
706serverconfig_EnemyDifficulty_QueryName() {
707 echo "Enemy difficulty"
708}
709serverconfig_EnemyDifficulty_Type() {
710 echo "number"
711}
712serverconfig_EnemyDifficulty_Default() {
713 echo "0"
714}
715serverconfig_EnemyDifficulty_Range() {
716 echo "0-1"
717}
718serverconfig_EnemyDifficulty_Values() {
719 config_allowed_values=("Normal" "Feral")
720}
721
722
[302]723serverconfig_BloodMoonEnemyCount_QueryName() {
724 echo "Enemies per Player on Blood moons"
725}
726serverconfig_BloodMoonEnemyCount_Type() {
727 echo "number"
728}
729serverconfig_BloodMoonEnemyCount_Default() {
730 echo "8"
731}
732serverconfig_BloodMoonEnemyCount_Range() {
733 echo "0-64"
734}
[19]735
736
[302]737
738
[353]739serverconfig_BlockDamagePlayer_QueryName() {
740 echo "Block damage modifier for players (%)"
[19]741}
[353]742serverconfig_BlockDamagePlayer_Type() {
[19]743 echo "number"
744}
[353]745serverconfig_BlockDamagePlayer_Default() {
[19]746 echo "100"
747}
748
749
[353]750serverconfig_BlockDamageAI_QueryName() {
751 echo "Block damage modifier for AIs (%)"
752}
753serverconfig_BlockDamageAI_Type() {
754 echo "number"
755}
756serverconfig_BlockDamageAI_Default() {
757 echo "100"
758}
[19]759
760
[353]761serverconfig_BlockDamageAIBM_QueryName() {
762 echo "Block damage modifier for AIs during blood moons (%)"
763}
764serverconfig_BlockDamageAIBM_Type() {
765 echo "number"
766}
767serverconfig_BlockDamageAIBM_Default() {
768 echo "100"
769}
770
771
772
773
774
[19]775serverconfig_LootAbundance_QueryName() {
776 echo "Loot abundance (%)"
777}
778serverconfig_LootAbundance_Type() {
779 echo "number"
780}
781serverconfig_LootAbundance_Default() {
782 echo "100"
783}
784
785
786serverconfig_LootRespawnDays_QueryName() {
787 echo "Loot respawn delay (days)"
788}
789serverconfig_LootRespawnDays_Type() {
790 echo "number"
791}
792serverconfig_LootRespawnDays_Default() {
793 echo "7"
794}
795
[302]796serverconfig_BedrollDeadZoneSize_QueryName() {
797 echo "Bedroll deadzone size"
798}
799serverconfig_BedrollDeadZoneSize_Type() {
800 echo "number"
801}
802serverconfig_BedrollDeadZoneSize_Default() {
803 echo "15"
804}
[19]805
[356]806serverconfig_BedrollExpiryTime_QueryName() {
807 echo "Bedroll expiry time (days)"
808}
809serverconfig_BedrollExpiryTime_Type() {
810 echo "number"
811}
812serverconfig_BedrollExpiryTime_Default() {
813 echo "45"
814}
[19]815
816
[302]817
[19]818serverconfig_LandClaimSize_QueryName() {
819 echo "Land claim size"
820}
821serverconfig_LandClaimSize_Type() {
822 echo "number"
823}
824serverconfig_LandClaimSize_Default() {
825 echo "7"
826}
827
828
829serverconfig_LandClaimDeadZone_QueryName() {
830 echo "Minimum keystone distance"
831}
832serverconfig_LandClaimDeadZone_Type() {
833 echo "number"
834}
835serverconfig_LandClaimDeadZone_Default() {
836 echo "30"
837}
838
839
840serverconfig_LandClaimExpiryTime_QueryName() {
841 echo "Claim expiry time (days)"
842}
843serverconfig_LandClaimExpiryTime_Type() {
844 echo "number"
845}
846serverconfig_LandClaimExpiryTime_Default() {
847 echo "3"
848}
849
850
851serverconfig_LandClaimDecayMode_QueryName() {
852 echo "Claim decay mode"
853}
854serverconfig_LandClaimDecayMode_Type() {
855 echo "number"
856}
857serverconfig_LandClaimDecayMode_Default() {
858 echo "0"
859}
860serverconfig_LandClaimDecayMode_Range() {
861 echo "0-2"
862}
863serverconfig_LandClaimDecayMode_Values() {
864 config_allowed_values=("Linear" "Exponential" "Full protection")
865}
866
867
868serverconfig_LandClaimOnlineDurabilityModifier_QueryName() {
869 echo "Claim durability modifier - online"
870}
871serverconfig_LandClaimOnlineDurabilityModifier_Type() {
872 echo "number"
873}
874serverconfig_LandClaimOnlineDurabilityModifier_Default() {
875 echo "4"
876}
877
878
879serverconfig_LandClaimOfflineDurabilityModifier_QueryName() {
880 echo "Claim durability modifier - offline"
881}
882serverconfig_LandClaimOfflineDurabilityModifier_Type() {
883 echo "number"
884}
885serverconfig_LandClaimOfflineDurabilityModifier_Default() {
886 echo "4"
887}
888
889
890
891
892serverconfig_AirDropFrequency_QueryName() {
893 echo "Airdrop delay (hours)"
894}
895serverconfig_AirDropFrequency_Type() {
896 echo "number"
897}
898serverconfig_AirDropFrequency_Default() {
[204]899 echo "72"
[19]900}
901
902
[294]903serverconfig_AirDropMarker_QueryName() {
904 echo "Enable AirDrop markers"
905}
906serverconfig_AirDropMarker_Type() {
907 echo "boolean"
908}
909serverconfig_AirDropMarker_Default() {
910 echo "false"
911}
912serverconfig_AirDropMarker_ErrorMessage() {
913 echo "Not a valid boolean given (true/false or yes/no or y/n)."
914}
915
916
917
[67]918serverconfig_MaxSpawnedZombies_QueryName() {
919 echo "Maximum number of concurrent zombies"
920}
921serverconfig_MaxSpawnedZombies_Type() {
922 echo "number"
923}
924serverconfig_MaxSpawnedZombies_Default() {
925 echo "60"
926}
[19]927
928
[294]929serverconfig_MaxSpawnedAnimals_QueryName() {
930 echo "Maximum number of concurrent animals"
931}
932serverconfig_MaxSpawnedAnimals_Type() {
933 echo "number"
934}
935serverconfig_MaxSpawnedAnimals_Default() {
936 echo "50"
937}
938
939
[204]940serverconfig_EACEnabled_QueryName() {
941 echo "Enable EasyAntiCheat"
[67]942}
[204]943serverconfig_EACEnabled_Type() {
[67]944 echo "boolean"
945}
[204]946serverconfig_EACEnabled_Default() {
[67]947 echo "true"
948}
[204]949serverconfig_EACEnabled_ErrorMessage() {
[67]950 echo "Not a valid boolean given (true/false or yes/no or y/n)."
951}
952
953
954
955
[23]956#################################
957## Edit option functions
958
959configEditServer() {
960 local CV
961
962 echo "Server"
963 echo "--------------------------------"
964 for CV in \
[344]965 ServerName ServerPassword ServerVisibility ServerPort ServerDisabledNetworkProtocols ServerDescription ServerWebsiteURL \
[356]966 HideCommandExecutionLog MaxUncoveredMapChunksPerPlayer ServerMaxWorldTransferSpeedKiBs ServerMaxAllowedViewDistance EACEnabled MaxSpawnedZombies MaxSpawnedAnimals \
[23]967 ; do
[24]968 $1 $CV
[23]969 done
970 echo
971}
972
[302]973configEditSlots() {
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
[23]986configEditRemoteControl() {
987 local CV
988
989 echo "Remote control"
990 echo "--------------------------------"
991 for CV in \
992 ControlPanelEnabled ControlPanelPort ControlPanelPassword \
[344]993 TelnetPort TelnetPassword TelnetFailedLoginLimit TelnetFailedLoginsBlocktime \
[23]994 ; do
995 if [ "$CV" = "TelnetPort" ]; then
996 echo
997 echo "NOTE: Telnet will always be enabled for management purposes!"
[88]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!"
[23]1000 echo
1001 fi
[24]1002 $1 $CV
[23]1003 done
1004 echo
1005}
1006
1007configEditGameType() {
1008 local CV
1009
1010 echo "Game type"
1011 echo "--------------------------------"
1012 for CV in \
[344]1013 GameName GameWorld WorldGenSeed WorldGenSize GameMode \
[23]1014 ; do
[24]1015 $1 $CV
[23]1016 done
1017 echo
1018}
1019
1020configEditGeneric() {
1021 local CV
1022
1023 echo "Generic options"
1024 echo "--------------------------------"
1025 for CV in \
[353]1026 XPMultiplier \
[344]1027 PartySharedKillRange PlayerKillingMode PersistentPlayerProfiles \
[294]1028 PlayerSafeZoneLevel PlayerSafeZoneHours \
1029 BuildCreate \
[353]1030 BlockDamagePlayer BlockDamageAI BlockDamageAIBM \
[23]1031 ; do
[24]1032 $1 $CV
[23]1033 done
1034 echo
1035}
1036
1037configEditDropLoot() {
1038 local CV
1039
1040 echo "Drop and Loot"
1041 echo "--------------------------------"
1042 for CV in \
1043 DropOnDeath DropOnQuit \
[294]1044 LootAbundance LootRespawnDays \
1045 AirDropFrequency AirDropMarker \
[23]1046 ; do
[24]1047 $1 $CV
[23]1048 done
1049 echo
1050}
1051
1052configEditTimes() {
1053 local CV
1054
1055 echo "Times / Durations"
1056 echo "--------------------------------"
1057 for CV in \
[239]1058 DayNightLength DayLightLength \
[23]1059 ; do
[24]1060 $1 $CV
[23]1061 done
1062 echo
1063}
1064
1065configEditDifficulty() {
1066 local CV
1067
1068 echo "Difficulty"
1069 echo "--------------------------------"
1070 for CV in \
[344]1071 GameDifficulty ZombieMove ZombieMoveNight ZombieFeralMove ZombieBMMove \
[302]1072 EnemySpawnMode EnemyDifficulty \
[356]1073 BloodMoonEnemyCount BedrollDeadZoneSize BedrollExpiryTime \
[23]1074 ; do
[24]1075 $1 $CV
[23]1076 done
1077 echo
1078}
1079
1080configEditLandClaim() {
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
[24]1089 $1 $CV
[23]1090 done
1091 echo
1092}
1093
1094configEditAll() {
[24]1095 configEditServer "$1"
[303]1096 configEditSlots "$1"
[24]1097 configEditRemoteControl "$1"
1098 configEditGameType "$1"
1099 configEditGeneric "$1"
1100 configEditDropLoot "$1"
1101 configEditTimes "$1"
1102 configEditDifficulty "$1"
1103 configEditLandClaim "$1"
[23]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
1117listConfigEditFuncs() {
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
[19]1129listConfigValues() {
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
[23]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
[19]1145isValidOptionValue() {
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
[23]1195# Query for the value of a single config option
1196# Will be stored in $configCurrent_$1
1197# Params:
1198# 1: Option name
[19]1199configQueryValue() {
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")
[24]1256 prompt=$(printf "%-*s " 40 "$prompt")
[19]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
[45]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
[19]1276 if [ "$TYPE" = "enum" ]; then
1277 export $currentValName="${config_allowed_values[$currentValName-1]}"
1278 fi
[24]1279 echo
[19]1280}
1281
[23]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
[353]1286# - UserDataFolder (for GeneratedWorlds) is made to point to the <user home directory>/serverdata/
[23]1287# Params:
[19]1288# 1: Instance name
1289configSetAutoParameters() {
1290 configCurrent_TelnetEnabled=true
1291 configCurrent_AdminFileName=admins.xml
[35]1292 configCurrent_SaveGameFolder="$(getInstancePath "$1")"
[353]1293 configCurrent_UserDataFolder=$SDTD_BASE/serverdata
[19]1294}
1295
1296
[24]1297# Print defined config value
1298# Params:
1299# 1: Config option
1300printConfigValue() {
1301 local currentValName=configCurrent_$1
1302 printf "%-25s = %s\n" "$(serverconfig_$1_QueryName)" "${!currentValName}"
[19]1303}
1304
[23]1305# Query for an instance name (will be saved in $INSTANCE)
[19]1306readInstanceName() {
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
[23]1319# Undefine the current config values
[19]1320unsetAllConfigValues() {
1321 local CV
1322 for CV in $(listConfigValues); do
1323 local currentValName=configCurrent_$CV
1324 export $currentValName=
1325 done
1326}
1327
[23]1328# Load all config values from the config.xml of the given instance
1329# Params:
[19]1330# 1: Instance name
1331loadCurrentConfigValues() {
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
[23]1344# Save all config values to the config.xml of the given instance
1345# Params:
[19]1346# 1: Instance name
1347saveCurrentConfigValues() {
1348 local CV
[353]1349 for CV in $(listConfigValues) TelnetEnabled AdminFileName SaveGameFolder UserDataFolder; do
[19]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
[23]1370# Check if the config template exists
1371# Returns:
1372# 0/1: no/yes
[19]1373configTemplateExists() {
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
1387getConfigValue() {
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
1397setConfigValue() {
1398 local CONF=$(getInstancePath $1)/config.xml
1399 $XMLSTARLET ed -L -u "/ServerSettings/property[@name='$2']/@value" -v "$3" $CONF
1400}
1401
Note: See TracBrowser for help on using the repository browser.