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,12 +12,12 @@ async fn index(name: web::Path<String>) -> Result<impl Responder> {
|
|||||||
name: name.to_string(),
|
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();
|
let name = name.to_string();
|
||||||
if name == "penis" {
|
if name == "penis" {
|
||||||
sleep_command.status().expect("failed to shutdown serwer");
|
sleep_command.status().expect("failed to send command");
|
||||||
}
|
}
|
||||||
Ok(web::Json(obj))
|
Ok(web::Json(obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
use actix_web::{App, HttpServer};
|
use actix_web::{App, HttpServer};
|
||||||
|
|
||||||
HttpServer::new(|| App::new().service(index))
|
HttpServer::new(|| App::new().service(index))
|
||||||
.bind(("192.168.0.10", 2137))?
|
.bind(("0.0.0.0", 2137))?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user