From 18811105a6658e6734e32e9f46c689385ef65ff9 Mon Sep 17 00:00:00 2001 From: lgromero Date: Mon, 28 Oct 2024 07:23:15 +0100 Subject: [PATCH] refs #1053 Adds new parameter to nginx template to public dinamic dir. Use dinamic route to obtain disk usage function in controller --- etc/nginxServer.conf.tmpl | 2 +- installer/ogdhcp_installer.sh | 6 ++++-- src/DhcpBundle/Controller/DhcpController.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/etc/nginxServer.conf.tmpl b/etc/nginxServer.conf.tmpl index b67abda..e4f60ac 100644 --- a/etc/nginxServer.conf.tmpl +++ b/etc/nginxServer.conf.tmpl @@ -3,7 +3,7 @@ server { server_name __SERVERIP__ localhost; # IP del servidor # Raíz del documento para el proyecto Symfony - root /opt/ogdhcp/public; + root __PUBLICDIR__; # Bloque para manejar las solicitudes a /ogdhcp location /ogdhcp { diff --git a/installer/ogdhcp_installer.sh b/installer/ogdhcp_installer.sh index 3691df9..6780301 100755 --- a/installer/ogdhcp_installer.sh +++ b/installer/ogdhcp_installer.sh @@ -373,7 +373,8 @@ add_write_permission_apparmor() { # Función para configurar Nginx setup_nginx() { - + local path_opengnsys_base="$1" + local public_dir="$path_opengnsys_base/public" #ip_address_server=$(get_ip_address "$DEFAULTDEV") if [[ ! -f "$CONFIG_FILE" ]]; then echo "Error: El archivo de configuración no se encontró." @@ -398,10 +399,11 @@ setup_nginx() { echo "Error: La plantilla de Nginx no se encontró." exit 1 fi - + nginx_content=$(<"$NGINX_TEMPLATE") nginx_content="${nginx_content//__SERVERIP__/$ip_address_server}" nginx_content="${nginx_content//__PHPVERSION__/$php_version}" + nginx_content="${nginx_content//__PUBLICDIR__/$public_dir}" # Crear el archivo de configuración de Nginx echo "$nginx_content" > "$NGINX_OUTPUT" diff --git a/src/DhcpBundle/Controller/DhcpController.php b/src/DhcpBundle/Controller/DhcpController.php index 2d7ed3e..9c7d759 100644 --- a/src/DhcpBundle/Controller/DhcpController.php +++ b/src/DhcpBundle/Controller/DhcpController.php @@ -98,7 +98,7 @@ class DhcpController private function getDiskUsage(): array { // Simular la salida del comando df para obtener el uso del disco - $output = shell_exec("df -h /opt/ogdhcp | tail -1 | awk '{print $2, $3, $4, $5}'"); + $output = shell_exec("df -h " . realpath($this->backup_dir) . " | tail -1 | awk '{print $2, $3, $4, $5}'"); if (!$output) { $this->logger->error("Failed to execute disk usage command"); return null;