6 Commits

Author SHA1 Message Date
Mikaël Cluseau f29dc650b4 chore: Release init version 2.6.4 2026-05-08 11:54:39 +02:00
Mikaël Cluseau 5ebf1331bb bump dkl 2026-05-08 11:54:39 +02:00
Mikaël Cluseau be0e10723a chore: Release init version 2.6.2 2026-05-08 11:54:39 +02:00
Mikaël Cluseau 01b211d0c5 sanity 2026-05-08 11:54:39 +02:00
Mikaël Cluseau 0ef1ae769e bump dkl to get FilePart support 2026-05-08 11:54:39 +02:00
Mikaël Cluseau afac751118 handle seed_{ca,proxy,servername} 2026-05-08 11:54:20 +02:00
4 changed files with 151 additions and 628 deletions
Generated
+112 -614
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "init"
version = "2.6.0"
version = "2.6.4"
edition = "2024"
[profile.release]
@@ -28,6 +28,7 @@ unix_mode = "0.1.4"
sys-info = "0.9.1"
dkl = { git = "https://novit.tech/direktil/dkl", version = "1.0.0" }
openssl = "0.10.73"
reqwest = { version = "0.13.1", features = ["native-tls"] }
#reqwest = { version = "0.13.1", features = ["native-tls", "system-proxy"], default-features = false }
reqwest = { git = "https://github.com/mcluseau/rs-reqwest", version = "0.13.1", features = ["native-tls", "system-proxy", "socks"], default-features = false }
glob = "0.3.3"
hex = "0.4.3"
+35 -11
View File
@@ -1,5 +1,5 @@
use eyre::{format_err, Result};
use log::{info, warn};
use log::{debug, info, warn};
use std::path::{Path, PathBuf};
use tokio::{
fs,
@@ -49,7 +49,7 @@ pub async fn bootstrap(cfg: Config) {
.await;
let sys_cfg: dkl::Config = retry(async || {
let sys_cfg_bytes = seed_config(base_dir, &bs.seed, &verifier).await?;
let sys_cfg_bytes = seed_config(base_dir, &bs, &verifier).await?;
Ok(serde_yaml::from_slice(&sys_cfg_bytes)?)
})
.await;
@@ -130,7 +130,7 @@ impl Verifier {
async fn seed_config(
base_dir: &str,
seed_url: &Option<String>,
bs: &dkl::bootstrap::Bootstrap,
verifier: &Verifier,
) -> Result<Vec<u8>> {
let cfg_path = &format!("{base_dir}/config.yaml");
@@ -141,13 +141,12 @@ async fn seed_config(
let bs_tar = "/bootstrap.tar";
if !fs::try_exists(bs_tar).await? {
if let Some(seed_url) = seed_url.as_ref() {
fetch_bootstrap(seed_url, bs_tar).await?;
} else {
if bs.seed.is_none() {
return Err(format_err!(
"no {cfg_path}, no {bs_tar} and no seed, can't bootstrap"
"no {cfg_path}, no {bs_tar} and no seed URL, can't bootstrap"
));
}
fetch_bootstrap(bs, bs_tar).await?;
}
try_exec("tar", &["xf", bs_tar, "-C", base_dir]).await?;
@@ -159,15 +158,41 @@ async fn seed_config(
verifier.verify_path(&cfg_path).await
}
async fn fetch_bootstrap(seed_url: &str, output_file: &str) -> Result<()> {
let seed_url: reqwest::Url = seed_url.parse()?;
async fn fetch_bootstrap(bs: &dkl::bootstrap::Bootstrap, output_file: &str) -> Result<()> {
let seed_url: reqwest::Url = (bs.seed.as_ref())
.ok_or(format_err!("no seed URL"))?
.parse()
.map_err(|e| format_err!("invalid seed URL: {e}"))?;
info!(
"fetching {output_file} from {}",
seed_url.host_str().unwrap_or("<no host>")
);
let resp = reqwest::get(seed_url).await?;
let mut builder = reqwest::Client::builder();
if let Some(ref proxy) = bs.seed_proxy {
debug!("using proxy {proxy}");
let proxy = reqwest::Proxy::all(proxy) //
.map_err(|e| format_err!("seed proxy setup failed: {e}"))?;
builder = builder.proxy(proxy);
}
if let Some(ref ca) = bs.seed_ca {
debug!("using custom CA certificate");
let ca = base64_decode(ca).map_err(|e| format_err!("invalid seed CA: decode: {e}"))?;
let ca = reqwest::Certificate::from_der(&ca)
.map_err(|e| format_err!("invalid seed CA: parse: {e}"))?;
builder = builder.tls_certs_only([ca]);
}
if let Some(ref sn) = bs.seed_servername {
debug!("tls server name: {sn}");
builder = builder.tls_server_name(bs.seed_servername.clone());
}
let req = builder.build()?.get(seed_url);
let resp = req.send().await?;
if !resp.status().is_success() {
return Err(format_err!("HTTP request failed: {}", resp.status()));
@@ -315,7 +340,6 @@ async fn mount_system(cfg: &dkl::Config, bs_cfg: &Config, bs_dir: &str, verifier
if layer == "modules" && bs_cfg.modules.is_some() {
continue; // take modules from initrd
}
mounter.mount(layer).await;
}
}
+1 -1
View File
@@ -98,5 +98,5 @@ lvm:
signer_public_key: 'MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBe6Y3zGQUIHvVXoS5GI8irY8yoB0ozFpzn/cUykA46TkHdJ8xCEaaM1MpqMrfWgDtP/rA2KeE9HjVerLnEFD01uUAUh4/OYgCBDYJPhridVDoC78KOJpkWBj7Shl0Rp0AtETvatNPa1RRe15V7nDF/Nm75Y6O3IL29lYPQ6jqEGhR810='
bootstrap:
dev: /dev/storage/bootstrap
seed: http://192.168.12.254:7606/public/download-set/host/m1/bootstrap.tar?set=ICIXKJJWA6U4RQESD3KQMWO3IBW6THG4FJUM2HUNFPTIODVSXGDPXTCHSFT6IOUZO6LBAG65QIGYUMIZA3TEHTPB6BXKUFONNUWKUWAJAQRE2GDEOC4RWAAAQA3DSZJXMNSDGN34NA5G2MJ2MJXW65DTORZGC4BOORQXEAAAAAACMICVFM
seed: https://192.168.12.254:7606/public/download-set/host/m1/bootstrap.tar?set=IDZTK4AUNCYCTKF3GIEGSNZF3I7XCINCTJSOWL2JPHCJ2IAZWDECY2XCGQ5MCTJBNFIKBNCLIA3PJSN7IOH7URGXYRYZRCGF4VSW4RIAAQRE2GDEOC4RWAAAQA3DSZJZMU4TGOL4NA5G2MJ2MJXW65DTORZGC4BOORQXEAAAAAADJMFLUE