Update
This commit is contained in:
+18
-1
@@ -39,10 +39,13 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
// start_pre()
|
||||
script.push_str("start_pre() {\n");
|
||||
let mut start_pre_commands = Vec::new();
|
||||
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
|
||||
for network in networks.iter() {
|
||||
start_pre_commands.push(format!("podman network create {} --ignore;", network));
|
||||
}
|
||||
start_pre_commands.push(format!("podman rm {} --ignore;", config.service.name));
|
||||
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {
|
||||
start_pre_commands.push(format!("podman volume create {} --ignore;", volume.source));
|
||||
}
|
||||
script.push_str(&start_pre_commands.iter().map(|c|wrap(c)).collect::<Vec<String>>().join("\n"));
|
||||
script.push_str("\n}\n\n");
|
||||
// }
|
||||
@@ -167,6 +170,20 @@ pub fn generate_openrc(config: &ServiceConfig) -> String {
|
||||
"podman stop {} --ignore",
|
||||
config.service.name
|
||||
)));
|
||||
script.push_str("\n}\n\n");
|
||||
// }
|
||||
|
||||
// cleanup()
|
||||
script.push_str("cleanup() {\n");
|
||||
let mut cleanup_commands = Vec::new();
|
||||
cleanup_commands.push(format!("podman rm {} --ignore --force;", config.service.name));
|
||||
for network in networks.iter() {
|
||||
cleanup_commands.push(format!("podman network rm {} --force;", network));
|
||||
}
|
||||
for volume in config.volumes.iter().filter(|v| v.create.is_some_and(|c|c)) {
|
||||
cleanup_commands.push(format!("podman volume rm {} --force;", volume.source));
|
||||
}
|
||||
script.push_str(&cleanup_commands.iter().map(|c|wrap(c)).collect::<Vec<String>>().join("\n"));
|
||||
script.push_str("\n}\n");
|
||||
// }
|
||||
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ pub struct PortMapping {
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct VolumeMapping {
|
||||
pub source: String,
|
||||
pub target: String
|
||||
pub target: String,
|
||||
pub create: Option<bool>
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user