aurora70456f7
install.sh: unattended --yes, services, plugins, chroot-aware desktop step
+99 −29
2 files changed
- M install/desktop.sh +69 −28
- M install/lib.sh +30 −1
| @@ -1,6 +1,10 @@ | |||
| 1 | 1 | # shellcheck shell=bash | |
| 2 | 2 | # Desktop part: packages, dotfiles (stow), zsh, services. Sourced by install.sh; | |
| 3 | 3 | # runs as the user, asks for sudo when it needs it. | |
| 4 | + | # AURORA_CHROOT=1: run by the full install inside the new system's chroot (unattended, | |
| 5 | + | # nothing is running there yet: no --now, no user bus). | |
| 6 | + | ||
| 7 | + | IN_CHROOT="${AURORA_CHROOT:-0}" | |
| 4 | 8 | ||
| 5 | 9 | ################# | |
| 6 | 10 | ## GATEKEEPING ## | |
| @@ -51,9 +55,26 @@ check_fresh_system() { | |||
| 51 | 55 | read -rp "Type 'I understand' to continue anyway: " answer | |
| 52 | 56 | [[ "$answer" == "I understand" ]] || { log WARN "Aborted."; exit 1; } | |
| 53 | 57 | } | |
| 54 | − | check_fresh_system | |
| 58 | + | ((IN_CHROOT)) || check_fresh_system | |
| 55 | 59 | ||
| 56 | 60 | ||
| 61 | + | # Enable a unit (--user: a user unit). In the chroot nothing runs yet: | |
| 62 | + | # no --now, and user units are enabled offline (--root writes the links into $HOME). | |
| 63 | + | enable_unit() { | |
| 64 | + | if [[ "$1" == --user ]]; then | |
| 65 | + | shift | |
| 66 | + | if ((IN_CHROOT)); then | |
| 67 | + | systemctl --user --root=/ enable "$@" | |
| 68 | + | else | |
| 69 | + | systemctl --user daemon-reload && systemctl --user enable "$@" | |
| 70 | + | fi | |
| 71 | + | elif ((IN_CHROOT)); then | |
| 72 | + | sudo systemctl enable "$@" | |
| 73 | + | else | |
| 74 | + | sudo systemctl enable --now "$@" | |
| 75 | + | fi | |
| 76 | + | } | |
| 77 | + | ||
| 57 | 78 | install_prerequisites() { | |
| 58 | 79 | sudo pacman -S --needed --noconfirm stow gum git zsh | |
| 59 | 80 | } | |
| @@ -88,31 +109,18 @@ This script is provided AS IS, WITHOUT ANY WARRANTY. It will: | |||
| 88 | 109 | Proceed at your OWN RISK." | |
| 89 | 110 | ) | |
| 90 | 111 | ||
| 91 | − | confirm "$DISCLAIMER | |
| 112 | + | # The full install showed its own summary already | |
| 113 | + | if ! ((IN_CHROOT)); then | |
| 114 | + | confirm "$DISCLAIMER | |
| 92 | 115 | ||
| 93 | 116 | Do you understand the risks and want to continue?" || exit 1 | |
| 117 | + | fi | |
| 94 | 118 | ||
| 95 | 119 | ||
| 96 | 120 | ####################### | |
| 97 | 121 | ## Package selection ## | |
| 98 | 122 | ####################### | |
| 99 | − | SELECTED_PKGS=() | |
| 100 | − | for list in utils dev gpu optional aur; do | |
| 101 | − | case "$list" in | |
| 102 | − | utils) prompt_style "Important utilities (Most likely go with defaults)" ;; | |
| 103 | − | dev) prompt_style "Select Development Tools" ;; | |
| 104 | − | gpu) prompt_style "Select GPU drivers" ;; | |
| 105 | − | optional) prompt_style "Select Optional Desktop Packages" ;; | |
| 106 | − | aur) prompt_style "Select AUR packages" ;; | |
| 107 | − | esac | |
| 108 | − | ||
| 109 | − | if ((AUTO_YES)); then | |
| 110 | − | mapfile -t picked < <(preselected "$list") | |
| 111 | − | else | |
| 112 | − | gum_to_array picked < <(choose_packages "$list") | |
| 113 | − | fi | |
| 114 | − | SELECTED_PKGS+=("${picked[@]}") | |
| 115 | − | done | |
| 123 | + | pick_packages | |
| 116 | 124 | ||
| 117 | 125 | ||
| 118 | 126 | ########################## | |
| @@ -160,11 +168,16 @@ Proceed with system configuration (stow, shell)?"; then | |||
| 160 | 168 | && log SUCCESS "Dotfiles stowed successfully" \ | |
| 161 | 169 | || log ERROR "Stow failed" | |
| 162 | 170 | ||
| 171 | + | # Hyprland's Lua plugins are git checkouts, not in this repo (hyprland.lua also fetches them when missing) | |
| 172 | + | "$currentDir/.local/bin/hypr/hypr_update_plugins.sh" \ | |
| 173 | + | && log SUCCESS "Hyprland plugins installed" \ | |
| 174 | + | || log WARN "Couldn't fetch the Hyprland plugins, Hyprland fetches them at its first start" | |
| 175 | + | ||
| 163 | 176 | ################################# | |
| 164 | 177 | ## Change default shell to zsh ## | |
| 165 | 178 | ################################# | |
| 166 | 179 | log INFO "Changing the default shell to ZSH" | |
| 167 | − | if [[ "$SHELL" != "$(command -v zsh)" ]]; then | |
| 180 | + | if [[ "$(getent passwd "$USER" | cut -d: -f7)" != "$(command -v zsh)" ]]; then | |
| 168 | 181 | chsh -s "$(command -v zsh)" \ | |
| 169 | 182 | && log SUCCESS "Default shell successfully set to zsh" \ | |
| 170 | 183 | || log ERROR "Default shell could not be set to zsh" | |
| @@ -190,16 +203,22 @@ if ((${#ALL_PKGS[@]})); then | |||
| 190 | 203 | if confirm "Install all the selected packages?"; then | |
| 191 | 204 | log INFO "Installing selected packages..." | |
| 192 | 205 | ||
| 206 | + | # --yes: no prompts at all (makepkg, paru's review and provider questions take their defaults) | |
| 207 | + | noconfirm=() | |
| 208 | + | ((AUTO_YES)) && noconfirm=(--noconfirm) | |
| 209 | + | ||
| 193 | 210 | ## Installing paru if not installed already | |
| 194 | 211 | if ! command -v paru >/dev/null 2>&1; then | |
| 195 | 212 | log INFO "Installing Paru (AUR package manager)" | |
| 196 | 213 | sudo pacman -S --needed --noconfirm base-devel | |
| 197 | − | git clone https://aur.archlinux.org/paru.git | |
| 198 | − | (cd paru && makepkg -sri) | |
| 199 | − | rm -rf paru | |
| 214 | + | build="$(mktemp -d)" | |
| 215 | + | git clone https://aur.archlinux.org/paru.git "$build/paru" \ | |
| 216 | + | && (cd "$build/paru" && makepkg -sri "${noconfirm[@]}") | |
| 217 | + | rm -rf "$build" | |
| 200 | 218 | fi | |
| 201 | 219 | ||
| 202 | − | if paru -Syu --needed "${ALL_PKGS[@]}"; then | |
| 220 | + | ((AUTO_YES)) && noconfirm+=(--skipreview) | |
| 221 | + | if paru -Syu --needed "${noconfirm[@]}" "${ALL_PKGS[@]}"; then | |
| 203 | 222 | INSTALL_STATUS="complete" | |
| 204 | 223 | else | |
| 205 | 224 | INSTALL_STATUS="failed" | |
| @@ -221,8 +240,8 @@ fi | |||
| 221 | 240 | if command -v keyd >/dev/null 2>&1; then | |
| 222 | 241 | if confirm "Configure and enable keyd? "; then | |
| 223 | 242 | log INFO "Copying keyd configuration to /etc/keyd/default.conf" | |
| 224 | − | sudo cp "$currentDir/system/etc/keyd/default.conf" /etc/keyd/ | |
| 225 | − | sudo systemctl enable --now keyd.service \ | |
| 243 | + | sudo install -Dm644 "$currentDir/system/etc/keyd/default.conf" /etc/keyd/default.conf | |
| 244 | + | enable_unit keyd.service \ | |
| 226 | 245 | && log SUCCESS "Successfully enabled keyd.service" \ | |
| 227 | 246 | || log ERROR "Couldn't enable keyd.service" | |
| 228 | 247 | fi | |
| @@ -242,6 +261,26 @@ if confirm "Unlock GNOME keyring at login (writes /etc/pam.d/login and passwd)?" | |||
| 242 | 261 | fi | |
| 243 | 262 | ||
| 244 | 263 | ||
| 264 | + | ############## | |
| 265 | + | ## Services ## | |
| 266 | + | ############## | |
| 267 | + | # What the desktop expects to be running (all optional packages: only if installed) | |
| 268 | + | if confirm "Enable bluetooth, power-profiles-daemon and mpd-mpris (if installed)?"; then | |
| 269 | + | for unit in bluetooth power-profiles-daemon; do | |
| 270 | + | [[ -f "/usr/lib/systemd/system/$unit.service" ]] || continue | |
| 271 | + | enable_unit "$unit.service" \ | |
| 272 | + | && log SUCCESS "Enabled $unit.service" \ | |
| 273 | + | || log ERROR "Couldn't enable $unit.service" | |
| 274 | + | done | |
| 275 | + | # media keys reach mpd through mpd-mpris (playerctl) | |
| 276 | + | if [[ -f /usr/lib/systemd/user/mpd-mpris.service ]]; then | |
| 277 | + | enable_unit --user mpd-mpris.service \ | |
| 278 | + | && log SUCCESS "Enabled mpd-mpris.service" \ | |
| 279 | + | || log ERROR "Couldn't enable mpd-mpris.service" | |
| 280 | + | fi | |
| 281 | + | fi | |
| 282 | + | ||
| 283 | + | ||
| 245 | 284 | ######################### | |
| 246 | 285 | ## Enable aurora shell ## | |
| 247 | 286 | ######################### | |
| @@ -249,8 +288,7 @@ fi | |||
| 249 | 288 | # enabling it also ties it to graphical-session.target. No --now: no session yet. | |
| 250 | 289 | if [[ -f "$HOME/.config/systemd/user/aurora-shell.service" ]]; then | |
| 251 | 290 | if confirm "Enable aurora-shell.service (the desktop shell)?"; then | |
| 252 | − | systemctl --user daemon-reload | |
| 253 | − | systemctl --user enable aurora-shell.service \ | |
| 291 | + | enable_unit --user aurora-shell.service \ | |
| 254 | 292 | && log SUCCESS "Successfully enabled aurora-shell.service" \ | |
| 255 | 293 | || log ERROR "Couldn't enable aurora-shell.service (run 'systemctl --user enable aurora-shell' after logging in)" | |
| 256 | 294 | fi | |
| @@ -306,3 +344,6 @@ Check the logs above.$BACKUP_NOTE" | |||
| 306 | 344 | gum style --bold "Finished.$BACKUP_NOTE" | |
| 307 | 345 | ;; | |
| 308 | 346 | esac | |
| 347 | + | ||
| 348 | + | # the full install looks at this | |
| 349 | + | [[ "$INSTALL_STATUS" != failed ]] | |
| @@ -19,7 +19,8 @@ log() { | |||
| 19 | 19 | } | |
| 20 | 20 | ||
| 21 | 21 | usage() { | |
| 22 | − | sed -n '3,19s/^# \{0,1\}//p' "$0" | |
| 22 | + | # install.sh's header comment, up to the first line that isn't a comment | |
| 23 | + | sed -n '3,/^[^#]/s/^# \{0,1\}//p' "$currentDir/install.sh" | |
| 23 | 24 | } | |
| 24 | 25 | ||
| 25 | 26 | ################### | |
| @@ -90,3 +91,31 @@ confirm() { | |||
| 90 | 91 | fi | |
| 91 | 92 | gum confirm --default=false "$msg" | |
| 92 | 93 | } | |
| 94 | + | ||
| 95 | + | # Package pickers -> SELECTED_PKGS (desktop.txt is always installed, it has no picker). | |
| 96 | + | # --picks FILE (from the full install) replaces them. | |
| 97 | + | pick_packages() { | |
| 98 | + | SELECTED_PKGS=() | |
| 99 | + | if [[ -n "$PICKS" ]]; then | |
| 100 | + | gum_to_array SELECTED_PKGS < "$PICKS" | |
| 101 | + | return | |
| 102 | + | fi | |
| 103 | + | ||
| 104 | + | local list picked | |
| 105 | + | for list in utils dev gpu optional aur; do | |
| 106 | + | case "$list" in | |
| 107 | + | utils) prompt_style "Important utilities (Most likely go with defaults)" ;; | |
| 108 | + | dev) prompt_style "Select Development Tools" ;; | |
| 109 | + | gpu) prompt_style "Select GPU drivers" ;; | |
| 110 | + | optional) prompt_style "Select Optional Desktop Packages" ;; | |
| 111 | + | aur) prompt_style "Select AUR packages" ;; | |
| 112 | + | esac | |
| 113 | + | ||
| 114 | + | if ((AUTO_YES)); then | |
| 115 | + | mapfile -t picked < <(preselected "$list") | |
| 116 | + | else | |
| 117 | + | gum_to_array picked < <(choose_packages "$list") | |
| 118 | + | fi | |
| 119 | + | SELECTED_PKGS+=("${picked[@]}") | |
| 120 | + | done | |
| 121 | + | } | |