From 1705d336086be696cf67419a17782323537e5803 Mon Sep 17 00:00:00 2001 From: nyanloutre Date: Mon, 26 Nov 2018 17:26:55 +0100 Subject: [PATCH] serveur 7 days to die --- services/sdtdserver.nix | 113 ++++++++++++++++++++++++++++++++++ systems/LoutreOS/services.nix | 3 + 2 files changed, 116 insertions(+) create mode 100644 services/sdtdserver.nix diff --git a/services/sdtdserver.nix b/services/sdtdserver.nix new file mode 100644 index 0000000..2e75443 --- /dev/null +++ b/services/sdtdserver.nix @@ -0,0 +1,113 @@ +{lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.services.sdtdserver; + gamePath = "/var/lib/sdtdserver"; + gameOptions = { + ServerPort="26900"; + ServerIsPublic="true"; + ServerName="Serveur des loutres"; + ServerPassword=""; + ServerMaxPlayerCount="16"; + ServerReservedSlots="0"; + ServerReservedSlotsPermission="100"; + ServerAdminSlots="0"; + ServerAdminSlotsPermission="0"; + ServerDescription="Un serveur idiot anti gilets jaunes"; + ServerWebsiteURL=""; + ServerDisabledNetworkProtocols="UNET"; + GameWorld="Random Gen"; + GameName="Loutre Game"; + GameDifficulty="2"; + GameMode="GameModeSurvivalMP"; + ZombiesRun="0"; + BuildCreate="false"; + DayNightLength="60"; + DayLightLength="18"; + PlayerKillingMode="3"; + PersistentPlayerProfiles="false"; + PlayerSafeZoneLevel="5"; + PlayerSafeZoneHours="5"; + ControlPanelEnabled="false"; + ControlPanelPort="8080"; + ControlPanelPassword="CHANGEME"; + TelnetEnabled="false"; + TelnetPort="8081"; + TelnetPassword=""; + AdminFileName="serveradmin.xml"; + DropOnDeath="0"; + DropOnQuit="0"; + BloodMoonEnemyCount="8"; + EnemySpawnMode="true"; + EnemyDifficulty="0"; + BlockDurabilityModifier="100"; + LootAbundance="100"; + LootRespawnDays="30"; + LandClaimSize="41"; + LandClaimDeadZone="30"; + LandClaimExpiryTime="3"; + LandClaimDecayMode="0"; + LandClaimOnlineDurabilityModifier="4"; + LandClaimOfflineDurabilityModifier="4"; + AirDropFrequency="72"; + AirDropMarker="false"; + MaxSpawnedZombies="60"; + MaxSpawnedAnimals="50"; + EACEnabled="true"; + HideCommandExecutionLog="0"; + MaxUncoveredMapChunksPerPlayer="131072"; + BedrollDeadZoneSize="15"; + }; + gameConfig = builtins.toFile "serverconfig.xml" '' + + + ${concatStrings ( + mapAttrsToList (name: value: + " \n" + ) gameOptions)} + + ''; +in +{ + options.services.sdtdserver = { + enable = mkEnableOption "Activation du serveur dédié 7 Days to Die"; + }; + + config = mkIf cfg.enable { + + systemd.services.sdtdserver = { + description = "Serveur dédié 7 Days to Die"; + requires = ["network-online.target"]; + wantedBy = ["multi-user.target"]; + environment = { HOME = gamePath; }; + serviceConfig = { + DynamicUser = true; + StateDirectory = "sdtdserver"; + }; + preStart = let + libPath = with pkgs; lib.makeLibraryPath [ + stdenv.cc.cc.lib + ]; + in '' + ${pkgs.steamcmd}/bin/steamcmd +login anonymous +force_install_dir ${gamePath} +app_update 294420 validate +quit + ${pkgs.patchelf}/bin/patchelf \ + --set-interpreter "$(cat ${pkgs.gcc}/nix-support/dynamic-linker)" \ + --set-rpath "${libPath}" \ + ${gamePath}/7DaysToDieServer.x86_64 + install -m666 ${gameConfig} ${gamePath}/serverconfig.xml + ''; + script = '' + ${gamePath}/7DaysToDieServer.x86_64 -quit -batchmode -nographics -dedicated -configfile=serverconfig.xml + ''; + }; + + networking.firewall = { + allowedTCPPorts = [ 26900 ]; + allowedUDPPorts = [ 26900 26901 26902 ]; + }; + + }; + +} diff --git a/systems/LoutreOS/services.nix b/systems/LoutreOS/services.nix index 3a26b77..f246a1e 100644 --- a/systems/LoutreOS/services.nix +++ b/systems/LoutreOS/services.nix @@ -19,6 +19,7 @@ in ../../services/site-max.nix ../../services/auto-pr.nix ../../services/python-ci.nix + ../../services/sdtdserver.nix ../../containers/vsftpd.nix ]; @@ -360,6 +361,8 @@ in auto-pr.enable = true; python-ci.enable = true; + + sdtdserver.enable = true; }; /*