fix(post-boot,shell): address CodeRabbit review — marker-based bashrc, passwd-based USER_HOME, pacman -Sy, remove unused Configurator fields, document danklinux trust
- commit
- 309513574ed07bb44fecc0606db247f870508aea
- author
- bnema · · 2026-02-26 21:25 UTC
- parent
- fc43554
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +18 -36
M install/mandatory/post-boot/cli-tools.sh +12 -8
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | set -euo pipefail | |
| 4 | 4 | ||
| 5 | 5 | LOG_FILE="/var/log/archup-first-boot.log" | |
| 6 | - | USERNAME=$(getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 {print $1; exit}') | |
| 7 | - | USER_HOME="/home/$USERNAME" | |
| 6 | + | USERNAME=$(getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 && $1 != "nobody" {print $1; exit}') | |
| 7 | + | USER_HOME=$(getent passwd "$USERNAME" | cut -d: -f6) | |
| 8 | 8 | ||
| 9 | 9 | log() { echo "[cli-tools] $*" | tee -a "$LOG_FILE"; } | |
| 10 | 10 | ||
| @@ -15,21 +15,24 @@ fi | |||
| 15 | 15 | ||
| 16 | 16 | log "Installing modern CLI toolkit for $USERNAME..." | |
| 17 | 17 | ||
| 18 | + | log "Refreshing package databases..." | |
| 19 | + | pacman -Sy --noconfirm | |
| 20 | + | ||
| 18 | 21 | pacman -S --needed --noconfirm \ | |
| 19 | 22 | eza bat fd ripgrep fzf zoxide starship \ | |
| 20 | 23 | btop yazi git-delta gdu procs tealdeer \ | |
| 21 | 24 | lazygit atuin man-db neovim wget curl git | |
| 22 | 25 | ||
| 23 | - | log "Writing ~/.bashrc for $USERNAME..." | |
| 26 | + | log "Configuring shell environment for $USERNAME..." | |
| 24 | 27 | ||
| 25 | - | # Back up existing .bashrc if present | |
| 28 | + | # Remove any previous archup block (idempotent re-run) | |
| 26 | 29 | if [ -f "$USER_HOME/.bashrc" ]; then | |
| 27 | - | cp "$USER_HOME/.bashrc" "$USER_HOME/.bashrc.bak" | |
| 28 | - | log "Backed up existing .bashrc to .bashrc.bak" | |
| 30 | + | sed -i '/# BEGIN archup cli tools/,/# END archup cli tools/d' "$USER_HOME/.bashrc" | |
| 29 | 31 | fi | |
| 30 | 32 | ||
| 31 | - | cat > "$USER_HOME/.bashrc" << 'BASHRC' | |
| 32 | - | # ArchUp barebone bash — modern CLI tools | |
| 33 | + | # Append archup block | |
| 34 | + | cat >> "$USER_HOME/.bashrc" << 'BASHRC' | |
| 35 | + | # BEGIN archup cli tools | |
| 33 | 36 | # Aliases | |
| 34 | 37 | alias ls='eza --icons' | |
| 35 | 38 | alias ll='eza -la --icons --git' | |
| @@ -63,6 +66,7 @@ eval "$(starship init bash)" | |||
| 63 | 66 | ||
| 64 | 67 | # ble.sh (Bash Line Editor) — must be sourced last | |
| 65 | 68 | [[ $- == *i* ]] && source -- ~/.local/share/blesh/ble.sh 2>/dev/null || true | |
| 69 | + | # END archup cli tools | |
| 66 | 70 | BASHRC | |
| 67 | 71 | ||
| 68 | 72 | chown "$USERNAME:$USERNAME" "$USER_HOME/.bashrc" | |
| @@ -3,8 +3,8 @@ | |||||
| 3 | set -euo pipefail | 3 | set -euo pipefail | ||
| 4 | 4 | ||||
| 5 | LOG_FILE="/var/log/archup-first-boot.log" | 5 | LOG_FILE="/var/log/archup-first-boot.log" | ||
| 6 | - | USERNAME=$(getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 {print $1; exit}') | 6 | + | USERNAME=$(getent passwd | awk -F: '$3 >= 1000 && $3 < 65534 && $1 != "nobody" {print $1; exit}') |
| 7 | - | USER_HOME="/home/$USERNAME" | 7 | + | USER_HOME=$(getent passwd "$USERNAME" | cut -d: -f6) |
| 8 | 8 | ||||
| 9 | log() { echo "[cli-tools] $*" | tee -a "$LOG_FILE"; } | 9 | log() { echo "[cli-tools] $*" | tee -a "$LOG_FILE"; } | ||
| 10 | 10 | ||||
| @@ -15,21 +15,24 @@ fi | |||||
| 15 | 15 | ||||
| 16 | log "Installing modern CLI toolkit for $USERNAME..." | 16 | log "Installing modern CLI toolkit for $USERNAME..." | ||
| 17 | 17 | ||||
| 18 | + | log "Refreshing package databases..." | |||
| 19 | + | pacman -Sy --noconfirm | |||
| 20 | + | ||||
| 18 | pacman -S --needed --noconfirm \ | 21 | pacman -S --needed --noconfirm \ | ||
| 19 | eza bat fd ripgrep fzf zoxide starship \ | 22 | eza bat fd ripgrep fzf zoxide starship \ | ||
| 20 | btop yazi git-delta gdu procs tealdeer \ | 23 | btop yazi git-delta gdu procs tealdeer \ | ||
| 21 | lazygit atuin man-db neovim wget curl git | 24 | lazygit atuin man-db neovim wget curl git | ||
| 22 | 25 | ||||
| 23 | - | log "Writing ~/.bashrc for $USERNAME..." | 26 | + | log "Configuring shell environment for $USERNAME..." |
| 24 | 27 | ||||
| 25 | - | # Back up existing .bashrc if present | 28 | + | # Remove any previous archup block (idempotent re-run) |
| 26 | if [ -f "$USER_HOME/.bashrc" ]; then | 29 | if [ -f "$USER_HOME/.bashrc" ]; then | ||
| 27 | - | cp "$USER_HOME/.bashrc" "$USER_HOME/.bashrc.bak" | 30 | + | sed -i '/# BEGIN archup cli tools/,/# END archup cli tools/d' "$USER_HOME/.bashrc" |
| 28 | - | log "Backed up existing .bashrc to .bashrc.bak" | |||
| 29 | fi | 31 | fi | ||
| 30 | 32 | ||||
| 31 | - | cat > "$USER_HOME/.bashrc" << 'BASHRC' | 33 | + | # Append archup block |
| 32 | - | # ArchUp barebone bash — modern CLI tools | 34 | + | cat >> "$USER_HOME/.bashrc" << 'BASHRC' |
| 35 | + | # BEGIN archup cli tools | |||
| 33 | # Aliases | 36 | # Aliases | ||
| 34 | alias ls='eza --icons' | 37 | alias ls='eza --icons' | ||
| 35 | alias ll='eza -la --icons --git' | 38 | alias ll='eza -la --icons --git' | ||
| @@ -63,6 +66,7 @@ eval "$(starship init bash)" | |||||
| 63 | 66 | ||||
| 64 | # ble.sh (Bash Line Editor) — must be sourced last | 67 | # ble.sh (Bash Line Editor) — must be sourced last | ||
| 65 | [[ $- == *i* ]] && source -- ~/.local/share/blesh/ble.sh 2>/dev/null || true | 68 | [[ $- == *i* ]] && source -- ~/.local/share/blesh/ble.sh 2>/dev/null || true | ||
| 69 | + | # END archup cli tools | |||
| 66 | BASHRC | 70 | BASHRC | ||
| 67 | 71 | ||||
| 68 | chown "$USERNAME:$USERNAME" "$USER_HOME/.bashrc" | 72 | chown "$USERNAME:$USERNAME" "$USER_HOME/.bashrc" | ||
M install/mandatory/post-boot/dms-opt-in.sh +3 -1
| @@ -27,7 +27,9 @@ echo " - Auto-theming, notifications, app launcher," | |||
| 27 | 27 | echo " lock screen, system tray, search — all" | |
| 28 | 28 | echo " integrated. One install. Everything works." | |
| 29 | 29 | echo "" | |
| 30 | - | echo " Install: curl -fsSL https://install.danklinux.com | sh" | |
| 30 | + | echo " Install: curl -fsSL https://install.danklinux.com | sh" | |
| 31 | + | echo " Note: This runs the official Dank Linux installer. Review at:" | |
| 32 | + | echo " https://github.com/AvengeMedia/DankMaterialShell" | |
| 31 | 33 | echo "" | |
| 32 | 34 | ||
| 33 | 35 | read -r -p " Do you want to run the Dank Linux installer? [y/N] " REPLY || true | |
| @@ -27,7 +27,9 @@ echo " - Auto-theming, notifications, app launcher," | |||||
| 27 | echo " lock screen, system tray, search — all" | 27 | echo " lock screen, system tray, search — all" | ||
| 28 | echo " integrated. One install. Everything works." | 28 | echo " integrated. One install. Everything works." | ||
| 29 | echo "" | 29 | echo "" | ||
| 30 | - | echo " Install: curl -fsSL https://install.danklinux.com | sh" | 30 | + | echo " Install: curl -fsSL https://install.danklinux.com | sh" |
| 31 | + | echo " Note: This runs the official Dank Linux installer. Review at:" | |||
| 32 | + | echo " https://github.com/AvengeMedia/DankMaterialShell" | |||
| 31 | echo "" | 33 | echo "" | ||
| 32 | 34 | ||||
| 33 | read -r -p " Do you want to run the Dank Linux installer? [y/N] " REPLY || true | 35 | read -r -p " Do you want to run the Dank Linux installer? [y/N] " REPLY || true | ||
M internal/shell/configurator.go +3 -27
| @@ -1,11 +1,5 @@ | |||
| 1 | 1 | package shell | |
| 2 | 2 | ||
| 3 | - | import ( | |
| 4 | - | "github.com/bnema/archup/internal/config" | |
| 5 | - | "github.com/bnema/archup/internal/interfaces" | |
| 6 | - | "github.com/bnema/archup/internal/logger" | |
| 7 | - | ) | |
| 8 | - | ||
| 9 | 3 | // ConfigResult holds the result of shell configuration | |
| 10 | 4 | type ConfigResult struct { | |
| 11 | 5 | ThemesApplied int | |
| @@ -14,29 +8,11 @@ type ConfigResult struct { | |||
| 14 | 8 | } | |
| 15 | 9 | ||
| 16 | 10 | // Configurator handles shell and bash configuration setup | |
| 17 | - | type Configurator struct { | |
| 18 | - | fs interfaces.FileSystem | |
| 19 | - | http interfaces.HTTPClient | |
| 20 | - | chrExec interfaces.ChrootExecutor | |
| 21 | - | config *config.Config | |
| 22 | - | logger *logger.Logger | |
| 23 | - | } | |
| 11 | + | type Configurator struct{} | |
| 24 | 12 | ||
| 25 | 13 | // NewConfigurator creates a new shell configurator | |
| 26 | - | func NewConfigurator( | |
| 27 | - | fs interfaces.FileSystem, | |
| 28 | - | http interfaces.HTTPClient, | |
| 29 | - | chrExec interfaces.ChrootExecutor, | |
| 30 | - | cfg *config.Config, | |
| 31 | - | log *logger.Logger, | |
| 32 | - | ) *Configurator { | |
| 33 | - | return &Configurator{ | |
| 34 | - | fs: fs, | |
| 35 | - | http: http, | |
| 36 | - | chrExec: chrExec, | |
| 37 | - | config: cfg, | |
| 38 | - | logger: log, | |
| 39 | - | } | |
| 14 | + | func NewConfigurator() *Configurator { | |
| 15 | + | return &Configurator{} | |
| 40 | 16 | } | |
| 41 | 17 | ||
| 42 | 18 | // Configure is a no-op. Shell configuration is handled by cli-tools.sh at first boot. | |
| @@ -1,11 +1,5 @@ | |||||
| 1 | package shell | 1 | package shell | ||
| 2 | 2 | ||||
| 3 | - | import ( | |||
| 4 | - | "github.com/bnema/archup/internal/config" | |||
| 5 | - | "github.com/bnema/archup/internal/interfaces" | |||
| 6 | - | "github.com/bnema/archup/internal/logger" | |||
| 7 | - | ) | |||
| 8 | - | ||||
| 9 | // ConfigResult holds the result of shell configuration | 3 | // ConfigResult holds the result of shell configuration | ||
| 10 | type ConfigResult struct { | 4 | type ConfigResult struct { | ||
| 11 | ThemesApplied int | 5 | ThemesApplied int | ||
| @@ -14,29 +8,11 @@ type ConfigResult struct { | |||||
| 14 | } | 8 | } | ||
| 15 | 9 | ||||
| 16 | // Configurator handles shell and bash configuration setup | 10 | // Configurator handles shell and bash configuration setup | ||
| 17 | - | type Configurator struct { | 11 | + | type Configurator struct{} |
| 18 | - | fs interfaces.FileSystem | |||
| 19 | - | http interfaces.HTTPClient | |||
| 20 | - | chrExec interfaces.ChrootExecutor | |||
| 21 | - | config *config.Config | |||
| 22 | - | logger *logger.Logger | |||
| 23 | - | } | |||
| 24 | 12 | ||||
| 25 | // NewConfigurator creates a new shell configurator | 13 | // NewConfigurator creates a new shell configurator | ||
| 26 | - | func NewConfigurator( | 14 | + | func NewConfigurator() *Configurator { |
| 27 | - | fs interfaces.FileSystem, | 15 | + | return &Configurator{} |
| 28 | - | http interfaces.HTTPClient, | |||
| 29 | - | chrExec interfaces.ChrootExecutor, | |||
| 30 | - | cfg *config.Config, | |||
| 31 | - | log *logger.Logger, | |||
| 32 | - | ) *Configurator { | |||
| 33 | - | return &Configurator{ | |||
| 34 | - | fs: fs, | |||
| 35 | - | http: http, | |||
| 36 | - | chrExec: chrExec, | |||
| 37 | - | config: cfg, | |||
| 38 | - | logger: log, | |||
| 39 | - | } | |||
| 40 | } | 16 | } | ||
| 41 | 17 | ||||
| 42 | // Configure is a no-op. Shell configuration is handled by cli-tools.sh at first boot. | 18 | // Configure is a no-op. Shell configuration is handled by cli-tools.sh at first boot. | ||