Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Commit

Permalink
v1.0.0: Public release
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-simon committed Nov 13, 2021
1 parent 1885b02 commit f7ce4b2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 0.7.0 - 2021-10-20
## 1.0.0 - 2021-11-13

# Added

* New logs for DHCP hosts watcher and rickrollage.

# Fixed

* Typos in Makefile / README.


## 0.8.0 - 2021-10-20

# Added

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ update:
env/bin/flask translate compile
env/bin/flask sass compile
@echo "Starting application..."
sudo supervisorctl restart intrarez
sudo supervisorctl start intrarez
@echo "Update live!"
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Application Flask de l'Intranet de la Rez.


## Quoi de neuf dans l'IntraRez ?

Seules les fonctionnalités majeures sont listées ici ; voir
[`CHANGELOG.md`](CHANGELOG.md) pour les détails.

### 1.0

* Release initiale, fonctionnalités de base :
* Connexion des rezidents, chambres et appareils (détection automatique),
* Génération des règes DHCP pour chaque chambre et script de mise à jour,
* Menu GRI avec liste des rezidents.


## Exigences

* Python : Probablement >= 3.10 à terme, pour l'instant >= 3.8 suffit ;
Expand All @@ -14,7 +28,6 @@ Application Flask de l'Intranet de la Rez.
* Pour le déploiement : un utilisateur Linux ``intrarez`` dédié.



## Installation

Je reprends pour l'essentiel le déploiement conseillé dans le tutoriel :
Expand Down Expand Up @@ -47,7 +60,7 @@ https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deploymen
sudo su postgres -c psql
```
```sql
CREATE ROLE intrarez WITH LOGIN md5 '<mdp-db>';
CREATE ROLE intrarez WITH LOGIN PASSWORD '<mdp-db>';
CREATE DATABASE intrarez OWNER intrarez ENCODING "UTF8";
EXIT;
```
Expand Down
4 changes: 4 additions & 0 deletions app/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re

import flask
import flask_login
from flask_babel import _
from discord_webhook import DiscordWebhook

Expand Down Expand Up @@ -91,4 +92,7 @@ def profile():
@check_device
def rickroll():
"""The old good days..."""
with open("logs/rickrolled.log", "a") as fh:
fh.write(f"{datetime.datetime.now()}: rickrolled "
f"{flask_login.current_user.full_name}\n")
return flask.redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "intrarez",
"version": "0.8.0",
"version": "1.0.0",
"description": "Intranet de la Rez Flask Web App",
"main": "n/a",
"scripts": {
Expand Down
15 changes: 10 additions & 5 deletions watch_dhcp_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
DHCP_HOSTS_FILE, voir .env) et relance le serveur DHCP dès qu'il est modifié.
"""

import logging
import os
import subprocess
import time
Expand All @@ -15,6 +16,8 @@
import pyinotify


logging.basicConfig(level=logging.DEBUG, style="{",
format="{asctime} {levelname}:{name}:{message}")
load_dotenv()
file = os.getenv("DHCP_HOSTS_FILE")
if not os.path.isfile(file):
Expand All @@ -31,19 +34,21 @@ def restart_dhpc_server(event):
# Ignorer les doubles appels (trop rapprochés)
return
last_event = now
print(f"File modification detected, restarting DHCP server...")
logging.info(f"File modification detected, restarting DHCP server...")
try:
retcode = subprocess.call(["systemctl", "restart", "isc-dhcp-server"])
if retcode < 0:
print("ERROR - Restart order was terminated by signal", -retcode)
logging.error(f"ERROR - Restart terminated by signal {-retcode}")
elif retcode == 0:
print(f"DHCP server restarted!")
logging.info(f"DHCP server restarted!")
else:
print("ERROR - Restart order returned", retcode)
logging.error(f"ERROR - Restart order returned {retcode}")
except OSError as exc:
print("ERROR - Restart order execution failed:", exc)
logging.error(f"ERROR - Restart order execution failed: {exc}")


wm = pyinotify.WatchManager()
wm.add_watch(file, pyinotify.IN_MODIFY, restart_dhpc_server)
logging.info(f"Started watching {file}...")
pyinotify.Notifier(wm).loop()
logging.info(f"Sopped watching {file}.")

0 comments on commit f7ce4b2

Please sign in to comment.