diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa19ba..f57636a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index 4eb93af..f5f1cfd 100644 --- a/Makefile +++ b/Makefile @@ -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!" diff --git a/README.md b/README.md index 2c0e30e..674ae3e 100644 --- a/README.md +++ b/README.md @@ -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 ; @@ -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 : @@ -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 ''; + CREATE ROLE intrarez WITH LOGIN PASSWORD ''; CREATE DATABASE intrarez OWNER intrarez ENCODING "UTF8"; EXIT; ``` diff --git a/app/main/routes.py b/app/main/routes.py index e561ac8..757b374 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -6,6 +6,7 @@ import re import flask +import flask_login from flask_babel import _ from discord_webhook import DiscordWebhook @@ -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") diff --git a/package.json b/package.json index a68170e..6ac7072 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/watch_dhcp_hosts.py b/watch_dhcp_hosts.py index 0e8470e..3810e2e 100644 --- a/watch_dhcp_hosts.py +++ b/watch_dhcp_hosts.py @@ -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 @@ -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): @@ -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}.")