Compare commits
1 Commits
v2.5.2
...
5adda3f5d4
| Author | SHA1 | Date | |
|---|---|---|---|
| 5adda3f5d4 |
829
Cargo.lock
generated
829
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "init"
|
name = "init"
|
||||||
version = "2.5.2"
|
version = "2.5.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|||||||
12
Dockerfile
12
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
from rust:1.93.0-alpine as rust
|
from rust:1.91.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
|
run apk add --no-cache git musl-dev libudev-zero-dev openssl-dev cryptsetup-dev lvm2-dev clang-libs clang-dev
|
||||||
|
|
||||||
@ -14,15 +14,13 @@ run apk add zstd lz4
|
|||||||
|
|
||||||
workdir /system
|
workdir /system
|
||||||
|
|
||||||
env VERSION=3.23.2
|
|
||||||
|
|
||||||
run . /etc/os-release \
|
run . /etc/os-release \
|
||||||
&& wget -O- https://dl-cdn.alpinelinux.org/alpine/v${VERSION%.*}/releases/x86_64/alpine-minirootfs-${VERSION}-x86_64.tar.gz |tar zxv
|
&& 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 \
|
run apk add --no-cache --update -p . musl libgcc coreutils \
|
||||||
iproute2 lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
|
lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
|
||||||
e2fsprogs lsblk openssl openssh-server wireguard-tools-wg-quick \
|
e2fsprogs lsblk openssl openssh-server wireguard-tools-wg-quick \
|
||||||
&& rm -rf usr/share/apk var/cache/apk etc/motd dev/*
|
&& rm -rf usr/share/apk var/cache/apk etc/motd
|
||||||
|
|
||||||
copy etc/sshd_config etc/ssh/sshd_config
|
copy etc/sshd_config etc/ssh/sshd_config
|
||||||
|
|
||||||
@ -36,6 +34,6 @@ run chroot . init-version
|
|||||||
run find * |cpio -H newc -oF /initrd
|
run find * |cpio -H newc -oF /initrd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
from alpine:3.23.0
|
from alpine:3.22.2
|
||||||
copy --from=initrd /initrd /
|
copy --from=initrd /initrd /
|
||||||
entrypoint ["base64","/initrd"]
|
entrypoint ["base64","/initrd"]
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use eyre::{format_err, Result};
|
use eyre::{format_err, Result};
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use std::collections::BTreeSet as Set;
|
use std::collections::BTreeSet as Set;
|
||||||
use std::convert::Infallible;
|
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio::{fs, process::Command};
|
use tokio::{fs, process::Command};
|
||||||
@ -324,7 +323,13 @@ async fn child_reaper() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn switch_root(root: &str) -> Result<Infallible> {
|
macro_rules! cstr {
|
||||||
|
($s:expr) => {
|
||||||
|
std::ffi::CString::new($s)?.as_c_str()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn switch_root(root: &str) -> Result<()> {
|
||||||
info!("killing all processes and switching root");
|
info!("killing all processes and switching root");
|
||||||
dklog::LOG.close().await;
|
dklog::LOG.close().await;
|
||||||
|
|
||||||
@ -335,13 +340,7 @@ async fn switch_root(root: &str) -> Result<Infallible> {
|
|||||||
eprintln!("failed to kill processes: {e}");
|
eprintln!("failed to kill processes: {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! cstr {
|
nix::unistd::execv(
|
||||||
($s:expr) => {
|
|
||||||
std::ffi::CString::new($s)?.as_c_str()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(nix::unistd::execv(
|
|
||||||
cstr!("/sbin/switch_root"),
|
cstr!("/sbin/switch_root"),
|
||||||
&[
|
&[
|
||||||
cstr!("switch_root"),
|
cstr!("switch_root"),
|
||||||
@ -350,5 +349,8 @@ async fn switch_root(root: &str) -> Result<Infallible> {
|
|||||||
cstr!(root),
|
cstr!(root),
|
||||||
cstr!("/sbin/init"),
|
cstr!("/sbin/init"),
|
||||||
],
|
],
|
||||||
)?)
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user