Redesign wizard UI with gum (charmbracelet)
- Bootstrap gum automatically on first run (Arch/Debian/RHEL/Fedora/SUSE) - utils.sh: replace all bash color helpers with gum equivalents - gum input for text prompts (with value pre-fill for defaults) - gum choose for selection menus - gum confirm for yes/no - gum spin for long-running operations - gum style/log for output (catppuccin mocha palette) - gum style for banners and summary box - core.sh: spinner on git clone/pull - workflow.sh: spinner on git clone - prereqs.sh: spinner on package installs - wizard.sh: double-border welcome banner, rounded summary box, success banner with next-steps panel Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8a82d27dae
commit
699087f08c
6 changed files with 267 additions and 243 deletions
116
lib/prereqs.sh
116
lib/prereqs.sh
|
|
@ -1,13 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
# prereqs.sh — detect distro, install missing prerequisites
|
||||
|
||||
# Detect package manager / distro family
|
||||
detect_distro() {
|
||||
if command -v pacman &>/dev/null; then echo "arch";
|
||||
if command -v pacman &>/dev/null; then echo "arch";
|
||||
elif command -v apt-get &>/dev/null; then echo "debian";
|
||||
elif command -v dnf &>/dev/null; then echo "rhel";
|
||||
elif command -v yum &>/dev/null; then echo "rhel-yum";
|
||||
elif command -v zypper &>/dev/null; then echo "suse";
|
||||
elif command -v dnf &>/dev/null; then echo "rhel";
|
||||
elif command -v yum &>/dev/null; then echo "rhel-yum";
|
||||
elif command -v zypper &>/dev/null; then echo "suse";
|
||||
else echo "unknown";
|
||||
fi
|
||||
}
|
||||
|
|
@ -16,130 +15,91 @@ install_pkg() {
|
|||
local pkg="$1"
|
||||
local distro
|
||||
distro="$(detect_distro)"
|
||||
|
||||
info "Installing $pkg (distro: $distro)..."
|
||||
case "$distro" in
|
||||
arch)
|
||||
sudo pacman -Sy --noconfirm "$pkg" ;;
|
||||
debian)
|
||||
sudo apt-get update -qq && sudo apt-get install -y "$pkg" ;;
|
||||
rhel)
|
||||
sudo dnf install -y "$pkg" ;;
|
||||
rhel-yum)
|
||||
sudo yum install -y "$pkg" ;;
|
||||
suse)
|
||||
sudo zypper install -y "$pkg" ;;
|
||||
*)
|
||||
die "Unsupported distro — please install $pkg manually." ;;
|
||||
arch) sudo pacman -Sy --noconfirm "$pkg" ;;
|
||||
debian) sudo apt-get update -qq && sudo apt-get install -y "$pkg" ;;
|
||||
rhel) sudo dnf install -y "$pkg" ;;
|
||||
rhel-yum) sudo yum install -y "$pkg" ;;
|
||||
suse) sudo zypper install -y "$pkg" ;;
|
||||
*) die "Unsupported distro — please install $pkg manually." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_git() {
|
||||
if command -v git &>/dev/null; then
|
||||
success "git: $(git --version)"
|
||||
success "git $(git --version | awk '{print $3}')"
|
||||
return
|
||||
fi
|
||||
warn "git not found."
|
||||
ask_yn _install "Install git now?" "y"
|
||||
if [[ "$_install" != "y" ]]; then die "git is required."; fi
|
||||
install_pkg git
|
||||
gum spin --spinner dot --spinner.foreground "$C_MAUVE" \
|
||||
--title " Installing git..." --title.foreground "$C_SKY" \
|
||||
-- bash -c "$(declare -f install_pkg detect_distro); install_pkg git"
|
||||
command -v git &>/dev/null || die "git installation failed."
|
||||
success "git installed: $(git --version)"
|
||||
success "git $(git --version | awk '{print $3}')"
|
||||
}
|
||||
|
||||
ensure_container_runtime() {
|
||||
# Already available?
|
||||
if command -v podman &>/dev/null; then
|
||||
CONTAINER_CMD="podman"
|
||||
success "podman: $(podman --version)"
|
||||
success "podman $(podman --version | awk '{print $3}')"
|
||||
return
|
||||
fi
|
||||
if command -v docker &>/dev/null; then
|
||||
CONTAINER_CMD="docker"
|
||||
success "docker: $(docker --version | head -1)"
|
||||
success "docker $(docker --version | awk '{print $3}' | tr -d ',')"
|
||||
return
|
||||
fi
|
||||
|
||||
warn "No container runtime found (podman or docker)."
|
||||
warn "No container runtime found."
|
||||
echo ""
|
||||
echo -e " ${CYAN}podman${RESET} is preferred (rootless, no daemon)"
|
||||
echo -e " ${CYAN}docker${RESET} is the alternative"
|
||||
gum style --foreground "$C_SKY" --margin "0 4" \
|
||||
"podman — recommended (rootless, no daemon)" \
|
||||
"docker — alternative"
|
||||
echo ""
|
||||
|
||||
ask_choice _runtime "Which would you like to install?" \
|
||||
"podman (recommended)" \
|
||||
"docker"
|
||||
|
||||
local runtime_choice="$_runtime"
|
||||
case "$runtime_choice" in
|
||||
podman*)
|
||||
_install_podman
|
||||
CONTAINER_CMD="podman"
|
||||
;;
|
||||
docker*)
|
||||
_install_docker
|
||||
CONTAINER_CMD="docker"
|
||||
;;
|
||||
podman*) _install_podman; CONTAINER_CMD="podman" ;;
|
||||
docker*) _install_docker; CONTAINER_CMD="docker" ;;
|
||||
esac
|
||||
|
||||
command -v "$CONTAINER_CMD" &>/dev/null \
|
||||
|| die "$CONTAINER_CMD installation failed. Please install manually."
|
||||
success "$CONTAINER_CMD installed: $($CONTAINER_CMD --version | head -1)"
|
||||
success "$CONTAINER_CMD installed"
|
||||
}
|
||||
|
||||
_install_podman() {
|
||||
local distro
|
||||
distro="$(detect_distro)"
|
||||
case "$distro" in
|
||||
arch) install_pkg podman ;;
|
||||
debian) install_pkg podman ;;
|
||||
rhel) install_pkg podman ;;
|
||||
rhel-yum) install_pkg podman ;;
|
||||
suse) install_pkg podman ;;
|
||||
*) die "Unsupported distro — install podman manually: https://podman.io/getting-started/installation" ;;
|
||||
esac
|
||||
gum spin --spinner dot --spinner.foreground "$C_MAUVE" \
|
||||
--title " Installing podman..." --title.foreground "$C_SKY" \
|
||||
-- bash -c "$(declare -f install_pkg detect_distro); install_pkg podman"
|
||||
}
|
||||
|
||||
_install_docker() {
|
||||
local distro
|
||||
distro="$(detect_distro)"
|
||||
case "$distro" in
|
||||
arch)
|
||||
install_pkg docker
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker "$USER"
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
;;
|
||||
debian)
|
||||
install_pkg docker.io
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker "$USER"
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
;;
|
||||
rhel)
|
||||
install_pkg docker
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker "$USER"
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
;;
|
||||
rhel-yum)
|
||||
install_pkg docker
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker "$USER"
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
;;
|
||||
suse)
|
||||
install_pkg docker
|
||||
sudo systemctl enable --now docker
|
||||
sudo usermod -aG docker "$USER"
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
;;
|
||||
*)
|
||||
die "Unsupported distro — install docker manually: https://docs.docker.com/engine/install/" ;;
|
||||
arch) install_pkg docker ;;
|
||||
debian) install_pkg docker.io ;;
|
||||
rhel) install_pkg docker ;;
|
||||
rhel-yum) install_pkg docker ;;
|
||||
suse) install_pkg docker ;;
|
||||
*) die "Unsupported distro — install docker manually." ;;
|
||||
esac
|
||||
sudo systemctl enable --now docker 2>/dev/null || true
|
||||
sudo usermod -aG docker "$USER" 2>/dev/null || true
|
||||
warn "Added $USER to docker group — log out and back in for it to take effect."
|
||||
}
|
||||
|
||||
check_prerequisites() {
|
||||
header "Checking Prerequisites"
|
||||
header "Prerequisites"
|
||||
ensure_git
|
||||
ensure_container_runtime
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue