Files
omarchy-iso/builder/cmds/autostart.sh
T
Ryan Hughes 0128542255 Revert "Eliminate duplicate trap"
This reverts commit dd32200181ef6a5688fcb5ed11bec12c060a1c90.
2025-09-12 00:48:50 -04:00

79 lines
3.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
chroot_bash() {
HOME=/home/$OMARCHY_USER \
arch-chroot -u $OMARCHY_USER /mnt/ \
env OMARCHY_CHROOT_INSTALL=1 \
OMARCHY_USER_NAME="$(<user_full_name.txt)" \
OMARCHY_USER_EMAIL="$(<user_email_address.txt)" \
USER="$OMARCHY_USER" \
HOME="/home/$OMARCHY_USER" \
OMARCHY_REPO="$(<omarchy_installer_repo.txt)" \
OMARCHY_REF="$(<omarchy_installer_ref.txt)" \
/bin/bash "$@"
}
catch_errors() {
echo -e "\n\e[31mOmarchy ISO installation failed!\e[0m"
echo
echo "This command halted with exit code $?:"
echo "$BASH_COMMAND"
echo
echo "Get help from the community via QR code or at https://discord.gg/tXFUdasqhY"
echo " "
echo " █▀▀▀▀▀█ ▄ ▄ ▀▄▄▄█ █▀▀▀▀▀█ "
echo " █ ███ █ ▄▄▄▄▀▄▀▄▀ █ ███ █ "
echo " █ ▀▀▀ █ ▄█ ▄█▄▄▀ █ ▀▀▀ █ "
echo " ▀▀▀▀▀▀▀ ▀▄█ █ █ █ ▀▀▀▀▀▀▀ "
echo " ▀▀█▀▀▄▀▀▀▀▄█▀▀█ ▀ █ ▀ █ "
echo " █▄█ ▄▄▀▄▄ ▀ ▄ ▀█▄▄▄▄ ▀ ▀█ "
echo " ▄ ▄▀█ ▀▄▀▀▀▄ ▄█▀▄█▀▄▀▄▀█▀ "
echo " █ ▄▄█▄▀▄█ ▄▄▄ ▀ ▄▀██▀ ▀█ "
echo " ▀ ▀ ▀ █ ▀▄ ▀▀█▀▀▀█▄▀ "
echo " █▀▀▀▀▀█ ▀█ ▄▀▀ █ ▀ █▄▀██ "
echo " █ ███ █ █▀▄▄▀ █▀███▀█▄██▄ "
echo " █ ▀▀▀ █ ██ ▀ █▄█ ▄▄▄█▀ █ "
echo " ▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀ ▀ ▀▀▀▀▀▀ "
echo " "
if [[ -z ${OMARCHY_USER-} ]]; then
echo "You can retry by running: ~/.automated_script.sh"
else
echo "You can retry by running: bash ~/.local/share/omarchy/install.sh || bash"
chroot_bash
fi
}
trap catch_errors ERR
if [[ $(tty) == "/dev/tty1" ]]; then
# Configurator for user information, disk selection, and wifi configuration
./configurator
# Get username from installer config for reliable error recovery
OMARCHY_USER="$(jq -r '.users[0].username' user_credentials.json)"
# Ensure that no mounts exist from past install attempts
findmnt -R /mnt >/dev/null && umount -R /mnt
# Install using files generated by the ./configurator
archinstall \
--config user_configuration.json \
--creds user_credentials.json \
--silent
# No need to ask for sudo during the installation (omarchy itself responsible for removing after install)
mkdir -p /mnt/etc/sudoers.d
cat >/mnt/etc/sudoers.d/99-omarchy-installer <<EOF
root ALL=(ALL:ALL) NOPASSWD: ALL
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
$OMARCHY_USER ALL=(ALL:ALL) NOPASSWD: ALL
EOF
chmod 440 /mnt/etc/sudoers.d/99-omarchy-installer
# Run Omarchy web installer
OMARCHY_INSTALL_URL=$(cat omarchy_installer_url.txt 2>/dev/null || echo "https://omarchy.org/install")
chroot_bash -lc "curl -fsSL $OMARCHY_INSTALL_URL | bash || bash"
fi