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