1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use bollard::Docker;
use std::fs;
use super::log_exit;
use crate::docker::run_image;
use crate::file::get_jinx_files;
use crate::file::JinxFiles;
pub async fn run_letsencrypt_container(client: Docker, jinx_files: &JinxFiles, domain: String) {
let ports = vec!["80:80/tcp", "443:443/tcp"];
let conf = format!("{}:/etc/letsencrypt", jinx_files.letsencrypt_conf);
let www = format!("{}:/var/www/certbot", jinx_files.letsencrypt_www);
let volumes = vec![conf.as_str(), www.as_str()];
let std_domain = format!("-d {}", domain);
let www_domain = format!("-d www.{}", domain);
let cmds = vec![
"certonly",
"--register-unsafely-without-email",
"--agree-tos",
"--standalone",
std_domain.as_str(),
www_domain.as_str(),
];
run_image(client, "certbot/certbot", ports, volumes, None, Some(cmds)).await
}
pub fn write_letsencrypt() {
let jinx_files = get_jinx_files();
match fs::create_dir_all(jinx_files.letsencrypt_conf) {
Ok(dir) => dir,
Err(err) => log_exit!("[CERT] Failed to create letsencrypt conf directory", err),
};
match fs::create_dir_all(jinx_files.letsencrypt_www) {
Ok(dir) => dir,
Err(err) => log_exit!("[CERT] Failed to create letsencrypt www directory", err),
};
}