Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

motd: maintain a /etc/motd file with interesting info about the TAC #57

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/target
/.cargo
/demo_files/home/root/.ssh/authorized_keys
/demo_files/var/run/tacd/motd
/web/npm-shrinkwrap.json
/web/oe-logs
/web/oe-workdir
28 changes: 24 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod iobus;
mod journal;
mod led;
mod measurement;
mod motd;
mod regulators;
mod setup_mode;
mod system;
Expand All @@ -48,6 +49,7 @@ use dut_power::DutPwrThread;
use http_server::HttpServer;
use iobus::IoBus;
use led::Led;
use motd::Motd;
use regulators::Regulators;
use setup_mode::SetupMode;
use system::{HardwareGeneration, System};
Expand All @@ -57,7 +59,7 @@ use usb_hub::UsbHub;
use watchdog::Watchdog;
use watched_tasks::WatchedTasksBuilder;

async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)> {
async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder, Motd)> {
// The tacd spawns a couple of async tasks that should run as long as
// the tacd runs and if any one fails the tacd should stop.
// These tasks are spawned via the watched task builder.
Expand Down Expand Up @@ -133,6 +135,19 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)>
// in the web interface.
journal::serve(&mut http_server.server);

// Maintain a /etc/motd with useful information about the TAC.
// Keep a reference around because the motd file / bind mount is removed once
// the reference is dropped.
let motd = motd::Motd::new(
&mut wtb,
&dut_pwr,
&iobus,
&rauc,
&setup_mode,
&temperatures,
&usb_hub,
)?;

// Set up the user interface for the hardware display on the TAC.
// The different screens receive updates via the topics provided in
// the UiResources struct.
Expand Down Expand Up @@ -173,7 +188,7 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)>
watchdog.keep_fed(&mut wtb)?;
}

Ok((ui, wtb))
Ok((ui, wtb, motd))
}

#[async_std::main]
Expand All @@ -187,13 +202,18 @@ async fn main() -> Result<()> {
let screenshooter = display.screenshooter();

match init(screenshooter).await {
Ok((ui, mut wtb)) => {
Ok((ui, mut wtb, motd)) => {
// Start drawing the UI
ui.run(&mut wtb, display)?;

info!("Setup complete. Handling requests");

wtb.watch().await
let res = wtb.watch().await;

// Remove the motd so we do not leave stale information behind.
motd.remove();

res
}
Err(e) => {
// Display a detailed error message on stderr (and thus in the journal) ...
Expand Down
Loading
Loading