From bffba8d70fb8d21588917fabc180de1ca4dccbca Mon Sep 17 00:00:00 2001 From: Benjamin Sigonneau Date: Wed, 20 Jul 2022 23:54:11 +0200 Subject: [PATCH] Add README with installation instructions --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..27398c4 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +Get current fioul price from Bretagne Multi Énergie and store it. Also with an +incredible web interface to list price history. + +# Requirements + +This project is written in Python and uses the following libraries: + +* requests: to retrieve current price using a GraphQL query; +* peewee: a simple ORM, to store and query the data in a SQL database; +* bottle: a micro web framework. + +Those libraries are all packaged in Debian and can be installed with: + +``` +apt install python3-request python3-peewee python3-bottle +``` + +Optional: a MySQL server (although switching to another database should be +easy). Otherwise, a SQLite backend can be used. + + +# Installation + +We suppose the repository is cloned under `/opt/fioul`. + +Create a `fioul.ini` config file, and fill in MySQL credentials. You can use +`fioul.ini.example` as a starting point. MySQL database can be created with the +following commands: + +```sql +create database fiouldb; +create user 'fioul'@'localhost' identified by 'fioul_is_beautifioul'; +grant all privileges on fiouldb.* TO 'fioul'@'localhost'; +``` + +Tables can be created by running `./fioul.py initdb` + + +To update the database every 15 minutes, the following line can be +installed as a cronjob: + +``` +*/15 * * * * /opt/fioul/fioul.py update +``` + +To launch the server automatically, you can install and use the systemd +service file : + +``` +adduser --system --group --no-create-home fioul +ln -s /opt/fioul/fioul.service /etc/systemd/system/fioul.service +systemctl enable fioul.service +systemctl start fioul.service +``` + +The server listens to port 9980 on localhost by default, unless +otherwise specified in the config file. Setting up a reverse proxy and +ssl is left as an exercise to the reader.