|
|
|
@@ -348,6 +348,94 @@ async fn lifecycle(ip_s: &str, verb: &str) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Read (no tz arg) or set the miner's timezone (round 16 / G10). Capability-gated.
|
|
|
|
|
async fn timezone(ip_s: &str, tz: Option<&str>) {
|
|
|
|
|
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
|
|
|
|
|
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
|
|
|
|
|
eprintln!("bad ip {ip_s}");
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
match factory().scan_miner(ip).await {
|
|
|
|
|
Ok(Some(m)) => {
|
|
|
|
|
if !m.supports_timezone_config() {
|
|
|
|
|
eprintln!("{ip}: timezone config not supported");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if let Some(tz_s) = tz {
|
|
|
|
|
let Ok(zone) = tz_s.parse::<Tz>() else {
|
|
|
|
|
eprintln!("bad IANA timezone '{tz_s}' (e.g. America/Edmonton)");
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let cfg = TimezoneConfig {
|
|
|
|
|
timezone: Some(zone),
|
|
|
|
|
available: Vec::new(),
|
|
|
|
|
};
|
|
|
|
|
match m.set_timezone_config(cfg).await {
|
|
|
|
|
Ok(v) => println!("{ip} set timezone {zone} -> Ok({v})"),
|
|
|
|
|
Err(e) => println!("{ip} set timezone -> Err: {e:#}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
match m.get_timezone_config().await {
|
|
|
|
|
Ok(c) => println!(
|
|
|
|
|
"{ip} timezone now: {:?} ({} available)",
|
|
|
|
|
c.timezone.map(|t| t.to_string()),
|
|
|
|
|
c.available.len()
|
|
|
|
|
),
|
|
|
|
|
Err(e) => println!("{ip} read timezone -> Err: {e:#}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(None) => eprintln!("no miner at {ip}"),
|
|
|
|
|
Err(e) => eprintln!("scan_miner {ip}: {e}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Change the miner's web/API password (round 16 / G11). Capability-gated.
|
|
|
|
|
/// DANGEROUS: a failed change can lock the toolkit out -- use a dedicated unit.
|
|
|
|
|
async fn passwd(ip_s: &str, newpass: &str) {
|
|
|
|
|
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
|
|
|
|
|
eprintln!("bad ip {ip_s}");
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
match factory().scan_miner(ip).await {
|
|
|
|
|
Ok(Some(mut m)) => {
|
|
|
|
|
if !m.supports_change_password() {
|
|
|
|
|
eprintln!("{ip}: change password not supported");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
match m.change_password(newpass).await {
|
|
|
|
|
Ok(v) => println!("{ip} change_password -> Ok({v})"),
|
|
|
|
|
Err(e) => println!("{ip} change_password -> Err: {e:#}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(None) => eprintln!("no miner at {ip}"),
|
|
|
|
|
Err(e) => eprintln!("scan_miner {ip}: {e}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Factory-reset the miner (round 16 / G12). Capability-gated. DESTRUCTIVE:
|
|
|
|
|
/// wipes config and may reset the network (unit can drop off its IP) -- only run
|
|
|
|
|
/// on a sacrificial/console-attached unit.
|
|
|
|
|
async fn factoryreset(ip_s: &str) {
|
|
|
|
|
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
|
|
|
|
|
eprintln!("bad ip {ip_s}");
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
match factory().scan_miner(ip).await {
|
|
|
|
|
Ok(Some(m)) => {
|
|
|
|
|
if !m.supports_factory_reset() {
|
|
|
|
|
eprintln!("{ip}: factory reset not supported");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
match m.factory_reset().await {
|
|
|
|
|
Ok(v) => println!("{ip} factory_reset -> Ok({v})"),
|
|
|
|
|
Err(e) => println!("{ip} factory_reset -> Err: {e:#}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(None) => eprintln!("no miner at {ip}"),
|
|
|
|
|
Err(e) => eprintln!("scan_miner {ip}: {e}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let args: Vec<String> = std::env::args().collect();
|
|
|
|
|
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
|
|
|
@@ -379,6 +467,10 @@ fn main() {
|
|
|
|
|
rt.block_on(setpools(&args[2], &args[3], &args[4], &args[5]))
|
|
|
|
|
}
|
|
|
|
|
Some("msgs") if args.len() == 3 => rt.block_on(msgs(&args[2])),
|
|
|
|
|
Some("timezone") if args.len() == 3 => rt.block_on(timezone(&args[2], None)),
|
|
|
|
|
Some("timezone") if args.len() == 4 => rt.block_on(timezone(&args[2], Some(&args[3]))),
|
|
|
|
|
Some("passwd") if args.len() == 4 => rt.block_on(passwd(&args[2], &args[3])),
|
|
|
|
|
Some("factoryreset") if args.len() == 3 => rt.block_on(factoryreset(&args[2])),
|
|
|
|
|
_ => {
|
|
|
|
|
eprintln!(
|
|
|
|
|
"miner_probe -- asic-rs config + scan CLI for the alkane-toolkit fleet\n\
|
|
|
|
@@ -396,6 +488,9 @@ fn main() {
|
|
|
|
|
\x20 restart <ip> restart/reboot\n\
|
|
|
|
|
\x20 setpl <ip> <watts> set power limit\n\
|
|
|
|
|
\x20 setpools <ip> <url> <user> <pass> set the default pool group\n\
|
|
|
|
|
\x20 timezone <ip> [<IANA>] read (no arg) or set the timezone\n\
|
|
|
|
|
\x20 passwd <ip> <newpass> change the web/API password (DANGEROUS)\n\
|
|
|
|
|
\x20 factoryreset <ip> factory reset (DESTRUCTIVE; sacrificial units only)\n\
|
|
|
|
|
\n\
|
|
|
|
|
Each write verb is capability-gated (skips miners that do not support it).\n\
|
|
|
|
|
Credentials: ALKANE_PROBE_USER/PASS or ~/.config/alkane-toolkit/scan-credentials.txt."
|
|
|
|
|