4 Commits

Author SHA1 Message Date
f886692c7f docker: bump alpine 2026-01-26 11:40:07 +01:00
96f801e27d update deps 2026-01-25 22:00:36 +01:00
3f7cd80a96 chore: Release init version 2.5.2 2026-01-25 22:00:36 +01:00
41c3f9badd bump deps, rust, alpine, and add the real iproute2 2025-12-17 17:46:43 +01:00
4 changed files with 675 additions and 204 deletions

845
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "init"
version = "2.5.1"
version = "2.5.2"
edition = "2024"
[profile.release]

View File

@ -1,4 +1,4 @@
from rust:1.91.0-alpine as rust
from rust:1.93.0-alpine as rust
run apk add --no-cache git musl-dev libudev-zero-dev openssl-dev cryptsetup-dev lvm2-dev clang-libs clang-dev
@ -9,7 +9,7 @@ run --mount=type=cache,id=novit-rs,target=/usr/local/cargo/registry \
RUSTFLAGS="-C target-feature=-crt-static" cargo install --path . --root /dist
# ------------------------------------------------------------------------
from alpine:3.22.2 as initrd
from alpine:3.23.2 as initrd
run apk add zstd lz4
workdir /system
@ -18,9 +18,9 @@ run . /etc/os-release \
&& wget -O- https://dl-cdn.alpinelinux.org/alpine/v${VERSION_ID%.*}/releases/x86_64/alpine-minirootfs-${VERSION_ID}-x86_64.tar.gz |tar zxv
run apk add --no-cache --update -p . musl libgcc coreutils \
lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
iproute2 lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
e2fsprogs lsblk openssl openssh-server wireguard-tools-wg-quick \
&& rm -rf usr/share/apk var/cache/apk etc/motd
&& rm -rf usr/share/apk var/cache/apk etc/motd dev/*
copy etc/sshd_config etc/ssh/sshd_config
@ -34,6 +34,6 @@ run chroot . init-version
run find * |cpio -H newc -oF /initrd
# ------------------------------------------------------------------------
from alpine:3.22.2
from alpine:3.23.2
copy --from=initrd /initrd /
entrypoint ["base64","/initrd"]

View File

@ -1,6 +1,7 @@
use eyre::{format_err, Result};
use log::{error, info, warn};
use std::collections::BTreeSet as Set;
use std::convert::Infallible;
use std::os::unix::fs::symlink;
use tokio::sync::Mutex;
use tokio::{fs, process::Command};
@ -323,13 +324,7 @@ async fn child_reaper() {
}
}
macro_rules! cstr {
($s:expr) => {
std::ffi::CString::new($s)?.as_c_str()
};
}
async fn switch_root(root: &str) -> Result<()> {
async fn switch_root(root: &str) -> Result<Infallible> {
info!("killing all processes and switching root");
dklog::LOG.close().await;
@ -340,7 +335,13 @@ async fn switch_root(root: &str) -> Result<()> {
eprintln!("failed to kill processes: {e}");
}
nix::unistd::execv(
macro_rules! cstr {
($s:expr) => {
std::ffi::CString::new($s)?.as_c_str()
};
}
Ok(nix::unistd::execv(
cstr!("/sbin/switch_root"),
&[
cstr!("switch_root"),
@ -349,8 +350,5 @@ async fn switch_root(root: &str) -> Result<()> {
cstr!(root),
cstr!("/sbin/init"),
],
)
.unwrap();
unreachable!();
)?)
}