#!/bin/bash echo "===================================" echo "HotWives Platform - Instalação" echo "===================================" # Verificar se está rodando como root if [ "$EUID" -ne 0 ]; then echo "Por favor, execute como root (sudo)" exit 1 fi # Atualizar sistema echo "Atualizando sistema..." apt update && apt upgrade -y # Instalar dependências echo "Instalando dependências..." apt install -y curl git nginx postgresql postgresql-contrib # Instalar Node.js 18.x echo "Instalando Node.js..." curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt install -y nodejs # Verificar instalações echo "Verificando instalações..." node -v npm -v psql --version # Configurar PostgreSQL echo "Configurando banco de dados PostgreSQL..." sudo -u postgres psql -c "CREATE DATABASE hotwives;" sudo -u postgres psql -c "CREATE USER hotwives WITH ENCRYPTED PASSWORD 'sua_senha_forte_aqui';" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE hotwives TO hotwives;" # Instalar dependências do projeto echo "Instalando dependências do projeto..." cd /var/www/hotwives # Root npm install # Backend cd backend npm install cp .env.example .env echo "⚠️ Configure o arquivo backend/.env com suas credenciais!" # Gerar Prisma Client npx prisma generate # Frontend cd ../frontend npm install # Configurar Nginx echo "Configurando Nginx..." cd /var/www/hotwives cp nginx.conf /etc/nginx/sites-available/hotwives ln -sf /etc/nginx/sites-available/hotwives /etc/nginx/sites-enabled/ rm -f /etc/nginx/sites-enabled/default # Testar configuração do Nginx nginx -t # Instalar Certbot para SSL echo "Instalando Certbot..." apt install -y certbot python3-certbot-nginx echo "" echo "===================================" echo "Instalação concluída!" echo "===================================" echo "" echo "Próximos passos:" echo "" echo "1. Configure o arquivo .env do backend:" echo " nano /var/www/hotwives/backend/.env" echo "" echo "2. Execute as migrações do banco de dados:" echo " cd /var/www/hotwives/backend" echo " npx prisma migrate dev" echo "" echo "3. Configure SSL com Certbot:" echo " certbot --nginx -d hotwives.com.br -d www.hotwives.com.br" echo "" echo "4. Inicie os serviços:" echo " pm2 start ecosystem.config.js" echo "" echo "5. Reinicie o Nginx:" echo " systemctl restart nginx" echo ""