Renombrar FlotillasGPS a ADAN en todo el proyecto
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# ============================================
|
||||
# Sistema de Flotillas - Script de Instalacion
|
||||
# Sistema de ADAN - 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/flotillas}"
|
||||
REPO_URL="${REPO_URL:-https://github.com/tuorganizacion/flotillas.git}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/opt/adan}"
|
||||
REPO_URL="${REPO_URL:-https://github.com/tuorganizacion/adan.git}"
|
||||
REPO_BRANCH="${REPO_BRANCH:-main}"
|
||||
BACKUP_DIR="${BACKUP_DIR:-/var/backups/flotillas}"
|
||||
BACKUP_DIR="${BACKUP_DIR:-/var/backups/adan}"
|
||||
|
||||
# Versiones
|
||||
POSTGRES_VERSION="15"
|
||||
@@ -51,7 +51,7 @@ SKIP_TRACCAR=false
|
||||
DEV_MODE=false
|
||||
|
||||
# Archivo de credenciales generadas
|
||||
CREDENTIALS_FILE="/root/flotillas-credentials.txt"
|
||||
CREDENTIALS_FILE="/root/adan-credentials.txt"
|
||||
|
||||
# ---------------------------------------------
|
||||
# Funciones de utilidad
|
||||
@@ -478,8 +478,8 @@ configure_database() {
|
||||
DB_PASSWORD=$(generate_password 24)
|
||||
fi
|
||||
|
||||
DB_NAME="${POSTGRES_DB:-flotillas}"
|
||||
DB_USER="${POSTGRES_USER:-flotillas}"
|
||||
DB_NAME="${POSTGRES_DB:-adan}"
|
||||
DB_USER="${POSTGRES_USER:-adan}"
|
||||
|
||||
log_info "Creando usuario y base de datos..."
|
||||
|
||||
@@ -611,7 +611,7 @@ generate_credentials() {
|
||||
# Guardar en archivo seguro
|
||||
cat > "$CREDENTIALS_FILE" <<EOF
|
||||
# ============================================
|
||||
# Credenciales del Sistema de Flotillas
|
||||
# Credenciales del Sistema de ADAN
|
||||
# Generadas: $(date)
|
||||
# IMPORTANTE: Guardar en lugar seguro y eliminar este archivo
|
||||
# ============================================
|
||||
@@ -619,10 +619,10 @@ generate_credentials() {
|
||||
# PostgreSQL
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB=flotillas
|
||||
POSTGRES_USER=flotillas
|
||||
POSTGRES_DB=adan
|
||||
POSTGRES_USER=adan
|
||||
POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
DATABASE_URL=postgresql://flotillas:${DB_PASSWORD}@localhost:5432/flotillas
|
||||
DATABASE_URL=postgresql://adan:${DB_PASSWORD}@localhost:5432/adan
|
||||
|
||||
# Redis
|
||||
REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||
@@ -633,11 +633,11 @@ SECRET_KEY=${SECRET_KEY}
|
||||
API_PORT=${API_PORT}
|
||||
|
||||
# MQTT
|
||||
MQTT_USER=flotillas
|
||||
MQTT_USER=adan
|
||||
MQTT_PASSWORD=${MQTT_PASSWORD}
|
||||
|
||||
# Admin inicial
|
||||
ADMIN_EMAIL=admin@flotillas.local
|
||||
ADMIN_EMAIL=admin@adan.local
|
||||
ADMIN_PASSWORD=${ADMIN_PASSWORD}
|
||||
|
||||
# Puertos
|
||||
@@ -665,10 +665,10 @@ create_env_file() {
|
||||
# Base de Datos
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB=flotillas
|
||||
POSTGRES_USER=flotillas
|
||||
POSTGRES_DB=adan
|
||||
POSTGRES_USER=adan
|
||||
POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
DATABASE_URL=postgresql://flotillas:${DB_PASSWORD}@localhost:5432/flotillas
|
||||
DATABASE_URL=postgresql://adan:${DB_PASSWORD}@localhost:5432/adan
|
||||
|
||||
# Redis
|
||||
REDIS_HOST=localhost
|
||||
@@ -697,7 +697,7 @@ TRACCAR_FORWARD_URL=http://localhost:${API_PORT}/api/v1/traccar/position
|
||||
# MQTT
|
||||
MQTT_HOST=localhost
|
||||
MQTT_PORT=1883
|
||||
MQTT_USER=flotillas
|
||||
MQTT_USER=adan
|
||||
MQTT_PASSWORD=${MQTT_PASSWORD}
|
||||
|
||||
# MediaMTX
|
||||
@@ -771,11 +771,11 @@ configure_mosquitto() {
|
||||
|
||||
# Crear archivo de passwords
|
||||
touch /etc/mosquitto/passwd
|
||||
mosquitto_passwd -b /etc/mosquitto/passwd flotillas "${MQTT_PASSWORD}"
|
||||
mosquitto_passwd -b /etc/mosquitto/passwd adan "${MQTT_PASSWORD}"
|
||||
|
||||
# Configuracion
|
||||
cat > /etc/mosquitto/conf.d/flotillas.conf <<EOF
|
||||
# Configuracion para Sistema de Flotillas
|
||||
cat > /etc/mosquitto/conf.d/adan.conf <<EOF
|
||||
# Configuracion para Sistema de ADAN
|
||||
|
||||
listener 1883 localhost
|
||||
listener 9001
|
||||
@@ -819,7 +819,7 @@ install_services() {
|
||||
SERVICES_DIR="$INSTALL_DIR/deploy/services"
|
||||
|
||||
# Copiar servicios
|
||||
for service in flotillas-api flotillas-web mediamtx cloudflared; do
|
||||
for service in adan-api adan-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 +830,14 @@ install_services() {
|
||||
systemctl daemon-reload
|
||||
|
||||
# Habilitar servicios
|
||||
systemctl enable flotillas-api 2>/dev/null || true
|
||||
systemctl enable flotillas-web 2>/dev/null || true
|
||||
systemctl enable adan-api 2>/dev/null || true
|
||||
systemctl enable adan-web 2>/dev/null || true
|
||||
systemctl enable mediamtx 2>/dev/null || true
|
||||
|
||||
# Iniciar servicios
|
||||
log_info "Iniciando servicios..."
|
||||
systemctl start flotillas-api 2>/dev/null || log_warn "flotillas-api no pudo iniciar (puede requerir configuracion adicional)"
|
||||
systemctl start flotillas-web 2>/dev/null || log_warn "flotillas-web no pudo iniciar"
|
||||
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 mediamtx 2>/dev/null || log_warn "mediamtx no pudo iniciar"
|
||||
|
||||
log_success "Servicios instalados"
|
||||
@@ -864,7 +864,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 flotillas -d flotillas -f "$INSTALL_DIR/deploy/postgres/init.sql" || true
|
||||
PGPASSWORD="${DB_PASSWORD}" psql -h localhost -U adan -d adan -f "$INSTALL_DIR/deploy/postgres/init.sql" || true
|
||||
fi
|
||||
|
||||
deactivate
|
||||
@@ -936,8 +936,8 @@ EOF
|
||||
configure_logrotate() {
|
||||
log_section "Configurando Logrotate"
|
||||
|
||||
cat > /etc/logrotate.d/flotillas <<EOF
|
||||
/var/log/flotillas/*.log {
|
||||
cat > /etc/logrotate.d/adan <<EOF
|
||||
/var/log/adan/*.log {
|
||||
daily
|
||||
missingok
|
||||
rotate 14
|
||||
@@ -947,12 +947,12 @@ configure_logrotate() {
|
||||
create 0640 root root
|
||||
sharedscripts
|
||||
postrotate
|
||||
systemctl reload flotillas-api > /dev/null 2>&1 || true
|
||||
systemctl reload adan-api > /dev/null 2>&1 || true
|
||||
endscript
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p /var/log/flotillas
|
||||
mkdir -p /var/log/adan
|
||||
|
||||
log_success "Logrotate configurado"
|
||||
}
|
||||
@@ -964,7 +964,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/flotillas/backup.log 2>&1"
|
||||
CRON_JOB="0 3 * * * $INSTALL_DIR/deploy/scripts/backup.sh >> /var/log/adan/backup.log 2>&1"
|
||||
|
||||
# Agregar si no existe
|
||||
(crontab -l 2>/dev/null | grep -v "backup.sh"; echo "$CRON_JOB") | crontab -
|
||||
@@ -980,7 +980,7 @@ show_summary() {
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}============================================${NC}"
|
||||
echo -e "${GREEN} SISTEMA DE FLOTILLAS INSTALADO ${NC}"
|
||||
echo -e "${GREEN} SISTEMA DE ADAN INSTALADO ${NC}"
|
||||
echo -e "${GREEN}============================================${NC}"
|
||||
echo ""
|
||||
echo -e "${BLUE}Servicios:${NC}"
|
||||
@@ -992,8 +992,8 @@ show_summary() {
|
||||
echo ""
|
||||
echo -e "${BLUE}Base de Datos:${NC}"
|
||||
echo " - PostgreSQL: localhost:5432"
|
||||
echo " - Database: flotillas"
|
||||
echo " - Usuario: flotillas"
|
||||
echo " - Database: adan"
|
||||
echo " - Usuario: adan"
|
||||
echo ""
|
||||
echo -e "${BLUE}Credenciales:${NC}"
|
||||
echo " - Guardadas en: ${CREDENTIALS_FILE}"
|
||||
@@ -1004,8 +1004,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 flotillas-api -f"
|
||||
echo " - Reiniciar API: systemctl restart flotillas-api"
|
||||
echo " - Ver logs API: journalctl -u adan-api -f"
|
||||
echo " - Reiniciar API: systemctl restart adan-api"
|
||||
echo " - Backup manual: ${INSTALL_DIR}/deploy/scripts/backup.sh"
|
||||
echo " - Actualizar: ${INSTALL_DIR}/deploy/scripts/update.sh"
|
||||
echo ""
|
||||
@@ -1026,7 +1026,7 @@ main() {
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}============================================${NC}"
|
||||
echo -e "${GREEN} INSTALADOR SISTEMA DE FLOTILLAS ${NC}"
|
||||
echo -e "${GREEN} INSTALADOR SISTEMA DE ADAN ${NC}"
|
||||
echo -e "${GREEN}============================================${NC}"
|
||||
echo ""
|
||||
echo "Directorio instalacion: $INSTALL_DIR"
|
||||
|
||||
Reference in New Issue
Block a user