misc fixes

This commit is contained in:
Aiden McClelland
2021-09-06 17:58:48 -06:00
committed by Aiden McClelland
parent 73d7d3f855
commit ccf505d0d3
9 changed files with 27 additions and 9 deletions

View File

@@ -48,6 +48,13 @@ async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
false,
)
.await?;
// cp -r "/var/lib/docker", "/tmp/docker-data"
embassy::disk::util::bind(
"/tmp/docker-data",
"/var/lib/journal",
false,
)
.await?;
embassy::ssh::sync_keys_from_db(todo!(), "/root/.ssh/authorized_keys").await?;
todo!("sync wifi");
embassy::hostname::sync_hostname().await?;
@@ -92,8 +99,6 @@ async fn inner_main(cfg_path: Option<&str>) -> Result<(), Error> {
})
.await
.with_kind(embassy::ErrorKind::Network)?;
} else {
embassy::sound::MARIO_COIN.play().await?;
}
Ok(())

View File

@@ -200,6 +200,8 @@ async fn inner_main(cfg_path: Option<&str>) -> Result<Option<Shutdown>, Error> {
rpc_ctx.shutdown.subscribe(),
);
embassy::sound::MARIO_COIN.play().await?;
futures::try_join!(
server.map_err(|e| Error::new(e, ErrorKind::Network)),
revision_cache_task.map_err(|e| Error::new(

View File

@@ -61,9 +61,10 @@ impl RpcContextConfig {
.unwrap_or_else(|| Cow::Owned(Path::new("/").join(self.zfs_pool_name())))
}
pub async fn db(&self) -> Result<PatchDb, Error> {
PatchDb::open(self.datadir().join("main").join("embassy.db"))
let db_path = self.datadir().join("main").join("embassy.db");
PatchDb::open(&db_path)
.await
.map_err(Error::from)
.with_ctx(|_| (crate::ErrorKind::Filesystem, db_path.display().to_string()))
}
pub async fn secret_store(&self) -> Result<SqlitePool, Error> {
let secret_store_url = format!(

View File

@@ -51,7 +51,7 @@ pub async fn create_fs(cfg: &RpcContextConfig) -> Result<(), Error> {
.arg("-o")
.arg("keylocation=file:///etc/embassy/password")
.arg("-o")
.arg("keyformat=password")
.arg("keyformat=passphrase")
.arg(format!("{}/main", cfg.zfs_pool_name()))
.invoke(crate::ErrorKind::Zfs)
.await?;
@@ -62,7 +62,7 @@ pub async fn create_fs(cfg: &RpcContextConfig) -> Result<(), Error> {
.arg("-o")
.arg("keylocation=file:///etc/embassy/password")
.arg("-o")
.arg("keyformat=password")
.arg("keyformat=passphrase")
.arg(format!("{}/package-data", cfg.zfs_pool_name()))
.invoke(crate::ErrorKind::Zfs)
.await?;
@@ -177,6 +177,11 @@ pub async fn mount(cfg: &RpcContextConfig, password: &str) -> Result<(), Error>
.arg(format!("{}/main", cfg.zfs_pool_name()))
.invoke(crate::ErrorKind::Zfs)
.await?;
Command::new("zfs")
.arg("load-key")
.arg(format!("{}/package-data", cfg.zfs_pool_name()))
.invoke(crate::ErrorKind::Zfs)
.await?;
tokio::fs::remove_file(PASSWORD_PATH)
.await
.with_ctx(|_| (crate::ErrorKind::Filesystem, PASSWORD_PATH))?;

View File

@@ -511,6 +511,10 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
.await?;
log::info!("Install {}@{}: Unpacked Docker Images", pkg_id, version,);
log::info!("Install {}@{}: Unpacking Assets", pkg_id, version);
// TODO
log::info!("Install {}@{}: Unpacked Assets", pkg_id, version);
progress.unpack_complete.store(true, Ordering::SeqCst);
progress_model.put(&mut ctx.db.handle(), &progress).await?;

View File

@@ -23,7 +23,7 @@ use crate::{Error, ErrorKind, ResultExt as _};
#[test]
fn random_key() {
println!("'0x{}'", hex::encode(TorSecretKeyV3::generate().as_bytes()));
println!("x'{}'", hex::encode(TorSecretKeyV3::generate().as_bytes()));
}
#[command(subcommands(list_services))]

View File

@@ -24,6 +24,7 @@ impl Shutdown {
Command::new("reboot").spawn().unwrap().wait().unwrap();
} else {
Command::new("shutdown")
.arg("-h")
.arg("now")
.spawn()
.unwrap()

View File

@@ -20,7 +20,7 @@ lazy_static::lazy_static! {
static ref SOUND_MUTEX: Mutex<Option<fd_lock_rs::FdLock<tokio::fs::File>>> = Mutex::new(None);
}
pub const SOUND_LOCK_FILE: &'static str = "/TODO/AIDEN/CHANGEME";
pub const SOUND_LOCK_FILE: &'static str = "/etc/embassy/sound.lock";
struct SoundInterface(Option<MutexGuard<'static, Option<fd_lock_rs::FdLock<tokio::fs::File>>>>);
impl SoundInterface {

View File

@@ -8,7 +8,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --prod && tsc postprocess.ts && node postprocess.js && git log | head -n1 > www/git-hash.txt",
"build-prod": "ng build --configuration production && tsc postprocess.ts && node postprocess.js && git log | head -n1 > www/git-hash.txt",
"lint": "ng lint"
},
"dependencies": {