[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] | 23 | serverconfig_ServerPort_QueryName() {
|
---|
| 24 | echo "Base Port"
|
---|
| 25 | }
|
---|
| 26 | serverconfig_ServerPort_Type() {
|
---|
| 27 | echo "number"
|
---|
| 28 | }
|
---|
| 29 | serverconfig_ServerPort_Default() {
|
---|
| 30 | echo "25000"
|
---|
| 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 ]; then
|
---|
| 38 | echo "1"
|
---|
| 39 | else
|
---|
| 40 | echo "0"
|
---|
| 41 | fi
|
---|
| 42 | }
|
---|
| 43 | serverconfig_ServerPort_ErrorMessage() {
|
---|
| 44 | echo "Illegal port number or port already in use by another instance."
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | serverconfig_ServerIsPublic_QueryName() {
|
---|
| 50 | echo "Public server"
|
---|
| 51 | }
|
---|
| 52 | serverconfig_ServerIsPublic_Type() {
|
---|
| 53 | echo "boolean"
|
---|
| 54 | }
|
---|
| 55 | serverconfig_ServerIsPublic_Default() {
|
---|
| 56 | echo "true"
|
---|
| 57 | }
|
---|
| 58 | serverconfig_ServerIsPublic_ErrorMessage() {
|
---|
| 59 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | serverconfig_ServerName_QueryName() {
|
---|
| 65 | echo "Server name"
|
---|
| 66 | }
|
---|
| 67 | serverconfig_ServerName_Type() {
|
---|
| 68 | echo "string"
|
---|
| 69 | }
|
---|
| 70 | serverconfig_ServerName_Validate() {
|
---|
| 71 | if [ ! -z "$1" ]; then
|
---|
| 72 | echo "1"
|
---|
| 73 | else
|
---|
| 74 | echo "0"
|
---|
| 75 | fi
|
---|
| 76 | }
|
---|
| 77 | serverconfig_ServerName_ErrorMessage() {
|
---|
| 78 | echo "Server name cannot be empty."
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 |
|
---|
[204] | 83 | serverconfig_ServerDescription_QueryName() {
|
---|
| 84 | echo "Server description"
|
---|
| 85 | }
|
---|
| 86 | serverconfig_ServerDescription_Type() {
|
---|
| 87 | echo "string"
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | serverconfig_ServerWebsiteURL_QueryName() {
|
---|
| 93 | echo "Server website URL"
|
---|
| 94 | }
|
---|
| 95 | serverconfig_ServerWebsiteURL_Type() {
|
---|
| 96 | echo "string"
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|
[19] | 101 | serverconfig_ServerPassword_QueryName() {
|
---|
| 102 | echo "Server password"
|
---|
| 103 | }
|
---|
| 104 | serverconfig_ServerPassword_Type() {
|
---|
| 105 | echo "string"
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | serverconfig_ServerMaxPlayerCount_QueryName() {
|
---|
| 111 | echo "Max players"
|
---|
| 112 | }
|
---|
| 113 | serverconfig_ServerMaxPlayerCount_Type() {
|
---|
| 114 | echo "number"
|
---|
| 115 | }
|
---|
| 116 | serverconfig_ServerMaxPlayerCount_Default() {
|
---|
| 117 | echo "4"
|
---|
| 118 | }
|
---|
| 119 | serverconfig_ServerMaxPlayerCount_Range() {
|
---|
| 120 | echo "1-64"
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | serverconfig_GameWorld_QueryName() {
|
---|
| 126 | echo "World name"
|
---|
| 127 | }
|
---|
| 128 | serverconfig_GameWorld_Type() {
|
---|
| 129 | echo "enum"
|
---|
| 130 | }
|
---|
| 131 | serverconfig_GameWorld_Default() {
|
---|
| 132 | echo "1"
|
---|
| 133 | }
|
---|
| 134 | serverconfig_GameWorld_Values() {
|
---|
[294] | 135 | config_allowed_values=("Random Gen" "Navezgane") # "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War"
|
---|
[19] | 136 | }
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | serverconfig_GameName_QueryName() {
|
---|
[204] | 141 | echo "Random gen seed"
|
---|
[19] | 142 | }
|
---|
| 143 | serverconfig_GameName_Type() {
|
---|
| 144 | echo "string"
|
---|
| 145 | }
|
---|
| 146 | serverconfig_GameName_Validate() {
|
---|
| 147 | if [ ! -z "$1" ]; then
|
---|
| 148 | echo "1"
|
---|
| 149 | else
|
---|
| 150 | echo "0"
|
---|
| 151 | fi
|
---|
| 152 | }
|
---|
| 153 | serverconfig_GameName_ErrorMessage() {
|
---|
[204] | 154 | echo "Seed cannot be empty."
|
---|
[19] | 155 | }
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | serverconfig_GameDifficulty_QueryName() {
|
---|
[204] | 160 | echo "Difficulty (+ damage given / received)"
|
---|
[19] | 161 | }
|
---|
| 162 | serverconfig_GameDifficulty_Type() {
|
---|
| 163 | echo "number"
|
---|
| 164 | }
|
---|
| 165 | serverconfig_GameDifficulty_Default() {
|
---|
| 166 | echo "2"
|
---|
| 167 | }
|
---|
| 168 | serverconfig_GameDifficulty_Range() {
|
---|
[204] | 169 | echo "0-5"
|
---|
[19] | 170 | }
|
---|
| 171 | serverconfig_GameDifficulty_Values() {
|
---|
[204] | 172 | config_allowed_values=("Scavenger (200% / 50%)" "Adventurer (150% / 75%)" "Nomad (100% / 100%)" "Warrior (75% / 150%)" "Survivalist (50% / 200%)" "Insane (25% / 250%)")
|
---|
[19] | 173 | }
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | serverconfig_GameMode_QueryName() {
|
---|
| 178 | echo "Game mode"
|
---|
| 179 | }
|
---|
| 180 | serverconfig_GameMode_Type() {
|
---|
| 181 | echo "enum"
|
---|
| 182 | }
|
---|
| 183 | serverconfig_GameMode_Default() {
|
---|
| 184 | echo "1"
|
---|
| 185 | }
|
---|
| 186 | serverconfig_GameMode_Values() {
|
---|
| 187 | config_allowed_values=("GameModeSurvivalMP" "GameModeSurvivalSP")
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 | serverconfig_ZombiesRun_QueryName() {
|
---|
| 193 | echo "Zombies run"
|
---|
| 194 | }
|
---|
| 195 | serverconfig_ZombiesRun_Type() {
|
---|
| 196 | echo "number"
|
---|
| 197 | }
|
---|
| 198 | serverconfig_ZombiesRun_Default() {
|
---|
| 199 | echo "0"
|
---|
| 200 | }
|
---|
| 201 | serverconfig_ZombiesRun_Range() {
|
---|
| 202 | echo "0-2"
|
---|
| 203 | }
|
---|
| 204 | serverconfig_ZombiesRun_Values() {
|
---|
| 205 | config_allowed_values=("Default day/night walk/run" "Never run" "Always run")
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | serverconfig_BuildCreate_QueryName() {
|
---|
| 211 | echo "Item spawn menu"
|
---|
| 212 | }
|
---|
| 213 | serverconfig_BuildCreate_Type() {
|
---|
| 214 | echo "boolean"
|
---|
| 215 | }
|
---|
| 216 | serverconfig_BuildCreate_Default() {
|
---|
[204] | 217 | echo "false"
|
---|
[19] | 218 | }
|
---|
| 219 | serverconfig_BuildCreate_ErrorMessage() {
|
---|
| 220 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 |
|
---|
| 225 | serverconfig_DayNightLength_QueryName() {
|
---|
| 226 | echo "Length of one day"
|
---|
| 227 | }
|
---|
| 228 | serverconfig_DayNightLength_Type() {
|
---|
| 229 | echo "number"
|
---|
| 230 | }
|
---|
| 231 | serverconfig_DayNightLength_Default() {
|
---|
[294] | 232 | echo "50"
|
---|
[19] | 233 | }
|
---|
| 234 |
|
---|
| 235 |
|
---|
| 236 |
|
---|
[294] | 237 | serverconfig_DayLightLength_QueryName() {
|
---|
| 238 | echo "Duration of daylight (in ingame hours)"
|
---|
[19] | 239 | }
|
---|
[294] | 240 | serverconfig_DayLightLength_Type() {
|
---|
| 241 | echo "number"
|
---|
| 242 | }
|
---|
| 243 | serverconfig_DayLightLength_Default() {
|
---|
| 244 | echo "18"
|
---|
| 245 | }
|
---|
| 246 | serverconfig_DayLightLength_Range() {
|
---|
| 247 | echo "0-24"
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | serverconfig_PlayerKillingMode_QueryName() {
|
---|
| 253 | echo "Player killing"
|
---|
| 254 | }
|
---|
| 255 | serverconfig_PlayerKillingMode_Type() {
|
---|
[296] | 256 | echo "number"
|
---|
[294] | 257 | }
|
---|
| 258 | serverconfig_PlayerKillingMode_Default() {
|
---|
| 259 | echo "3"
|
---|
| 260 | }
|
---|
[296] | 261 | serverconfig_PlayerKillingMode_Range() {
|
---|
| 262 | echo "0-3"
|
---|
| 263 | }
|
---|
[294] | 264 | serverconfig_PlayerKillingMode_Values() {
|
---|
| 265 | config_allowed_values=("No player killing" "Kill allies only" "Kill strangers only" "Kill everyone")
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 |
|
---|
| 269 |
|
---|
| 270 | serverconfig_PersistentPlayerProfiles_QueryName() {
|
---|
| 271 | echo "Persistent player profiles"
|
---|
| 272 | }
|
---|
| 273 | serverconfig_PersistentPlayerProfiles_Type() {
|
---|
[19] | 274 | echo "boolean"
|
---|
| 275 | }
|
---|
[294] | 276 | serverconfig_PersistentPlayerProfiles_Default() {
|
---|
[19] | 277 | echo "false"
|
---|
| 278 | }
|
---|
[294] | 279 | serverconfig_PersistentPlayerProfiles_ErrorMessage() {
|
---|
[19] | 280 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 |
|
---|
| 284 |
|
---|
[294] | 285 | serverconfig_PlayerSafeZoneLevel_QueryName() {
|
---|
| 286 | echo "Safe zone up to player level"
|
---|
| 287 | }
|
---|
| 288 | serverconfig_PlayerSafeZoneLevel_Type() {
|
---|
| 289 | echo "number"
|
---|
| 290 | }
|
---|
| 291 | serverconfig_PlayerSafeZoneLevel_Default() {
|
---|
| 292 | echo "5"
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | serverconfig_PlayerSafeZoneHours_QueryName() {
|
---|
| 297 | echo "Safe zone up to played hours"
|
---|
| 298 | }
|
---|
| 299 | serverconfig_PlayerSafeZoneHours_Type() {
|
---|
| 300 | echo "number"
|
---|
| 301 | }
|
---|
| 302 | serverconfig_PlayerSafeZoneHours_Default() {
|
---|
| 303 | echo "5"
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 |
|
---|
[19] | 307 | serverconfig_ControlPanelEnabled_QueryName() {
|
---|
| 308 | echo "Enable control panel"
|
---|
| 309 | }
|
---|
| 310 | serverconfig_ControlPanelEnabled_Type() {
|
---|
| 311 | echo "boolean"
|
---|
| 312 | }
|
---|
| 313 | serverconfig_ControlPanelEnabled_Default() {
|
---|
| 314 | echo "false"
|
---|
| 315 | }
|
---|
| 316 | serverconfig_ControlPanelEnabled_ErrorMessage() {
|
---|
| 317 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 318 | }
|
---|
| 319 |
|
---|
| 320 |
|
---|
| 321 |
|
---|
| 322 | serverconfig_ControlPanelPort_QueryName() {
|
---|
| 323 | echo "Control panel port"
|
---|
| 324 | }
|
---|
| 325 | serverconfig_ControlPanelPort_Type() {
|
---|
| 326 | echo "number"
|
---|
| 327 | }
|
---|
| 328 | serverconfig_ControlPanelPort_Default() {
|
---|
| 329 | echo "8080"
|
---|
| 330 | }
|
---|
| 331 | serverconfig_ControlPanelPort_Range() {
|
---|
| 332 | echo "1024-65535"
|
---|
| 333 | }
|
---|
| 334 | serverconfig_ControlPanelPort_Validate() {
|
---|
| 335 | local I=${INSTANCE:-!}
|
---|
| 336 | if [ $(checkTCPPortUsed "$1" "$I") -eq 0 ]; then
|
---|
| 337 | echo "1"
|
---|
| 338 | else
|
---|
| 339 | echo "0"
|
---|
| 340 | fi
|
---|
| 341 | }
|
---|
| 342 | serverconfig_ControlPanelPort_ErrorMessage() {
|
---|
| 343 | echo "Illegal port number or port already in use by another instance."
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 |
|
---|
| 347 |
|
---|
| 348 | serverconfig_ControlPanelPassword_QueryName() {
|
---|
| 349 | echo "Control panel password"
|
---|
| 350 | }
|
---|
| 351 | serverconfig_ControlPanelPassword_Type() {
|
---|
| 352 | echo "string"
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 |
|
---|
| 356 |
|
---|
| 357 | serverconfig_TelnetPort_QueryName() {
|
---|
| 358 | echo "Telnet port"
|
---|
| 359 | }
|
---|
| 360 | serverconfig_TelnetPort_Type() {
|
---|
| 361 | echo "number"
|
---|
| 362 | }
|
---|
| 363 | serverconfig_TelnetPort_Default() {
|
---|
| 364 | echo "8081"
|
---|
| 365 | }
|
---|
| 366 | serverconfig_TelnetPort_Range() {
|
---|
| 367 | echo "1024-65535"
|
---|
| 368 | }
|
---|
| 369 | serverconfig_TelnetPort_Validate() {
|
---|
| 370 | local I=${INSTANCE:-!}
|
---|
| 371 | if [ $(checkTCPPortUsed "$1" "$I") -eq 0 ]; then
|
---|
| 372 | echo "1"
|
---|
| 373 | else
|
---|
| 374 | echo "0"
|
---|
| 375 | fi
|
---|
| 376 | }
|
---|
| 377 | serverconfig_TelnetPort_ErrorMessage() {
|
---|
| 378 | echo "Illegal port number or port already in use by another instance."
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 |
|
---|
| 382 |
|
---|
| 383 | serverconfig_TelnetPassword_QueryName() {
|
---|
| 384 | echo "Telnet password"
|
---|
| 385 | }
|
---|
| 386 | serverconfig_TelnetPassword_Type() {
|
---|
| 387 | echo "string"
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 |
|
---|
| 391 |
|
---|
| 392 | serverconfig_DropOnDeath_QueryName() {
|
---|
| 393 | echo "Drop on Death"
|
---|
| 394 | }
|
---|
| 395 | serverconfig_DropOnDeath_Type() {
|
---|
| 396 | echo "number"
|
---|
| 397 | }
|
---|
| 398 | serverconfig_DropOnDeath_Default() {
|
---|
| 399 | echo "0"
|
---|
| 400 | }
|
---|
| 401 | serverconfig_DropOnDeath_Range() {
|
---|
| 402 | echo "0-3"
|
---|
| 403 | }
|
---|
| 404 | serverconfig_DropOnDeath_Values() {
|
---|
| 405 | config_allowed_values=("Everything" "Toolbelt only" "Backpack only" "Delete all")
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 |
|
---|
| 409 | serverconfig_DropOnQuit_QueryName() {
|
---|
| 410 | echo "Drop on Quit"
|
---|
| 411 | }
|
---|
| 412 | serverconfig_DropOnQuit_Type() {
|
---|
| 413 | echo "number"
|
---|
| 414 | }
|
---|
| 415 | serverconfig_DropOnQuit_Default() {
|
---|
[204] | 416 | echo "1"
|
---|
[19] | 417 | }
|
---|
| 418 | serverconfig_DropOnQuit_Range() {
|
---|
| 419 | echo "0-3"
|
---|
| 420 | }
|
---|
| 421 | serverconfig_DropOnQuit_Values() {
|
---|
| 422 | config_allowed_values=("Nothing" "Everything" "Toolbelt only" "Backpack only")
|
---|
| 423 | }
|
---|
| 424 |
|
---|
| 425 |
|
---|
| 426 |
|
---|
| 427 |
|
---|
| 428 | serverconfig_EnemySenseMemory_QueryName() {
|
---|
| 429 | echo "Sense memory (seconds)"
|
---|
| 430 | }
|
---|
| 431 | serverconfig_EnemySenseMemory_Type() {
|
---|
| 432 | echo "number"
|
---|
| 433 | }
|
---|
| 434 | serverconfig_EnemySenseMemory_Default() {
|
---|
| 435 | echo "60"
|
---|
| 436 | }
|
---|
| 437 |
|
---|
| 438 |
|
---|
| 439 | serverconfig_EnemySpawnMode_QueryName() {
|
---|
| 440 | echo "Spawn mode"
|
---|
| 441 | }
|
---|
| 442 | serverconfig_EnemySpawnMode_Type() {
|
---|
| 443 | echo "number"
|
---|
| 444 | }
|
---|
| 445 | serverconfig_EnemySpawnMode_Default() {
|
---|
| 446 | echo "3"
|
---|
| 447 | }
|
---|
| 448 | serverconfig_EnemySpawnMode_Range() {
|
---|
| 449 | echo "0-5"
|
---|
| 450 | }
|
---|
| 451 | serverconfig_EnemySpawnMode_Values() {
|
---|
| 452 | config_allowed_values=("Disabled" "50%" "75%" "100%" "125%" "150%")
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 |
|
---|
| 456 | serverconfig_EnemyDifficulty_QueryName() {
|
---|
| 457 | echo "Enemy difficulty"
|
---|
| 458 | }
|
---|
| 459 | serverconfig_EnemyDifficulty_Type() {
|
---|
| 460 | echo "number"
|
---|
| 461 | }
|
---|
| 462 | serverconfig_EnemyDifficulty_Default() {
|
---|
| 463 | echo "0"
|
---|
| 464 | }
|
---|
| 465 | serverconfig_EnemyDifficulty_Range() {
|
---|
| 466 | echo "0-1"
|
---|
| 467 | }
|
---|
| 468 | serverconfig_EnemyDifficulty_Values() {
|
---|
| 469 | config_allowed_values=("Normal" "Feral")
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 |
|
---|
| 475 | serverconfig_BlockDurabilityModifier_QueryName() {
|
---|
| 476 | echo "Block durability (%)"
|
---|
| 477 | }
|
---|
| 478 | serverconfig_BlockDurabilityModifier_Type() {
|
---|
| 479 | echo "number"
|
---|
| 480 | }
|
---|
| 481 | serverconfig_BlockDurabilityModifier_Default() {
|
---|
| 482 | echo "100"
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 |
|
---|
| 486 |
|
---|
| 487 |
|
---|
| 488 | serverconfig_LootAbundance_QueryName() {
|
---|
| 489 | echo "Loot abundance (%)"
|
---|
| 490 | }
|
---|
| 491 | serverconfig_LootAbundance_Type() {
|
---|
| 492 | echo "number"
|
---|
| 493 | }
|
---|
| 494 | serverconfig_LootAbundance_Default() {
|
---|
| 495 | echo "100"
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 |
|
---|
| 499 | serverconfig_LootRespawnDays_QueryName() {
|
---|
| 500 | echo "Loot respawn delay (days)"
|
---|
| 501 | }
|
---|
| 502 | serverconfig_LootRespawnDays_Type() {
|
---|
| 503 | echo "number"
|
---|
| 504 | }
|
---|
| 505 | serverconfig_LootRespawnDays_Default() {
|
---|
| 506 | echo "7"
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 |
|
---|
| 510 |
|
---|
| 511 |
|
---|
| 512 | serverconfig_LandClaimSize_QueryName() {
|
---|
| 513 | echo "Land claim size"
|
---|
| 514 | }
|
---|
| 515 | serverconfig_LandClaimSize_Type() {
|
---|
| 516 | echo "number"
|
---|
| 517 | }
|
---|
| 518 | serverconfig_LandClaimSize_Default() {
|
---|
| 519 | echo "7"
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 |
|
---|
| 523 | serverconfig_LandClaimDeadZone_QueryName() {
|
---|
| 524 | echo "Minimum keystone distance"
|
---|
| 525 | }
|
---|
| 526 | serverconfig_LandClaimDeadZone_Type() {
|
---|
| 527 | echo "number"
|
---|
| 528 | }
|
---|
| 529 | serverconfig_LandClaimDeadZone_Default() {
|
---|
| 530 | echo "30"
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 |
|
---|
| 534 | serverconfig_LandClaimExpiryTime_QueryName() {
|
---|
| 535 | echo "Claim expiry time (days)"
|
---|
| 536 | }
|
---|
| 537 | serverconfig_LandClaimExpiryTime_Type() {
|
---|
| 538 | echo "number"
|
---|
| 539 | }
|
---|
| 540 | serverconfig_LandClaimExpiryTime_Default() {
|
---|
| 541 | echo "3"
|
---|
| 542 | }
|
---|
| 543 |
|
---|
| 544 |
|
---|
| 545 | serverconfig_LandClaimDecayMode_QueryName() {
|
---|
| 546 | echo "Claim decay mode"
|
---|
| 547 | }
|
---|
| 548 | serverconfig_LandClaimDecayMode_Type() {
|
---|
| 549 | echo "number"
|
---|
| 550 | }
|
---|
| 551 | serverconfig_LandClaimDecayMode_Default() {
|
---|
| 552 | echo "0"
|
---|
| 553 | }
|
---|
| 554 | serverconfig_LandClaimDecayMode_Range() {
|
---|
| 555 | echo "0-2"
|
---|
| 556 | }
|
---|
| 557 | serverconfig_LandClaimDecayMode_Values() {
|
---|
| 558 | config_allowed_values=("Linear" "Exponential" "Full protection")
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 |
|
---|
| 562 | serverconfig_LandClaimOnlineDurabilityModifier_QueryName() {
|
---|
| 563 | echo "Claim durability modifier - online"
|
---|
| 564 | }
|
---|
| 565 | serverconfig_LandClaimOnlineDurabilityModifier_Type() {
|
---|
| 566 | echo "number"
|
---|
| 567 | }
|
---|
| 568 | serverconfig_LandClaimOnlineDurabilityModifier_Default() {
|
---|
| 569 | echo "4"
|
---|
| 570 | }
|
---|
| 571 |
|
---|
| 572 |
|
---|
| 573 | serverconfig_LandClaimOfflineDurabilityModifier_QueryName() {
|
---|
| 574 | echo "Claim durability modifier - offline"
|
---|
| 575 | }
|
---|
| 576 | serverconfig_LandClaimOfflineDurabilityModifier_Type() {
|
---|
| 577 | echo "number"
|
---|
| 578 | }
|
---|
| 579 | serverconfig_LandClaimOfflineDurabilityModifier_Default() {
|
---|
| 580 | echo "4"
|
---|
| 581 | }
|
---|
| 582 |
|
---|
| 583 |
|
---|
| 584 |
|
---|
| 585 |
|
---|
| 586 | serverconfig_AirDropFrequency_QueryName() {
|
---|
| 587 | echo "Airdrop delay (hours)"
|
---|
| 588 | }
|
---|
| 589 | serverconfig_AirDropFrequency_Type() {
|
---|
| 590 | echo "number"
|
---|
| 591 | }
|
---|
| 592 | serverconfig_AirDropFrequency_Default() {
|
---|
[204] | 593 | echo "72"
|
---|
[19] | 594 | }
|
---|
| 595 |
|
---|
| 596 |
|
---|
[294] | 597 | serverconfig_AirDropMarker_QueryName() {
|
---|
| 598 | echo "Enable AirDrop markers"
|
---|
| 599 | }
|
---|
| 600 | serverconfig_AirDropMarker_Type() {
|
---|
| 601 | echo "boolean"
|
---|
| 602 | }
|
---|
| 603 | serverconfig_AirDropMarker_Default() {
|
---|
| 604 | echo "false"
|
---|
| 605 | }
|
---|
| 606 | serverconfig_AirDropMarker_ErrorMessage() {
|
---|
| 607 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 |
|
---|
| 611 |
|
---|
[67] | 612 | serverconfig_MaxSpawnedZombies_QueryName() {
|
---|
| 613 | echo "Maximum number of concurrent zombies"
|
---|
| 614 | }
|
---|
| 615 | serverconfig_MaxSpawnedZombies_Type() {
|
---|
| 616 | echo "number"
|
---|
| 617 | }
|
---|
| 618 | serverconfig_MaxSpawnedZombies_Default() {
|
---|
| 619 | echo "60"
|
---|
| 620 | }
|
---|
[19] | 621 |
|
---|
| 622 |
|
---|
[294] | 623 | serverconfig_MaxSpawnedAnimals_QueryName() {
|
---|
| 624 | echo "Maximum number of concurrent animals"
|
---|
| 625 | }
|
---|
| 626 | serverconfig_MaxSpawnedAnimals_Type() {
|
---|
| 627 | echo "number"
|
---|
| 628 | }
|
---|
| 629 | serverconfig_MaxSpawnedAnimals_Default() {
|
---|
| 630 | echo "50"
|
---|
| 631 | }
|
---|
| 632 |
|
---|
| 633 |
|
---|
[204] | 634 | serverconfig_EACEnabled_QueryName() {
|
---|
| 635 | echo "Enable EasyAntiCheat"
|
---|
[67] | 636 | }
|
---|
[204] | 637 | serverconfig_EACEnabled_Type() {
|
---|
[67] | 638 | echo "boolean"
|
---|
| 639 | }
|
---|
[204] | 640 | serverconfig_EACEnabled_Default() {
|
---|
[67] | 641 | echo "true"
|
---|
| 642 | }
|
---|
[204] | 643 | serverconfig_EACEnabled_ErrorMessage() {
|
---|
[67] | 644 | echo "Not a valid boolean given (true/false or yes/no or y/n)."
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 |
|
---|
| 648 |
|
---|
| 649 |
|
---|
[23] | 650 | #################################
|
---|
| 651 | ## Edit option functions
|
---|
| 652 |
|
---|
| 653 | configEditServer() {
|
---|
| 654 | local CV
|
---|
| 655 |
|
---|
| 656 | echo "Server"
|
---|
| 657 | echo "--------------------------------"
|
---|
| 658 | for CV in \
|
---|
[204] | 659 | ServerName ServerPassword ServerIsPublic ServerPort ServerMaxPlayerCount ServerDescription ServerWebsiteURL \
|
---|
[294] | 660 | EACEnabled MaxSpawnedZombies MaxSpawnedAnimals \
|
---|
[23] | 661 | ; do
|
---|
[24] | 662 | $1 $CV
|
---|
[23] | 663 | done
|
---|
| 664 | echo
|
---|
| 665 | }
|
---|
| 666 |
|
---|
| 667 | configEditRemoteControl() {
|
---|
| 668 | local CV
|
---|
| 669 |
|
---|
| 670 | echo "Remote control"
|
---|
| 671 | echo "--------------------------------"
|
---|
| 672 | for CV in \
|
---|
| 673 | ControlPanelEnabled ControlPanelPort ControlPanelPassword \
|
---|
| 674 | TelnetPort TelnetPassword \
|
---|
| 675 | ; do
|
---|
| 676 | if [ "$CV" = "TelnetPort" ]; then
|
---|
| 677 | echo
|
---|
| 678 | echo "NOTE: Telnet will always be enabled for management purposes!"
|
---|
[88] | 679 | echo "Make sure you block external access to this port or set no password"
|
---|
| 680 | echo "so the server will only listen on the loopback interface!"
|
---|
[23] | 681 | echo
|
---|
| 682 | fi
|
---|
[24] | 683 | $1 $CV
|
---|
[23] | 684 | done
|
---|
| 685 | echo
|
---|
| 686 | }
|
---|
| 687 |
|
---|
| 688 | configEditGameType() {
|
---|
| 689 | local CV
|
---|
| 690 |
|
---|
| 691 | echo "Game type"
|
---|
| 692 | echo "--------------------------------"
|
---|
| 693 | for CV in \
|
---|
| 694 | GameName GameWorld GameMode \
|
---|
| 695 | ; do
|
---|
[24] | 696 | $1 $CV
|
---|
[23] | 697 | done
|
---|
| 698 | echo
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | configEditGeneric() {
|
---|
| 702 | local CV
|
---|
| 703 |
|
---|
| 704 | echo "Generic options"
|
---|
| 705 | echo "--------------------------------"
|
---|
| 706 | for CV in \
|
---|
[295] | 707 | PlayerKillingMode PersistentPlayerProfiles \
|
---|
[294] | 708 | PlayerSafeZoneLevel PlayerSafeZoneHours \
|
---|
| 709 | BuildCreate \
|
---|
[23] | 710 | BlockDurabilityModifier \
|
---|
| 711 | ; do
|
---|
[24] | 712 | $1 $CV
|
---|
[23] | 713 | done
|
---|
| 714 | echo
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 | configEditDropLoot() {
|
---|
| 718 | local CV
|
---|
| 719 |
|
---|
| 720 | echo "Drop and Loot"
|
---|
| 721 | echo "--------------------------------"
|
---|
| 722 | for CV in \
|
---|
| 723 | DropOnDeath DropOnQuit \
|
---|
[294] | 724 | LootAbundance LootRespawnDays \
|
---|
| 725 | AirDropFrequency AirDropMarker \
|
---|
[23] | 726 | ; do
|
---|
[24] | 727 | $1 $CV
|
---|
[23] | 728 | done
|
---|
| 729 | echo
|
---|
| 730 | }
|
---|
| 731 |
|
---|
| 732 | configEditTimes() {
|
---|
| 733 | local CV
|
---|
| 734 |
|
---|
| 735 | echo "Times / Durations"
|
---|
| 736 | echo "--------------------------------"
|
---|
| 737 | for CV in \
|
---|
[239] | 738 | DayNightLength DayLightLength \
|
---|
[23] | 739 | ; do
|
---|
[24] | 740 | $1 $CV
|
---|
[23] | 741 | done
|
---|
| 742 | echo
|
---|
| 743 | }
|
---|
| 744 |
|
---|
| 745 | configEditDifficulty() {
|
---|
| 746 | local CV
|
---|
| 747 |
|
---|
| 748 | echo "Difficulty"
|
---|
| 749 | echo "--------------------------------"
|
---|
| 750 | for CV in \
|
---|
| 751 | GameDifficulty ZombiesRun \
|
---|
[204] | 752 | EnemySenseMemory EnemySpawnMode EnemyDifficulty \
|
---|
[23] | 753 | ; do
|
---|
[24] | 754 | $1 $CV
|
---|
[23] | 755 | done
|
---|
| 756 | echo
|
---|
| 757 | }
|
---|
| 758 |
|
---|
| 759 | configEditLandClaim() {
|
---|
| 760 | local CV
|
---|
| 761 |
|
---|
| 762 | echo "Land claim options"
|
---|
| 763 | echo "--------------------------------"
|
---|
| 764 | for CV in \
|
---|
| 765 | LandClaimSize LandClaimDeadZone LandClaimExpiryTime LandClaimDecayMode \
|
---|
| 766 | LandClaimOnlineDurabilityModifier LandClaimOfflineDurabilityModifier \
|
---|
| 767 | ; do
|
---|
[24] | 768 | $1 $CV
|
---|
[23] | 769 | done
|
---|
| 770 | echo
|
---|
| 771 | }
|
---|
| 772 |
|
---|
| 773 | configEditAll() {
|
---|
[24] | 774 | configEditServer "$1"
|
---|
| 775 | configEditRemoteControl "$1"
|
---|
| 776 | configEditGameType "$1"
|
---|
| 777 | configEditGeneric "$1"
|
---|
| 778 | configEditDropLoot "$1"
|
---|
| 779 | configEditTimes "$1"
|
---|
| 780 | configEditDifficulty "$1"
|
---|
| 781 | configEditLandClaim "$1"
|
---|
[23] | 782 | }
|
---|
| 783 |
|
---|
| 784 |
|
---|
| 785 |
|
---|
| 786 |
|
---|
| 787 |
|
---|
| 788 | #################################
|
---|
| 789 | ## Generic worker functions
|
---|
| 790 |
|
---|
| 791 |
|
---|
| 792 | # List all defined config editing parts
|
---|
| 793 | # Returns:
|
---|
| 794 | # List of config funcs
|
---|
| 795 | listConfigEditFuncs() {
|
---|
| 796 | local CV
|
---|
| 797 | for CV in $(declare -F | cut -d\ -f3 | grep "^configEdit.*$"); do
|
---|
| 798 | CV=${CV#configEdit}
|
---|
| 799 | printf "%s " "$CV"
|
---|
| 800 | done
|
---|
| 801 | }
|
---|
| 802 |
|
---|
| 803 |
|
---|
| 804 | # List all defined config options
|
---|
| 805 | # Returns:
|
---|
| 806 | # List of defined config options
|
---|
[19] | 807 | listConfigValues() {
|
---|
| 808 | local CV
|
---|
| 809 | for CV in $(declare -F | cut -d\ -f3 | grep "^serverconfig_.*_Type$"); do
|
---|
| 810 | CV=${CV#serverconfig_}
|
---|
| 811 | CV=${CV%_Type}
|
---|
| 812 | printf "%s " "$CV"
|
---|
| 813 | done
|
---|
| 814 | }
|
---|
| 815 |
|
---|
| 816 |
|
---|
[23] | 817 | # Validate the given value for the given option
|
---|
| 818 | # Params:
|
---|
| 819 | # 1: Option name
|
---|
| 820 | # 2: Value
|
---|
| 821 | # Returns:
|
---|
| 822 | # 0/1: invalid/valid
|
---|
[19] | 823 | isValidOptionValue() {
|
---|
| 824 | local TYPE=$(serverconfig_$1_Type)
|
---|
| 825 | local RANGE=""
|
---|
| 826 |
|
---|
| 827 | if [ "$TYPE" = "enum" ]; then
|
---|
| 828 | TYPE="number"
|
---|
| 829 | serverconfig_$1_Values
|
---|
| 830 | RANGE=1-${#config_allowed_values[@]}
|
---|
| 831 | else
|
---|
| 832 | if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then
|
---|
| 833 | RANGE=$(serverconfig_$1_Range)
|
---|
| 834 | fi
|
---|
| 835 | fi
|
---|
| 836 |
|
---|
| 837 | case "$TYPE" in
|
---|
| 838 | number)
|
---|
| 839 | if [ $(isANumber "$2") -eq 0 ]; then
|
---|
| 840 | echo "0"
|
---|
| 841 | return
|
---|
| 842 | fi
|
---|
| 843 | if [ ! -z "$RANGE" ]; then
|
---|
| 844 | local MIN=$(cut -d- -f1 <<< "$RANGE")
|
---|
| 845 | local MAX=$(cut -d- -f2 <<< "$RANGE")
|
---|
| 846 | if [ $2 -lt $MIN -o $2 -gt $MAX ]; then
|
---|
| 847 | echo "0"
|
---|
| 848 | return
|
---|
| 849 | fi
|
---|
| 850 | fi
|
---|
| 851 | ;;
|
---|
| 852 | boolean)
|
---|
| 853 | if [ $(isABool "$2") -eq 0 ]; then
|
---|
| 854 | echo "0"
|
---|
| 855 | return
|
---|
| 856 | fi
|
---|
| 857 | ;;
|
---|
| 858 | string)
|
---|
| 859 | ;;
|
---|
| 860 | esac
|
---|
| 861 |
|
---|
| 862 |
|
---|
| 863 | if [ "$(type -t serverconfig_$1_Validate)" = "function" ]; then
|
---|
| 864 | if [ $(serverconfig_$1_Validate "$2") -eq 0 ]; then
|
---|
| 865 | echo "0"
|
---|
| 866 | return
|
---|
| 867 | fi
|
---|
| 868 | fi
|
---|
| 869 |
|
---|
| 870 | echo "1"
|
---|
| 871 | }
|
---|
| 872 |
|
---|
[23] | 873 | # Query for the value of a single config option
|
---|
| 874 | # Will be stored in $configCurrent_$1
|
---|
| 875 | # Params:
|
---|
| 876 | # 1: Option name
|
---|
[19] | 877 | configQueryValue() {
|
---|
| 878 | local TYPE=$(serverconfig_$1_Type)
|
---|
| 879 | local NAME=""
|
---|
| 880 | local RANGE=""
|
---|
| 881 | local DEFAULT=""
|
---|
| 882 | local currentValName=configCurrent_$1
|
---|
| 883 |
|
---|
| 884 | if [ "$(type -t serverconfig_$1_Values)" = "function" ]; then
|
---|
| 885 | echo "$(serverconfig_$1_QueryName), options:"
|
---|
| 886 | serverconfig_$1_Values
|
---|
| 887 | NAME="Select option"
|
---|
| 888 | if [ "$TYPE" = "enum" ]; then
|
---|
| 889 | local OPTOFFSET=1
|
---|
| 890 | else
|
---|
| 891 | local OPTOFFSET=0
|
---|
| 892 | fi
|
---|
| 893 | for (( i=$OPTOFFSET; i < ${#config_allowed_values[@]}+$OPTOFFSET; i++ )); do
|
---|
| 894 | printf " %2d: %s\n" $i "${config_allowed_values[$i-$OPTOFFSET]}"
|
---|
| 895 | done
|
---|
| 896 | else
|
---|
| 897 | NAME=$(serverconfig_$1_QueryName)
|
---|
| 898 | fi
|
---|
| 899 |
|
---|
| 900 | if [ "$TYPE" = "enum" ]; then
|
---|
| 901 | RANGE=1-${#config_allowed_values[@]}
|
---|
| 902 | if [ ! -z "${!currentValName}" ]; then
|
---|
| 903 | for (( i=1; i < ${#config_allowed_values[@]}+1; i++ )); do
|
---|
| 904 | if [ "${!currentValName}" = "${config_allowed_values[$i-1]}" ]; then
|
---|
| 905 | DEFAULT=$i
|
---|
| 906 | fi
|
---|
| 907 | done
|
---|
| 908 | export $currentValName=
|
---|
| 909 | fi
|
---|
| 910 | else
|
---|
| 911 | if [ "$(type -t serverconfig_$1_Range)" = "function" ]; then
|
---|
| 912 | RANGE=$(serverconfig_$1_Range)
|
---|
| 913 | fi
|
---|
| 914 | fi
|
---|
| 915 |
|
---|
| 916 | if [ -z "$DEFAULT" ]; then
|
---|
| 917 | if [ ! -z "${!currentValName}" ]; then
|
---|
| 918 | DEFAULT=${!currentValName}
|
---|
| 919 | else
|
---|
| 920 | if [ "$(type -t serverconfig_$1_Default)" = "function" ]; then
|
---|
| 921 | DEFAULT=$(serverconfig_$1_Default)
|
---|
| 922 | fi
|
---|
| 923 | fi
|
---|
| 924 | fi
|
---|
| 925 |
|
---|
| 926 | local prompt=$(printf "%s" "$NAME")
|
---|
| 927 | if [ ! -z "$RANGE" ]; then
|
---|
| 928 | prompt=$(printf "%s (%s)" "$prompt" "$RANGE")
|
---|
| 929 | fi
|
---|
| 930 | if [ ! -z "$DEFAULT" ]; then
|
---|
| 931 | prompt=$(printf "%s [%s]" "$prompt" "$DEFAULT")
|
---|
| 932 | fi
|
---|
| 933 | prompt=$(printf "%s:" "$prompt")
|
---|
[24] | 934 | prompt=$(printf "%-*s " 40 "$prompt")
|
---|
[19] | 935 |
|
---|
| 936 | while : ; do
|
---|
| 937 | read -p "$prompt" $currentValName
|
---|
| 938 | export $currentValName="${!currentValName:-$DEFAULT}"
|
---|
| 939 | if [ $(isValidOptionValue "$1" "${!currentValName}") -eq 0 ]; then
|
---|
| 940 | if [ "$(type -t serverconfig_$1_ErrorMessage)" = "function" ]; then
|
---|
| 941 | serverconfig_$1_ErrorMessage "${!currentValName}"
|
---|
| 942 | fi
|
---|
| 943 | fi
|
---|
| 944 | [ $(isValidOptionValue "$1" "${!currentValName}") -eq 1 ] && break
|
---|
| 945 | done
|
---|
| 946 |
|
---|
[45] | 947 | if [ "$TYPE" = "boolean" ]; then
|
---|
| 948 | if [ $(getBool ${!currentValName}) -eq 1 ]; then
|
---|
| 949 | export $currentValName="true"
|
---|
| 950 | else
|
---|
| 951 | export $currentValName="false"
|
---|
| 952 | fi
|
---|
| 953 | fi
|
---|
[19] | 954 | if [ "$TYPE" = "enum" ]; then
|
---|
| 955 | export $currentValName="${config_allowed_values[$currentValName-1]}"
|
---|
| 956 | fi
|
---|
[24] | 957 | echo
|
---|
[19] | 958 | }
|
---|
| 959 |
|
---|
[23] | 960 | # Set parameters for current instance that have forced values:
|
---|
| 961 | # - TelnetEnabled must be set so that management scripts can work
|
---|
| 962 | # - AdminFileName is made to point to the local instance admins.xml
|
---|
| 963 | # - SaveGameFolder is made to point to the instance folder
|
---|
| 964 | # Params:
|
---|
[19] | 965 | # 1: Instance name
|
---|
| 966 | configSetAutoParameters() {
|
---|
| 967 | configCurrent_TelnetEnabled=true
|
---|
| 968 | configCurrent_AdminFileName=admins.xml
|
---|
[35] | 969 | configCurrent_SaveGameFolder="$(getInstancePath "$1")"
|
---|
[19] | 970 | }
|
---|
| 971 |
|
---|
| 972 |
|
---|
[24] | 973 | # Print defined config value
|
---|
| 974 | # Params:
|
---|
| 975 | # 1: Config option
|
---|
| 976 | printConfigValue() {
|
---|
| 977 | local currentValName=configCurrent_$1
|
---|
| 978 | printf "%-25s = %s\n" "$(serverconfig_$1_QueryName)" "${!currentValName}"
|
---|
[19] | 979 | }
|
---|
| 980 |
|
---|
[23] | 981 | # Query for an instance name (will be saved in $INSTANCE)
|
---|
[19] | 982 | readInstanceName() {
|
---|
| 983 | until [ $(isValidInstanceName "$INSTANCE") -eq 1 ]; do
|
---|
| 984 | read -p "Instance name: " INSTANCE
|
---|
| 985 | if [ $(isValidInstanceName "$INSTANCE") -eq 0 ]; then
|
---|
| 986 | echo "Invalid instance name, may only contain:"
|
---|
| 987 | echo " - letters (A-Z / a-z)"
|
---|
| 988 | echo " - digits (0-9)"
|
---|
| 989 | echo " - underscores (_)"
|
---|
| 990 | echo " - hyphens (-)"
|
---|
| 991 | fi
|
---|
| 992 | done
|
---|
| 993 | }
|
---|
| 994 |
|
---|
[23] | 995 | # Undefine the current config values
|
---|
[19] | 996 | unsetAllConfigValues() {
|
---|
| 997 | local CV
|
---|
| 998 | for CV in $(listConfigValues); do
|
---|
| 999 | local currentValName=configCurrent_$CV
|
---|
| 1000 | export $currentValName=
|
---|
| 1001 | done
|
---|
| 1002 | }
|
---|
| 1003 |
|
---|
[23] | 1004 | # Load all config values from the config.xml of the given instance
|
---|
| 1005 | # Params:
|
---|
[19] | 1006 | # 1: Instance name
|
---|
| 1007 | loadCurrentConfigValues() {
|
---|
| 1008 | local CV
|
---|
| 1009 | for CV in $(listConfigValues); do
|
---|
| 1010 | local currentValName=configCurrent_$CV
|
---|
| 1011 | local cfile=$(getInstancePath "$1")/config.xml
|
---|
| 1012 | local XPATH="/ServerSettings/property[@name='$CV']/@value"
|
---|
| 1013 | local VAL=$($XMLSTARLET sel -t -v "$XPATH" $cfile)
|
---|
| 1014 | if [ ! -z "$VAL" ]; then
|
---|
| 1015 | export $currentValName="$VAL"
|
---|
| 1016 | fi
|
---|
| 1017 | done
|
---|
| 1018 | }
|
---|
| 1019 |
|
---|
[23] | 1020 | # Save all config values to the config.xml of the given instance
|
---|
| 1021 | # Params:
|
---|
[19] | 1022 | # 1: Instance name
|
---|
| 1023 | saveCurrentConfigValues() {
|
---|
| 1024 | local CV
|
---|
| 1025 | for CV in $(listConfigValues) TelnetEnabled AdminFileName SaveGameFolder; do
|
---|
| 1026 | local currentValName=configCurrent_$CV
|
---|
| 1027 | local val="${!currentValName}"
|
---|
| 1028 | local cfile=$(getInstancePath "$1")/config.xml
|
---|
| 1029 |
|
---|
| 1030 | XPATHBASE="/ServerSettings/property[@name='$CV']"
|
---|
| 1031 |
|
---|
| 1032 | if [ -z $($XMLSTARLET sel -t -v "$XPATHBASE/@name" $cfile) ]; then
|
---|
| 1033 | $XMLSTARLET ed -L \
|
---|
| 1034 | -s "/ServerSettings" -t elem -n "property" -v "" \
|
---|
| 1035 | -i "/ServerSettings/property[not(@name)]" -t attr -n "name" -v "$CV" \
|
---|
| 1036 | -i "$XPATHBASE" -t attr -n "value" -v "$val" \
|
---|
| 1037 | $cfile
|
---|
| 1038 | else
|
---|
| 1039 | $XMLSTARLET ed -L \
|
---|
| 1040 | -u "$XPATHBASE/@value" -v "$val" \
|
---|
| 1041 | $cfile
|
---|
| 1042 | fi
|
---|
| 1043 | done
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
[23] | 1046 | # Check if the config template exists
|
---|
| 1047 | # Returns:
|
---|
| 1048 | # 0/1: no/yes
|
---|
[19] | 1049 | configTemplateExists() {
|
---|
| 1050 | if [ -f $SDTD_BASE/templates/config.xml ]; then
|
---|
| 1051 | echo 1
|
---|
| 1052 | else
|
---|
| 1053 | echo 0
|
---|
| 1054 | fi
|
---|
| 1055 | }
|
---|
| 1056 |
|
---|
| 1057 | # Get a single value from a serverconfig
|
---|
| 1058 | # Params:
|
---|
| 1059 | # 1: Instance name
|
---|
| 1060 | # 2: Property name
|
---|
| 1061 | # Returns:
|
---|
| 1062 | # Property value
|
---|
| 1063 | getConfigValue() {
|
---|
| 1064 | local CONF=$(getInstancePath $1)/config.xml
|
---|
| 1065 | $XMLSTARLET sel -t -v "/ServerSettings/property[@name='$2']/@value" $CONF
|
---|
| 1066 | }
|
---|
| 1067 |
|
---|
| 1068 | # Update a single value in a serverconfig
|
---|
| 1069 | # Params:
|
---|
| 1070 | # 1: Instance name
|
---|
| 1071 | # 2: Property name
|
---|
| 1072 | # 3: New value
|
---|
| 1073 | setConfigValue() {
|
---|
| 1074 | local CONF=$(getInstancePath $1)/config.xml
|
---|
| 1075 | $XMLSTARLET ed -L -u "/ServerSettings/property[@name='$2']/@value" -v "$3" $CONF
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|