code now execute script from file
This commit is contained in:
3
gotosleep.sh
Normal file
3
gotosleep.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
|
||||
ssh root@192.168.0.22 shutdown now
|
||||
@@ -12,11 +12,11 @@ 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
|
||||
}
|
||||
Reference in New Issue
Block a user