154 lines
5.2 KiB
Bash
Executable File
154 lines
5.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script de verificação do sistema Gitea
|
|
|
|
echo "╔══════════════════════════════════════════════════════════════════╗"
|
|
echo "║ VERIFICAÇÃO DO SISTEMA GITEA ║"
|
|
echo "╚══════════════════════════════════════════════════════════════════╝"
|
|
echo ""
|
|
|
|
# Cores
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
check_service() {
|
|
if [ $2 -eq 0 ]; then
|
|
echo -e "${GREEN}✓${NC} $1"
|
|
else
|
|
echo -e "${RED}✗${NC} $1"
|
|
fi
|
|
}
|
|
|
|
# 1. Verificar Docker
|
|
echo "1. Verificando Docker..."
|
|
docker --version > /dev/null 2>&1
|
|
check_service "Docker instalado" $?
|
|
|
|
# 2. Verificar containers
|
|
echo ""
|
|
echo "2. Verificando containers Gitea..."
|
|
GITEA_RUNNING=$(docker ps | grep -c "gitea/gitea")
|
|
DB_RUNNING=$(docker ps | grep -c "postgres:14")
|
|
|
|
if [ $GITEA_RUNNING -eq 1 ]; then
|
|
echo -e "${GREEN}✓${NC} Container Gitea rodando"
|
|
else
|
|
echo -e "${RED}✗${NC} Container Gitea NÃO está rodando"
|
|
fi
|
|
|
|
if [ $DB_RUNNING -eq 1 ]; then
|
|
echo -e "${GREEN}✓${NC} Container PostgreSQL rodando"
|
|
else
|
|
echo -e "${RED}✗${NC} Container PostgreSQL NÃO está rodando"
|
|
fi
|
|
|
|
# 3. Verificar Nginx
|
|
echo ""
|
|
echo "3. Verificando Nginx..."
|
|
systemctl is-active --quiet nginx
|
|
check_service "Nginx rodando" $?
|
|
|
|
nginx -t > /dev/null 2>&1
|
|
check_service "Configuração do Nginx válida" $?
|
|
|
|
# 4. Verificar se Gitea responde
|
|
echo ""
|
|
echo "4. Verificando acesso ao Gitea..."
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)
|
|
if [ "$HTTP_CODE" != "000" ]; then
|
|
echo -e "${GREEN}✓${NC} Gitea respondendo na porta 3000 (HTTP $HTTP_CODE)"
|
|
else
|
|
echo -e "${RED}✗${NC} Gitea NÃO está respondendo"
|
|
fi
|
|
|
|
# 5. Verificar portas
|
|
echo ""
|
|
echo "5. Verificando portas..."
|
|
netstat -tuln | grep -q ":80 "
|
|
check_service "Porta 80 (HTTP) aberta" $?
|
|
|
|
netstat -tuln | grep -q ":3000 "
|
|
check_service "Porta 3000 (Gitea) aberta" $?
|
|
|
|
netstat -tuln | grep -q ":222 "
|
|
check_service "Porta 222 (SSH Git) aberta" $?
|
|
|
|
# 6. Verificar SSL
|
|
echo ""
|
|
echo "6. Verificando SSL..."
|
|
if [ -d "/etc/letsencrypt/live/meurepositorio.com" ]; then
|
|
echo -e "${GREEN}✓${NC} Certificado SSL instalado"
|
|
|
|
# Verificar validade do certificado
|
|
CERT_EXPIRY=$(openssl x509 -enddate -noout -in /etc/letsencrypt/live/meurepositorio.com/cert.pem 2>/dev/null | cut -d= -f2)
|
|
if [ ! -z "$CERT_EXPIRY" ]; then
|
|
echo -e " ${GREEN}→${NC} Válido até: $CERT_EXPIRY"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} Certificado SSL NÃO instalado (execute ./configure-ssl.sh)"
|
|
fi
|
|
|
|
# 7. Verificar disco
|
|
echo ""
|
|
echo "7. Verificando espaço em disco..."
|
|
DISK_USAGE=$(df -h /root/gitea | tail -1 | awk '{print $5}' | sed 's/%//')
|
|
if [ $DISK_USAGE -lt 80 ]; then
|
|
echo -e "${GREEN}✓${NC} Espaço em disco OK (${DISK_USAGE}% usado)"
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} Espaço em disco alto (${DISK_USAGE}% usado)"
|
|
fi
|
|
|
|
# 8. Verificar DNS
|
|
echo ""
|
|
echo "8. Verificando DNS..."
|
|
DNS_IP=$(dig +short meurepositorio.com 2>/dev/null | tail -1)
|
|
SERVER_IP=$(curl -s ifconfig.me)
|
|
|
|
if [ ! -z "$DNS_IP" ]; then
|
|
echo -e " DNS aponta para: $DNS_IP"
|
|
echo -e " IP do servidor: $SERVER_IP"
|
|
|
|
if [ "$DNS_IP" == "$SERVER_IP" ]; then
|
|
echo -e "${GREEN}✓${NC} DNS configurado corretamente"
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} DNS não aponta para este servidor"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} Não foi possível resolver DNS (pode não estar configurado ainda)"
|
|
fi
|
|
|
|
# 9. Verificar logs recentes
|
|
echo ""
|
|
echo "9. Últimas linhas do log do Gitea:"
|
|
echo "─────────────────────────────────────────────────────────────────"
|
|
docker logs gitea --tail 5 2>&1
|
|
echo "─────────────────────────────────────────────────────────────────"
|
|
|
|
# 10. Resumo
|
|
echo ""
|
|
echo "╔══════════════════════════════════════════════════════════════════╗"
|
|
echo "║ RESUMO ║"
|
|
echo "╚══════════════════════════════════════════════════════════════════╝"
|
|
|
|
if [ $GITEA_RUNNING -eq 1 ] && [ $DB_RUNNING -eq 1 ]; then
|
|
echo -e "${GREEN}Sistema funcionando corretamente!${NC}"
|
|
echo ""
|
|
echo "Acesse seu Gitea em:"
|
|
if [ -d "/etc/letsencrypt/live/meurepositorio.com" ]; then
|
|
echo " https://meurepositorio.com"
|
|
else
|
|
echo " http://meurepositorio.com"
|
|
echo ""
|
|
echo -e "${YELLOW}RECOMENDAÇÃO:${NC} Configure SSL executando: ./configure-ssl.sh"
|
|
fi
|
|
else
|
|
echo -e "${RED}Há problemas com o sistema!${NC}"
|
|
echo "Execute: /root/gitea/manage-gitea.sh restart"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
|