Team Ai
Apppublic

diegobeyl/backtesting

sourceHugging Faceupdated 9mo agoView on Hugging Face
2likes
check_system.sh181 linesDownload Raw Back to utilities
1#!/bin/bash2 3# Script de verificación del sistema para macOS4 5# Colores6RED='\033[0;31m'7GREEN='\033[0;32m'8YELLOW='\033[1;33m'9BLUE='\033[0;34m'10NC='\033[0m'11 12echo ""13echo "=========================================="14echo "  Verificación del Sistema - macOS"15echo "=========================================="16echo ""17 18# Detectar arquitectura19ARCH=$(uname -m)20echo -n "Arquitectura: "21if [ "$ARCH" = "arm64" ]; then22    echo -e "${GREEN}Apple Silicon (M1/M2/M3)${NC}"23else24    echo -e "${YELLOW}$ARCH${NC}"25fi26 27# Verificar macOS28echo -n "Sistema Operativo: "29if [[ "$OSTYPE" == "darwin"* ]]; then30    MACOS_VERSION=$(sw_vers -productVersion)31    echo -e "${GREEN}macOS $MACOS_VERSION${NC}"32else33    echo -e "${YELLOW}$OSTYPE${NC}"34fi35 36# Verificar Python37echo -n "Python: "38if command -v python3 &> /dev/null; then39    PYTHON_VERSION=$(python3 --version | awk '{print $2}')40    PYTHON_PATH=$(which python3)41    echo -e "${GREEN}$PYTHON_VERSION${NC}"42    echo "   Ubicación: $PYTHON_PATH"43else44    echo -e "${RED}No instalado${NC}"45    echo "   Instala con: brew install python@3.11"46fi47 48# Verificar pip49echo -n "pip: "50if command -v pip3 &> /dev/null; then51    PIP_VERSION=$(pip3 --version | awk '{print $2}')52    echo -e "${GREEN}$PIP_VERSION${NC}"53else54    echo -e "${RED}No instalado${NC}"55fi56 57# Verificar Homebrew58echo -n "Homebrew: "59if command -v brew &> /dev/null; then60    BREW_VERSION=$(brew --version | head -n1)61    echo -e "${GREEN}Instalado${NC}"62    echo "   $BREW_VERSION"63else64    echo -e "${YELLOW}No instalado (opcional)${NC}"65    echo "   Instala desde: https://brew.sh"66fi67 68# Verificar Git69echo -n "Git: "70if command -v git &> /dev/null; then71    GIT_VERSION=$(git --version | awk '{print $3}')72    echo -e "${GREEN}$GIT_VERSION${NC}"73else74    echo -e "${YELLOW}No instalado${NC}"75fi76 77# Verificar Docker (opcional)78echo -n "Docker: "79if command -v docker &> /dev/null; then80    DOCKER_VERSION=$(docker --version | awk '{print $3}' | tr -d ',')81    echo -e "${GREEN}$DOCKER_VERSION${NC}"82    83    # Verificar si Docker está corriendo84    if docker info &> /dev/null; then85        echo -e "   ${GREEN}Docker daemon está corriendo${NC}"86    else87        echo -e "   ${YELLOW}Docker daemon no está corriendo${NC}"88    fi89else90    echo -e "${YELLOW}No instalado (opcional)${NC}"91    echo "   Para usar Docker: https://www.docker.com/products/docker-desktop"92fi93 94echo ""95 96# Verificar entorno virtual97echo -n "Entorno Virtual: "98if [ -d "venv" ]; then99    echo -e "${GREEN}Creado${NC}"100    if [ -f "venv/bin/python" ]; then101        VENV_PYTHON=$(venv/bin/python --version | awk '{print $2}')102        echo "   Python en venv: $VENV_PYTHON"103    fi104else105    echo -e "${YELLOW}No creado${NC}"106    echo "   Ejecuta: ./setup.sh"107fi108 109# Verificar archivo .env110echo -n "Archivo .env: "111if [ -f ".env" ]; then112    echo -e "${GREEN}Existe${NC}"113else114    echo -e "${YELLOW}No existe${NC}"115    echo "   Se creará al ejecutar: ./setup.sh"116fi117 118# Verificar directorios119echo -n "Directorios: "120DIRS_OK=true121for dir in logs cache config; do122    if [ ! -d "$dir" ]; then123        DIRS_OK=false124        break125    fi126done127if [ "$DIRS_OK" = true ]; then128    echo -e "${GREEN}Creados${NC}"129else130    echo -e "${YELLOW}No todos creados${NC}"131    echo "   Se crearán al ejecutar: ./setup.sh"132fi133 134# Verificar puertos135echo ""136echo "Verificando puertos..."137echo -n "Puerto 8000 (API): "138if lsof -Pi :8000 -sTCP:LISTEN -t &>/dev/null ; then139    echo -e "${RED}Ocupado${NC}"140    lsof -Pi :8000 -sTCP:LISTEN | tail -n +2141else142    echo -e "${GREEN}Disponible${NC}"143fi144 145echo -n "Puerto 8501 (Streamlit): "146if lsof -Pi :8501 -sTCP:LISTEN -t &>/dev/null ; then147    echo -e "${RED}Ocupado${NC}"148    lsof -Pi :8501 -sTCP:LISTEN | tail -n +2149else150    echo -e "${GREEN}Disponible${NC}"151fi152 153echo ""154echo "=========================================="155echo "  Resumen"156echo "=========================================="157echo ""158 159# Determinar si está listo para usar160READY=true161if ! command -v python3 &> /dev/null; then162    READY=false163    echo -e "${RED}✗ Falta instalar Python 3${NC}"164fi165 166if [ ! -d "venv" ]; then167    READY=false168    echo -e "${YELLOW}○ Ejecuta ./setup.sh para configurar${NC}"169fi170 171if [ "$READY" = true ]; then172    echo -e "${GREEN}✓ Sistema listo para ejecutar la aplicación${NC}"173    echo ""174    echo "Ejecuta: ./start.sh"175else176    echo ""177    echo "Ejecuta: ./setup.sh"178fi179 180echo ""181