mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
adds bep to embassy startup sequence (#468)
* adds bep to embassy startup sequence * always run postinit * Update appmgr/src/bin/embassy-init.rs Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
committed by
Aiden McClelland
parent
db91e2396f
commit
288ad14060
@@ -115,15 +115,12 @@ async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// BLOCKING
|
||||
fn run_script_if_exists<P: AsRef<Path>>(path: P) {
|
||||
use std::process::Command;
|
||||
|
||||
async fn run_script_if_exists<P: AsRef<Path>>(path: P) {
|
||||
let script = path.as_ref();
|
||||
if script.exists() {
|
||||
match Command::new("/bin/bash").arg(script).spawn() {
|
||||
Ok(mut c) => {
|
||||
if let Err(e) = c.wait() {
|
||||
if let Err(e) = c.wait().await {
|
||||
log::error!("Error Running {}: {}", script.display(), e)
|
||||
}
|
||||
}
|
||||
@@ -133,28 +130,40 @@ fn run_script_if_exists<P: AsRef<Path>>(path: P) {
|
||||
}
|
||||
|
||||
async fn inner_main(cfg_path: Option<&str>) -> Result<(), Error> {
|
||||
if let Err(e) = init(cfg_path).await {
|
||||
log::error!("{}", e.source);
|
||||
log::debug!("{}", e.source);
|
||||
embassy::sound::BEETHOVEN.play().await?;
|
||||
let ctx = RecoveryContext::init(cfg_path).await?;
|
||||
rpc_server!({
|
||||
command: embassy::recovery_api,
|
||||
context: ctx.clone(),
|
||||
status: status_fn,
|
||||
middleware: [ ]
|
||||
})
|
||||
.with_graceful_shutdown({
|
||||
let mut shutdown = ctx.shutdown.subscribe();
|
||||
async move {
|
||||
shutdown.recv().await.expect("context dropped");
|
||||
}
|
||||
})
|
||||
.await
|
||||
.with_kind(embassy::ErrorKind::Network)?;
|
||||
}
|
||||
embassy::sound::BEP.play().await?;
|
||||
|
||||
Ok(())
|
||||
run_script_if_exists("/embassy-os/preinit.sh").await;
|
||||
|
||||
let res = if let Err(e) = init(cfg_path).await {
|
||||
(|| async {
|
||||
log::error!("{}", e.source);
|
||||
log::debug!("{}", e.source);
|
||||
embassy::sound::BEETHOVEN.play().await?;
|
||||
let ctx = RecoveryContext::init(cfg_path).await?;
|
||||
rpc_server!({
|
||||
command: embassy::recovery_api,
|
||||
context: ctx.clone(),
|
||||
status: status_fn,
|
||||
middleware: [ ]
|
||||
})
|
||||
.with_graceful_shutdown({
|
||||
let mut shutdown = ctx.shutdown.subscribe();
|
||||
async move {
|
||||
shutdown.recv().await.expect("context dropped");
|
||||
}
|
||||
})
|
||||
.await
|
||||
.with_kind(embassy::ErrorKind::Network)?;
|
||||
Ok::<_, Error>(())
|
||||
})()
|
||||
.await
|
||||
} else {
|
||||
Ok(())
|
||||
};
|
||||
|
||||
run_script_if_exists("/embassy-os/postinit.sh").await;
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -183,8 +192,6 @@ fn main() {
|
||||
});
|
||||
let cfg_path = matches.value_of("config");
|
||||
|
||||
run_script_if_exists("/embassy-os/preinit.sh");
|
||||
|
||||
let res = {
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
@@ -193,8 +200,6 @@ fn main() {
|
||||
rt.block_on(inner_main(cfg_path))
|
||||
};
|
||||
|
||||
run_script_if_exists("/embassy-os/postinit.sh");
|
||||
|
||||
match res {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
|
||||
@@ -337,6 +337,8 @@ macro_rules! song {
|
||||
};
|
||||
}
|
||||
|
||||
pub const BEP: Song<[(Option<Note>, TimeSlice); 1]> = song!(120, [note(A, 4, Quarter);]);
|
||||
|
||||
pub const MARIO_DEATH: Song<[(Option<Note>, TimeSlice); 12]> = song!(400, [
|
||||
note(B, 4, Quarter);
|
||||
note(F, 5, Quarter);
|
||||
|
||||
Reference in New Issue
Block a user