jinx_proxy/
file.rs

1use dirs;
2use serde_derive::{Deserialize, Serialize};
3
4use super::log_exit;
5
6// Struct that contains Jinx home, Jinx configuration, and Nginx configuration paths
7#[derive(Debug, Deserialize, Serialize, Clone)]
8pub struct JinxFiles {
9  pub jinx_home: String,
10  pub jinx_conf: String,
11  pub nginx_conf: String,
12  pub letsencrypt_conf: String,
13  pub letsencrypt_www: String,
14}
15
16// returns JinxFiles
17pub fn get_jinx_files() -> JinxFiles {
18  // get users home directory
19  let home_dir = match dirs::home_dir() {
20    None => log_exit!("[JINX] Failed to get home directory"),
21    Some(dir) => dir,
22  };
23
24  // create jinx file paths
25  let jinx_home = format!("{}/.jinx", home_dir.display());
26  let jinx_conf = format!("{}/jinx_conf.json", jinx_home);
27  let nginx_conf = format!("{}/nginx.conf", jinx_home);
28  let letsencrypt_conf = format!("{}/letsencrypt/conf", jinx_home);
29  let letsencrypt_www = format!("{}/letsencrypt/www", jinx_home);
30
31  JinxFiles {
32    jinx_home,
33    jinx_conf,
34    nginx_conf,
35    letsencrypt_conf,
36    letsencrypt_www,
37  }
38}