rollback makefile change
add ip addr command
This commit is contained in:
parent
8d6f07bc26
commit
aaff62cbc6
1
Makefile
1
Makefile
@ -12,7 +12,6 @@ release: clean
|
||||
@cargo build --release
|
||||
|
||||
update: release
|
||||
@git pull
|
||||
ifeq ($(UNAME), Darwin)
|
||||
cp target/release/bp ~/bin/
|
||||
endif
|
||||
|
15
src/sys.rs
15
src/sys.rs
@ -6,6 +6,8 @@ use core::str;
|
||||
pub enum SysCommand {
|
||||
/// Reboot breadpi.
|
||||
Reboot,
|
||||
/// Returns the local IP address of breadpi.
|
||||
Ip
|
||||
}
|
||||
|
||||
pub async fn handle_sys(cmd: &SysCommand) {
|
||||
@ -14,7 +16,8 @@ pub async fn handle_sys(cmd: &SysCommand) {
|
||||
.expect("Could not connect to breadpi");
|
||||
|
||||
match cmd {
|
||||
SysCommand::Reboot => { sys_reboot(&session).await; }
|
||||
SysCommand::Reboot => { sys_reboot(&session).await; },
|
||||
SysCommand::Ip => { ip_addr(&session).await; }
|
||||
}
|
||||
|
||||
let _ = session.close();
|
||||
@ -30,3 +33,13 @@ async fn sys_reboot(session: &Session) {
|
||||
println!("Error: {:?}", String::from_utf8(cmd.stderr));
|
||||
}
|
||||
}
|
||||
|
||||
async fn ip_addr(session: &Session) {
|
||||
let cmd = session.command("hostname")
|
||||
.arg("-I")
|
||||
.raw_arg("| grep -o '^[0-9.]*'")
|
||||
.output().await.unwrap();
|
||||
|
||||
|
||||
println!("{}", String::from_utf8(cmd.stdout).expect("nuh uh"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user