| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # aurora installer (krolyxon's desktop) |
| 4 | # |
| 5 | # READ THIS FIRST: |
| 6 | # This sets up MY personal desktop (Arch + Hyprland + aurora), built around my own |
| 7 | # hardware (Lenovo Legion, Intel + NVIDIA hybrid, linux-zen) and my habits. |
| 8 | # It is NOT a general purpose installer and I'm not trying to make it one. |
| 9 | # |
| 10 | # From the Arch ISO it installs everything: it ERASES the disk you pick (or uses |
| 11 | # partitions you pick), installs Arch, GRUB and your user, then the desktop. |
| 12 | # On an installed system it only does the desktop part. Only run that on a |
| 13 | # FRESHLY INSTALLED, UNCONFIGURED Arch Linux system: it installs a lot of packages, |
| 14 | # moves your existing configs out of the way, changes your login shell and can |
| 15 | # enable system services. |
| 16 | # |
| 17 | # If you just want a piece of the setup, copy the files you like instead. |
| 18 | # |
| 19 | # Usage: |
| 20 | # From the Arch ISO (as root, network up): |
| 21 | # bash <(curl -fsSL https://git.krolyxon.com/aurora/raw/master/install.sh) |
| 22 | # |
| 23 | # ./install.sh on the Arch ISO: full install (disk, Arch, desktop) |
| 24 | # on an installed Arch: the desktop only (= --desktop) |
| 25 | # ./install.sh --desktop desktop only: packages, dotfiles (stow), zsh, services |
| 26 | # ./install.sh --base Arch ISO only: disk, Arch, GRUB, user, no desktop |
| 27 | # ./install.sh --yes pre-select everything, don't ask (still asks the fresh-system question) |
| 28 | # ./install.sh --check compare installed packages with packages/*.txt, changes nothing |
| 29 | |
| 30 | trap 'log WARN "Interrupted by user"; exit 130' INT |
| 31 | |
| 32 | INSTALL_STATUS="none" # none | partial | complete | failed |
| 33 | MODE="" # full | base | desktop |
| 34 | AUTO_YES=0 |
| 35 | CHECK_ONLY=0 |
| 36 | PICKS="" # file with the packages to install instead of the pickers |
| 37 | BACKUP_DIR="" |
| 38 | |
| 39 | REPO_URLS=(https://git.krolyxon.com/aurora https://github.com/krolyxon/aurora) |
| 40 | |
| 41 | currentDir="$(dirname "$(readlink -f "$0")")" |
| 42 | |
| 43 | ############### |
| 44 | ## Bootstrap ## |
| 45 | ############### |
| 46 | # Started without the repo (bash <(curl ...)): clone it and run the clone's install.sh. |
| 47 | # On the ISO the clone is temporary (the full install copies it to the new home); |
| 48 | # elsewhere it's the checkout the dotfiles get stowed from, so it goes to ~/aurora. |
| 49 | if [[ ! -f "$currentDir/install/lib.sh" ]]; then |
| 50 | if [[ $EUID -eq 0 && -d /run/archiso ]]; then |
| 51 | dest=/tmp/aurora |
| 52 | command -v git >/dev/null || pacman -Sy --needed --noconfirm git || exit 1 |
| 53 | else |
| 54 | dest="$HOME/aurora" |
| 55 | command -v git >/dev/null || sudo pacman -S --needed --noconfirm git || exit 1 |
| 56 | fi |
| 57 | if [[ ! -f "$dest/install/lib.sh" ]]; then |
| 58 | [[ -e "$dest" ]] && { echo "$dest exists but isn't an aurora checkout, move it away first." >&2; exit 1; } |
| 59 | for url in "${REPO_URLS[@]}"; do |
| 60 | git clone "$url" "$dest" && break |
| 61 | done |
| 62 | fi |
| 63 | [[ -f "$dest/install/lib.sh" ]] || { echo "Couldn't clone aurora." >&2; exit 1; } |
| 64 | exec bash "$dest/install.sh" "$@" |
| 65 | fi |
| 66 | |
| 67 | cd "$currentDir" || exit 1 |
| 68 | PKG_DIR="$currentDir/packages" |
| 69 | |
| 70 | # shellcheck source=install/lib.sh |
| 71 | source "$currentDir/install/lib.sh" |
| 72 | |
| 73 | ####################### |
| 74 | ## Arguement Parsing ## |
| 75 | ####################### |
| 76 | while (($#)); do |
| 77 | case "$1" in |
| 78 | --desktop) |
| 79 | MODE=desktop |
| 80 | ;; |
| 81 | --base) |
| 82 | MODE=base |
| 83 | ;; |
| 84 | --yes|--ci|--non-interactive) |
| 85 | AUTO_YES=1 |
| 86 | ;; |
| 87 | --check) |
| 88 | CHECK_ONLY=1 |
| 89 | ;; |
| 90 | --picks) |
| 91 | # internal: the full install hands the pickers' answers to the desktop part |
| 92 | PICKS="${2:-}" |
| 93 | shift |
| 94 | [[ -f "$PICKS" ]] || { log ERROR "--picks: no such file: $PICKS"; exit 1; } |
| 95 | ;; |
| 96 | -h|--help) |
| 97 | usage |
| 98 | exit 0 |
| 99 | ;; |
| 100 | *) |
| 101 | log ERROR "Unknown option: $1" |
| 102 | usage |
| 103 | exit 1 |
| 104 | ;; |
| 105 | esac |
| 106 | shift |
| 107 | done |
| 108 | |
| 109 | if ((CHECK_ONLY)); then |
| 110 | check_packages |
| 111 | exit 0 |
| 112 | fi |
| 113 | |
| 114 | # No mode given: the ISO means a bare machine, anything else already runs Arch |
| 115 | if [[ -z "$MODE" ]]; then |
| 116 | if [[ $EUID -eq 0 && -d /run/archiso ]]; then MODE=full; else MODE=desktop; fi |
| 117 | fi |
| 118 | |
| 119 | case "$MODE" in |
| 120 | full|base) |
| 121 | # shellcheck source=install/base.sh |
| 122 | source "$currentDir/install/base.sh" |
| 123 | ;; |
| 124 | desktop) |
| 125 | # shellcheck source=install/desktop.sh |
| 126 | source "$currentDir/install/desktop.sh" |
| 127 | ;; |
| 128 | esac |