code now execute script from file

This commit is contained in:
2024-02-18 20:25:16 +01:00
parent db240b0bd0
commit ea905dfc25
2 changed files with 7 additions and 4 deletions

3
gotosleep.sh Normal file
View File

@@ -0,0 +1,3 @@
#! /bin/bash
ssh root@192.168.0.22 shutdown now

View File

@@ -12,12 +12,12 @@ async fn index(name: web::Path<String>) -> Result<impl Responder> {
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
}