Verifica Ambiente

Script e controlli per verificare che l'ambiente di sviluppo sia configurato correttamente dopo l'installazione.

Script di Verifica Automatico

Salva questo script come check_env.sh e rendilo eseguibile:

#!/bin/bash

# Colori per output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Funzioni helper
print_header() {
    echo -e "\n${BLUE}=== $1 ===${NC}"
}

check_command() {
    if command -v "$1" &> /dev/null; then
        echo -e "${GREEN}✓${NC} $1 installato: $(command -v "$1")"
        if [ "$2" ]; then
            echo -e "  Versione: $($1 $2 2>/dev/null || echo 'N/A')"
        fi
        return 0
    else
        echo -e "${RED}✗${NC} $1 non trovato"
        return 1
    fi
}

check_service() {
    if systemctl is-active --quiet "$1" 2>/dev/null; then
        echo -e "${GREEN}✓${NC} Servizio $1 attivo"
        return 0
    elif pgrep -x "$1" > /dev/null; then
        echo -e "${GREEN}✓${NC} Processo $1 in esecuzione"
        return 0
    else
        echo -e "${RED}✗${NC} Servizio $1 non attivo"
        return 1
    fi
}

# Inizio verifiche
echo -e "${BLUE}🔍 Verifica Ambiente di Sviluppo PANDEV${NC}"
echo "Data: $(date)"
echo "Sistema: $(uname -s) $(uname -r)"
echo "Utente: $(whoami)"

# 1. Strumenti Core
print_header "Strumenti Core"
check_command "git" "--version"
check_command "curl" "--version"
check_command "wget" "--version"

# 2. Version Managers
print_header "Version Managers"
check_command "asdf" "--version"
if command -v asdf &> /dev/null; then
    echo "Plugin asdf installati:"
    asdf plugin list 2>/dev/null | sed 's/^/  - /'
fi

# 3. Linguaggi di Programmazione
print_header "Linguaggi di Programmazione"
check_command "ruby" "--version"
check_command "gem" "--version"
check_command "bundle" "--version"
check_command "rails" "--version"
check_command "node" "--version"
check_command "npm" "--version"

# 4. Database
print_header "Database"
check_command "psql" "--version"
check_command "redis-cli" "--version"

if command -v psql &> /dev/null; then
    if pg_isready -q 2>/dev/null; then
        echo -e "${GREEN}✓${NC} PostgreSQL server disponibile"
    else
        echo -e "${YELLOW}⚠${NC} PostgreSQL server non raggiungibile"
    fi
fi

if command -v redis-cli &> /dev/null; then
    if redis-cli ping &> /dev/null; then
        echo -e "${GREEN}✓${NC} Redis server disponibile"
    else
        echo -e "${YELLOW}⚠${NC} Redis server non raggiungibile"
    fi
fi

# 5. Container
print_header "Containerizzazione"
check_command "docker" "--version"
check_command "docker-compose" "--version"

if command -v docker &> /dev/null; then
    if docker info &> /dev/null; then
        echo -e "${GREEN}✓${NC} Docker daemon in esecuzione"
    else
        echo -e "${RED}✗${NC} Docker daemon non in esecuzione"
    fi
fi

# 6. Editor
print_header "Editor e IDE"
check_command "code" "--version"
check_command "vim" "--version"
check_command "nvim" "--version"

# 7. CLI Utilities
print_header "CLI Utilities"
check_command "http" "--version"
check_command "jq" "--version"
check_command "fzf" "--version"
check_command "bat" "--version"
check_command "tree" "--version"
check_command "htop" "--version"
check_command "delta" "--version"

# 8. Rails Specific
print_header "Rails Specific Tools"
check_command "overmind" "--version"
check_command "convert" "-version" # ImageMagick

# 9. SSH
print_header "SSH Configuration"
if [ -f ~/.ssh/id_ed25519 ]; then
    echo -e "${GREEN}✓${NC} Chiave SSH Ed25519 presente"
    echo "  Fingerprint: $(ssh-keygen -lf ~/.ssh/id_ed25519.pub 2>/dev/null | awk '{print $2}')"
elif [ -f ~/.ssh/id_rsa ]; then
    echo -e "${YELLOW}⚠${NC} Chiave SSH RSA presente (consigliata Ed25519)"
else
    echo -e "${RED}✗${NC} Nessuna chiave SSH trovata"
fi

# 10. Git Configuration
print_header "Git Configuration"
GIT_USER=$(git config --global user.name 2>/dev/null)
GIT_EMAIL=$(git config --global user.email 2>/dev/null)

if [ "$GIT_USER" ]; then
    echo -e "${GREEN}✓${NC} Git user.name: $GIT_USER"
else
    echo -e "${RED}✗${NC} Git user.name non configurato"
fi

if [ "$GIT_EMAIL" ]; then
    echo -e "${GREEN}✓${NC} Git user.email: $GIT_EMAIL"
else
    echo -e "${RED}✗${NC} Git user.email non configurato"
fi

# 11. Environment Variables
print_header "Environment Variables"
ENV_VARS=("EDITOR" "SHELL" "PATH")
for var in "${ENV_VARS[@]}"; do
    if [ "${!var}" ]; then
        echo -e "${GREEN}✓${NC} $var: ${!var}"
    else
        echo -e "${YELLOW}⚠${NC} $var non impostato"
    fi
done

# 12. Network Connectivity
print_header "Connettività"
if ping -c 1 google.com &> /dev/null; then
    echo -e "${GREEN}✓${NC} Connessione internet disponibile"
else
    echo -e "${RED}✗${NC} Problemi di connettività"
fi

if command -v git &> /dev/null; then
    if git ls-remote https://github.com/rails/rails.git &> /dev/null; then
        echo -e "${GREEN}✓${NC} Accesso a GitHub disponibile"
    else
        echo -e "${RED}✗${NC} Problemi di accesso a GitHub"
    fi
fi

# Summary
print_header "Riepilogo"
echo "Verifica completata. Controlla i punti contrassegnati con ✗ o ⚠ sopra."
echo -e "\nPer risolvere problemi specifici, consulta: ${BLUE}troubleshooting.md${NC}"

Verifica Rapida Manuale

1. Test Ruby Environment

2. Test Database Connectivity

3. Test Development Workflow

4. Test Docker Environment

Controlli di Performance

Disk Space

Memory Usage

Ruby Performance Test

Test VS Code Extensions

Health Check Project Rails

Crea un progetto di test completo:

Automatizzazione Controlli

Aggiungi al tuo .bashrc o .zshrc:

Questo permette di eseguire rapidamente:

Last updated

Was this helpful?