- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/lib/7dtd/serverconfig.sh
r20 r24 1 1 #!/bin/bash 2 # Version 53 2 4 3 # Provides functions to query and validate values for serverconfig.xml 4 5 ################################# 6 ## Definition of options 5 7 6 8 serverconfig_ServerPort_QueryName() { … … 684 686 685 687 686 ############ 688 ################################# 689 ## Edit option functions 690 691 configEditServer() { 692 local CV 693 694 echo "Server" 695 echo "--------------------------------" 696 for CV in \ 697 ServerName ServerPassword ServerIsPublic ServerPort ServerMaxPlayerCount \ 698 DisableNAT \ 699 ; do 700 $1 $CV 701 done 702 echo 703 } 704 705 configEditRemoteControl() { 706 local CV 707 708 echo "Remote control" 709 echo "--------------------------------" 710 for CV in \ 711 ControlPanelEnabled ControlPanelPort ControlPanelPassword \ 712 TelnetPort TelnetPassword \ 713 ; do 714 if [ "$CV" = "TelnetPort" ]; then 715 echo 716 echo "NOTE: Telnet will always be enabled for management purposes!" 717 echo "Make sure you block external access to this port!" 718 echo 719 fi 720 $1 $CV 721 done 722 echo 723 } 724 725 configEditGameType() { 726 local CV 727 728 echo "Game type" 729 echo "--------------------------------" 730 for CV in \ 731 GameName GameWorld GameMode \ 732 ; do 733 $1 $CV 734 done 735 echo 736 } 737 738 configEditGameTypeSpecific() { 739 local CV 740 741 echo "Options for specific game types" 742 echo "--------------------------------" 743 for CV in \ 744 DayCount FragLimit MatchLength RebuildMap \ 745 ; do 746 $1 $CV 747 done 748 echo 749 } 750 751 configEditGeneric() { 752 local CV 753 754 echo "Generic options" 755 echo "--------------------------------" 756 for CV in \ 757 ShowAllPlayersOnMap FriendlyFire BuildCreate \ 758 BlockDurabilityModifier \ 759 ; do 760 $1 $CV 761 done 762 echo 763 } 764 765 configEditDropLoot() { 766 local CV 767 768 echo "Drop and Loot" 769 echo "--------------------------------" 770 for CV in \ 771 DropOnDeath DropOnQuit \ 772 LootAbundance LootRespawnDays AirDropFrequency \ 773 ; do 774 $1 $CV 775 done 776 echo 777 } 778 779 configEditTimes() { 780 local CV 781 782 echo "Times / Durations" 783 echo "--------------------------------" 784 for CV in \ 785 CraftTimer LootTimer \ 786 DayNightLength NightPercentage \ 787 ; do 788 $1 $CV 789 done 790 echo 791 } 792 793 configEditDifficulty() { 794 local CV 795 796 echo "Difficulty" 797 echo "--------------------------------" 798 for CV in \ 799 GameDifficulty ZombiesRun \ 800 PlayerDamageGiven PlayerDamageRecieved EnemySenseMemory EnemySpawnMode EnemyDifficulty \ 801 ; do 802 $1 $CV 803 done 804 echo 805 } 806 807 configEditLandClaim() { 808 local CV 809 810 echo "Land claim options" 811 echo "--------------------------------" 812 for CV in \ 813 LandClaimSize LandClaimDeadZone LandClaimExpiryTime LandClaimDecayMode \ 814 LandClaimOnlineDurabilityModifier LandClaimOfflineDurabilityModifier \ 815 ; do 816 $1 $CV 817 done 818 echo 819 } 820 821 configEditAll() { 822 configEditServer "$1" 823 configEditRemoteControl "$1" 824 configEditGameType "$1" 825 configEditGameTypeSpecific "$1" 826 configEditGeneric "$1" 827 configEditDropLoot "$1" 828 configEditTimes "$1" 829 configEditDifficulty "$1" 830 configEditLandClaim "$1" 831 } 832 833 834 835 836 837 ################################# 838 ## Generic worker functions 839 840 841 # List all defined config editing parts 842 # Returns: 843 # List of config funcs 844 listConfigEditFuncs() { 845 local CV 846 for CV in $(declare -F | cut -d\ -f3 | grep "^configEdit.*$"); do 847 CV=${CV#configEdit} 848 printf "%s " "$CV" 849 done 850 } 851 852 853 # List all defined config options 854 # Returns: 855 # List of defined config options 687 856 listConfigValues() { 688 857 local CV … … 695 864 696 865 697 # 1: Option name 698 # 2: Value 866 # Validate the given value for the given option 867 # Params: 868 # 1: Option name 869 # 2: Value 870 # Returns: 871 # 0/1: invalid/valid 699 872 isValidOptionValue() { 700 873 local TYPE=$(serverconfig_$1_Type) … … 747 920 } 748 921 749 # 1: Option name 750 # 2: Target variable 922 # Query for the value of a single config option 923 # Will be stored in $configCurrent_$1 924 # Params: 925 # 1: Option name 751 926 configQueryValue() { 752 927 local TYPE=$(serverconfig_$1_Type) … … 806 981 fi 807 982 prompt=$(printf "%s:" "$prompt") 808 prompt=$(printf "%-*s " 35"$prompt")983 prompt=$(printf "%-*s " 40 "$prompt") 809 984 810 985 while : ; do … … 822 997 export $currentValName="${config_allowed_values[$currentValName-1]}" 823 998 fi 824 } 825 999 echo 1000 } 1001 1002 # Set parameters for current instance that have forced values: 1003 # - TelnetEnabled must be set so that management scripts can work 1004 # - AdminFileName is made to point to the local instance admins.xml 1005 # - SaveGameFolder is made to point to the instance folder 1006 # Params: 826 1007 # 1: Instance name 827 1008 configSetAutoParameters() { … … 831 1012 } 832 1013 833 configEditAll() { 834 local CV 835 for CV in \ 836 ServerName ServerPort ServerIsPublic ServerPassword ServerMaxPlayerCount \ 837 DisableNAT \ 838 ControlPanelEnabled ControlPanelPort ControlPanelPassword \ 839 TelnetPort TelnetPassword \ 840 GameWorld GameName GameMode \ 841 ShowAllPlayersOnMap FriendlyFire BuildCreate \ 842 DayCount FragLimit MatchLength RebuildMap \ 843 DropOnDeath DropOnQuit \ 844 LootAbundance LootRespawnDays AirDropFrequency \ 845 CraftTimer LootTimer \ 846 DayNightLength NightPercentage \ 847 GameDifficulty ZombiesRun \ 848 PlayerDamageGiven PlayerDamageRecieved EnemySenseMemory EnemySpawnMode EnemyDifficulty \ 849 BlockDurabilityModifier \ 850 LandClaimSize LandClaimDeadZone LandClaimExpiryTime LandClaimDecayMode \ 851 LandClaimOnlineDurabilityModifier LandClaimOfflineDurabilityModifier \ 852 ; do 853 configQueryValue $CV 854 echo 855 done 856 } 857 858 printCurrentConfig() { 859 local CV 860 for CV in $(listConfigValues); do 861 local currentValName=configCurrent_$CV 862 printf "%-20s = %s\n" "$CV" "${!currentValName}" 863 done 864 } 865 1014 1015 # Print defined config value 1016 # Params: 1017 # 1: Config option 1018 printConfigValue() { 1019 local currentValName=configCurrent_$1 1020 printf "%-25s = %s\n" "$(serverconfig_$1_QueryName)" "${!currentValName}" 1021 } 1022 1023 # Query for an instance name (will be saved in $INSTANCE) 866 1024 readInstanceName() { 867 1025 until [ $(isValidInstanceName "$INSTANCE") -eq 1 ]; do … … 877 1035 } 878 1036 1037 # Undefine the current config values 879 1038 unsetAllConfigValues() { 880 1039 local CV … … 885 1044 } 886 1045 1046 # Load all config values from the config.xml of the given instance 1047 # Params: 887 1048 # 1: Instance name 888 1049 loadCurrentConfigValues() { … … 899 1060 } 900 1061 1062 # Save all config values to the config.xml of the given instance 1063 # Params: 901 1064 # 1: Instance name 902 1065 saveCurrentConfigValues() { … … 923 1086 } 924 1087 1088 # Check if the config template exists 1089 # Returns: 1090 # 0/1: no/yes 925 1091 configTemplateExists() { 926 1092 if [ -f $SDTD_BASE/templates/config.xml ]; then
Note:
See TracChangeset
for help on using the changeset viewer.