feat(post-install): add post-installation phase with snapper and Plymouth setup
- commit
- 026da9c237bed853fb2fcc2bb864b3c2dd03adf3
- author
- bnema · · 2025-10-20 18:45 UTC
- parent
- df0ae50
- signature
- unsigned
7 files · +281 -0
A install/post-install/all.sh +9 -0
| @@ -0,0 +1,9 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Post-install phase: Final touches after system is configured | |
| 3 | + | ||
| 4 | + | source "$ARCHUP_INSTALL/post-install/boot-logo.sh" | |
| 5 | + | source "$ARCHUP_INSTALL/post-install/plymouth.sh" | |
| 6 | + | source "$ARCHUP_INSTALL/post-install/snapper.sh" | |
| 7 | + | source "$ARCHUP_INSTALL/post-install/hooks.sh" | |
| 8 | + | source "$ARCHUP_INSTALL/post-install/verify.sh" | |
| 9 | + | # source "$ARCHUP_INSTALL/post-install/unmount.sh" # DISABLED FOR DEBUGGING | |
| @@ -0,0 +1,9 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Post-install phase: Final touches after system is configured | |||
| 3 | + | ||||
| 4 | + | source "$ARCHUP_INSTALL/post-install/boot-logo.sh" | |||
| 5 | + | source "$ARCHUP_INSTALL/post-install/plymouth.sh" | |||
| 6 | + | source "$ARCHUP_INSTALL/post-install/snapper.sh" | |||
| 7 | + | source "$ARCHUP_INSTALL/post-install/hooks.sh" | |||
| 8 | + | source "$ARCHUP_INSTALL/post-install/verify.sh" | |||
| 9 | + | # source "$ARCHUP_INSTALL/post-install/unmount.sh" # DISABLED FOR DEBUGGING | |||
A install/post-install/boot-logo.sh +16 -0
| @@ -0,0 +1,16 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Download and configure Limine boot logo | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing boot logo..." | |
| 5 | + | ||
| 6 | + | # Download logo directly to boot partition (no chroot needed, boot is mounted at /mnt/boot) | |
| 7 | + | curl -fsSL "$ARCHUP_RAW_URL/assets/Arch_Linux__Crystal__icon.png" \ | |
| 8 | + | -o /mnt/boot/arch-logo.png >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 9 | + | ||
| 10 | + | if [ -f /mnt/boot/arch-logo.png ]; then | |
| 11 | + | if [ -f /mnt/boot/EFI/limine/limine.conf ]; then | |
| 12 | + | sed -i '/^graphics: yes$/a wallpaper: boot():/arch-logo.png\nwallpaper_style: centered\nbackdrop: 000000' \ | |
| 13 | + | /mnt/boot/EFI/limine/limine.conf | |
| 14 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Boot logo installed" | |
| 15 | + | fi | |
| 16 | + | fi | |
| @@ -0,0 +1,16 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Download and configure Limine boot logo | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing boot logo..." | |||
| 5 | + | ||||
| 6 | + | # Download logo directly to boot partition (no chroot needed, boot is mounted at /mnt/boot) | |||
| 7 | + | curl -fsSL "$ARCHUP_RAW_URL/assets/Arch_Linux__Crystal__icon.png" \ | |||
| 8 | + | -o /mnt/boot/arch-logo.png >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 9 | + | ||||
| 10 | + | if [ -f /mnt/boot/arch-logo.png ]; then | |||
| 11 | + | if [ -f /mnt/boot/EFI/limine/limine.conf ]; then | |||
| 12 | + | sed -i '/^graphics: yes$/a wallpaper: boot():/arch-logo.png\nwallpaper_style: centered\nbackdrop: 000000' \ | |||
| 13 | + | /mnt/boot/EFI/limine/limine.conf | |||
| 14 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Boot logo installed" | |||
| 15 | + | fi | |||
| 16 | + | fi | |||
A install/post-install/hooks.sh +24 -0
| @@ -0,0 +1,24 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Install pacman hooks for automatic system maintenance | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing pacman hooks..." | |
| 5 | + | ||
| 6 | + | mkdir -p /mnt/etc/pacman.d/hooks | |
| 7 | + | ||
| 8 | + | # Limine bootloader auto-update hook | |
| 9 | + | cat > /mnt/etc/pacman.d/hooks/99-limine.hook <<'EOF' | |
| 10 | + | [Trigger] | |
| 11 | + | Operation = Install | |
| 12 | + | Operation = Upgrade | |
| 13 | + | Type = Package | |
| 14 | + | Target = limine | |
| 15 | + | ||
| 16 | + | [Action] | |
| 17 | + | Description = Deploying Limine after upgrade... | |
| 18 | + | When = PostTransaction | |
| 19 | + | Exec = /usr/bin/cp /usr/share/limine/BOOTX64.EFI /boot/EFI/limine/ | |
| 20 | + | EOF | |
| 21 | + | ||
| 22 | + | echo "Installed Limine update hook" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 23 | + | ||
| 24 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Pacman hooks installed" | |
| @@ -0,0 +1,24 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Install pacman hooks for automatic system maintenance | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing pacman hooks..." | |||
| 5 | + | ||||
| 6 | + | mkdir -p /mnt/etc/pacman.d/hooks | |||
| 7 | + | ||||
| 8 | + | # Limine bootloader auto-update hook | |||
| 9 | + | cat > /mnt/etc/pacman.d/hooks/99-limine.hook <<'EOF' | |||
| 10 | + | [Trigger] | |||
| 11 | + | Operation = Install | |||
| 12 | + | Operation = Upgrade | |||
| 13 | + | Type = Package | |||
| 14 | + | Target = limine | |||
| 15 | + | ||||
| 16 | + | [Action] | |||
| 17 | + | Description = Deploying Limine after upgrade... | |||
| 18 | + | When = PostTransaction | |||
| 19 | + | Exec = /usr/bin/cp /usr/share/limine/BOOTX64.EFI /boot/EFI/limine/ | |||
| 20 | + | EOF | |||
| 21 | + | ||||
| 22 | + | echo "Installed Limine update hook" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 23 | + | ||||
| 24 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Pacman hooks installed" | |||
A install/post-install/plymouth.sh +38 -0
| @@ -0,0 +1,38 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Configure Plymouth splash screen with ArchUp theme | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring Plymouth splash screen..." | |
| 5 | + | ||
| 6 | + | THEME_NAME="archup" | |
| 7 | + | THEME_DIR="/mnt/usr/share/plymouth/themes/$THEME_NAME" | |
| 8 | + | ||
| 9 | + | # Create theme directory | |
| 10 | + | mkdir -p "$THEME_DIR" | |
| 11 | + | ||
| 12 | + | # Download all Plymouth theme files from GitHub | |
| 13 | + | PLYMOUTH_FILES=( | |
| 14 | + | "archup.plymouth" | |
| 15 | + | "archup.script" | |
| 16 | + | "logo.png" | |
| 17 | + | "bullet.png" | |
| 18 | + | "entry.png" | |
| 19 | + | "lock.png" | |
| 20 | + | "progress_bar.png" | |
| 21 | + | "progress_box.png" | |
| 22 | + | ) | |
| 23 | + | ||
| 24 | + | for file in "${PLYMOUTH_FILES[@]}"; do | |
| 25 | + | curl -fsSL "$ARCHUP_RAW_URL/assets/plymouth/$file" \ | |
| 26 | + | -o "$THEME_DIR/$file" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 27 | + | done | |
| 28 | + | ||
| 29 | + | # Set permissions | |
| 30 | + | chmod 644 "$THEME_DIR"/* | |
| 31 | + | ||
| 32 | + | # Set as default theme | |
| 33 | + | arch-chroot /mnt plymouth-set-default-theme "$THEME_NAME" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 34 | + | ||
| 35 | + | # Regenerate initramfs with Plymouth | |
| 36 | + | arch-chroot /mnt mkinitcpio -P >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 37 | + | ||
| 38 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Plymouth configured" | |
| @@ -0,0 +1,38 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Configure Plymouth splash screen with ArchUp theme | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring Plymouth splash screen..." | |||
| 5 | + | ||||
| 6 | + | THEME_NAME="archup" | |||
| 7 | + | THEME_DIR="/mnt/usr/share/plymouth/themes/$THEME_NAME" | |||
| 8 | + | ||||
| 9 | + | # Create theme directory | |||
| 10 | + | mkdir -p "$THEME_DIR" | |||
| 11 | + | ||||
| 12 | + | # Download all Plymouth theme files from GitHub | |||
| 13 | + | PLYMOUTH_FILES=( | |||
| 14 | + | "archup.plymouth" | |||
| 15 | + | "archup.script" | |||
| 16 | + | "logo.png" | |||
| 17 | + | "bullet.png" | |||
| 18 | + | "entry.png" | |||
| 19 | + | "lock.png" | |||
| 20 | + | "progress_bar.png" | |||
| 21 | + | "progress_box.png" | |||
| 22 | + | ) | |||
| 23 | + | ||||
| 24 | + | for file in "${PLYMOUTH_FILES[@]}"; do | |||
| 25 | + | curl -fsSL "$ARCHUP_RAW_URL/assets/plymouth/$file" \ | |||
| 26 | + | -o "$THEME_DIR/$file" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 27 | + | done | |||
| 28 | + | ||||
| 29 | + | # Set permissions | |||
| 30 | + | chmod 644 "$THEME_DIR"/* | |||
| 31 | + | ||||
| 32 | + | # Set as default theme | |||
| 33 | + | arch-chroot /mnt plymouth-set-default-theme "$THEME_NAME" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 34 | + | ||||
| 35 | + | # Regenerate initramfs with Plymouth | |||
| 36 | + | arch-chroot /mnt mkinitcpio -P >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 37 | + | ||||
| 38 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Plymouth configured" | |||
A install/post-install/snapper.sh +43 -0
| @@ -0,0 +1,43 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Configure Snapper and Limine integration for btrfs snapshots | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring btrfs snapshots..." | |
| 5 | + | ||
| 6 | + | arch-chroot /mnt pacman -S --noconfirm --needed limine-snapper-sync >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 7 | + | ||
| 8 | + | mkdir -p /mnt/usr/local/share/archup/post-boot | |
| 9 | + | ||
| 10 | + | cp "$ARCHUP_INSTALL/post-boot/all.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 11 | + | cp "$ARCHUP_INSTALL/post-boot/snapper.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 12 | + | cp "$ARCHUP_INSTALL/post-boot/ssh-keygen.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 13 | + | chmod +x /mnt/usr/local/share/archup/post-boot/*.sh | |
| 14 | + | ||
| 15 | + | sed "s|__ARCHUP_EMAIL__|$(config_get "ARCHUP_EMAIL")|g; s|__ARCHUP_USERNAME__|$(config_get "ARCHUP_USERNAME")|g" \ | |
| 16 | + | "$ARCHUP_INSTALL/post-boot/archup-first-boot.service" > /mnt/etc/systemd/system/archup-first-boot.service | |
| 17 | + | ||
| 18 | + | arch-chroot /mnt systemctl enable archup-first-boot.service >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 19 | + | ||
| 20 | + | LIMINE_CONFIG="/mnt/boot/EFI/limine/limine.conf" | |
| 21 | + | CMDLINE=$(grep "^[[:space:]]*cmdline:" "$LIMINE_CONFIG" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//') | |
| 22 | + | cat > /mnt/etc/default/limine <<EOF | |
| 23 | + | TARGET_OS_NAME="ArchUp" | |
| 24 | + | ||
| 25 | + | ESP_PATH="/boot" | |
| 26 | + | ||
| 27 | + | KERNEL_CMDLINE[default]="$CMDLINE" | |
| 28 | + | ||
| 29 | + | ENABLE_UKI=no | |
| 30 | + | ENABLE_LIMINE_FALLBACK=yes | |
| 31 | + | ||
| 32 | + | FIND_BOOTLOADERS=yes | |
| 33 | + | ||
| 34 | + | BOOT_ORDER="*, *fallback, Snapshots" | |
| 35 | + | ||
| 36 | + | MAX_SNAPSHOT_ENTRIES=5 | |
| 37 | + | ||
| 38 | + | SNAPSHOT_FORMAT_CHOICE=5 | |
| 39 | + | EOF | |
| 40 | + | ||
| 41 | + | arch-chroot /mnt systemctl enable limine-snapper-sync.service >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 42 | + | ||
| 43 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Btrfs snapshots configured" | |
| @@ -0,0 +1,43 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Configure Snapper and Limine integration for btrfs snapshots | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Configuring btrfs snapshots..." | |||
| 5 | + | ||||
| 6 | + | arch-chroot /mnt pacman -S --noconfirm --needed limine-snapper-sync >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 7 | + | ||||
| 8 | + | mkdir -p /mnt/usr/local/share/archup/post-boot | |||
| 9 | + | ||||
| 10 | + | cp "$ARCHUP_INSTALL/post-boot/all.sh" /mnt/usr/local/share/archup/post-boot/ | |||
| 11 | + | cp "$ARCHUP_INSTALL/post-boot/snapper.sh" /mnt/usr/local/share/archup/post-boot/ | |||
| 12 | + | cp "$ARCHUP_INSTALL/post-boot/ssh-keygen.sh" /mnt/usr/local/share/archup/post-boot/ | |||
| 13 | + | chmod +x /mnt/usr/local/share/archup/post-boot/*.sh | |||
| 14 | + | ||||
| 15 | + | sed "s|__ARCHUP_EMAIL__|$(config_get "ARCHUP_EMAIL")|g; s|__ARCHUP_USERNAME__|$(config_get "ARCHUP_USERNAME")|g" \ | |||
| 16 | + | "$ARCHUP_INSTALL/post-boot/archup-first-boot.service" > /mnt/etc/systemd/system/archup-first-boot.service | |||
| 17 | + | ||||
| 18 | + | arch-chroot /mnt systemctl enable archup-first-boot.service >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 19 | + | ||||
| 20 | + | LIMINE_CONFIG="/mnt/boot/EFI/limine/limine.conf" | |||
| 21 | + | CMDLINE=$(grep "^[[:space:]]*cmdline:" "$LIMINE_CONFIG" | head -1 | sed 's/^[[:space:]]*cmdline:[[:space:]]*//') | |||
| 22 | + | cat > /mnt/etc/default/limine <<EOF | |||
| 23 | + | TARGET_OS_NAME="ArchUp" | |||
| 24 | + | ||||
| 25 | + | ESP_PATH="/boot" | |||
| 26 | + | ||||
| 27 | + | KERNEL_CMDLINE[default]="$CMDLINE" | |||
| 28 | + | ||||
| 29 | + | ENABLE_UKI=no | |||
| 30 | + | ENABLE_LIMINE_FALLBACK=yes | |||
| 31 | + | ||||
| 32 | + | FIND_BOOTLOADERS=yes | |||
| 33 | + | ||||
| 34 | + | BOOT_ORDER="*, *fallback, Snapshots" | |||
| 35 | + | ||||
| 36 | + | MAX_SNAPSHOT_ENTRIES=5 | |||
| 37 | + | ||||
| 38 | + | SNAPSHOT_FORMAT_CHOICE=5 | |||
| 39 | + | EOF | |||
| 40 | + | ||||
| 41 | + | arch-chroot /mnt systemctl enable limine-snapper-sync.service >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 42 | + | ||||
| 43 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] Btrfs snapshots configured" | |||
A install/post-install/unmount.sh +21 -0
| @@ -0,0 +1,21 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Unmount all drives in preparation for reboot | |
| 3 | + | ||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Unmounting partitions..." | |
| 5 | + | ||
| 6 | + | # Unmount in reverse order (nested mounts first) | |
| 7 | + | umount -R /mnt >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 8 | + | ||
| 9 | + | if [ $? -eq 0 ]; then | |
| 10 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] All partitions unmounted" | |
| 11 | + | echo "Unmounted all partitions successfully" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 12 | + | ||
| 13 | + | # Close encrypted volume if encryption was enabled | |
| 14 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 15 | + | cryptsetup close cryptroot >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | |
| 16 | + | echo "Closed encrypted volume" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 17 | + | fi | |
| 18 | + | else | |
| 19 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[WARN] Some partitions may still be mounted" | |
| 20 | + | echo "Warning: Failed to unmount all partitions cleanly" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 21 | + | fi | |
| @@ -0,0 +1,21 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Unmount all drives in preparation for reboot | |||
| 3 | + | ||||
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Unmounting partitions..." | |||
| 5 | + | ||||
| 6 | + | # Unmount in reverse order (nested mounts first) | |||
| 7 | + | umount -R /mnt >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 8 | + | ||||
| 9 | + | if [ $? -eq 0 ]; then | |||
| 10 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] All partitions unmounted" | |||
| 11 | + | echo "Unmounted all partitions successfully" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 12 | + | ||||
| 13 | + | # Close encrypted volume if encryption was enabled | |||
| 14 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |||
| 15 | + | cryptsetup close cryptroot >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | |||
| 16 | + | echo "Closed encrypted volume" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 17 | + | fi | |||
| 18 | + | else | |||
| 19 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[WARN] Some partitions may still be mounted" | |||
| 20 | + | echo "Warning: Failed to unmount all partitions cleanly" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 21 | + | fi | |||
A install/post-install/verify.sh +130 -0
| @@ -0,0 +1,130 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Post-install verification: Ensure everything is configured correctly | |
| 3 | + | ||
| 4 | + | ####################################### | |
| 5 | + | # Description: Verify installation components | |
| 6 | + | # Globals: | |
| 7 | + | # ARCHUP_INSTALL_LOG_FILE | |
| 8 | + | # ARCHUP_ENCRYPTION | |
| 9 | + | # PADDING_LEFT | |
| 10 | + | # Arguments: | |
| 11 | + | # None | |
| 12 | + | # Outputs: | |
| 13 | + | # Verification status to log and terminal | |
| 14 | + | # Returns: | |
| 15 | + | # 0 if successful, 1 on critical failure | |
| 16 | + | ####################################### | |
| 17 | + | ||
| 18 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Verifying installation..." | |
| 19 | + | ||
| 20 | + | # Track verification failures | |
| 21 | + | VERIFICATION_FAILED=0 | |
| 22 | + | ||
| 23 | + | ####################################### | |
| 24 | + | # Description: Verify a file exists | |
| 25 | + | # Arguments: | |
| 26 | + | # $1 - File path (without /mnt prefix) | |
| 27 | + | # $2 - Description | |
| 28 | + | # Returns: | |
| 29 | + | # 0 if exists, 1 if missing | |
| 30 | + | ####################################### | |
| 31 | + | verify_file() { | |
| 32 | + | local file=$1 | |
| 33 | + | local description=$2 | |
| 34 | + | ||
| 35 | + | if [ -f "/mnt$file" ]; then | |
| 36 | + | echo "[OK] $description: $file" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 37 | + | return 0 | |
| 38 | + | else | |
| 39 | + | echo "[ERROR] $description missing: $file" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 40 | + | VERIFICATION_FAILED=1 | |
| 41 | + | return 1 | |
| 42 | + | fi | |
| 43 | + | } | |
| 44 | + | ||
| 45 | + | verify_dir() { | |
| 46 | + | local dir=$1 | |
| 47 | + | local description=$2 | |
| 48 | + | ||
| 49 | + | if [ -d "/mnt$dir" ]; then | |
| 50 | + | echo "[OK] $description: $dir" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 51 | + | return 0 | |
| 52 | + | else | |
| 53 | + | echo "[ERROR] $description missing: $dir" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 54 | + | VERIFICATION_FAILED=1 | |
| 55 | + | return 1 | |
| 56 | + | fi | |
| 57 | + | } | |
| 58 | + | verify_file "/boot/vmlinuz-linux" "Kernel" | |
| 59 | + | verify_file "/boot/initramfs-linux.img" "Initramfs" | |
| 60 | + | verify_file "/boot/initramfs-linux-fallback.img" "Fallback initramfs" | |
| 61 | + | ||
| 62 | + | verify_file "/boot/EFI/limine/BOOTX64.EFI" "Limine bootloader" | |
| 63 | + | verify_file "/boot/EFI/limine/limine.conf" "Limine configuration" | |
| 64 | + | ||
| 65 | + | if [ -f "/mnt/boot/EFI/limine/limine.conf" ]; then | |
| 66 | + | if grep -q "^/" /mnt/boot/EFI/limine/limine.conf && \ | |
| 67 | + | grep -q "protocol:" /mnt/boot/EFI/limine/limine.conf && \ | |
| 68 | + | grep -q "path:" /mnt/boot/EFI/limine/limine.conf; then | |
| 69 | + | echo "[OK] Limine config validated" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 70 | + | else | |
| 71 | + | echo "[ERROR] Limine config validation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 72 | + | VERIFICATION_FAILED=1 | |
| 73 | + | fi | |
| 74 | + | fi | |
| 75 | + | verify_file "/etc/fstab" "Filesystem table" | |
| 76 | + | verify_file "/etc/hostname" "Hostname" | |
| 77 | + | verify_file "/etc/locale.conf" "Locale configuration" | |
| 78 | + | verify_file "/etc/locale.gen" "Locale generation file" | |
| 79 | + | ||
| 80 | + | if [ -f "/mnt/etc/systemd/network/20-wired.network" ] || [ -f "/mnt/etc/NetworkManager/NetworkManager.conf" ]; then | |
| 81 | + | echo "[OK] Network configuration present" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 82 | + | else | |
| 83 | + | echo "[ERROR] Network configuration missing" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 84 | + | VERIFICATION_FAILED=1 | |
| 85 | + | fi | |
| 86 | + | ||
| 87 | + | if arch-chroot /mnt ls /home 2>/dev/null | grep -q .; then | |
| 88 | + | USERNAME=$(arch-chroot /mnt ls /home 2>/dev/null | head -1) | |
| 89 | + | echo "[OK] User created: $USERNAME" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 90 | + | verify_dir "/home/$USERNAME" "User home directory" | |
| 91 | + | else | |
| 92 | + | echo "[ERROR] No user account found" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 93 | + | VERIFICATION_FAILED=1 | |
| 94 | + | fi | |
| 95 | + | ||
| 96 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |
| 97 | + | if grep -q "encrypt" /mnt/etc/mkinitcpio.conf 2>/dev/null; then | |
| 98 | + | echo "[OK] Encryption hooks configured" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 99 | + | else | |
| 100 | + | echo "[ERROR] Encryption hooks missing in mkinitcpio.conf" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 101 | + | VERIFICATION_FAILED=1 | |
| 102 | + | fi | |
| 103 | + | fi | |
| 104 | + | ||
| 105 | + | if [ -f "/mnt/boot/arch-logo.png" ]; then | |
| 106 | + | echo "[OK] Boot logo installed" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 107 | + | else | |
| 108 | + | echo "[WARN] Boot logo not installed (optional)" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 109 | + | fi | |
| 110 | + | ||
| 111 | + | # Final verification result | |
| 112 | + | echo "" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 113 | + | if [ $VERIFICATION_FAILED -eq 0 ]; then | |
| 114 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] All critical components verified" | |
| 115 | + | echo "=== POST-INSTALL VERIFICATION: PASSED ===" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 116 | + | else | |
| 117 | + | gum style --foreground 1 --padding "0 0 1 $PADDING_LEFT" "[ERROR] Verification failed - check logs" | |
| 118 | + | echo "=== POST-INSTALL VERIFICATION: FAILED ===" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 119 | + | echo "" | |
| 120 | + | ||
| 121 | + | # Ask user if they want to continue despite errors | |
| 122 | + | if ! gum confirm "Continue with unmounting despite verification errors?" --default=false --padding "0 0 1 $PADDING_LEFT"; then | |
| 123 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Installation aborted by user" | |
| 124 | + | echo "Installation aborted by user after verification failure" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 125 | + | exit 1 | |
| 126 | + | fi | |
| 127 | + | ||
| 128 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[WARN] Continuing despite verification errors" | |
| 129 | + | echo "User chose to continue despite verification errors" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 130 | + | fi | |
| @@ -0,0 +1,130 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Post-install verification: Ensure everything is configured correctly | |||
| 3 | + | ||||
| 4 | + | ####################################### | |||
| 5 | + | # Description: Verify installation components | |||
| 6 | + | # Globals: | |||
| 7 | + | # ARCHUP_INSTALL_LOG_FILE | |||
| 8 | + | # ARCHUP_ENCRYPTION | |||
| 9 | + | # PADDING_LEFT | |||
| 10 | + | # Arguments: | |||
| 11 | + | # None | |||
| 12 | + | # Outputs: | |||
| 13 | + | # Verification status to log and terminal | |||
| 14 | + | # Returns: | |||
| 15 | + | # 0 if successful, 1 on critical failure | |||
| 16 | + | ####################################### | |||
| 17 | + | ||||
| 18 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Verifying installation..." | |||
| 19 | + | ||||
| 20 | + | # Track verification failures | |||
| 21 | + | VERIFICATION_FAILED=0 | |||
| 22 | + | ||||
| 23 | + | ####################################### | |||
| 24 | + | # Description: Verify a file exists | |||
| 25 | + | # Arguments: | |||
| 26 | + | # $1 - File path (without /mnt prefix) | |||
| 27 | + | # $2 - Description | |||
| 28 | + | # Returns: | |||
| 29 | + | # 0 if exists, 1 if missing | |||
| 30 | + | ####################################### | |||
| 31 | + | verify_file() { | |||
| 32 | + | local file=$1 | |||
| 33 | + | local description=$2 | |||
| 34 | + | ||||
| 35 | + | if [ -f "/mnt$file" ]; then | |||
| 36 | + | echo "[OK] $description: $file" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 37 | + | return 0 | |||
| 38 | + | else | |||
| 39 | + | echo "[ERROR] $description missing: $file" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 40 | + | VERIFICATION_FAILED=1 | |||
| 41 | + | return 1 | |||
| 42 | + | fi | |||
| 43 | + | } | |||
| 44 | + | ||||
| 45 | + | verify_dir() { | |||
| 46 | + | local dir=$1 | |||
| 47 | + | local description=$2 | |||
| 48 | + | ||||
| 49 | + | if [ -d "/mnt$dir" ]; then | |||
| 50 | + | echo "[OK] $description: $dir" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 51 | + | return 0 | |||
| 52 | + | else | |||
| 53 | + | echo "[ERROR] $description missing: $dir" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 54 | + | VERIFICATION_FAILED=1 | |||
| 55 | + | return 1 | |||
| 56 | + | fi | |||
| 57 | + | } | |||
| 58 | + | verify_file "/boot/vmlinuz-linux" "Kernel" | |||
| 59 | + | verify_file "/boot/initramfs-linux.img" "Initramfs" | |||
| 60 | + | verify_file "/boot/initramfs-linux-fallback.img" "Fallback initramfs" | |||
| 61 | + | ||||
| 62 | + | verify_file "/boot/EFI/limine/BOOTX64.EFI" "Limine bootloader" | |||
| 63 | + | verify_file "/boot/EFI/limine/limine.conf" "Limine configuration" | |||
| 64 | + | ||||
| 65 | + | if [ -f "/mnt/boot/EFI/limine/limine.conf" ]; then | |||
| 66 | + | if grep -q "^/" /mnt/boot/EFI/limine/limine.conf && \ | |||
| 67 | + | grep -q "protocol:" /mnt/boot/EFI/limine/limine.conf && \ | |||
| 68 | + | grep -q "path:" /mnt/boot/EFI/limine/limine.conf; then | |||
| 69 | + | echo "[OK] Limine config validated" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 70 | + | else | |||
| 71 | + | echo "[ERROR] Limine config validation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 72 | + | VERIFICATION_FAILED=1 | |||
| 73 | + | fi | |||
| 74 | + | fi | |||
| 75 | + | verify_file "/etc/fstab" "Filesystem table" | |||
| 76 | + | verify_file "/etc/hostname" "Hostname" | |||
| 77 | + | verify_file "/etc/locale.conf" "Locale configuration" | |||
| 78 | + | verify_file "/etc/locale.gen" "Locale generation file" | |||
| 79 | + | ||||
| 80 | + | if [ -f "/mnt/etc/systemd/network/20-wired.network" ] || [ -f "/mnt/etc/NetworkManager/NetworkManager.conf" ]; then | |||
| 81 | + | echo "[OK] Network configuration present" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 82 | + | else | |||
| 83 | + | echo "[ERROR] Network configuration missing" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 84 | + | VERIFICATION_FAILED=1 | |||
| 85 | + | fi | |||
| 86 | + | ||||
| 87 | + | if arch-chroot /mnt ls /home 2>/dev/null | grep -q .; then | |||
| 88 | + | USERNAME=$(arch-chroot /mnt ls /home 2>/dev/null | head -1) | |||
| 89 | + | echo "[OK] User created: $USERNAME" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 90 | + | verify_dir "/home/$USERNAME" "User home directory" | |||
| 91 | + | else | |||
| 92 | + | echo "[ERROR] No user account found" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 93 | + | VERIFICATION_FAILED=1 | |||
| 94 | + | fi | |||
| 95 | + | ||||
| 96 | + | if [ "$ARCHUP_ENCRYPTION" = "enabled" ]; then | |||
| 97 | + | if grep -q "encrypt" /mnt/etc/mkinitcpio.conf 2>/dev/null; then | |||
| 98 | + | echo "[OK] Encryption hooks configured" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 99 | + | else | |||
| 100 | + | echo "[ERROR] Encryption hooks missing in mkinitcpio.conf" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 101 | + | VERIFICATION_FAILED=1 | |||
| 102 | + | fi | |||
| 103 | + | fi | |||
| 104 | + | ||||
| 105 | + | if [ -f "/mnt/boot/arch-logo.png" ]; then | |||
| 106 | + | echo "[OK] Boot logo installed" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 107 | + | else | |||
| 108 | + | echo "[WARN] Boot logo not installed (optional)" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 109 | + | fi | |||
| 110 | + | ||||
| 111 | + | # Final verification result | |||
| 112 | + | echo "" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 113 | + | if [ $VERIFICATION_FAILED -eq 0 ]; then | |||
| 114 | + | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] All critical components verified" | |||
| 115 | + | echo "=== POST-INSTALL VERIFICATION: PASSED ===" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 116 | + | else | |||
| 117 | + | gum style --foreground 1 --padding "0 0 1 $PADDING_LEFT" "[ERROR] Verification failed - check logs" | |||
| 118 | + | echo "=== POST-INSTALL VERIFICATION: FAILED ===" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 119 | + | echo "" | |||
| 120 | + | ||||
| 121 | + | # Ask user if they want to continue despite errors | |||
| 122 | + | if ! gum confirm "Continue with unmounting despite verification errors?" --default=false --padding "0 0 1 $PADDING_LEFT"; then | |||
| 123 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Installation aborted by user" | |||
| 124 | + | echo "Installation aborted by user after verification failure" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 125 | + | exit 1 | |||
| 126 | + | fi | |||
| 127 | + | ||||
| 128 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[WARN] Continuing despite verification errors" | |||
| 129 | + | echo "User chose to continue despite verification errors" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 130 | + | fi | |||