devops_armory/ini_parser/
parser.rs1use std::path::Path;
2
3use ini::Ini;
4
5pub fn ini_parser(
8 section_unit: &str,
9 description: &str,
10 after: &str,
11 section_service: &str,
12 environment: &str,
13 r#type: &str,
14 user: &str,
15 working_directory: &str,
16 exec_start: &str,
17 restart: &str,
18 restart_delay: &str,
19 std_out: &str,
20 std_err: &str,
21 section_install: &str,
22 wanted_by: &str,
23 filename: &Path
24) {
25 let mut conf = Ini::new();
27
28 conf.with_section(Some(section_unit))
29 .set("Description", description)
30 .set("After", after);
31 conf.with_section(Some(section_service))
32 .set("Environment", environment)
33 .set("Type", r#type)
34 .set("User", user)
35 .set("WorkingDirectory", working_directory)
36 .set("ExecStart", exec_start)
37 .set("Restart", restart)
38 .set("RestartSec", restart_delay)
39 .set("StandardOutput", std_out)
40 .set("StandardError", std_err);
41 conf.with_section(Some(section_install))
42 .set("WantedBy", wanted_by);
43 conf.write_to_file(filename).unwrap();
44
45}