rename application
This commit is contained in:
parent
f2a26baf97
commit
e8b61d2caa
3 changed files with 19 additions and 17 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -265,6 +265,15 @@ version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "servus"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
"emojis-rs",
|
||||||
|
"ssh2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
@ -277,15 +286,6 @@ version = "1.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ssh-test"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
"emojis-rs",
|
|
||||||
"ssh2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ssh2"
|
name = "ssh2"
|
||||||
version = "0.9.5"
|
version = "0.9.5"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ssh-test"
|
name = "servus"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -10,9 +10,11 @@ use emojis_rs::*;
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
/// user needs access to systemd
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
username: String,
|
user: String,
|
||||||
|
|
||||||
|
/// include port number :22
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
ip: String,
|
ip: String,
|
||||||
}
|
}
|
||||||
|
@ -25,18 +27,18 @@ fn main() {
|
||||||
sess.set_tcp_stream(tcp);
|
sess.set_tcp_stream(tcp);
|
||||||
sess.handshake().expect("SSH handshake failed");
|
sess.handshake().expect("SSH handshake failed");
|
||||||
|
|
||||||
sess.userauth_agent(&args.username).expect("SSH authentication failed");
|
sess.userauth_agent(&args.user).expect("SSH authentication failed");
|
||||||
|
|
||||||
if sess.authenticated() {
|
if sess.authenticated() {
|
||||||
println!("Authentication successful! {EMOJI_CHECK}");
|
println!("{EMOJI_CHECK} Authentication successful!");
|
||||||
} else {
|
} else {
|
||||||
println!("Authentication failed! {EMOJI_CROSS}");
|
println!("{EMOJI_CROSS} Authentication failed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("-------------------------");
|
println!("-------------------------");
|
||||||
|
|
||||||
for service in ["gollum", "wastebin", "hydra-server"] {
|
for service in ["forgejo", "gollum", "hydra-server", "syncthing", "wastebin"] {
|
||||||
check_service_status(&sess, service);
|
check_service_status(&sess, service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +54,9 @@ fn check_service_status(sess: &Session, service: &str) {
|
||||||
let exit_code = channel.exit_status().expect("Failed to get exit status");
|
let exit_code = channel.exit_status().expect("Failed to get exit status");
|
||||||
|
|
||||||
if exit_code == 0 {
|
if exit_code == 0 {
|
||||||
println!("{service} service is active {EMOJI_CHECK}");
|
println!("{EMOJI_CHECK} {service} service is active");
|
||||||
} else {
|
} else {
|
||||||
println!("{service} service is inactive {EMOJI_CROSS} (exit code: {exit_code})");
|
println!("{EMOJI_CROSS} {service} service is inactive (exit code: {exit_code})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue