wip: PXE setup for ipxe and okd files in progress
Some checks failed
Run Check Script / check (pull_request) Failing after 36s
Some checks failed
Run Check Script / check (pull_request) Failing after 36s
This commit is contained in:
@@ -70,6 +70,10 @@ impl Config {
|
||||
self.shell.upload_folder(source, destination).await
|
||||
}
|
||||
|
||||
pub async fn upload_file_content(&self, path: &str, content: &str) -> Result<String, Error> {
|
||||
self.shell.write_content_to_file(content, path).await
|
||||
}
|
||||
|
||||
/// Checks in config file if system.firmware.plugins csv field contains the specified package
|
||||
/// name.
|
||||
///
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::Error;
|
||||
pub trait OPNsenseShell: std::fmt::Debug + Send + Sync {
|
||||
async fn exec(&self, command: &str) -> Result<String, Error>;
|
||||
async fn write_content_to_temp_file(&self, content: &str) -> Result<String, Error>;
|
||||
async fn write_content_to_file(&self, content: &str, filename: &str) -> Result<String, Error>;
|
||||
async fn upload_folder(&self, source: &str, destination: &str) -> Result<String, Error>;
|
||||
}
|
||||
|
||||
@@ -25,6 +26,14 @@ impl OPNsenseShell for DummyOPNSenseShell {
|
||||
async fn write_content_to_temp_file(&self, _content: &str) -> Result<String, Error> {
|
||||
unimplemented!("This is a dummy implementation");
|
||||
}
|
||||
|
||||
async fn write_content_to_file(
|
||||
&self,
|
||||
_content: &str,
|
||||
_filename: &str,
|
||||
) -> Result<String, Error> {
|
||||
unimplemented!("This is a dummy implementation");
|
||||
}
|
||||
async fn upload_folder(&self, _source: &str, _destination: &str) -> Result<String, Error> {
|
||||
unimplemented!("This is a dummy implementation");
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ impl OPNsenseShell for SshOPNSenseShell {
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
);
|
||||
self.write_content_to_file(content, &temp_filename).await
|
||||
}
|
||||
|
||||
async fn write_content_to_file(&self, content: &str, filename: &str) -> Result<String, Error> {
|
||||
// TODO fix this to create the directory before uploading the file
|
||||
let channel = self.get_ssh_channel().await?;
|
||||
channel
|
||||
.request_subsystem(true, "sftp")
|
||||
@@ -53,10 +58,10 @@ impl OPNsenseShell for SshOPNSenseShell {
|
||||
.await
|
||||
.expect("Should acquire sftp subsystem");
|
||||
|
||||
let mut file = sftp.create(&temp_filename).await.unwrap();
|
||||
let mut file = sftp.create(filename).await.unwrap();
|
||||
file.write_all(content.as_bytes()).await?;
|
||||
|
||||
Ok(temp_filename)
|
||||
Ok(filename.to_string())
|
||||
}
|
||||
|
||||
async fn upload_folder(&self, source: &str, destination: &str) -> Result<String, Error> {
|
||||
|
||||
Reference in New Issue
Block a user