allow setting extra_cfg

This commit is contained in:
Robin Appelman 2024-03-02 15:17:20 +01:00
commit c00b7b4ab8
3 changed files with 26 additions and 15 deletions

View file

@ -67,6 +67,11 @@ in {
type = types.bool;
description = "Take control of existing server";
};
extra_cfg = mkOption {
type = types.str;
description = "Extra config lines to set in the tf2 config";
default = "";
};
};
};
};

View file

@ -118,6 +118,8 @@ pub struct ServerConfig {
pub ssh_keys: Vec<String>,
#[serde(default)]
pub manage_existing: bool,
#[serde(default)]
pub extra_cfg: String,
}
fn server_default_image() -> String {

View file

@ -102,12 +102,12 @@ async fn setup(
}
info!("starting container");
let result = ssh
.exec(format!(
let cmnd = format!(
"docker run --name spire -d \
-e NAME={name} -e TV_NAME={tv_name} -e PASSWORD={password} -e RCON_PASSWORD={rcon} \
-e DEMOSTF_APIKEY={demostf} -e LOGSTF_APIKEY={logstf} \
-e CONFIG_LEAGUE={league} -e CONFIG_MODE={mode} \
-e CONFIG_LEAGUE={league} -e CONFIG_MODE={mode} -e 'EXTRA_CFG={extra_cfg}' \
-p 27015:27015 -p 27021:27021 -p 27015:27015/udp -p 27020:27020/udp -p 27025:27025 \
-p 28015:27015 -p 28015:27015/udp -p 27115:27015 -p 27115:27015/udp -p 27215:27015 \
-p 27215:27015/udp -p 27315:27015 -p 27315:27015/udp -p 27415:27015 -p 27415:27015/udp \
@ -123,9 +123,13 @@ async fn setup(
logstf = config.logstf_key.as_deref().unwrap_or_default(),
league = config.config_league,
mode = config.config_mode,
image = config.image
))
.await?;
image = config.image,
extra_cfg = config.extra_cfg,
);
debug!("running {cmnd}");
let result = ssh.exec(cmnd).await?;
if !result.success() {
return Err(Error::SetupError(result.output()));