Skip to content

Commit

Permalink
Merge pull request #31 from alegarsan11/master
Browse files Browse the repository at this point in the history
Apache server
  • Loading branch information
alegarsan11 committed May 28, 2024
2 parents 8429ed8 + a5b29b6 commit df2664b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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):
Expand All @@ -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`
`python -m pytest --cov --cov-report=html`
36 changes: 35 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,15 +22,47 @@ 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
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
Expand Down
Binary file removed nftables-frontend/instance/nftables.db
Binary file not shown.
2 changes: 1 addition & 1 deletion nftables-frontend/nftables-config.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<VirtualHost *:80>
<VirtualHost *:8080>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /usr/share/nftables-frontend
Expand Down

0 comments on commit df2664b

Please sign in to comment.