Add Zero-OS customization before CPIO creation
- Add initramfs_finalize_customization() function - Remove root password for passwordless login (sed -i 's/^root:[^:]*:/root::/' /etc/passwd) - Update /etc/motd and /etc/issue to Zero-OS branding instead of Alpine - Called automatically before CPIO creation - Fixes init script duplication issue (/init vs /sbin/init) - Correct boot flow: /init → switch_root → /sbin/zinit init (no /sbin/init needed)
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="alpine_configure"
|
|
||||||
COMPLETED_AT="2025-09-05T08:50:10+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_alpine_configure"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="alpine_extract"
|
|
||||||
COMPLETED_AT="2025-09-05T08:50:10+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_alpine_extract"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="alpine_firmware"
|
|
||||||
COMPLETED_AT="2025-09-05T08:50:17+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 3s, Function: stage_alpine_firmware"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="alpine_packages"
|
|
||||||
COMPLETED_AT="2025-09-05T08:50:14+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 4s, Function: stage_alpine_packages"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="boot_tests"
|
|
||||||
COMPLETED_AT="2025-09-05T09:00:10+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_boot_tests"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="cleanup"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:22+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_cleanup"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="components_build"
|
|
||||||
COMPLETED_AT="2025-09-05T08:52:40+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 143s, Function: stage_components_build"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="components_copy"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:21+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 82s, Function: stage_components_copy"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="components_verify"
|
|
||||||
COMPLETED_AT="2025-09-05T08:52:40+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_components_verify"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="init_script"
|
|
||||||
COMPLETED_AT="2025-09-05T09:33:59+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_init_script"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="initramfs_create"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:47+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 25s, Function: stage_initramfs_create"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="initramfs_test"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:48+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 1s, Function: stage_initramfs_test"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="kernel_build"
|
|
||||||
COMPLETED_AT="2025-09-05T09:36:19+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 31s, Function: stage_kernel_build"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="kernel_modules"
|
|
||||||
COMPLETED_AT="2025-09-05T08:57:54+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 314s, Function: stage_kernel_modules"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="modules_copy"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:22+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_modules_copy"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="modules_setup"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:22+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 1s, Function: stage_modules_setup"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="validation"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:22+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_validation"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Stage completion marker
|
|
||||||
STAGE_NAME="zinit_setup"
|
|
||||||
COMPLETED_AT="2025-09-05T09:35:21+00:00"
|
|
||||||
COMPLETED_BY="root"
|
|
||||||
DETAILS="Duration: 0s, Function: stage_zinit_setup"
|
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,6 +5,7 @@ components/
|
|||||||
initramfs/
|
initramfs/
|
||||||
kernel/
|
kernel/
|
||||||
dist/
|
dist/
|
||||||
|
.build-stages/
|
||||||
|
|
||||||
# Build logs
|
# Build logs
|
||||||
*.log
|
*.log
|
||||||
@@ -36,5 +37,4 @@ linux-*.tar.xz
|
|||||||
|
|
||||||
# OS generated files
|
# OS generated files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db# Build stage tracking (should not be in git)
|
Thumbs.db
|
||||||
.build-stages/
|
|
||||||
|
|||||||
@@ -112,6 +112,6 @@ fi
|
|||||||
|
|
||||||
echo "[+] switching root"
|
echo "[+] switching root"
|
||||||
echo " exec switch_root /mnt/root /sbin/zinit init"
|
echo " exec switch_root /mnt/root /sbin/zinit init"
|
||||||
exec switch_root /mnt/root /sbin/zinit init
|
exec switch_root /mnt/root /sbin/zinit -d init
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
exec: sh /etc/zinit/init/cgroup.sh
|
|
||||||
oneshot: true
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
exec: sh /etc/zinit/init/stage1-modules.sh
|
|
||||||
oneshot: true
|
|
||||||
after:
|
|
||||||
- udevd
|
|
||||||
test: /etc/zinit/init/stage1-modules.sh
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
exec: sh /etc/zinit/init/stage2-modules.sh
|
|
||||||
oneshot: true
|
|
||||||
after:
|
|
||||||
- stage1-modules
|
|
||||||
- network
|
|
||||||
test: /etc/zinit/init/stage2-modules.sh
|
|
||||||
@@ -12,11 +12,10 @@ target="/mnt/root"
|
|||||||
mkdir -p $target
|
mkdir -p $target
|
||||||
mount -t proc proc /proc
|
mount -t proc proc /proc
|
||||||
mount -t sysfs sysfs /sys
|
mount -t sysfs sysfs /sys
|
||||||
mount -t tmpfs tmpfs /mnt/root -o size=1536M
|
mount -t tmpfs tmpfs /mnt/root -o size=1024M
|
||||||
mount -t devtmpfs devtmpfs /dev
|
mount -t devtmpfs devtmpfs /dev
|
||||||
|
|
||||||
echo "[+] building ram filesystem"
|
echo "[+] building ram filesystem"
|
||||||
target="/mnt/root"
|
|
||||||
|
|
||||||
# Copy Alpine filesystem to tmpfs (same as original)
|
# Copy Alpine filesystem to tmpfs (same as original)
|
||||||
echo " copying /bin..."
|
echo " copying /bin..."
|
||||||
@@ -102,6 +101,6 @@ fi
|
|||||||
|
|
||||||
echo "[+] switching root"
|
echo "[+] switching root"
|
||||||
echo " exec switch_root /mnt/root /sbin/zinit init"
|
echo " exec switch_root /mnt/root /sbin/zinit init"
|
||||||
exec switch_root /mnt/root /sbin/zinit init
|
exec switch_root /mnt/root /sbin/zinit -d init
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -570,6 +570,49 @@ function initramfs_strip_and_upx() {
|
|||||||
log_info "Total initramfs size after optimization: ${total_mb}MB"
|
log_info "Total initramfs size after optimization: ${total_mb}MB"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Final initramfs customization before CPIO creation
|
||||||
|
function initramfs_finalize_customization() {
|
||||||
|
local initramfs_dir="$1"
|
||||||
|
|
||||||
|
section_header "Final Zero-OS Customization"
|
||||||
|
|
||||||
|
# Remove root password for passwordless login
|
||||||
|
log_info "Removing root password for passwordless login"
|
||||||
|
if [[ -f "${initramfs_dir}/etc/passwd" ]]; then
|
||||||
|
safe_execute sed -i 's/^root:[^:]*:/root::/' "${initramfs_dir}/etc/passwd"
|
||||||
|
log_info "✓ Root password removed"
|
||||||
|
else
|
||||||
|
log_warn "/etc/passwd not found, skipping password removal"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update /etc/motd to Zero-OS
|
||||||
|
log_info "Updating /etc/motd to Zero-OS branding"
|
||||||
|
cat > "${initramfs_dir}/etc/motd" << 'EOF'
|
||||||
|
|
||||||
|
Welcome to Zero-OS!
|
||||||
|
|
||||||
|
This is a minimal operating system designed for decentralized infrastructure.
|
||||||
|
Built on Alpine Linux with ThreeFold components.
|
||||||
|
|
||||||
|
For more information: https://github.com/threefoldtech/zos
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Update /etc/issue to Zero-OS
|
||||||
|
log_info "Updating /etc/issue to Zero-OS branding"
|
||||||
|
cat > "${initramfs_dir}/etc/issue" << 'EOF'
|
||||||
|
Zero-OS \r \m
|
||||||
|
Built on \l
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Set proper permissions
|
||||||
|
safe_execute chmod 644 "${initramfs_dir}/etc/motd"
|
||||||
|
safe_execute chmod 644 "${initramfs_dir}/etc/issue"
|
||||||
|
|
||||||
|
log_info "Zero-OS customization complete"
|
||||||
|
}
|
||||||
|
|
||||||
# Create final initramfs.cpio.xz archive
|
# Create final initramfs.cpio.xz archive
|
||||||
function initramfs_create_cpio() {
|
function initramfs_create_cpio() {
|
||||||
local initramfs_dir="$1"
|
local initramfs_dir="$1"
|
||||||
@@ -594,6 +637,9 @@ function initramfs_create_cpio() {
|
|||||||
log_info "Output file: ${output_file}"
|
log_info "Output file: ${output_file}"
|
||||||
log_info "Compression: ${compression}"
|
log_info "Compression: ${compression}"
|
||||||
|
|
||||||
|
# Run final Zero-OS customization before creating CPIO
|
||||||
|
initramfs_finalize_customization "$initramfs_dir"
|
||||||
|
|
||||||
# Change to initramfs directory for relative paths
|
# Change to initramfs directory for relative paths
|
||||||
safe_execute cd "$initramfs_dir"
|
safe_execute cd "$initramfs_dir"
|
||||||
|
|
||||||
@@ -896,5 +942,5 @@ function initramfs_copy_resolved_modules() {
|
|||||||
# Export all functions at the end after they're all defined
|
# Export all functions at the end after they're all defined
|
||||||
export -f initramfs_setup_zinit initramfs_setup_modules initramfs_resolve_module_dependencies
|
export -f initramfs_setup_zinit initramfs_setup_modules initramfs_resolve_module_dependencies
|
||||||
export -f initramfs_install_init_script initramfs_copy_components initramfs_create_module_scripts
|
export -f initramfs_install_init_script initramfs_copy_components initramfs_create_module_scripts
|
||||||
export -f initramfs_strip_and_upx initramfs_create_cpio initramfs_validate initramfs_test_archive
|
export -f initramfs_strip_and_upx initramfs_finalize_customization initramfs_create_cpio
|
||||||
export -f initramfs_copy_resolved_modules
|
export -f initramfs_validate initramfs_test_archive initramfs_copy_resolved_modules
|
||||||
Reference in New Issue
Block a user