depend on proxmox 0.1.38, use new fs helper functions
This commit is contained in:
parent
f5056656b2
commit
3eeba68785
|
@ -36,7 +36,7 @@ pam = "0.7"
|
|||
pam-sys = "0.5"
|
||||
percent-encoding = "2.1"
|
||||
pin-utils = "0.1.0"
|
||||
proxmox = { version = "0.1.37", features = [ "sortable-macro", "api-macro" ] }
|
||||
proxmox = { version = "0.1.38", features = [ "sortable-macro", "api-macro" ] }
|
||||
#proxmox = { git = "ssh://gitolite3@proxdev.maurer-it.com/rust/proxmox", version = "0.1.2", features = [ "sortable-macro", "api-macro" ] }
|
||||
#proxmox = { path = "../proxmox/proxmox", features = [ "sortable-macro", "api-macro" ] }
|
||||
regex = "1.2"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anyhow::{bail, Error};
|
||||
use anyhow::{Error};
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
@ -113,16 +113,9 @@ pub const DATASTORE_CFG_FILENAME: &str = "/etc/proxmox-backup/datastore.cfg";
|
|||
pub const DATASTORE_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.datastore.lck";
|
||||
|
||||
pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
let content = match std::fs::read_to_string(DATASTORE_CFG_FILENAME) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
String::from("")
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", DATASTORE_CFG_FILENAME, err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let content = proxmox::tools::fs::file_read_optional_string(DATASTORE_CFG_FILENAME)?;
|
||||
let content = content.unwrap_or(String::from(""));
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
let data = CONFIG.parse(DATASTORE_CFG_FILENAME, &content)?;
|
||||
|
|
|
@ -477,24 +477,15 @@ pub const NETWORK_INTERFACES_FILENAME: &str = "/etc/network/interfaces";
|
|||
pub const NETWORK_INTERFACES_NEW_FILENAME: &str = "/etc/network/interfaces.new";
|
||||
pub const NETWORK_LOCKFILE: &str = "/var/lock/pve-network.lck";
|
||||
|
||||
|
||||
pub fn config() -> Result<(NetworkConfig, [u8;32]), Error> {
|
||||
let content = std::fs::read(NETWORK_INTERFACES_NEW_FILENAME)
|
||||
.or_else(|err| {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
std::fs::read(NETWORK_INTERFACES_FILENAME)
|
||||
.or_else(|err| {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
Ok(Vec::new())
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", NETWORK_INTERFACES_FILENAME, err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", NETWORK_INTERFACES_NEW_FILENAME, err);
|
||||
}
|
||||
})?;
|
||||
|
||||
let content = match proxmox::tools::fs::file_get_optional_contents(NETWORK_INTERFACES_NEW_FILENAME)? {
|
||||
Some(content) => content,
|
||||
None => {
|
||||
let content = proxmox::tools::fs::file_get_optional_contents(NETWORK_INTERFACES_FILENAME)?;
|
||||
content.unwrap_or(Vec::new())
|
||||
}
|
||||
};
|
||||
|
||||
let digest = openssl::sha::sha256(&content);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anyhow::{bail, Error};
|
||||
use anyhow::{Error};
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
@ -83,16 +83,9 @@ pub const REMOTE_CFG_FILENAME: &str = "/etc/proxmox-backup/remote.cfg";
|
|||
pub const REMOTE_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.remote.lck";
|
||||
|
||||
pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
let content = match std::fs::read_to_string(REMOTE_CFG_FILENAME) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
String::from("")
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", REMOTE_CFG_FILENAME, err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let content = proxmox::tools::fs::file_read_optional_string(REMOTE_CFG_FILENAME)?;
|
||||
let content = content.unwrap_or(String::from(""));
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
let data = CONFIG.parse(REMOTE_CFG_FILENAME, &content)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use anyhow::{bail, Error};
|
||||
use anyhow::{Error};
|
||||
use lazy_static::lazy_static;
|
||||
use std::collections::HashMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
@ -83,16 +83,9 @@ pub const SYNC_CFG_FILENAME: &str = "/etc/proxmox-backup/sync.cfg";
|
|||
pub const SYNC_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.sync.lck";
|
||||
|
||||
pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
let content = match std::fs::read_to_string(SYNC_CFG_FILENAME) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
String::from("")
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", SYNC_CFG_FILENAME, err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let content = proxmox::tools::fs::file_read_optional_string(SYNC_CFG_FILENAME)?;
|
||||
let content = content.unwrap_or(String::from(""));
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
let data = CONFIG.parse(SYNC_CFG_FILENAME, &content)?;
|
||||
|
|
|
@ -120,16 +120,9 @@ pub const USER_CFG_FILENAME: &str = "/etc/proxmox-backup/user.cfg";
|
|||
pub const USER_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.user.lck";
|
||||
|
||||
pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
let content = match std::fs::read_to_string(USER_CFG_FILENAME) {
|
||||
Ok(c) => c,
|
||||
Err(err) => {
|
||||
if err.kind() == std::io::ErrorKind::NotFound {
|
||||
String::from("")
|
||||
} else {
|
||||
bail!("unable to read '{}' - {}", USER_CFG_FILENAME, err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let content = proxmox::tools::fs::file_read_optional_string(USER_CFG_FILENAME)?;
|
||||
let content = content.unwrap_or(String::from(""));
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
let mut data = CONFIG.parse(USER_CFG_FILENAME, &content)?;
|
||||
|
|
Loading…
Reference in New Issue