commit ac99940e17b8ae4b5efff08e7a3437f851a011be Author: Alex Date: Sat Aug 22 16:49:50 2020 +0200 Initial commit diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..f000443 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,49 @@ +- name: Fetch TShock server + get_url: + url: "https://github.com/Pryaxis/TShock/releases/download/v4.4.0-pre12/TShock4.4.0_Pre12_Terraria1.4.0.5.zip" + dest: "/tmp/tshock.zip" + tags: + - terraria + - fetch + notify: Run service actions +- name: Extract TShock server + command: + chdir: "/opt/terraria" + warn: false + argv: + - "unzip" + - "/tmp/tshock.zip" + tags: + - terraria + - fetch +- name: Change ownership of server + command: + argv: + - "chown" + - "-R" + - "nobody:nogroup" + - "/opt/terraria" + tags: + - terraria + - fetch +- name: Copy configurations + loop: "{{ terraria.configs }}" + template: + src: "{{ item }}" + dest: "{{ terraria.paths.data }}/tshock/{{ item }}" + mode: "600" + owner: "nobody" + group: "nogroup" + tags: + - terraria + - configs + notify: Run service actions + when: ( terraria.configs|default([]) ) | length +- name: Copy service + template: + src: "tshock.service.j2" + dest: "/etc/systemd/system/tshock.service" + tags: + - terraria + - systemd + notify: Run service actions diff --git a/templates/config.json b/templates/config.json new file mode 100644 index 0000000..5ef79f9 --- /dev/null +++ b/templates/config.json @@ -0,0 +1,142 @@ +{ + "ServerPassword": "", + "ServerPort": {{ terraria.bind.port }}, + "MaxSlots": 16, + "ReservedSlots": 20, + "ServerName": "[RX] The blocky game that's not Minecraft!", + "UseServerName": true, + "LogPath": "tshock", + "DebugLogs": true, + "DisableLoginBeforeJoin": false, + "IgnoreChestStacksOnLoad": false, + "AutoSave": true, + "AnnounceSave": true, + "ShowBackupAutosaveMessages": true, + "BackupInterval": 0, + "BackupKeepFor": 60, + "SaveWorldOnCrash": true, + "SaveWorldOnLastPlayerExit": true, + "InvasionMultiplier": 1, + "DefaultMaximumSpawns": 5, + "DefaultSpawnRate": 600, + "InfiniteInvasion": false, + "PvPMode": "normal", + "SpawnProtection": true, + "SpawnProtectionRadius": 40, + "RangeChecks": true, + "HardcoreOnly": false, + "MediumcoreOnly": false, + "DisableBuild": false, + "DisableHardmode": false, + "DisableDungeonGuardian": false, + "DisableClownBombs": false, + "DisableSnowBalls": false, + "DisableTombstones": true, + "ForceTime": "normal", + "DisableInvisPvP": false, + "MaxRangeForDisabled": 10, + "RegionProtectChests": false, + "RegionProtectGemLocks": true, + "IgnoreProjUpdate": false, + "IgnoreProjKill": false, + "AllowCutTilesAndBreakables": false, + "AllowIce": true, + "AllowCrimsonCreep": true, + "AllowCorruptionCreep": true, + "AllowHallowCreep": true, + "StatueSpawn200": 3, + "StatueSpawn600": 6, + "StatueSpawnWorld": 10, + "PreventBannedItemSpawn": false, + "PreventDeadModification": true, + "PreventInvalidPlaceStyle": true, + "ForceXmas": false, + "ForceHalloween": false, + "AllowAllowedGroupsToSpawnBannedItems": false, + "RespawnSeconds": 5, + "RespawnBossSeconds": 10, + "AnonymousBossInvasions": true, + "MaxHP": 500, + "MaxMP": 200, + "BombExplosionRadius": 5, + "DefaultRegistrationGroupName": "default", + "DefaultGuestGroupName": "guest", + "RememberLeavePos": false, + "MaximumLoginAttempts": 3, + "KickOnMediumcoreDeath": false, + "MediumcoreKickReason": "Death results in a kick", + "BanOnMediumcoreDeath": false, + "MediumcoreBanReason": "Death results in a ban", + "EnableWhitelist": false, + "WhitelistKickReason": "You are not on the whitelist.", + "ServerFullReason": "Server is full", + "ServerFullNoReservedReason": "Server is full. No reserved slots open.", + "KickOnHardcoreDeath": false, + "HardcoreKickReason": "Death results in a kick", + "BanOnHardcoreDeath": false, + "HardcoreBanReason": "Death results in a ban", + "EnableIPBans": true, + "EnableUUIDBans": true, + "EnableBanOnUsernames": false, + "KickProxyUsers": false, + "RequireLogin": false, + "AllowLoginAnyUsername": true, + "AllowRegisterAnyUsername": false, + "MinimumPasswordLength": 4, + "HashAlgorithm": "sha512", + "BCryptWorkFactor": 7, + "DisableUUIDLogin": false, + "KickEmptyUUID": false, + "TilePaintThreshold": 15, + "KickOnTilePaintThresholdBroken": false, + "MaxDamage": 1175, + "MaxProjDamage": 1175, + "KickOnDamageThresholdBroken": false, + "TileKillThreshold": 60, + "KickOnTileKillThresholdBroken": false, + "TilePlaceThreshold": 32, + "KickOnTilePlaceThresholdBroken": false, + "TileLiquidThreshold": 50, + "KickOnTileLiquidThresholdBroken": false, + "ProjIgnoreShrapnel": true, + "ProjectileThreshold": 50, + "KickOnProjectileThresholdBroken": false, + "HealOtherThreshold": 50, + "KickOnHealOtherThresholdBroken": false, + "CommandSpecifier": "/", + "CommandSilentSpecifier": ".", + "DisableSpewLogs": true, + "DisableSecondUpdateLogs": false, + "SuperAdminChatRGB": [ + 255, + 255, + 255 + ], + "SuperAdminChatPrefix": "[SA] ", + "SuperAdminChatSuffix": "", + "EnableGeoIP": false, + "DisplayIPToAdmins": false, + "ChatFormat": "{1}{2}{3}: {4}", + "ChatAboveHeadsFormat": "{2}", + "EnableChatAboveHeads": false, + "BroadcastRGB": [ + 127, + 255, + 212 + ], + "StorageType": "sqlite", + "SqliteDBPath": "tshock.sqlite", + "MySqlHost": "localhost:3306", + "MySqlDbName": "", + "MySqlUsername": "", + "MySqlPassword": "", + "UseSqlLogs": false, + "RevertToTextLogsOnSqlFailures": 10, + "RestApiEnabled": false, + "RestApiPort": 7878, + "LogRest": false, + "EnableTokenEndpointAuthentication": false, + "RESTMaximumRequestsPerInterval": 5, + "RESTRequestBucketDecreaseIntervalMinutes": 1, + "ApplicationRestTokens": {} +} diff --git a/templates/sscconfig.json b/templates/sscconfig.json new file mode 100644 index 0000000..20ef458 --- /dev/null +++ b/templates/sscconfig.json @@ -0,0 +1,24 @@ +{ + "Enabled": true, + "ServerSideCharacterSave": 5, + "LogonDiscardThreshold": 250, + "StartingHealth": 100, + "StartingMana": 20, + "StartingInventory": [ + { + "netID": -15, + "prefix": 0, + "stack": 1 + }, + { + "netID": -13, + "prefix": 0, + "stack": 1 + }, + { + "netID": -16, + "prefix": 0, + "stack": 1 + } + ] +} diff --git a/templates/tshock.service.j2 b/templates/tshock.service.j2 new file mode 100644 index 0000000..068e00f --- /dev/null +++ b/templates/tshock.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=Terraria server +After=network.target + +[Service] +ExecStart=/bin/mono /opt/terraria/TerrariaServer.exe -world "Worlds/{{ terraria.world }}.wld" -autocreate 3 +Restart=on-failure +User=nobody +Group=nogroup +WorkingDirectory={{ terraria.paths.data }} +ProtectSystem=strict +BindPaths=-{{ terraria.paths.data }} +TemporaryFileSystem=/:rw +PrivateTmp=true + +[Install] +WantedBy=multi-user.target