Compare commits
5 Commits
63f67c7188
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a1df4dcfdf | |||
| af3d1fd3cb | |||
| 0989f51a55 | |||
| 827ed9f83b | |||
| 6d5dbee874 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
.venv
|
||||
.env
|
||||
**/.venv
|
||||
**/.env
|
||||
**/__pycache__
|
||||
**/*.pem
|
||||
|
||||
26
README.md
26
README.md
@@ -20,7 +20,7 @@ The repository contains a Flask-based API proxy that allows Omada controller to
|
||||
On an Ubuntu/Debian system, you can install the required packages using apt:
|
||||
|
||||
```bash
|
||||
sudo apt install -y python3 python3-dotenv python3-flask python3-flask-httpauth python3-requests
|
||||
sudo apt install -y python3 python3-dotenv python3-flask python3-flask-httpauth python3-requests gunicorn
|
||||
```
|
||||
|
||||
Copy the `app.py` file to your desired location, and run it using Python:
|
||||
@@ -29,6 +29,12 @@ Copy the `app.py` file to your desired location, and run it using Python:
|
||||
flask run app.py
|
||||
```
|
||||
|
||||
or use Gunicorn for production:
|
||||
|
||||
```bash
|
||||
gunicorn --bind 0.0.0.0:8080 app:app
|
||||
```
|
||||
|
||||
## Self-Signed SSL Certificate (Optional)
|
||||
|
||||
To run the Flask app with HTTPS, you can create a self-signed SSL certificate:
|
||||
@@ -42,3 +48,21 @@ Then run the Flask app with SSL context:
|
||||
```bash
|
||||
flask run --cert=cert.pem --key=key.pem
|
||||
```
|
||||
|
||||
To use the Mail In A Box server's SSL certificate, use the following files:
|
||||
|
||||
- certificate: `/miab-data/ssl/ssl_certificate.pem`
|
||||
- private key: `/miab-data/ssl/ssl_private_key.pem`
|
||||
|
||||
> **Note:** You have to run the web server as root to access the private key file.
|
||||
|
||||
## Service Installation
|
||||
|
||||
```
|
||||
sudo mkdir -p /opt/dns-updater
|
||||
sudo cp app.py /opt/dns-updater/
|
||||
sudo cp dns-updater.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now dns-updater.service
|
||||
sudo systemctl status dns-updater.service
|
||||
```
|
||||
|
||||
14
app/dns-updater.service
Normal file
14
app/dns-updater.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=dns-updater
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/dns-updater
|
||||
Environment="MIAB_HOST=box.koszewscy.waw.pl"
|
||||
ExecStart=/usr/bin/gunicorn --workers 4 --bind 0.0.0.0:8443 --certfile="/miab-data/ssl/ssl_certificate.pem" --keyfile="/miab-data/ssl/ssl_private_key.pem" app:app
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
13
app/install
Executable file
13
app/install
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if [[ $(id -u) -ne 0 ]]; then
|
||||
echo "This script must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /opt/dns-updater
|
||||
cp app.py /opt/dns-updater/
|
||||
cp dns-updater.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now dns-updater.service
|
||||
systemctl status dns-updater.service
|
||||
2
build
2
build
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Build the Docker image
|
||||
docker build -t skoszewski/omada-dyndns-miab-proxy .
|
||||
docker build -t skoszewski/omada-dyndns-miab-proxy app
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=dns-updater
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/home/slawek/src/dns-updater
|
||||
Environment="MIAB_HOST=box.koszewscy.waw.pl"
|
||||
ExecStart=/usr/bin/gunicorn --workers 4 --bind 0.0.0.0:8080 app:app
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user