#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 7: Create Essential Files and Symlinks # ============================================================================ # Purpose: Create the essential system files (/etc/passwd, /etc/group, # log files) and symlinks that programs expect to exist. # This script runs INSIDE the chroot environment. # Inputs: None (creates files from scratch) # Outputs: /etc/passwd, /etc/group, log files, essential symlinks # Assumes: Running inside chroot (script 023 completed) # Ref: LFS 13.0 §7.6 # ============================================================================ set -euo pipefail echo "=== DarkForge: Creating essential files and symlinks ===" # --- Create essential symlinks ------------------------------------------------ # Some programs hardcode paths to /bin/sh, /bin/cat, etc. # With the unified /usr layout, these are already correct via symlinks # created in 000-env-setup.sh, but verify: [ -L /bin ] || { echo "ERROR: /bin should be a symlink to usr/bin"; exit 1; } [ -L /lib ] || { echo "ERROR: /lib should be a symlink to usr/lib"; exit 1; } [ -L /sbin ] || { echo "ERROR: /sbin should be a symlink to usr/sbin"; exit 1; } # --- Create /etc/passwd ------------------------------------------------------- cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/dev/null:/usr/bin/false daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false nobody:x:65534:65534:Unprivileged User:/dev/null:/usr/bin/false EOF # --- Create /etc/group -------------------------------------------------------- cat > /etc/group << "EOF" root:x:0: bin:x:1:daemon sys:x:2: kmem:x:3: tape:x:4: tty:x:5: daemon:x:6: floppy:x:7: disk:x:8: lp:x:9: dialout:x:10: audio:x:11: video:x:12: utmp:x:13: cdrom:x:15: adm:x:16: messagebus:x:18: input:x:24: mail:x:34: kvm:x:61: uuidd:x:80: wheel:x:97: users:x:999: nogroup:x:65534: EOF # --- Create log files --------------------------------------------------------- # These must exist for certain programs to function correctly install -o root -g utmp -m 664 /dev/null /var/log/lastlog install -o root -g root -m 600 /dev/null /var/log/btmp install -o root -g root -m 664 /dev/null /var/log/faillog install -o root -g utmp -m 664 /dev/null /var/log/wtmp echo "=== Essential files and symlinks created ===" echo "" echo "Next: Run the chroot build scripts (025-xxx) to build additional tools."