diff --git a/installer/config_ogdhcp.json b/installer/config_ogdhcp.json index 3e9feca..a1ee03d 100644 --- a/installer/config_ogdhcp.json +++ b/installer/config_ogdhcp.json @@ -1,4 +1,7 @@ { "interfaces": ["eth0", "eth1"], - "ogbootIP": "172.17.8.37" + "ogbootIP": "172.17.8.37", + "ogDhcpIP": "172.17.8.37", + "ogDhcp_Dir": "/opt/opengnsys/ogdhcp" + } \ No newline at end of file diff --git a/installer/ogdhcp_installer.sh b/installer/ogdhcp_installer.sh index 37d2694..3691df9 100755 --- a/installer/ogdhcp_installer.sh +++ b/installer/ogdhcp_installer.sh @@ -33,7 +33,7 @@ function globalSetup() { # Directorios de instalación y destino de OpenGnsys. WORKDIR=/tmp/ogdhcp_installer - INSTALL_TARGET=/opt/ogdhcp + INSTALL_TARGET=$(jq -r '.ogDhcp_Dir' "$CONFIG_FILE") PATH=$PATH:$INSTALL_TARGET/bin if command -v service &>/dev/null; then @@ -176,9 +176,6 @@ function createDirs() { # Cambiar permisos de usuario echoAndLog "Changing user permission" chown -R "$OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER" "$INSTALL_TARGET" - - # Copiar .env - cp -a "$WORKDIR/ogdhcp/.env" "${path_opengnsys_base}/.env" } @@ -376,14 +373,19 @@ add_write_permission_apparmor() { # Función para configurar Nginx setup_nginx() { - get_first_network_interface_with_traffic - if [[ -z "$DEFAULTDEV" ]]; then - echo "Error: No se encontró una interfaz de red activa." + #ip_address_server=$(get_ip_address "$DEFAULTDEV") + if [[ ! -f "$CONFIG_FILE" ]]; then + echo "Error: El archivo de configuración no se encontró." exit 1 fi - ip_address_server=$(get_ip_address "$DEFAULTDEV") + ip_address_server=$(jq -r '.ogDhcpIP' "$CONFIG_FILE") + + if [[ -z "$ip_address_server" ]]; then + echo "Error: No se pudo obtener la dirección IP del servidor desde el archivo de configuración." + exit 1 + fi php_version=$(get_php_fpm_version) if [[ -z "$php_version" ]]; then diff --git a/src/DhcpBundle/Controller/DhcpController.php b/src/DhcpBundle/Controller/DhcpController.php index 5e66345..2d7ed3e 100644 --- a/src/DhcpBundle/Controller/DhcpController.php +++ b/src/DhcpBundle/Controller/DhcpController.php @@ -10,19 +10,22 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Exception; class DhcpController { private $logger; - + private $curlKeaService; + private $backup_dir; - public function __construct(CurlKeaService $curlKeaService, LoggerInterface $logger) + public function __construct(CurlKeaService $curlKeaService, LoggerInterface $logger, ParameterBagInterface $params) { $this->curlKeaService = $curlKeaService; $this->logger = $logger; + $this->backup_dir = $params->get('backup_dir'); } @@ -1439,7 +1442,8 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse */ public function getLatestBackupConfiguration(): JsonResponse { - $backup_dir = '/opt/ogdhcp/etc/kea/backup'; + #$backup_dir = '/opt/ogdhcp/etc/kea/backup'; + $backup_dir = $this->backup_dir; try { // Obtener los archivos de backup $backup_files = glob($backup_dir . '/*.conf'); @@ -1532,7 +1536,8 @@ public function getLatestBackupConfiguration(): JsonResponse */ public function restoreDhcpConfiguration(): JsonResponse { - $backup_dir = '/opt/ogdhcp/etc/kea/backup'; + #$backup_dir = '/opt/ogdhcp/etc/kea/backup'; + $backup_dir = $this->backup_dir; try { $backup_files = glob($backup_dir . '/*.conf'); if (empty($backup_files)) {