#!/bin/bash # # Omarchy Final Configurations Installer # # This script runs from archinstall's custom_commands after base packages # and user creation. It switches to the created user and runs install.sh # to complete package installation and system configuration. # # archinstall runs custom_commands as root via: # arch-chroot -S /mnt bash /var/tmp/user-command.0.sh # set -eEo pipefail # Setup comprehensive logging for chroot execution # This ensures all output is captured even though we're running inside chroot CHROOT_LOG_FILE="/var/log/omarchy-install-chroot.log" mkdir -p "$(dirname "$CHROOT_LOG_FILE")" touch "$CHROOT_LOG_FILE" # Redirect all output to both the log file and stdout # This way: # 1. Output is saved to /var/log/omarchy-install-chroot.log (inside chroot = /mnt/var/log on ISO) # 2. Output still goes to stdout so arch-chroot can potentially capture it # 3. We use exec to redirect the entire script's output from this point forward exec > >(tee -a "$CHROOT_LOG_FILE") 2>&1 # Log script start with timestamp echo "========================================" echo "Omarchy Chroot Install Starting" echo "Started at: $(date '+%Y-%m-%d %H:%M:%S')" echo "Log file: $CHROOT_LOG_FILE" echo "========================================" echo # Find the first non-root user (UID >= 1000, < 60000) OMARCHY_USER=$(getent passwd | awk -F: '$3 >= 1000 && $3 < 60000 {print $1; exit}') if [[ -z "$OMARCHY_USER" ]]; then echo "ERROR: No non-root user found!" echo "Users created:" getent passwd | awk -F: '$3 >= 1000 {print $1, $3}' exit 1 fi echo "Setting up Omarchy for user: $OMARCHY_USER" # Setup passwordless sudo (will be removed by post-install) echo "Setting up passwordless sudo..." mkdir -p /etc/sudoers.d cat >/etc/sudoers.d/99-omarchy-installer <