A bunch of updates for rework

This commit is contained in:
Ryan Hughes
2025-11-16 19:25:52 -05:00
parent 080d287d74
commit 234f670310
8 changed files with 722 additions and 131 deletions

View File

@@ -1,4 +1,5 @@
source $OMARCHY_INSTALL/helpers/chroot.sh
# Helper functions for ISO/non-chroot usage
# These are used by .automated_script.sh on the ISO
source $OMARCHY_INSTALL/helpers/presentation.sh
source $OMARCHY_INSTALL/helpers/errors.sh
source $OMARCHY_INSTALL/helpers/logging.sh
source $OMARCHY_INSTALL/helpers/errors.sh

View File

@@ -1,3 +1,5 @@
# Log output UI for .automated_script.sh
# Tails /var/log/omarchy-install.log and displays it with pretty formatting
start_log_output() {
local ANSI_SAVE_CURSOR="\033[s"
local ANSI_RESTORE_CURSOR="\033[u"
@@ -5,6 +7,8 @@ start_log_output() {
local ANSI_HIDE_CURSOR="\033[?25l"
local ANSI_RESET="\033[0m"
local ANSI_GRAY="\033[90m"
local log_file="${1:-/var/log/omarchy-install.log}"
# Save cursor position and hide cursor
printf $ANSI_SAVE_CURSOR
@@ -16,7 +20,7 @@ start_log_output() {
while true; do
# Read the last N lines into an array
mapfile -t current_lines < <(tail -n $log_lines "$OMARCHY_INSTALL_LOG_FILE" 2>/dev/null)
mapfile -t current_lines < <(tail -n $log_lines "$log_file" 2>/dev/null)
# Build complete output buffer with escape sequences
output=""
@@ -51,84 +55,3 @@ stop_log_output() {
unset monitor_pid
fi
}
start_install_log() {
sudo touch "$OMARCHY_INSTALL_LOG_FILE"
sudo chmod 666 "$OMARCHY_INSTALL_LOG_FILE"
export OMARCHY_START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
echo "=== Omarchy Installation Started: $OMARCHY_START_TIME ===" >>"$OMARCHY_INSTALL_LOG_FILE"
start_log_output
}
stop_install_log() {
stop_log_output
show_cursor
if [[ -n ${OMARCHY_INSTALL_LOG_FILE:-} ]]; then
OMARCHY_END_TIME=$(date '+%Y-%m-%d %H:%M:%S')
echo "=== Omarchy Installation Completed: $OMARCHY_END_TIME ===" >>"$OMARCHY_INSTALL_LOG_FILE"
echo "" >>"$OMARCHY_INSTALL_LOG_FILE"
echo "=== Installation Time Summary ===" >>"$OMARCHY_INSTALL_LOG_FILE"
if [ -f "/var/log/archinstall/install.log" ]; then
ARCHINSTALL_START=$(grep -m1 '^\[' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
ARCHINSTALL_END=$(grep 'Installation completed without any errors' /var/log/archinstall/install.log 2>/dev/null | sed 's/^\[\([^]]*\)\].*/\1/' || true)
if [ -n "$ARCHINSTALL_START" ] && [ -n "$ARCHINSTALL_END" ]; then
ARCH_START_EPOCH=$(date -d "$ARCHINSTALL_START" +%s)
ARCH_END_EPOCH=$(date -d "$ARCHINSTALL_END" +%s)
ARCH_DURATION=$((ARCH_END_EPOCH - ARCH_START_EPOCH))
ARCH_MINS=$((ARCH_DURATION / 60))
ARCH_SECS=$((ARCH_DURATION % 60))
echo "Archinstall: ${ARCH_MINS}m ${ARCH_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
fi
fi
if [ -n "$OMARCHY_START_TIME" ]; then
OMARCHY_START_EPOCH=$(date -d "$OMARCHY_START_TIME" +%s)
OMARCHY_END_EPOCH=$(date -d "$OMARCHY_END_TIME" +%s)
OMARCHY_DURATION=$((OMARCHY_END_EPOCH - OMARCHY_START_EPOCH))
OMARCHY_MINS=$((OMARCHY_DURATION / 60))
OMARCHY_SECS=$((OMARCHY_DURATION % 60))
echo "Omarchy: ${OMARCHY_MINS}m ${OMARCHY_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
if [ -n "$ARCH_DURATION" ]; then
TOTAL_DURATION=$((ARCH_DURATION + OMARCHY_DURATION))
TOTAL_MINS=$((TOTAL_DURATION / 60))
TOTAL_SECS=$((TOTAL_DURATION % 60))
echo "Total: ${TOTAL_MINS}m ${TOTAL_SECS}s" >>"$OMARCHY_INSTALL_LOG_FILE"
fi
fi
echo "=================================" >>"$OMARCHY_INSTALL_LOG_FILE"
echo "Rebooting system..." >>"$OMARCHY_INSTALL_LOG_FILE"
fi
}
run_logged() {
local script="$1"
export CURRENT_SCRIPT="$script"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting: $script" >>"$OMARCHY_INSTALL_LOG_FILE"
# Use bash -c to create a clean subshell
bash -c "source '$script'" </dev/null >>"$OMARCHY_INSTALL_LOG_FILE" 2>&1
local exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Completed: $script" >>"$OMARCHY_INSTALL_LOG_FILE"
unset CURRENT_SCRIPT
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Failed: $script (exit code: $exit_code)" >>"$OMARCHY_INSTALL_LOG_FILE"
fi
return $exit_code
}

View File

@@ -1,43 +1,7 @@
# Handle chroot install completion (non-interactive)
if [[ -n "${OMARCHY_CHROOT_INSTALL:-}" ]]; then
echo "[finished] Chroot installation completed, creating marker file"
if sudo test -f /etc/sudoers.d/99-omarchy-installer; then
sudo rm -f /etc/sudoers.d/99-omarchy-installer &>/dev/null
fi
touch /var/tmp/omarchy-install-completed
exit 0
fi
# Normal (non-chroot) finish
stop_install_log
echo_in_style() {
echo "$1" | tte --canvas-width 0 --anchor-text c --frame-rate 640 print
}
clear
echo
tte -i /usr/share/omarchy/logo.txt --canvas-width 0 --anchor-text c --frame-rate 920 laseretch
echo
# Display installation time if available
if [[ -f $OMARCHY_INSTALL_LOG_FILE ]] && grep -q "Total:" "$OMARCHY_INSTALL_LOG_FILE" 2>/dev/null; then
echo
TOTAL_TIME=$(tail -n 20 "$OMARCHY_INSTALL_LOG_FILE" | grep "^Total:" | sed 's/^Total:[[:space:]]*//')
if [ -n "$TOTAL_TIME" ]; then
echo_in_style "Installed in $TOTAL_TIME"
fi
else
echo_in_style "Finished installing"
fi
# Installation completed in chroot
echo "[finished] Chroot installation completed successfully"
# Clean up installer sudoers
if sudo test -f /etc/sudoers.d/99-omarchy-installer; then
sudo rm -f /etc/sudoers.d/99-omarchy-installer &>/dev/null
fi
# Exit gracefully if user chooses not to reboot
if gum confirm --padding "0 0 0 $((PADDING_LEFT + 32))" --show-help=false --default --affirmative "Reboot Now" --negative "" ""; then
# Clear screen to hide any shutdown messages
clear
sudo reboot 2>/dev/null
fi

View File

@@ -1,4 +0,0 @@
clear_logo
gum style --foreground 3 --padding "1 0 0 $PADDING_LEFT" "Installing..."
echo
start_install_log