forked from tfgrid/zosbuilder
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:
@@ -570,6 +570,49 @@ function initramfs_strip_and_upx() {
|
||||
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
|
||||
function initramfs_create_cpio() {
|
||||
local initramfs_dir="$1"
|
||||
@@ -594,6 +637,9 @@ function initramfs_create_cpio() {
|
||||
log_info "Output file: ${output_file}"
|
||||
log_info "Compression: ${compression}"
|
||||
|
||||
# Run final Zero-OS customization before creating CPIO
|
||||
initramfs_finalize_customization "$initramfs_dir"
|
||||
|
||||
# Change to initramfs directory for relative paths
|
||||
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 -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_strip_and_upx initramfs_create_cpio initramfs_validate initramfs_test_archive
|
||||
export -f initramfs_copy_resolved_modules
|
||||
export -f initramfs_strip_and_upx initramfs_finalize_customization initramfs_create_cpio
|
||||
export -f initramfs_validate initramfs_test_archive initramfs_copy_resolved_modules
|
||||
Reference in New Issue
Block a user