Three modes the installer now branches on:
iso-chroot Running inside the new system's chroot from the ISO build.
pacman is configured by archinstall; systemd isn't running,
so service enables skip --now.
online-package Running on an existing Arch where the omarchy-* packages
are already installed. Skip base.sh and the bootstrap
preflight steps; only the per-host runtime ops in
config/login/post-install need to run.
online-git boot.sh path: clone into $HOME/.local/share/omarchy and
bootstrap everything from scratch.
install.sh derives OMARCHY_PATH from its own location, so the same script
works whether it's at /usr/share/omarchy/install.sh (package mode) or
$HOME/.local/share/omarchy/install.sh (git mode). install_mode_is helper
replaces direct ${OMARCHY_CHROOT_INSTALL:-} / ${OMARCHY_ONLINE_INSTALL:-}
checks in chroot.sh, finished.sh, errors.sh, mise-work.sh, preflight/pacman.sh.
Legacy vars still work through export_legacy_mode_flags, which sets
OMARCHY_CHROOT_INSTALL=1 / OMARCHY_ONLINE_INSTALL=true based on the
canonical mode for any caller that hasn't been updated.
bin/omarchy-install-mode prints the current mode for scripts/users that
need to introspect.
Smoke-tested all four entry paths (explicit mode, both legacy shims,
auto-detection from OMARCHY_PATH); each resolves correctly and the
legacy flags are exported in matching modes.
164 lines
4.3 KiB
Bash
164 lines
4.3 KiB
Bash
# Directs user to Omarchy Discord
|
|
QR_CODE='
|
|
█▀▀▀▀▀█ ▄ ▄ ▀▄▄▄█ █▀▀▀▀▀█
|
|
█ ███ █ ▄▄▄▄▀▄▀▄▀ █ ███ █
|
|
█ ▀▀▀ █ ▄█ ▄█▄▄▀ █ ▀▀▀ █
|
|
▀▀▀▀▀▀▀ ▀▄█ █ █ █ ▀▀▀▀▀▀▀
|
|
▀▀█▀▀▄▀▀▀▀▄█▀▀█ ▀ █ ▀ █
|
|
█▄█ ▄▄▀▄▄ ▀ ▄ ▀█▄▄▄▄ ▀ ▀█
|
|
▄ ▄▀█ ▀▄▀▀▀▄ ▄█▀▄█▀▄▀▄▀█▀
|
|
█ ▄▄█▄▀▄█ ▄▄▄ ▀ ▄▀██▀ ▀█
|
|
▀ ▀ ▀ █ ▀▄ ▀▀█▀▀▀█▄▀
|
|
█▀▀▀▀▀█ ▀█ ▄▀▀ █ ▀ █▄▀██
|
|
█ ███ █ █▀▄▄▀ █▀███▀█▄██▄
|
|
█ ▀▀▀ █ ██ ▀ █▄█ ▄▄▄█▀ █
|
|
▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀ ▀ ▀▀▀▀▀▀'
|
|
|
|
# Track if we're already handling an error to prevent double-trapping
|
|
ERROR_HANDLING=false
|
|
|
|
# Cursor is usually hidden while we install
|
|
show_cursor() {
|
|
printf "\033[?25h"
|
|
}
|
|
|
|
# Display truncated log lines from the install log
|
|
show_log_tail() {
|
|
if [[ -f $OMARCHY_INSTALL_LOG_FILE ]]; then
|
|
local log_lines=$((TERM_HEIGHT - LOGO_HEIGHT - 35))
|
|
local max_line_width=$((LOGO_WIDTH - 4))
|
|
|
|
tail -n $log_lines "$OMARCHY_INSTALL_LOG_FILE" | while IFS= read -r line; do
|
|
if ((${#line} > max_line_width)); then
|
|
local truncated_line="${line:0:$max_line_width}..."
|
|
else
|
|
local truncated_line="$line"
|
|
fi
|
|
|
|
gum style "$truncated_line"
|
|
done
|
|
|
|
echo
|
|
fi
|
|
}
|
|
|
|
# Display the failed command or script name
|
|
show_failed_script_or_command() {
|
|
if [[ -n ${CURRENT_SCRIPT:-} ]]; then
|
|
gum style "Failed script: $CURRENT_SCRIPT"
|
|
else
|
|
# Truncate long command lines to fit the display
|
|
local cmd="$BASH_COMMAND"
|
|
local max_cmd_width=$((LOGO_WIDTH - 4))
|
|
|
|
if ((${#cmd} > max_cmd_width)); then
|
|
cmd="${cmd:0:$max_cmd_width}..."
|
|
fi
|
|
|
|
gum style "$cmd"
|
|
fi
|
|
}
|
|
|
|
# Save original stdout and stderr for trap to use
|
|
save_original_outputs() {
|
|
exec 3>&1 4>&2
|
|
}
|
|
|
|
# Restore stdout and stderr to original (saved in FD 3 and 4)
|
|
# This ensures output goes to screen, not log file
|
|
restore_outputs() {
|
|
if [[ -e /proc/self/fd/3 ]] && [[ -e /proc/self/fd/4 ]]; then
|
|
exec 1>&3 2>&4
|
|
fi
|
|
}
|
|
|
|
# Error handler
|
|
catch_errors() {
|
|
# Prevent recursive error handling
|
|
if [[ $ERROR_HANDLING == "true" ]]; then
|
|
return
|
|
else
|
|
ERROR_HANDLING=true
|
|
fi
|
|
|
|
# Store exit code immediately before it gets overwritten
|
|
local exit_code=$?
|
|
|
|
stop_log_output
|
|
restore_outputs
|
|
|
|
clear_logo
|
|
show_cursor
|
|
|
|
gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "Omarchy installation stopped!"
|
|
show_log_tail
|
|
|
|
gum style "This command halted with exit code $exit_code:"
|
|
show_failed_script_or_command
|
|
|
|
gum style "$QR_CODE"
|
|
echo
|
|
gum style "Get help from the community via QR code or at https://discord.gg/tXFUdasqhY"
|
|
|
|
# Offer options menu
|
|
while true; do
|
|
options=()
|
|
|
|
# Retry only makes sense for online flows (git clone or package install).
|
|
if install_mode_is online-git || install_mode_is online-package; then
|
|
options+=("Retry installation")
|
|
fi
|
|
|
|
# Add upload option if internet is available
|
|
if ping -c 1 -W 1 1.1.1.1 >/dev/null 2>&1; then
|
|
options+=("Upload log for support")
|
|
fi
|
|
|
|
# Add remaining options
|
|
options+=("View full log")
|
|
options+=("Exit")
|
|
|
|
choice=$(gum choose "${options[@]}" --header "What would you like to do?" --height 6 --padding "1 $PADDING_LEFT")
|
|
|
|
case "$choice" in
|
|
"Retry installation")
|
|
bash ~/.local/share/omarchy/install.sh
|
|
break
|
|
;;
|
|
"View full log")
|
|
if command -v less &>/dev/null; then
|
|
less "$OMARCHY_INSTALL_LOG_FILE"
|
|
else
|
|
tail "$OMARCHY_INSTALL_LOG_FILE"
|
|
fi
|
|
;;
|
|
"Upload log for support")
|
|
omarchy-upload-log
|
|
;;
|
|
"Exit" | "")
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
# Exit handler - ensures cleanup happens on any exit
|
|
exit_handler() {
|
|
local exit_code=$?
|
|
|
|
# Only run if we're exiting with an error and haven't already handled it
|
|
if (( exit_code != 0 )) && [[ $ERROR_HANDLING != "true" ]]; then
|
|
catch_errors
|
|
else
|
|
stop_log_output
|
|
show_cursor
|
|
fi
|
|
}
|
|
|
|
# Set up traps
|
|
trap catch_errors ERR INT TERM
|
|
trap exit_handler EXIT
|
|
|
|
# Save original outputs in case we trap
|
|
save_original_outputs
|