--- a/drivers/thermald/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ b/drivers/thermald/Cargo.toml 2026-05-03 15:54:52.487976196 +0100 @@ -0,0 +1,12 @@ +[package] +name = "thermald" +version = "0.1.0" +edition = "2021" + +[dependencies] +log.workspace = true +anyhow.workspace = true +common = { path = "../common" } + +[lints] +workspace = true --- a/drivers/thermald/src/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ b/drivers/thermald/src/main.rs 2026-05-03 15:54:52.488780946 +0100 @@ -0,0 +1,30 @@ +use anyhow::{Context, Result}; +use std::{thread, time}; + +fn read_temp() -> Option { + for zone in 0..4 { + let path = format!("/scheme/acpi/thermal_zone/{}/temperature", zone); + if let Ok(data) = std::fs::read_to_string(&path) { + if let Ok(mv) = data.trim().parse::() { + return Some(mv as f32 / 1000.0); + } + } + } + None +} + +fn main() -> Result<()> { + common::setup_logging("system", "thermald", "thermald", + common::output_level(), common::file_level()); + log::info!("thermald: started"); + loop { + if let Some(temp) = read_temp() { + if temp > 85.0 { + log::error!("thermald: CRITICAL {:.1}C", temp); + } else if temp > 70.0 { + log::warn!("thermald: WARNING {:.1}C", temp); + } + } + thread::sleep(time::Duration::from_secs(5)); + } +} --- a/init.d/30_thermald.service 1970-01-01 00:00:00.000000000 +0000 +++ b/init.d/30_thermald.service 2026-05-03 15:54:52.489441597 +0100 @@ -0,0 +1,7 @@ +[unit] +description = "CPU Thermal Monitor" +requires_weak = ["00_base.target"] + +[service] +cmd = "thermald" +type = "oneshot_async"