This commit is contained in:
Maurice
2025-10-22 16:59:26 +02:00
parent 1953f8cf1c
commit 23fc91f54e
3 changed files with 8 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ image = "<IMAGE>" # Podman image name
depend = ["<SERVICE NAME>"] # Name of any service in /etc/init.d to depend on depend = ["<SERVICE NAME>"] # Name of any service in /etc/init.d to depend on
restart = "unless-stopped" # Restart, optional. Defaults to "unless-stopped" restart = "unless-stopped" # Restart, optional. Defaults to "unless-stopped"
detach = true # Run container in detach mode, optional, default true. Recommended. detach = true # Run container in detach mode, optional, default true. Recommended.
interactive = false # Run container in interactive mode, optional, default false
hostname = "<HOSTNAME>" # Host name, optional. hostname = "<HOSTNAME>" # Host name, optional.
command = "<COMMAND>" # Container command to run, optional. command = "<COMMAND>" # Container command to run, optional.

View File

@@ -40,7 +40,7 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
script.push_str("start_pre() {\n"); script.push_str("start_pre() {\n");
let mut start_pre_commands = Vec::new(); let mut start_pre_commands = Vec::new();
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name)); start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
for network in networks.iter() { for network in networks.iter().filter(|n| *n != "host" && *n != "bridge") {
start_pre_commands.push(format!("podman network create {} --ignore;", network)); start_pre_commands.push(format!("podman network create {} --ignore;", network));
} }
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) { for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {
@@ -73,6 +73,10 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
arguments.push("--detach".to_string()); arguments.push("--detach".to_string());
} }
if config.service.interactive.unwrap_or(false) {
arguments.push("--interactive".to_string());
}
for network in networks.iter() { for network in networks.iter() {
arguments.push(format!("--network {}", network)); arguments.push(format!("--network {}", network));
} }
@@ -177,7 +181,7 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
script.push_str("cleanup() {\n"); script.push_str("cleanup() {\n");
let mut cleanup_commands = Vec::new(); let mut cleanup_commands = Vec::new();
cleanup_commands.push(format!("podman rm {} --ignore --force;", config.service.name)); cleanup_commands.push(format!("podman rm {} --ignore --force;", config.service.name));
for network in networks.iter() { for network in networks.iter().filter(|n| *n != "host" && *n != "bridge") {
cleanup_commands.push(format!("podman network rm {} --force;", network)); cleanup_commands.push(format!("podman network rm {} --force;", network));
} }
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) { for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {

View File

@@ -41,6 +41,7 @@ pub struct Service {
pub restart: Option<String>, pub restart: Option<String>,
pub detach: Option<bool>, pub detach: Option<bool>,
pub interactive: Option<bool>,
pub healthcheck: Option<HealthCheck>, pub healthcheck: Option<HealthCheck>,
pub command: Option<String>, pub command: Option<String>,