Update trap

This commit is contained in:
Ryan Hughes authored and Ryan Hughes committed 2025-09-12 00:48:41 -04:00
1 parent 22988b2f3b
commit efecc030a3
1 file changed
+132 -51
+132 -51
View File
@@ -1,67 +1,69 @@
#!/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_OFFLINE_INSTALL=1 \
OMARCHY_USER_NAME="$(<user_full_name.txt)" \
OMARCHY_USER_EMAIL="$(<user_email_address.txt)" \
USER="$OMARCHY_USER" \
HOME="/home/$OMARCHY_USER" \
/bin/bash "$@"
}
# Set Tokyo Night color scheme for the terminal
set_tokyo_night_colors() {
if [[ $(tty) == "/dev/tty"* ]]; then
# Tokyo Night color palette
echo -en "\e]P01a1b26" # black (background)
echo -en "\e]P1f7768e" # red
echo -en "\e]P29ece6a" # green
echo -en "\e]P3e0af68" # yellow
echo -en "\e]P47aa2f7" # blue
echo -en "\e]P5bb9af7" # magenta
echo -en "\e]P67dcfff" # cyan
echo -en "\e]P7a9b1d6" # white
echo -en "\e]P8414868" # bright black
echo -en "\e]P9f7768e" # bright red
echo -en "\e]PA9ece6a" # bright green
echo -en "\e]PBe0af68" # bright yellow
echo -en "\e]PC7aa2f7" # bright blue
echo -en "\e]PDbb9af7" # bright magenta
echo -en "\e]PE7dcfff" # bright cyan
echo -en "\e]PFc0caf5" # bright white (foreground)
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
# Set default foreground and background
echo -en "\033[0m"
clear
fi
}
trap catch_errors ERR
OMARCHY_LOGO=' ▄▄▄
▄█████▄ ▄███████████▄ ▄███████ ▄███████ ▄███████ ▄█ █▄ ▄█ █▄
███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
███ ███ ███ ███ ███ ███ ███ ███ ███ ███ █▀ ███ ███ ███ ███
███ ███ ███ ███ ███ ▄███▄▄▄███ ▄███▄▄▄██▀ ███ ▄███▄▄▄███▄ ███▄▄▄███
███ ███ ███ ███ ███ ▀███▀▀▀███ ▀███▀▀▀▀ ███ ▀▀███▀▀▀███ ▀▀▀▀▀▀███
███ ███ ███ ███ ███ ███ ███ ██████████ ███ █▄ ███ ███ ▄██ ███
███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
▀█████▀ ▀█ ███ █▀ ███ █▀ ███ ███ ███████▀ ███ █▀ ▀█████▀
███ █▀ '
if [[ $(tty) == "/dev/tty1" ]]; then
# Initialize and populate the keyring
# Always reinitialize to ensure it's properly set up
echo "Initializing pacman keyring..."
pacman-key --init
pacman-key --populate archlinux
clear_logo() {
clear
echo -e "\033[32m$OMARCHY_LOGO\033[0m\n"
echo
}
# Sync the offline database so pacman can find packages
echo "Syncing offline package database..."
pacman -Sy --noconfirm
run_configurator() {
set -euo pipefail
# Configurator for user information, disk selection, and wifi configuration
NETWORK_NOT_NEEDED=true ./configurator
# Get username from installer config for reliable error recovery
OMARCHY_USER="$(jq -r '.users[0].username' user_credentials.json)"
export OMARCHY_USER="$(jq -r '.users[0].username' user_credentials.json)"
}
install_base_system() {
set -euo pipefail
# Initialize and populate the keyring
pacman-key --init
pacman-key --populate archlinux
# Sync the offline database so pacman can find packages
pacman -Sy --noconfirm
# Install using files generated by the ./configurator
# Skip NTP and WKD sync since we're offline (keyring is pre-populated in ISO)
@@ -111,8 +113,87 @@ EOF
find /mnt/home/$OMARCHY_USER/.local/share/omarchy -type f -path "*/bin/*" -exec chmod +x {} \;
# Ensure install.sh is executable
chmod +x /mnt/home/$OMARCHY_USER/.local/share/omarchy/install.sh 2>/dev/null || true
}
chroot_bash() {
HOME=/home/$OMARCHY_USER \
arch-chroot -u $OMARCHY_USER /mnt/ \
env OMARCHY_CHROOT_INSTALL=1 \
OMARCHY_OFFLINE_INSTALL=1 \
OMARCHY_USER_NAME="$(<user_full_name.txt)" \
OMARCHY_USER_EMAIL="$(<user_email_address.txt)" \
USER="$OMARCHY_USER" \
HOME="/home/$OMARCHY_USER" \
/bin/bash "$@"
}
catch_errors() {
# Show the last lines of the log to help debug
if [ -f "/mnt/var/log/omarchy-install.log" ]; then
tail -50 "/mnt/var/log/omarchy-install.log"
else
tail -50 "/var/log/archinstall/install.log"
fi
echo -e "\n\e[31mOmarchy Offline 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
set_tokyo_night_colors
# Configure gum spinner to match theme
export GUM_SPIN_SPINNER="line"
export GUM_SPIN_SHOW_ERROR="true" # Show output if command fails
export GUM_SPIN_ALIGN="right"
run_configurator
clear_logo
# Export functions so they're available in the subshell
export -f install_base_system
# Run base system installation with spinner
gum spin --title "Formatting and installing base system..." -- bash -c 'install_base_system'
echo -e "Base system installed \033[32m[X]\033[0m"
# Get username from the config file after installation
OMARCHY_USER="$(jq -r '.users[0].username' user_credentials.json)"
# Install gum so we can have spinners
chroot_bash -lc "sudo pacman -S --noconfirm --needed gum" >/dev/null
# Run Omarchy installer directly (skip boot.sh since it would try to clone again)
# boot.sh just clones the repo and runs install.sh, but we already have the repo
# The omarchy installer will handle its own spinner/UI
chroot_bash -lc "source /home/$OMARCHY_USER/.local/share/omarchy/install.sh || bash"
fi