diff --git a/Cargo.lock b/Cargo.lock index e5905b3..34d2924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,6 +29,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +[[package]] +name = "emojis-rs" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5c5d55d32597632ca64765dd57c1e71aaa51e69f663671fdc955950062c38ff" + [[package]] name = "libc" version = "0.2.174" @@ -143,6 +149,7 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" name = "ssh-test" version = "0.1.0" dependencies = [ + "emojis-rs", "ssh2", ] diff --git a/Cargo.toml b/Cargo.toml index faaec5c..506336a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,5 @@ version = "0.1.0" edition = "2024" [dependencies] +emojis-rs = "0.1.3" ssh2 = "0.9.5" diff --git a/src/main.rs b/src/main.rs index 4b64d7f..0f475bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ +use std::io::prelude::*; use std::net::TcpStream; use ssh2::Session; +use emojis_rs::*; const USER: &str = "aaronh"; const EDI: &str = "100.94.173.5:22"; @@ -16,9 +18,22 @@ fn main() { sess.userauth_agent(USER).unwrap(); if sess.authenticated() { - println!("Authentication successful!"); + println!("Authentication successful! {EMOJI_CHECK}"); } else { - println!("Authentication failed!"); + println!("Authentication failed! {EMOJI_CROSS}"); } + let mut channel = sess.channel_session().unwrap(); + channel.exec("systemctl is-active gollum").unwrap(); + let mut s = String::new(); + channel.read_to_string(&mut s).unwrap(); + channel.wait_close().unwrap(); + + let exit_code = channel.exit_status().unwrap(); + + if exit_code == 0 { + println!("Gollum service is active {EMOJI_CHECK}"); + } else { + println!("Gollum service is inactive {EMOJI_CROSS}(exit code: {})", exit_code); + } }