Files
Archduino/install.sh
marvin.dietermann c9fa40b31c refactor: restructure installation to modular architecture
- Remove monolithic bootstrap.sh in favor of modular design
- Add install.sh as new main entry point with improved UX
- Split functionality into focused modules:
  - lib/common.sh: shared utilities and environment detection
  - lib/packages.sh: base system packages
  - lib/neovim.sh: Neovim and LazyVim setup
  - lib/arduino.sh: Arduino CLI and board cores
  - lib/git.sh: Git and Lazygit configuration
  - lib/shell-config.sh: Zsh and shell environment
  - lib/starship.sh: Starship prompt setup
  - lib/zellij.sh: Zellij terminal multiplexer
  - lib/scaffold.sh: project scaffolding utilities
- Update README with new installation instructions and architecture
- Improve error handling and user feedback across modules
- Maintain compatibility with both Arch Linux and Ubuntu/WSL2

This modular approach enables better maintainability, testing,
and allows users to selectively run components as needed.
2026-04-10 11:41:21 +02:00

95 lines
3.8 KiB
Bash

#!/bin/bash
#
# Archduino Install — TUI Arduino Development Environment
# Works on both native Arch Linux and Arch/Ubuntu WSL2
#
# Usage: curl -kL <url> | bash
# or: chmod +x install.sh && ./install.sh
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ── Load helpers and detect environment ─────────────────────────
source "$SCRIPT_DIR/lib/common.sh"
echo ""
echo " ╔═══════════════════════════════════════╗"
echo " ║ ⚡ Archduino Bootstrap ⚡ ║"
echo " ║ TUI Arduino Dev Environment Setup ║"
echo " ╚═══════════════════════════════════════╝"
echo ""
$IS_WSL && info "Detected WSL2" || info "Detected native Linux"
$IS_ARCH && info "Package manager: pacman (Arch)" || info "Package manager: apt (Ubuntu)"
echo ""
# ── Select colorscheme ────────────────────────────────────────────
source "$SCRIPT_DIR/lib/themes.sh"
select_theme
echo ""
# ── Select output mode ──────────────────────────────────────────
echo " Select installation output:"
echo ""
echo " 1) Progress bar (clean)"
echo " 2) Full details (verbose)"
echo ""
read -rp " Choice [1/2]: " output_choice
case "$output_choice" in
1) VERBOSE=false ;;
*) VERBOSE=true ;;
esac
echo ""
# ── Acquire sudo upfront and keep it alive ──────────────────────
info "Requesting sudo access (you will only be asked once)..."
sudo -v || error "Failed to obtain sudo. Aborting."
# Refresh sudo timestamp in the background until this script exits
( while kill -0 $$ 2>/dev/null; do sudo -n true; sleep 50; done ) &
SUDO_KEEPALIVE_PID=$!
cleanup() {
kill $SUDO_KEEPALIVE_PID 2>/dev/null
if ! $VERBOSE && [[ -e /proc/self/fd/3 ]]; then
exec 1>&3 2>&4 3>&- 4>&-
echo ""
echo -e " ${RED}[✗]${NC} Installation failed. See log: $LOG_FILE"
fi
}
trap cleanup EXIT
# ── Enter quiet mode if selected ────────────────────────────────
if ! $VERBOSE; then
begin_quiet_mode
fi
# ── Run install steps ───────────────────────────────────────────
source "$SCRIPT_DIR/lib/packages.sh"
source "$SCRIPT_DIR/lib/zsh.sh"
source "$SCRIPT_DIR/lib/starship.sh"
source "$SCRIPT_DIR/lib/zellij.sh"
source "$SCRIPT_DIR/lib/neovim.sh"
source "$SCRIPT_DIR/lib/arduino.sh"
source "$SCRIPT_DIR/lib/git.sh"
source "$SCRIPT_DIR/lib/scaffold.sh"
source "$SCRIPT_DIR/lib/shell-config.sh"
# ── Restore output if in quiet mode ────────────────────────────
if ! $VERBOSE; then
end_quiet_mode
fi
# ── Done ────────────────────────────────────────────────────────
echo ""
echo " ╔═══════════════════════════════════════╗"
echo " ║ ⚡ Archduino Setup Complete ⚡ ║"
echo " ╚═══════════════════════════════════════╝"
echo ""
info "Start a new shell or run: source ~/.zshrc"
info "Quick start:"
echo " arduino-new my-project uno # scaffold a project"
echo " adev # launch Arduino workspace"
echo " <leader>av # compile in Neovim"
echo " <leader>au # upload in Neovim"
echo ""