From ea905dfc251d055041824ad05be2b79d186866a8 Mon Sep 17 00:00:00 2001 From: turtel Date: Sun, 18 Feb 2024 20:25:16 +0100 Subject: [PATCH] code now execute script from file --- gotosleep.sh | 3 +++ src/main.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 gotosleep.sh diff --git a/gotosleep.sh b/gotosleep.sh new file mode 100644 index 0000000..980ba90 --- /dev/null +++ b/gotosleep.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +ssh root@192.168.0.22 shutdown now \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index def8965..6c4cbdd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,12 +12,12 @@ async fn index(name: web::Path) -> Result { name: name.to_string(), }; - let mut sleep_command = Command::new("ssh root@192.168.0.22 shutdown now"); + let mut sleep_command = Command::new("gotosleep.sh"); let name = name.to_string(); if name == "penis" { - sleep_command.status().expect("failed to shutdown serwer"); - } + sleep_command.status().expect("failed to send command"); + } Ok(web::Json(obj)) } @@ -26,7 +26,7 @@ async fn main() -> std::io::Result<()> { use actix_web::{App, HttpServer}; HttpServer::new(|| App::new().service(index)) - .bind(("192.168.0.10", 2137))? + .bind(("0.0.0.0", 2137))? .run() .await } \ No newline at end of file