Registro y elevación de componentes base (ADN, Scripts, Servicios)

This commit is contained in:
Ricardo Monla
2026-02-15 20:37:53 -03:00
parent 9e9bf62c68
commit c865a7772b
25279 changed files with 3354766 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
#!/bin/bash
# scripts/configurar_red_hibrida.sh
# CONFIGURACIÓN DE RED HÍBRIDA (Policy Routing)
# Objetivo:
# - Mantener Gateway Default 10.0.10.1 (Navegación Rápida).
# - Habilitar IP Pública 190.114.205.18 para acceso entrante.
# - Responder tráfico entrante de 190... por su propio Gateway (190.114.205.1).
CON_NAME="Red LAN 10"
IP_PUB="190.114.205.18/24"
GW_PUB="190.114.205.1"
TABLE_ID="190"
TIMEOUT_SEC=300 # 5 Minutos
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Ejecutar con sudo.${NC}"
exit 1
fi
echo -e "${YELLOW}Configurando Red Híbrida en conexión '$CON_NAME'...${NC}"
# 1. Agregar IP Pública (si no existe ya)
# Nota: nmcli es idempotente para esto si se usa correctamente, pero limpiaremos "ipv4.addresses" duplicadas si es manual.
# Aquí simplemente agregamos.
echo -e "[1/4] Agregando IP Pública $IP_PUB..."
nmcli con mod "$CON_NAME" +ipv4.addresses "$IP_PUB"
# 2. Agregar Ruta a Tabla Secundaria
# Sintaxis: ip/prefix next-hop priority attributes
echo -e "[2/4] Configurando ruta de retorno (Tabla $TABLE_ID)..."
nmcli con mod "$CON_NAME" +ipv4.routes "0.0.0.0/0 $GW_PUB 100 table=$TABLE_ID"
# 3. Agregar Regla de Enrutamiento
# Sintaxis: priority from <ip> table <id>
echo -e "[3/4] Configurando regla de política (Policy Rule)..."
nmcli con mod "$CON_NAME" +ipv4.routing-rules "priority 30000 from ${IP_PUB%/*} table $TABLE_ID"
# 4. Aplicar Cambios (Temporales para validación)
echo -e "Aplicando configuración... (Si pierdes conexión, espera $TIMEOUT_SEC segundos)"
nmcli con mod "$CON_NAME" +ipv4.addresses "$IP_PUB"
nmcli con mod "$CON_NAME" +ipv4.routes "0.0.0.0/0 $GW_PUB 100 table=$TABLE_ID"
nmcli con mod "$CON_NAME" +ipv4.routing-rules "priority 30000 from ${IP_PUB%/*} table $TABLE_ID"
nmcli con up "$CON_NAME"
# --- VERIFICACIÓN / ROLLBACK LOOP ---
echo -e "\n${GREEN}*** CAMBIOS APLICADOS ***${NC}"
echo "Verifica que tienes conectividad (tanto LAN como WAN)."
echo "Tienes $TIMEOUT_SEC segundos para confirmar escribiendo 's' y Enter."
CONFIRMADO=0
for ((i=TIMEOUT_SEC; i>0; i--)); do
echo -ne " Tiempo restante para ROLLBACK: $i segundos \r"
read -t 1 -n 1 key
if [[ $key = "s" ]] || [[ $key = "S" ]]; then
CONFIRMADO=1
break
fi
done
if [ $CONFIRMADO -eq 1 ]; then
echo -e "\n\n${GREEN}¡CONFIRMADO! Configuración de Red Híbrida establecida.${NC}"
exit 0
else
echo -e "\n\n${RED}¡TIEMPO AGOTADO! REVIERTIENDO CAMBIOS...${NC}"
# Revertir (Undo)
echo "Eliminando reglas..."
nmcli con mod "$CON_NAME" -ipv4.addresses "$IP_PUB"
nmcli con mod "$CON_NAME" -ipv4.routes "0.0.0.0/0 $GW_PUB 100 table=$TABLE_ID"
nmcli con mod "$CON_NAME" -ipv4.routing-rules "priority 30000 from ${IP_PUB%/*} table $TABLE_ID"
echo "Recargando conexión..."
nmcli con up "$CON_NAME"
echo -e "${GREEN}Sistema restaurado al estado original.${NC}"
fi
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# scripts/instalar_nginx_simple.sh
# Script para instalar Nginx y aplicar configuraciones (Sin manipulación de IP).
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Ejecutar con sudo.${NC}"
exit 1
fi
echo -e "${YELLOW}[1/3] Instalando Nginx...${NC}"
apt-get update && apt-get install -y nginx
echo -e "${YELLOW}[2/3] Aplicando configuraciones de servicios...${NC}"
# Remover default si molesta
# rm /etc/nginx/sites-enabled/default 2>/dev/null
# Enlazar configs
CONFIG_DIR="/home/rmonla/Documentos/GitHub/dtic-srv-NS8/servicios/nginx/conf.d"
ln -sf $CONFIG_DIR/*.conf /etc/nginx/conf.d/
echo -e "${YELLOW}[3/3] Iniciando servicio...${NC}"
systemctl enable nginx
systemctl restart nginx
echo -e "${GREEN}Instalación completada.${NC}"
echo "Nginx está corriendo en el Host."
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# scripts/instalar_ssl.sh
# Script para instalar Certbot y obtener certificado SSL para ns8.frlr.utn.edu.ar
DOMAIN="ns8.frlr.utn.edu.ar"
EMAIL="admin@ns8.frlr.utn.edu.ar" # Ajustar si es necesario, Certbot pedirá uno real interactivo o usará este
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Ejecutar con sudo.${NC}"
exit 1
fi
echo -e "${YELLOW}[1/4] Instalando Certbot y plugin Nginx...${NC}"
apt-get update
apt-get install -y certbot python3-certbot-nginx
echo -e "${YELLOW}[2/4] Activando configuración del dominio $DOMAIN...${NC}"
# Enlazar la nueva config si no existe
ln -sf /home/rmonla/Documentos/GitHub/dtic-srv-NS8/servicios/nginx/conf.d/ns8.conf /etc/nginx/conf.d/ns8.conf
echo -e "${YELLOW}[3/4] Verificando y Recargando Nginx...${NC}"
nginx -t && systemctl reload nginx
echo -e "${YELLOW}[4/4] Ejecutando Certbot...${NC}"
echo "Sigue las instrucciones en pantalla (ingresa tu email si se solicita)."
certbot --nginx -d $DOMAIN
echo -e "${GREEN}Proceso finalizado.${NC}"
echo "Prueba acceder a https://$DOMAIN"