Extract error trapping to its own file

This commit is contained in:
David Heinemeier Hansson 2025-08-24 07:21:49 +02:00
parent aa0b44b7f4
commit 2ae973108d
2 changed files with 38 additions and 33 deletions

View File

@ -6,39 +6,6 @@ set -e
export PATH="$HOME/.local/share/omarchy/bin:$PATH" export PATH="$HOME/.local/share/omarchy/bin:$PATH"
OMARCHY_INSTALL=~/.local/share/omarchy/install OMARCHY_INSTALL=~/.local/share/omarchy/install
# Give people a chance to retry running the installation
catch_errors() {
echo -e "\n\e[31mOmarchy 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 [[ -n $OMARCHY_BARE ]]; then
echo "You can retry by running: OMARCHY_BARE=true bash ~/.local/share/omarchy/install.sh"
else
echo "You can retry by running: bash ~/.local/share/omarchy/install.sh"
fi
}
trap catch_errors ERR
show_logo() { show_logo() {
clear clear
tte -i ~/.local/share/omarchy/logo.txt --frame-rate ${2:-120} ${1:-expand} tte -i ~/.local/share/omarchy/logo.txt --frame-rate ${2:-120} ${1:-expand}
@ -51,6 +18,7 @@ show_subtext() {
} }
# Install prerequisites # Install prerequisites
source $OMARCHY_INSTALL/preflight/trap-errors.sh
source $OMARCHY_INSTALL/preflight/chroot.sh source $OMARCHY_INSTALL/preflight/chroot.sh
source $OMARCHY_INSTALL/preflight/mirrorlist.sh source $OMARCHY_INSTALL/preflight/mirrorlist.sh
source $OMARCHY_INSTALL/preflight/guard.sh source $OMARCHY_INSTALL/preflight/guard.sh

View File

@ -0,0 +1,37 @@
#!/bin/bash
# Give people a chance to retry running the installation
catch_errors() {
echo -e "\n\e[31mOmarchy 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 [[ -n $OMARCHY_BARE ]]; then
echo "You can retry by running: OMARCHY_BARE=true bash ~/.local/share/omarchy/install.sh"
else
echo "You can retry by running: bash ~/.local/share/omarchy/install.sh"
fi
}
if [ -z "${OMARCHY_CHROOT_INSTALL:-}" ]; then
# ISO installer has its own trap we need to stay in the chroot
trap catch_errors ERR
fi