diff --git a/README.md b/README.md index 3531265..38d59e6 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,5 @@ You don't need to do both of these steps. The control panel runs the other serve 3. Install rust: `sudo apt install cargo` 3. Switch to control panel: `cd control-panel` 5. Build: `cargo build --release` -6. Run the web server in the background so that it doesn't quit when you leave ssh: `nohup sudo ./target/release/control-panel`. You'll have to install `nohup` with apt. \ No newline at end of file +6. `touch ../nohup.out ../restarts.log` +6. Run the web server in the background so that it doesn't quit when you leave ssh: `nohup sudo ./target/release/control-panel`. You'll have to install `nohup` with apt. diff --git a/config.txt b/config.txt index 0fe8d74..fbdf4df 100644 --- a/config.txt +++ b/config.txt @@ -1,5 +1,5 @@ { -"port":80, +"port":5000, "tcp_timeout":30, "tcp_send_buffer":100000 -} \ No newline at end of file +} diff --git a/control-panel/.gitignore b/control-panel/.gitignore index 2416ccc..25e2461 100644 --- a/control-panel/.gitignore +++ b/control-panel/.gitignore @@ -4,3 +4,4 @@ main main.exe main.pdb .idea/ +onefetch.out diff --git a/control-panel/onefetch_file.sh b/control-panel/onefetch_file.sh new file mode 100755 index 0000000..9e241f2 --- /dev/null +++ b/control-panel/onefetch_file.sh @@ -0,0 +1 @@ +sudo -u ubuntu bash -c "onefetch > onefetch.out" diff --git a/control-panel/src/main.rs b/control-panel/src/main.rs index 6d9de42..d5916ba 100644 --- a/control-panel/src/main.rs +++ b/control-panel/src/main.rs @@ -31,7 +31,6 @@ fn lines_from_file(filename: impl AsRef) -> Vec { .collect() } -// Macro documentation can be found in the actix_web_codegen crate #[get("/")] async fn index(hb: web::Data>) -> HttpResponse { @@ -47,11 +46,20 @@ async fn index(hb: web::Data>) -> HttpResponse { .output() .expect("failed to execute process"); + let _onefetch = Command::new("sh") + .arg("onefetch_file.sh") + .output() + .expect("failed"); + + let onefetch = fs::read_to_string("onefetch.out").unwrap(); + let data = json!({ "log_output": log_file, "restarts_output": restarts_log, "uptime": format!("{}", String::from_utf8_lossy(&uptime.stdout)), + //"onefetch": format!("{}", String::from_utf8_lossy(&onefetch.stdout)) + "onefetch": onefetch }); let body = hb.render("index", &data).unwrap(); @@ -65,8 +73,8 @@ async fn restart_server() -> HttpResponse { let _output = Command::new("sh") .arg("../run.sh") .stdin(Stdio::null()) - .stdout(Stdio::null()) - .stderr(Stdio::null()) + //.stdout(Stdio::null()) + //.stderr(Stdio::null()) .spawn(); HttpResponse::Ok().body("DONE") @@ -98,11 +106,15 @@ async fn compile() -> HttpResponse { let root = Path::new(&config.server_dir); let _new_dir = env::set_current_dir(&root); + print!("before"); + let output = Command::new("cargo") .arg("build") .arg("--release") .output() .expect("failed to execute process"); + + print!("after"); let _new_dir = env::set_current_dir(orig_dir); diff --git a/control-panel/static/templates/index.hbs b/control-panel/static/templates/index.hbs index bf09a2e..bfbb296 100644 --- a/control-panel/static/templates/index.hbs +++ b/control-panel/static/templates/index.hbs @@ -24,6 +24,7 @@
+

VelNet Control Panel

@@ -42,6 +43,7 @@
Uptime: {{uptime}}
+
{{onefetch}}
@@ -113,4 +115,4 @@ - \ No newline at end of file + diff --git a/run.sh b/run.sh index 65e21c8..7f8e88e 100755 --- a/run.sh +++ b/run.sh @@ -1,13 +1,15 @@ +#!/bin/bash + BASEDIR=$(dirname "$0") -# pushd $BASEDIR echo $(date +"%Y-%m-%dT%T.%3N%z") >> $BASEDIR/restarts.log -echo "Before: " -pgrep VelNetServer -pkill VelNetServer -echo "\nAfter: " -pgrep VelNetServer +echo "Before: " >> $BASEDIR/restarts.log +pgrep -f "VelNetServerRust -v2" >> $BASEDIR/restarts.log +#pgrep -f "VelNetServerRust -v2" | xargs sudo kill >> $BASEDIRE/restarts.log +#kill $(pgrep -f "VelNetServerRust -v2") +pkill -f "VelNetServerRust -v2" +echo "\nAfter: " >> $BASEDIR/restarts.log +pgrep -f "VelNetServerRust -v2" >> $BASEDIR/restarts.log echo "\n" -(cd $BASEDIR && nohup "./target/release/VelNetServerRust" &) +(cd $BASEDIR && nohup ./target/release/VelNetServerRust -v2 >> nohup.out &) # nohup "$BASEDIR/target/release/VelNetServerRust" & echo "Starting..." >> $BASEDIR/restarts.log -# popd $BASEDIR \ No newline at end of file