Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor kernel interface to remove mock and global var #997

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions althea_kernel_interface/src/babel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::KernelInterface;
use crate::run_command;

impl dyn KernelInterface {
pub fn restart_babel(&self) {
let _res = self.run_command("/etc/init.d/babeld", &["restart"]);
}
pub fn restart_babel() {
let _res = run_command("/etc/init.d/babeld", &["restart"]);
}
14 changes: 6 additions & 8 deletions althea_kernel_interface/src/bridge_tools.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Simple helper functions for brctl
use super::KernelInterface;
use crate::run_command;
use crate::KernelInterfaceError as Error;
use std::process::Output;

impl dyn KernelInterface {
pub fn add_if_to_bridge(&self, br: &str, iface: &str) -> Result<Output, Error> {
self.run_command("brctl", &["addif", br, iface])
}
pub fn add_if_to_bridge(br: &str, iface: &str) -> Result<Output, Error> {
run_command("brctl", &["addif", br, iface])
}

pub fn del_if_from_bridge(&self, br: &str, iface: &str) -> Result<Output, Error> {
self.run_command("brctl", &["delif", br, iface])
}
pub fn del_if_from_bridge(br: &str, iface: &str) -> Result<Output, Error> {
run_command("brctl", &["delif", br, iface])
}
25 changes: 11 additions & 14 deletions althea_kernel_interface/src/check_cron.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use super::KernelInterface;
use crate::KernelInterfaceError as Error;
use std::process::{Command, Stdio};

impl dyn KernelInterface {
/// Checks if the cron service is running and starts it if it's not
pub fn check_cron(&self) -> Result<(), Error> {
Command::new("/etc/init.d/cron")
.args(["enable"])
.stdout(Stdio::piped())
.output()?;
Command::new("/etc/init.d/cron")
.args(["start"])
.stdout(Stdio::piped())
.output()?;
/// Checks if the cron service is running and starts it if it's not
pub fn check_cron() -> Result<(), Error> {
Command::new("/etc/init.d/cron")
.args(["enable"])
.stdout(Stdio::piped())
.output()?;
Command::new("/etc/init.d/cron")
.args(["start"])
.stdout(Stdio::piped())
.output()?;

Ok(())
}
Ok(())
}
Loading
Loading