diff --git a/README.md b/README.md index c4d8f9e..f50a120 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ This repository is used to develop a web interface that enables the configuration of nftables through a graphical user interface. - ## Requirements To use this project, you need to install `python3-nftables` and `python3-hug`. For proper functioning, it's necessary to run the parsing file as an administrator. @@ -38,6 +37,8 @@ To deploy an Apache server, use the build.sh file: `sudo ./build.sh` +(Apache server will be available on port 8080) + ### Testing and Coverage To run the tests and generate coverage reports, use the following commands: - Execute the test files (in the nftables-frontend folder): @@ -50,4 +51,4 @@ To run the tests and generate coverage reports, use the following commands: - Generate a coverage report: - `python -m pytest --cov --cov-report=html` \ No newline at end of file + `python -m pytest --cov --cov-report=html` diff --git a/build.sh b/build.sh index 404ac01..b8c6d56 100755 --- a/build.sh +++ b/build.sh @@ -7,7 +7,9 @@ sudo chown www-data:www-data $MPLCONFIGDIR sudo chmod 777 $MPLCONFIGDIR sudo pip install -r requirements.txt # Instalación de dependencias -sudo apt-get install -y libfreetype6-dev libxft-dev apache2 +sudo apt-get install libfreetype6-dev +sudo apt-get install libxft-dev apache2 + sleep 5 # Copiar la aplicación sudo cp -r nftables-frontend /usr/share @@ -20,8 +22,10 @@ sudo a2enmod wsgi # Configuración del sitio de Apache sudo cp nftables-frontend/nftables-config.conf /etc/apache2/sites-available/nftables-config.conf sudo a2ensite nftables-config.conf +sudo a2dissite 000-default.conf # Ajuste de permisos +sudo touch /usr/share/nftables-frontend/instance/nftables.db sudo chmod 664 /usr/share/nftables-frontend/instance/nftables.db sudo chown www-data:www-data /usr/share/nftables-frontend/instance/nftables.db sudo chown -R www-data:www-data /usr/share/nftables-frontend @@ -29,6 +33,36 @@ sudo chmod -R 775 /usr/share/nftables-frontend sudo chmod -R 775 /usr/share/nftables-frontend/instance sudo chmod -R 775 /usr/share/nftables-frontend/static sudo chown -R www-data:www-data /usr/share/nftables-frontend/static +FICHERO="/etc/apache2/sites-available/000-default.conf" + +if [ -f "$FICHERO" ]; then + rm "$FICHERO" + echo "El fichero $FICHERO ha sido eliminado." +else + echo "El fichero $FICHERO no existe." +fi +FICHERO="/etc/apache2/sites-enabled/000-default.conf" + +if [ -f "$FICHERO" ]; then + rm "$FICHERO" + echo "El fichero $FICHERO ha sido eliminado." +else + echo "El fichero $FICHERO no existe." +fi + +ARCHIVO="/etc/apache2/ports.conf" + +# Línea a añadir +LINEA="Listen 8080" + +# Comprobar si la línea ya existe en el archivo +if ! grep -qF "$LINEA" "$ARCHIVO"; then + # Añadir la línea al final del archivo + echo "$LINEA" | sudo tee -a "$ARCHIVO" > /dev/null + echo "Línea añadida: $LINEA" +else + echo "La línea ya existe en el archivo: $LINEA" +fi # Reiniciar Apache sudo systemctl restart apache2 diff --git a/nftables-frontend/instance/nftables.db b/nftables-frontend/instance/nftables.db deleted file mode 100644 index 5753389..0000000 Binary files a/nftables-frontend/instance/nftables.db and /dev/null differ diff --git a/nftables-frontend/nftables-config.conf b/nftables-frontend/nftables-config.conf index a30a50b..1dc9eaf 100644 --- a/nftables-frontend/nftables-config.conf +++ b/nftables-frontend/nftables-config.conf @@ -1,4 +1,4 @@ - + ServerName www.example.com ServerAlias example.com DocumentRoot /usr/share/nftables-frontend