feat: Complete ATLAS system installation and API fixes

## Backend Changes
- Add new API endpoints: combustible, pois, mantenimiento, video, configuracion
- Fix vehiculos endpoint to return paginated response with items array
- Add /vehiculos/all endpoint for non-paginated list
- Add /geocercas/all endpoint
- Add /alertas/configuracion GET/PUT endpoints
- Add /viajes/activos and /viajes/iniciar endpoints
- Add /reportes/stats, /reportes/templates, /reportes/preview endpoints
- Add /conductores/all and /conductores/disponibles endpoints
- Update router.py to include all new modules

## Frontend Changes
- Fix authentication token handling (snake_case vs camelCase)
- Update vehiculosApi.listAll to use /vehiculos/all
- Fix FuelGauge component usage in Combustible page
- Fix chart component exports (named + default exports)
- Update API client for proper token refresh

## Infrastructure
- Rename services from ADAN to ATLAS
- Configure Cloudflare tunnel for atlas.consultoria-as.com
- Update systemd service files
- Configure PostgreSQL with TimescaleDB
- Configure Redis, Mosquitto, Traccar, MediaMTX

## Documentation
- Update installation guides
- Update API reference
- Rename all ADAN references to ATLAS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
ATLAS Admin
2026-01-25 03:04:23 +00:00
parent 0dfce3ce20
commit e59aa2a742
73 changed files with 4415 additions and 450 deletions

92
deploy/scripts/install.sh Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#!/bin/bash
# ============================================
# Sistema de ADAN - Script de Instalacion
# Sistema de ATLAS - Script de Instalacion
# ============================================
# Este script instala y configura todo el sistema
# Ejecutar como root en Ubuntu 22.04 LTS
@@ -28,10 +28,10 @@ NC='\033[0m' # No Color
# ---------------------------------------------
# Variables de Configuracion
# ---------------------------------------------
INSTALL_DIR="${INSTALL_DIR:-/opt/adan}"
REPO_URL="${REPO_URL:-https://github.com/tuorganizacion/adan.git}"
INSTALL_DIR="${INSTALL_DIR:-/opt/atlas}"
REPO_URL="${REPO_URL:-https://github.com/tuorganizacion/atlas.git}"
REPO_BRANCH="${REPO_BRANCH:-main}"
BACKUP_DIR="${BACKUP_DIR:-/var/backups/adan}"
BACKUP_DIR="${BACKUP_DIR:-/var/backups/atlas}"
# Versiones
POSTGRES_VERSION="15"
@@ -51,7 +51,7 @@ SKIP_TRACCAR=false
DEV_MODE=false
# Archivo de credenciales generadas
CREDENTIALS_FILE="/root/adan-credentials.txt"
CREDENTIALS_FILE="/root/atlas-credentials.txt"
# ---------------------------------------------
# Funciones de utilidad
@@ -147,17 +147,19 @@ check_requirements() {
exit 1
fi
# Verificar Ubuntu 22.04
# Verificar Ubuntu 22.04 o 24.04
if [[ -f /etc/os-release ]]; then
. /etc/os-release
if [[ "$ID" != "ubuntu" ]] || [[ ! "$VERSION_ID" =~ ^22 ]]; then
log_warn "Este script esta optimizado para Ubuntu 22.04"
if [[ "$ID" != "ubuntu" ]] || [[ ! "$VERSION_ID" =~ ^(22|24) ]]; then
log_warn "Este script esta optimizado para Ubuntu 22.04/24.04"
log_warn "Sistema detectado: $ID $VERSION_ID"
read -p "Continuar de todos modos? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
else
log_success "Sistema operativo: $ID $VERSION_ID"
fi
fi
@@ -331,11 +333,11 @@ install_python() {
# Instalar pip
if ! python3.11 -m pip --version &> /dev/null; then
log_info "Instalando pip..."
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 --user
fi
# Actualizar pip
python3.11 -m pip install --upgrade pip setuptools wheel -q
# Actualizar pip (ignorar paquetes del sistema)
python3.11 -m pip install --upgrade pip setuptools wheel --ignore-installed -q 2>/dev/null || true
log_success "Python ${PYTHON_VERSION} instalado"
}
@@ -478,8 +480,8 @@ configure_database() {
DB_PASSWORD=$(generate_password 24)
fi
DB_NAME="${POSTGRES_DB:-adan}"
DB_USER="${POSTGRES_USER:-adan}"
DB_NAME="${POSTGRES_DB:-atlas}"
DB_USER="${POSTGRES_USER:-atlas}"
log_info "Creando usuario y base de datos..."
@@ -549,9 +551,9 @@ setup_application() {
else
log_info "Clonando repositorio..."
# Si el directorio actual contiene el codigo, copiarlo
if [[ -f "/root/Adan/backend/app/main.py" ]] 2>/dev/null; then
if [[ -f "/root/Atlas/backend/app/main.py" ]] 2>/dev/null; then
log_info "Copiando desde directorio local..."
cp -r /root/Adan/* "$INSTALL_DIR/"
cp -r /root/Atlas/* "$INSTALL_DIR/"
else
git clone --branch "$REPO_BRANCH" "$REPO_URL" "$INSTALL_DIR"
fi
@@ -611,7 +613,7 @@ generate_credentials() {
# Guardar en archivo seguro
cat > "$CREDENTIALS_FILE" <<EOF
# ============================================
# Credenciales del Sistema de ADAN
# Credenciales del Sistema de ATLAS
# Generadas: $(date)
# IMPORTANTE: Guardar en lugar seguro y eliminar este archivo
# ============================================
@@ -619,10 +621,10 @@ generate_credentials() {
# PostgreSQL
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=adan
POSTGRES_USER=adan
POSTGRES_DB=atlas
POSTGRES_USER=atlas
POSTGRES_PASSWORD=${DB_PASSWORD}
DATABASE_URL=postgresql://adan:${DB_PASSWORD}@localhost:5432/adan
DATABASE_URL=postgresql://atlas:${DB_PASSWORD}@localhost:5432/atlas
# Redis
REDIS_PASSWORD=${REDIS_PASSWORD}
@@ -633,11 +635,11 @@ SECRET_KEY=${SECRET_KEY}
API_PORT=${API_PORT}
# MQTT
MQTT_USER=adan
MQTT_USER=atlas
MQTT_PASSWORD=${MQTT_PASSWORD}
# Admin inicial
ADMIN_EMAIL=admin@adan.local
ADMIN_EMAIL=admin@atlas.local
ADMIN_PASSWORD=${ADMIN_PASSWORD}
# Puertos
@@ -665,10 +667,10 @@ create_env_file() {
# Base de Datos
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=adan
POSTGRES_USER=adan
POSTGRES_DB=atlas
POSTGRES_USER=atlas
POSTGRES_PASSWORD=${DB_PASSWORD}
DATABASE_URL=postgresql://adan:${DB_PASSWORD}@localhost:5432/adan
DATABASE_URL=postgresql://atlas:${DB_PASSWORD}@localhost:5432/atlas
# Redis
REDIS_HOST=localhost
@@ -697,7 +699,7 @@ TRACCAR_FORWARD_URL=http://localhost:${API_PORT}/api/v1/traccar/position
# MQTT
MQTT_HOST=localhost
MQTT_PORT=1883
MQTT_USER=adan
MQTT_USER=atlas
MQTT_PASSWORD=${MQTT_PASSWORD}
# MediaMTX
@@ -771,11 +773,11 @@ configure_mosquitto() {
# Crear archivo de passwords
touch /etc/mosquitto/passwd
mosquitto_passwd -b /etc/mosquitto/passwd adan "${MQTT_PASSWORD}"
mosquitto_passwd -b /etc/mosquitto/passwd atlas "${MQTT_PASSWORD}"
# Configuracion
cat > /etc/mosquitto/conf.d/adan.conf <<EOF
# Configuracion para Sistema de ADAN
cat > /etc/mosquitto/conf.d/atlas.conf <<EOF
# Configuracion para Sistema de ATLAS
listener 1883 localhost
listener 9001
@@ -819,7 +821,7 @@ install_services() {
SERVICES_DIR="$INSTALL_DIR/deploy/services"
# Copiar servicios
for service in adan-api adan-web mediamtx cloudflared; do
for service in atlas-api atlas-web mediamtx cloudflared; do
if [[ -f "$SERVICES_DIR/${service}.service" ]]; then
log_info "Instalando servicio: ${service}"
cp "$SERVICES_DIR/${service}.service" /etc/systemd/system/
@@ -830,14 +832,14 @@ install_services() {
systemctl daemon-reload
# Habilitar servicios
systemctl enable adan-api 2>/dev/null || true
systemctl enable adan-web 2>/dev/null || true
systemctl enable atlas-api 2>/dev/null || true
systemctl enable atlas-web 2>/dev/null || true
systemctl enable mediamtx 2>/dev/null || true
# Iniciar servicios
log_info "Iniciando servicios..."
systemctl start adan-api 2>/dev/null || log_warn "adan-api no pudo iniciar (puede requerir configuracion adicional)"
systemctl start adan-web 2>/dev/null || log_warn "adan-web no pudo iniciar"
systemctl start atlas-api 2>/dev/null || log_warn "atlas-api no pudo iniciar (puede requerir configuracion adicional)"
systemctl start atlas-web 2>/dev/null || log_warn "atlas-web no pudo iniciar"
systemctl start mediamtx 2>/dev/null || log_warn "mediamtx no pudo iniciar"
log_success "Servicios instalados"
@@ -864,7 +866,7 @@ run_migrations() {
# Ejecutar init.sql si existe y no hay migraciones
if [[ ! -d "alembic" ]] && [[ -f "$INSTALL_DIR/deploy/postgres/init.sql" ]]; then
log_info "Ejecutando script init.sql..."
PGPASSWORD="${DB_PASSWORD}" psql -h localhost -U adan -d adan -f "$INSTALL_DIR/deploy/postgres/init.sql" || true
PGPASSWORD="${DB_PASSWORD}" psql -h localhost -U atlas -d atlas -f "$INSTALL_DIR/deploy/postgres/init.sql" || true
fi
deactivate
@@ -936,8 +938,8 @@ EOF
configure_logrotate() {
log_section "Configurando Logrotate"
cat > /etc/logrotate.d/adan <<EOF
/var/log/adan/*.log {
cat > /etc/logrotate.d/atlas <<EOF
/var/log/atlas/*.log {
daily
missingok
rotate 14
@@ -947,12 +949,12 @@ configure_logrotate() {
create 0640 root root
sharedscripts
postrotate
systemctl reload adan-api > /dev/null 2>&1 || true
systemctl reload atlas-api > /dev/null 2>&1 || true
endscript
}
EOF
mkdir -p /var/log/adan
mkdir -p /var/log/atlas
log_success "Logrotate configurado"
}
@@ -964,7 +966,7 @@ configure_cron() {
log_section "Configurando Backups Automaticos"
# Crear cron para backup diario a las 3 AM
CRON_JOB="0 3 * * * $INSTALL_DIR/deploy/scripts/backup.sh >> /var/log/adan/backup.log 2>&1"
CRON_JOB="0 3 * * * $INSTALL_DIR/deploy/scripts/backup.sh >> /var/log/atlas/backup.log 2>&1"
# Agregar si no existe
(crontab -l 2>/dev/null | grep -v "backup.sh"; echo "$CRON_JOB") | crontab -
@@ -980,7 +982,7 @@ show_summary() {
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN} SISTEMA DE ADAN INSTALADO ${NC}"
echo -e "${GREEN} SISTEMA DE ATLAS INSTALADO ${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo -e "${BLUE}Servicios:${NC}"
@@ -992,8 +994,8 @@ show_summary() {
echo ""
echo -e "${BLUE}Base de Datos:${NC}"
echo " - PostgreSQL: localhost:5432"
echo " - Database: adan"
echo " - Usuario: adan"
echo " - Database: atlas"
echo " - Usuario: atlas"
echo ""
echo -e "${BLUE}Credenciales:${NC}"
echo " - Guardadas en: ${CREDENTIALS_FILE}"
@@ -1004,8 +1006,8 @@ show_summary() {
echo " 3. El unico puerto publico es ${TRACCAR_PORT} (GPS)"
echo ""
echo -e "${BLUE}Comandos utiles:${NC}"
echo " - Ver logs API: journalctl -u adan-api -f"
echo " - Reiniciar API: systemctl restart adan-api"
echo " - Ver logs API: journalctl -u atlas-api -f"
echo " - Reiniciar API: systemctl restart atlas-api"
echo " - Backup manual: ${INSTALL_DIR}/deploy/scripts/backup.sh"
echo " - Actualizar: ${INSTALL_DIR}/deploy/scripts/update.sh"
echo ""
@@ -1026,7 +1028,7 @@ main() {
echo ""
echo -e "${GREEN}============================================${NC}"
echo -e "${GREEN} INSTALADOR SISTEMA DE ADAN ${NC}"
echo -e "${GREEN} INSTALADOR SISTEMA DE ATLAS ${NC}"
echo -e "${GREEN}============================================${NC}"
echo ""
echo "Directorio instalacion: $INSTALL_DIR"