diff options
| -rw-r--r-- | TODO.org | 9 | ||||
| -rwxr-xr-x | archsetup | 124 |
2 files changed, 115 insertions, 18 deletions
@@ -168,8 +168,15 @@ RESOLVED: Added preflight_checks() function that verifies: - pacman available - Running on Arch Linux (/etc/arch-release exists) -*** TODO [#A] Implement state tracking for install progress +*** DONE [#A] Implement state tracking for install progress +CLOSED: [2025-12-01 Sun] Track what completed vs failed mid-run to enable targeted recovery and resume capability +RESOLVED: Implemented file-based state tracking: +- State stored in /var/lib/archsetup/state/ as marker files +- run_step() wrapper skips completed steps on resume +- --status flag shows progress +- --fresh flag clears state for clean restart +- 12 major steps tracked (intro through boot_ux) *** TODO [#A] Fix sleep/suspend on Framework Laptop Critical functionality for laptop use - current battery drain unacceptable @@ -29,15 +29,36 @@ fi ### Parse Arguments skip_slow_packages=false +fresh_install=false +show_status_only=false + while [ $# -gt 0 ]; do case "$1" in --skip-slow-packages) skip_slow_packages=true shift ;; + --fresh) + fresh_install=true + shift + ;; + --status) + show_status_only=true + shift + ;; + --help|-h) + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Options:" + echo " --skip-slow-packages Skip texlive-meta and topgrade" + echo " --fresh Start fresh, ignore previous progress" + echo " --status Show installation progress and exit" + echo " --help, -h Show this help message" + exit 0 + ;; *) echo "Unknown option: $1" - echo "Usage: $0 [--skip-slow-packages]" + echo "Usage: $0 [--skip-slow-packages] [--fresh] [--status]" exit 1 ;; esac @@ -64,6 +85,75 @@ packages_after="/var/log/archsetup-post-install-package-list.txt" archsetup_packages="/var/log/archsetup-installed-packages.txt" min_disk_space_gb=20 +state_dir="/var/lib/archsetup/state" + +### State Tracking +# Enables resuming from where the script left off if interrupted. +# State is stored as marker files in $state_dir. +# Use --fresh to start over, --status to check progress. + +step_completed() { + [ -f "$state_dir/$1" ] +} + +mark_complete() { + mkdir -p "$state_dir" + echo "$(date +'%Y-%m-%d %H:%M:%S')" > "$state_dir/$1" +} + +run_step() { + step_name="$1" + step_func="$2" + + if step_completed "$step_name"; then + printf "Skipping %s (already completed)\n" "$step_name" + return 0 + fi + + if $step_func; then + mark_complete "$step_name" + return 0 + else + printf "FAILED: %s\n" "$step_name" + printf "To retry this step, remove: %s/%s\n" "$state_dir" "$step_name" + return 1 + fi +} + +show_status() { + echo "Archsetup State Status" + echo "======================" + echo "State directory: $state_dir" + echo "" + if [ ! -d "$state_dir" ]; then + echo "No state found. Script has not been run or was run with --fresh." + exit 0 + fi + echo "Completed steps:" + for step in intro prerequisites create_user user_customizations \ + aur_installer essential_services xorg dwm \ + desktop_environment developer_workstation \ + supplemental_software boot_ux; do + if step_completed "$step"; then + timestamp=$(cat "$state_dir/$step") + printf " [x] %-25s (%s)\n" "$step" "$timestamp" + else + printf " [ ] %-25s\n" "$step" + fi + done + exit 0 +} + +# Handle --status flag (must be after state_dir is defined) +if $show_status_only; then + show_status +fi + +# Handle --fresh flag +if $fresh_install; then + echo "Starting fresh installation (removing previous state)..." + rm -rf "$state_dir" +fi ### Pre-flight Checks preflight_checks() { @@ -1093,21 +1183,21 @@ outro() { } ### Installation Steps -preflight_checks # verify system requirements before starting -intro # take start stats - -prerequisites # install software required to install software -create_user # create user in wheel with :nopasswd sudo -user_customizations # dotfiles -aur_installer # install yay -essential_services # ssh, firewall, printing, etc -xorg # display manager -dwm # window manager -desktop_environment # commonly used applications -developer_workstation # development tools and utilities -supplemental_software # everything else -boot_ux # make booting visually nicer - -outro # take end stats; show summary +preflight_checks # verify system requirements (always runs) + +run_step "intro" intro +run_step "prerequisites" prerequisites +run_step "create_user" create_user +run_step "user_customizations" user_customizations +run_step "aur_installer" aur_installer +run_step "essential_services" essential_services +run_step "xorg" xorg +run_step "dwm" dwm +run_step "desktop_environment" desktop_environment +run_step "developer_workstation" developer_workstation +run_step "supplemental_software" supplemental_software +run_step "boot_ux" boot_ux + +outro # take end stats; show summary (always runs) exit 0 |
