Changeset 478
- Timestamp:
- Nov 13, 2023, 4:07:41 PM (13 months ago)
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
bootstrapper/bootstrap.sh
r477 r478 27 27 INSTALLOPTIONALDEPS=0 28 28 29 DEPENDENCIES="gcc wget rsync xmlstarlet "29 DEPENDENCIES="gcc wget rsync xmlstarlet expect" 30 30 31 31 if [ -n "$(command -v apt-get)" ]; then … … 110 110 111 111 checkSetupDeps() { 112 for DEP in gcc wget tr rsync xmlstarlet ; do112 for DEP in gcc wget tr rsync xmlstarlet expect; do 113 113 which $DEP > /dev/null 2>&1 114 114 if [ $? -ne 0 ]; then -
scripts/etc/7dtd.conf
r258 r478 40 40 export PKILL=/usr/bin/pkill 41 41 export SSD=/usr/local/lib/7dtd/start-stop-daemon/start-stop-daemon 42 42 export EDITOR=/usr/bin/editor -
scripts/usr/local/lib/7dtd/commands/instances.sh
r308 r478 60 60 y|Y) 61 61 cp $SDTD_BASE/templates/config.xml $IPATH/config.xml 62 loadCurrentConfigValues "$INSTANCE"63 62 break 64 63 ;; … … 70 69 echo 71 70 fi 72 configEditAll configQueryValue73 echo74 configSetAutoParameters "$INSTANCE"75 echo76 echo "Saving"77 71 78 72 if [ ! -f $IPATH/config.xml ]; then 79 echo "<ServerSettings/>" >$IPATH/config.xml73 cp $SDTD_BASE/engine/serverconfig.xml $IPATH/config.xml 80 74 fi 81 saveCurrentConfigValues "$INSTANCE" 75 76 $EDITOR $IPATH/config.xml 77 configSetAutoParameters "$INSTANCE" 78 82 79 if [ -f "$SDTD_BASE/templates/admins.xml" ]; then 83 80 cp "$SDTD_BASE/templates/admins.xml" "$IPATH/" … … 94 91 95 92 if [ $(isRunning "$1") -eq 0 ]; then 96 INSTANCE=$197 lo adCurrentConfigValues "$1"93 local INSTANCE=$1 94 local IPATH=$(getInstancePath "$INSTANCE") 98 95 99 while : ; do 100 echo "What section of the config do you want to edit?" 101 local i=0 102 local sects=() 103 for S in $(listConfigEditFuncs); do 104 (( i++ )) 105 sects[$i]=$S 106 printf " %2d: %s\n" $i "$S" 107 done 108 echo 109 echo " W: Save and exit" 110 echo " Q: Exit WITHOUT saving" 111 112 local SEC 113 while : ; do 114 read -p "Section number: " SEC 115 SEC=$(lowercase $SEC) 116 if [ $(isANumber $SEC) -eq 1 ]; then 117 if [ $SEC -ge 1 -a $SEC -le $i ]; then 118 break 119 fi 120 else 121 if [ "$SEC" = "q" -o "$SEC" = "w" ]; then 122 break 123 fi 124 fi 125 echo "Not a valid section number!" 126 done 127 echo 128 129 case "$SEC" in 130 q) 131 echo "Not saving" 132 break 133 ;; 134 w) 135 configSetAutoParameters "$INSTANCE" 136 echo "Saving" 137 saveCurrentConfigValues "$1" 138 echo "Done" 139 break 140 ;; 141 *) 142 configEdit${sects[$SEC]} configQueryValue 143 echo 144 esac 145 done 96 $EDITOR $IPATH/config.xml 146 97 else 147 98 echo "Instance $1 is currently running. Please stop it first." … … 184 135 fi 185 136 186 INSTANCE=$1 187 loadCurrentConfigValues "$1" 188 189 configEditAll printConfigValue 137 local INSTANCE=$1 138 local IPATH=$(getInstancePath "$INSTANCE") 139 cat $IPATH/config.xml 190 140 } 191 141 -
scripts/usr/local/lib/7dtd/commands/updateengine.sh
r344 r478 76 76 if [ "$CHECKONLY" = "yes" ]; then 77 77 local LOCAL=$(getLocalEngineVersion) 78 local REMOTE=$(get BuildId $(getLocalBranch))79 local REMOTETIME=$(get BuildUpdateTime $(getLocalBranch))78 local REMOTE=$(getRemoteBuildId $(getLocalBranch)) 79 local REMOTETIME=$(getRemoteBuildUpdateTime $(getLocalBranch)) 80 80 81 81 echo "Installed:" … … 91 91 for I in $(getBranchNames); do 92 92 if [[ $I != test* ]] || [ "$SHOWINTERNAL" = "yes" ]; then 93 local BUILD=$(get BuildId $I)94 local CREATED=$(get BuildUpdateTime $I)93 local BUILD=$(getRemoteBuildId $I) 94 local CREATED=$(getRemoteBuildUpdateTime $I) 95 95 printf "%-*s | %*s | %2s\n" 22 "$I" 8 "$BUILD" "$CREATED" 96 96 fi … … 107 107 for I in $(getBranchNames); do 108 108 if [[ $I != test* ]] || [ "$SHOWINTERNAL" = "yes" ]; then 109 local BUILD=$(get BuildId $I)110 local CREATED=$(get BuildUpdateTime $I)109 local BUILD=$(getRemoteBuildId $I) 110 local CREATED=$(getRemoteBuildUpdateTime $I) 111 111 if [ $BUILD -gt $MAXREMOTE ]; then 112 112 MAXREMOTE=$BUILD … … 134 134 135 135 local LOCAL=$(getLocalEngineVersion) 136 local REMOTE=$(get BuildId $BRANCHNAME)136 local REMOTE=$(getRemoteBuildId $BRANCHNAME) 137 137 138 138 if [ "$FORCED" = "yes" -o $REMOTE -gt $LOCAL ]; then 139 139 echo "A newer version of the engine is available." 140 140 echo "Local build id: $LOCAL (installed on $(getLocalEngineUpdateTime))" 141 echo "Available build id: $REMOTE (from $(get BuildUpdateTime $BRANCHNAME))"141 echo "Available build id: $REMOTE (from $(getRemoteBuildUpdateTime $BRANCHNAME))" 142 142 echo 143 143 … … 222 222 fi 223 223 } 224 225 # Get the latest remote (on Steam) engine version numbers etc226 updateRemoteEngineInfo() {227 local DOCHECK=no228 if [ ! -e /tmp/7dtd-appinfo ]; then229 DOCHECK=yes230 else231 AGE=$((`date +%s` - `stat -L --format %Y /tmp/7dtd-appinfo`))232 if [ $AGE -gt 600 ]; then233 DOCHECK=yes234 fi235 fi236 if [ "$DOCHECK" = "yes" ]; then237 echo "Updating version information..."238 rm /root/Steam/appcache/appinfo.vdf239 cd $SDTD_BASE/steamcmd240 241 ./steamcmd.sh +login anonymous +app_info_request 294420 +app_info_update +app_info_update 1 +app_info_print 294420 +quit | grep -A 1000 \"294420\" 2>/dev/null > /tmp/7dtd-appinfo242 243 local BUILDID=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"public\" | grep -B 10 \} --max-count=1 | grep \"buildid\" | cut -d\" -f4)244 245 if [ $(isANumber "$BUILDID") -eq 0 ]; then246 rm -f /tmp/7dtd-appinfo247 fi248 fi249 }250 251 # Get the latest build id (on Steam)252 # Params:253 # 1. Branch name254 # Returns:255 # "?" if data could not be retrieved256 # BuildId otherwise257 getBuildId() {258 local BUILDID=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"buildid\" | cut -d\" -f4)259 260 if [ $(isANumber "$BUILDID") -eq 0 ]; then261 echo "?"262 else263 echo $BUILDID264 fi265 }266 267 # Get the update time of the latest build (on Steam)268 # Params:269 # 1. Branch name270 # Returns:271 # "?" if data could not be retrieved272 # Update timestamp otherwise273 getBuildUpdateTime() {274 local TIMESTAMP=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"timeupdated\" | cut -d\" -f4)275 276 if [ $(isANumber "$TIMESTAMP") -eq 0 ]; then277 echo "?"278 else279 date --date="@${TIMESTAMP}" "+%Y-%m-%d %H:%M:%S"280 fi281 }282 283 # Get a list of available branch names, blank separated284 # Returns:285 # Blank separated list of branch names (can be empty if an error occured)286 getBranchNames() {287 grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -E '^[[:space:]]*"[^"]+"[[:space:]]*$' | tail --lines=+2 | cut -d\" -f2288 }289 -
scripts/usr/local/lib/7dtd/common.sh
r308 r478 116 116 # Branch name 117 117 getLocalBranch() { 118 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf")119 118 local LOCAL="public" 120 if [ -f "$APPMANIFEST" ]; then 121 LOCAL=$(grep betakey "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 122 if [[ -z $LOCAL ]]; then 123 LOCAL="public" 124 else 125 echo $LOCAL 126 return 119 if [ -d "$SDTD_BASE/engine" ]; then 120 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf") 121 if [ -f "$APPMANIFEST" ]; then 122 LOCAL=$(grep betakey "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 123 if [[ -z $LOCAL ]]; then 124 LOCAL="public" 125 else 126 echo $LOCAL 127 return 128 fi 127 129 fi 128 130 fi … … 135 137 # Build Id otherwise 136 138 getLocalEngineVersion() { 137 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf")138 139 local LOCAL=0 139 if [ -f "$APPMANIFEST" ]; then 140 LOCAL=$(grep buildid "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 141 if [ $(isANumber "$LOCAL") -eq 0 ]; then 142 LOCAL=0 140 if [ -d "$SDTD_BASE/engine" ]; then 141 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf") 142 if [ -f "$APPMANIFEST" ]; then 143 LOCAL=$(grep buildid "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 144 if [ $(isANumber "$LOCAL") -eq 0 ]; then 145 LOCAL=0 146 fi 143 147 fi 144 148 fi … … 151 155 # Update time otherwise 152 156 getLocalEngineUpdateTime() { 153 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf")154 157 local LOCAL=0 155 if [ -f "$APPMANIFEST" ]; then 156 LOCAL=$(grep LastUpdated "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 157 if [ $(isANumber "$LOCAL") -eq 0 ]; then 158 LOCAL=0 159 else 160 date --date="@${LOCAL}" "+%Y-%m-%d %H:%M:%S" 161 return 158 if [ -d "$SDTD_BASE/engine" ]; then 159 local APPMANIFEST=$(find $SDTD_BASE/engine -type f -name "appmanifest_294420.acf") 160 if [ -f "$APPMANIFEST" ]; then 161 LOCAL=$(grep LastUpdated "$APPMANIFEST" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) 162 if [ $(isANumber "$LOCAL") -eq 0 ]; then 163 LOCAL=0 164 else 165 date --date="@${LOCAL}" "+%Y-%m-%d %H:%M:%S" 166 return 167 fi 162 168 fi 163 169 fi 164 170 echo $LOCAL 171 } 172 173 174 # Get the latest remote (on Steam) engine version numbers etc 175 updateRemoteEngineInfo() { 176 local DOCHECK=no 177 if [ ! -e /tmp/7dtd-appinfo ]; then 178 DOCHECK=yes 179 else 180 AGE=$((`date +%s` - `stat -L --format %Y /tmp/7dtd-appinfo`)) 181 if [ $AGE -gt 300 ]; then 182 DOCHECK=yes 183 fi 184 fi 185 if [ "$DOCHECK" = "yes" ]; then 186 echo "Updating version information..." 187 rm /root/Steam/appcache/appinfo.vdf 188 cd $SDTD_BASE/steamcmd 189 190 expect /usr/local/lib/7dtd/steamcmd.exp $SDTD_BASE/steamcmd/steamcmd.sh 294420 2>/dev/null > /tmp/7dtd-appinfo 191 192 local BUILDID=$(getBuildId public) 193 194 if [ $(isANumber "$BUILDID") -eq 0 ]; then 195 rm -f /tmp/7dtd-appinfo 196 fi 197 fi 198 } 199 200 # Get the latest build id (on Steam) 201 # Params: 202 # 1. Branch name 203 # Returns: 204 # "?" if data could not be retrieved 205 # BuildId otherwise 206 getRemoteBuildId() { 207 local BUILDID=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"buildid\" | cut -d\" -f4) 208 209 if [ $(isANumber "$BUILDID") -eq 0 ]; then 210 echo "?" 211 else 212 echo $BUILDID 213 fi 214 } 215 216 # Get the update time of the latest build (on Steam) 217 # Params: 218 # 1. Branch name 219 # Returns: 220 # "?" if data could not be retrieved 221 # Update timestamp otherwise 222 getRemoteBuildUpdateTime() { 223 local TIMESTAMP=$(grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -A 1000 \"$1\" | grep -B 10 \} --max-count=1 | grep \"timeupdated\" | cut -d\" -f4) 224 225 if [ $(isANumber "$TIMESTAMP") -eq 0 ]; then 226 echo "?" 227 else 228 date --date="@${TIMESTAMP}" "+%Y-%m-%d %H:%M:%S" 229 fi 230 } 231 232 # Get a list of available branch names, blank separated 233 # Returns: 234 # Blank separated list of branch names (can be empty if an error occured) 235 getBranchNames() { 236 grep -A 1000 \"branches\" /tmp/7dtd-appinfo | grep -E '^[[:space:]]*"[^"]+"[[:space:]]*$' | tail --lines=+2 | cut -d\" -f2 165 237 } 166 238 -
scripts/usr/local/lib/7dtd/serverconfig.sh
r357 r478 16 16 17 17 18 # Provides functions to query and validate values for serverconfig.xml19 20 #################################21 ## Definition of options22 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 ]; then38 echo "1"39 else40 echo "0"41 fi42 }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" ]; then87 echo "1"88 else89 echo "0"90 fi91 }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" ]; then275 echo "1"276 else277 echo "0"278 fi279 }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" ]; then309 echo "1"310 else311 echo "0"312 fi313 }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 "1"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 ]; then577 echo "1"578 else579 echo "0"580 fi581 }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 ]; then612 echo "1"613 else614 echo "0"615 fi616 }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 functions958 959 configEditServer() {960 local CV961 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 ; do968 $1 $CV969 done970 echo971 }972 973 configEditSlots() {974 local CV975 976 echo "Slots"977 echo "--------------------------------"978 for CV in \979 ServerMaxPlayerCount ServerReservedSlots ServerReservedSlotsPermission ServerAdminSlots ServerAdminSlotsPermission \980 ; do981 $1 $CV982 done983 echo984 }985 986 configEditRemoteControl() {987 local CV988 989 echo "Remote control"990 echo "--------------------------------"991 for CV in \992 ControlPanelEnabled ControlPanelPort ControlPanelPassword \993 TelnetPort TelnetPassword TelnetFailedLoginLimit TelnetFailedLoginsBlocktime \994 ; do995 if [ "$CV" = "TelnetPort" ]; then996 echo997 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 echo1001 fi1002 $1 $CV1003 done1004 echo1005 }1006 1007 configEditGameType() {1008 local CV1009 1010 echo "Game type"1011 echo "--------------------------------"1012 for CV in \1013 GameName GameWorld WorldGenSeed WorldGenSize GameMode \1014 ; do1015 $1 $CV1016 done1017 echo1018 }1019 1020 configEditGeneric() {1021 local CV1022 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 ; do1032 $1 $CV1033 done1034 echo1035 }1036 1037 configEditDropLoot() {1038 local CV1039 1040 echo "Drop and Loot"1041 echo "--------------------------------"1042 for CV in \1043 DropOnDeath DropOnQuit \1044 LootAbundance LootRespawnDays \1045 AirDropFrequency AirDropMarker \1046 ; do1047 $1 $CV1048 done1049 echo1050 }1051 1052 configEditTimes() {1053 local CV1054 1055 echo "Times / Durations"1056 echo "--------------------------------"1057 for CV in \1058 DayNightLength DayLightLength \1059 ; do1060 $1 $CV1061 done1062 echo1063 }1064 1065 configEditDifficulty() {1066 local CV1067 1068 echo "Difficulty"1069 echo "--------------------------------"1070 for CV in \1071 GameDifficulty ZombieMove ZombieMoveNight ZombieFeralMove ZombieBMMove \1072 EnemySpawnMode EnemyDifficulty \1073 BloodMoonEnemyCount BedrollDeadZoneSize BedrollExpiryTime \1074 ; do1075 $1 $CV1076 done1077 echo1078 }1079 1080 configEditLandClaim() {1081 local CV1082 1083 echo "Land claim options"1084 echo "--------------------------------"1085 for CV in \1086 LandClaimSize LandClaimDeadZone LandClaimExpiryTime LandClaimDecayMode \1087 LandClaimOnlineDurabilityModifier LandClaimOfflineDurabilityModifier \1088 ; do1089 $1 $CV1090 done1091 echo1092 }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 18 1110 19 ################################# 1111 20 ## Generic worker functions 1112 21 1113 1114 # List all defined config editing parts1115 # Returns:1116 # List of config funcs1117 listConfigEditFuncs() {1118 local CV1119 for CV in $(declare -F | cut -d\ -f3 | grep "^configEdit.*$"); do1120 CV=${CV#configEdit}1121 printf "%s " "$CV"1122 done1123 }1124 1125 1126 # List all defined config options1127 # Returns:1128 # List of defined config options1129 listConfigValues() {1130 local CV1131 for CV in $(declare -F | cut -d\ -f3 | grep "^serverconfig_.*_Type$"); do1132 CV=${CV#serverconfig_}1133 CV=${CV%_Type}1134 printf "%s " "$CV"1135 done1136 }1137 1138 1139 # Validate the given value for the given option1140 # Params:1141 # 1: Option name1142 # 2: Value1143 # Returns:1144 # 0/1: invalid/valid1145 isValidOptionValue() {1146 local TYPE=$(serverconfig_$1_Type)1147 local RANGE=""1148 1149 if [ "$TYPE" = "enum" ]; then1150 TYPE="number"1151 serverconfig_$1_Values1152 RANGE=1-${#config_allowed_values[@]}1153 else1154 if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then1155 RANGE=$(serverconfig_$1_Range)1156 fi1157 fi1158 1159 case "$TYPE" in1160 number)1161 if [ $(isANumber "$2") -eq 0 ]; then1162 echo "0"1163 return1164 fi1165 if [ ! -z "$RANGE" ]; then1166 local MIN=$(cut -d- -f1 <<< "$RANGE")1167 local MAX=$(cut -d- -f2 <<< "$RANGE")1168 if [ $2 -lt $MIN -o $2 -gt $MAX ]; then1169 echo "0"1170 return1171 fi1172 fi1173 ;;1174 boolean)1175 if [ $(isABool "$2") -eq 0 ]; then1176 echo "0"1177 return1178 fi1179 ;;1180 string)1181 ;;1182 esac1183 1184 1185 if [ "$(type -t serverconfig_$1_Validate)" = "function" ]; then1186 if [ $(serverconfig_$1_Validate "$2") -eq 0 ]; then1187 echo "0"1188 return1189 fi1190 fi1191 1192 echo "1"1193 }1194 1195 # Query for the value of a single config option1196 # Will be stored in $configCurrent_$11197 # Params:1198 # 1: Option name1199 configQueryValue() {1200 local TYPE=$(serverconfig_$1_Type)1201 local NAME=""1202 local RANGE=""1203 local DEFAULT=""1204 local currentValName=configCurrent_$11205 1206 if [ "$(type -t serverconfig_$1_Values)" = "function" ]; then1207 echo "$(serverconfig_$1_QueryName), options:"1208 serverconfig_$1_Values1209 NAME="Select option"1210 if [ "$TYPE" = "enum" ]; then1211 local OPTOFFSET=11212 else1213 local OPTOFFSET=01214 fi1215 for (( i=$OPTOFFSET; i < ${#config_allowed_values[@]}+$OPTOFFSET; i++ )); do1216 printf " %2d: %s\n" $i "${config_allowed_values[$i-$OPTOFFSET]}"1217 done1218 else1219 NAME=$(serverconfig_$1_QueryName)1220 fi1221 1222 if [ "$TYPE" = "enum" ]; then1223 RANGE=1-${#config_allowed_values[@]}1224 if [ ! -z "${!currentValName}" ]; then1225 for (( i=1; i < ${#config_allowed_values[@]}+1; i++ )); do1226 if [ "${!currentValName}" = "${config_allowed_values[$i-1]}" ]; then1227 DEFAULT=$i1228 fi1229 done1230 export $currentValName=1231 fi1232 else1233 if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then1234 RANGE=$(serverconfig_$1_Range)1235 fi1236 fi1237 1238 if [ -z "$DEFAULT" ]; then1239 if [ ! -z "${!currentValName}" ]; then1240 DEFAULT=${!currentValName}1241 else1242 if [ "$(type -t serverconfig_$1_Default)" = "function" ]; then1243 DEFAULT=$(serverconfig_$1_Default)1244 fi1245 fi1246 fi1247 1248 local prompt=$(printf "%s" "$NAME")1249 if [ ! -z "$RANGE" ]; then1250 prompt=$(printf "%s (%s)" "$prompt" "$RANGE")1251 fi1252 if [ ! -z "$DEFAULT" ]; then1253 prompt=$(printf "%s [%s]" "$prompt" "$DEFAULT")1254 fi1255 prompt=$(printf "%s:" "$prompt")1256 prompt=$(printf "%-*s " 40 "$prompt")1257 1258 while : ; do1259 read -p "$prompt" $currentValName1260 export $currentValName="${!currentValName:-$DEFAULT}"1261 if [ $(isValidOptionValue "$1" "${!currentValName}") -eq 0 ]; then1262 if [ "$(type -t serverconfig_$1_ErrorMessage)" = "function" ]; then1263 serverconfig_$1_ErrorMessage "${!currentValName}"1264 fi1265 fi1266 [ $(isValidOptionValue "$1" "${!currentValName}") -eq 1 ] && break1267 done1268 1269 if [ "$TYPE" = "boolean" ]; then1270 if [ $(getBool ${!currentValName}) -eq 1 ]; then1271 export $currentValName="true"1272 else1273 export $currentValName="false"1274 fi1275 fi1276 if [ "$TYPE" = "enum" ]; then1277 export $currentValName="${config_allowed_values[$currentValName-1]}"1278 fi1279 echo1280 }1281 22 1282 23 # Set parameters for current instance that have forced values: … … 1288 29 # 1: Instance name 1289 30 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}" 31 setConfigValue "$1" "TelnetEnabled" "true" 32 setConfigValue "$1" "AdminFileName" "admins.xml" 33 setConfigValue "$1" "SaveGameFolder" "$(getInstancePath "$1")" 34 setConfigValue "$1" "UserDataFolder" "$SDTD_BASE/serverdata" 1303 35 } 1304 36 … … 1317 49 } 1318 50 1319 # Undefine the current config values1320 unsetAllConfigValues() {1321 local CV1322 for CV in $(listConfigValues); do1323 local currentValName=configCurrent_$CV1324 export $currentValName=1325 done1326 }1327 1328 # Load all config values from the config.xml of the given instance1329 # Params:1330 # 1: Instance name1331 loadCurrentConfigValues() {1332 local CV1333 for CV in $(listConfigValues); do1334 local currentValName=configCurrent_$CV1335 local cfile=$(getInstancePath "$1")/config.xml1336 local XPATH="/ServerSettings/property[@name='$CV']/@value"1337 local VAL=$($XMLSTARLET sel -t -v "$XPATH" $cfile)1338 if [ ! -z "$VAL" ]; then1339 export $currentValName="$VAL"1340 fi1341 done1342 }1343 1344 # Save all config values to the config.xml of the given instance1345 # Params:1346 # 1: Instance name1347 saveCurrentConfigValues() {1348 local CV1349 for CV in $(listConfigValues) TelnetEnabled AdminFileName SaveGameFolder UserDataFolder; do1350 local currentValName=configCurrent_$CV1351 local val="${!currentValName}"1352 local cfile=$(getInstancePath "$1")/config.xml1353 1354 XPATHBASE="/ServerSettings/property[@name='$CV']"1355 1356 if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@name" $cfile) ]; then1357 $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 $cfile1362 else1363 $XMLSTARLET ed -L \1364 -u "$XPATHBASE/@value" -v "$val" \1365 $cfile1366 fi1367 done1368 }1369 51 1370 52 # Check if the config template exists … … 1399 81 $XMLSTARLET ed -L -u "/ServerSettings/property[@name='$2']/@value" -v "$3" $CONF 1400 82 } 1401
Note:
See TracChangeset
for help on using the changeset viewer.