- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/lib/7dtd/serverconfig.sh
r24 r20 1 1 #!/bin/bash 2 # Version 5 2 3 3 4 # Provides functions to query and validate values for serverconfig.xml 4 5 #################################6 ## Definition of options7 5 8 6 serverconfig_ServerPort_QueryName() { … … 686 684 687 685 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 686 ############ 856 687 listConfigValues() { 857 688 local CV … … 864 695 865 696 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 697 # 1: Option name 698 # 2: Value 872 699 isValidOptionValue() { 873 700 local TYPE=$(serverconfig_$1_Type) … … 920 747 } 921 748 922 # Query for the value of a single config option 923 # Will be stored in $configCurrent_$1 924 # Params: 925 # 1: Option name 749 # 1: Option name 750 # 2: Target variable 926 751 configQueryValue() { 927 752 local TYPE=$(serverconfig_$1_Type) … … 981 806 fi 982 807 prompt=$(printf "%s:" "$prompt") 983 prompt=$(printf "%-*s " 40"$prompt")808 prompt=$(printf "%-*s " 35 "$prompt") 984 809 985 810 while : ; do … … 997 822 export $currentValName="${config_allowed_values[$currentValName-1]}" 998 823 fi 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: 824 } 825 1007 826 # 1: Instance name 1008 827 configSetAutoParameters() { … … 1012 831 } 1013 832 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) 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 1024 866 readInstanceName() { 1025 867 until [ $(isValidInstanceName "$INSTANCE") -eq 1 ]; do … … 1035 877 } 1036 878 1037 # Undefine the current config values1038 879 unsetAllConfigValues() { 1039 880 local CV … … 1044 885 } 1045 886 1046 # Load all config values from the config.xml of the given instance1047 # Params:1048 887 # 1: Instance name 1049 888 loadCurrentConfigValues() { … … 1060 899 } 1061 900 1062 # Save all config values to the config.xml of the given instance1063 # Params:1064 901 # 1: Instance name 1065 902 saveCurrentConfigValues() { … … 1086 923 } 1087 924 1088 # Check if the config template exists1089 # Returns:1090 # 0/1: no/yes1091 925 configTemplateExists() { 1092 926 if [ -f $SDTD_BASE/templates/config.xml ]; then
Note:
See TracChangeset
for help on using the changeset viewer.