add srcds
This commit is contained in:
@@ -17,6 +17,10 @@ in {
|
||||
type = lib.types.int;
|
||||
default = 27015;
|
||||
};
|
||||
tv_port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 27016;
|
||||
};
|
||||
hostname = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "recoil.pro CS2";
|
||||
@@ -25,7 +29,7 @@ in {
|
||||
type = lib.types.str;
|
||||
default = "de_dust2";
|
||||
};
|
||||
maxPlayers = lib.mkOption {
|
||||
max_players = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 10;
|
||||
};
|
||||
@@ -51,6 +55,8 @@ in {
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
steamcmd
|
||||
steam-run
|
||||
rcon
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
@@ -61,7 +67,6 @@ in {
|
||||
environment.etc."cs2/server.cfg".text = ''
|
||||
hostname "${cfg.hostname}"
|
||||
sv_lan 0
|
||||
sv_visiblemaxplayers ${toString cfg.maxPlayers}
|
||||
rcon_password "$(<${config.sops.secrets."cs2/rcon".path})"
|
||||
mp_autoteambalance 1
|
||||
mp_limitteams 2
|
||||
@@ -95,22 +100,30 @@ in {
|
||||
serviceConfig = {
|
||||
User = "cs2";
|
||||
Group = "cs2";
|
||||
WorkingDirectory = "${cfg.data_dir}/server/game/bin/linuxsteamrt64";
|
||||
WorkingDirectory = "${cfg.data_dir}";
|
||||
Restart = "always";
|
||||
ExecStart = pkgs.writeShellScript "cs2-start" ''
|
||||
export GSLT=$(cat ${config.sops.secrets."cs2/gslt".path})
|
||||
exec ./cs2.sh \
|
||||
exec ${pkgs.steam-run}/bin/steam-run -- \
|
||||
${cfg.data_dir}/server/game/bin/linuxsteamrt64/cs2 \
|
||||
-dedicated \
|
||||
-usercon \
|
||||
-console \
|
||||
-port ${toString cfg.port} \
|
||||
-tv_port ${toString cfg.tv_port} \
|
||||
-maxplayers_override ${toString cfg.max_players} \
|
||||
+game_type 0 \
|
||||
+game_mode 1 \
|
||||
+mapgroup mg_active \
|
||||
+map ${cfg.map} \
|
||||
+sv_setsteamaccount "$GSLT" \
|
||||
+exec server.cfg
|
||||
+exec /etc/gameserver/cs2/server.cfg
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [cfg.port];
|
||||
networking.firewall.allowedUDPPorts = [cfg.port];
|
||||
networking.firewall.allowedTCPPorts = [cfg.port cfg.tv_port];
|
||||
networking.firewall.allowedUDPPorts = [cfg.port cfg.tv_port];
|
||||
|
||||
# backups cs2 server with borg!
|
||||
services.borgbackup.jobs.${service} = {
|
||||
|
||||
Reference in New Issue
Block a user