Files
Archduino/install.sh
marvin.dietermann 040839862d refactor(install): improve modular architecture and error handling
- Remove redundant installation checks in arduino.sh, git.sh
- Add bash shell enforcement in install.sh to prevent compatibility issues
- Streamline Arduino CLI installation logic for both Arch and other systems
- Improve Git and Lazygit installation messaging consistency
- Update install usage instructions for better clarity
- Enhance shell compatibility by enforcing bash execution
2026-04-10 11:51:03 +02:00

100 lines
3.9 KiB
Bash

#!/bin/bash
#
# Archduino Install — TUI Arduino Development Environment
# Works on both native Arch Linux and Arch/Ubuntu WSL2
#
# Usage: chmod +x install.sh && ./install.sh
# or: bash install.sh
#
# Re-exec with bash if invoked via sh/dash
if [ -z "$BASH_VERSION" ]; then
exec bash "$0" "$@"
fi
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 ""