From 846f5475db15ef84ffb384319166052c902c5a99 Mon Sep 17 00:00:00 2001 From: Simon Cloutier Date: Mon, 7 Apr 2025 16:39:57 -0400 Subject: [PATCH] changes to env still and init-schema.sql --- .env.template | 13 ++++++++----- db/init/init-schema.sql | 13 ++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index 1c50721..17390c9 100644 --- a/.env.template +++ b/.env.template @@ -1,12 +1,15 @@ # Flask FLASK_SECRET_KEY=your-secret-key -# MariaDB container -MYSQL_HOST=db +# Database config (shared by all) +DB_HOST=db +DB_PORT=3306 +DB_NAME=radius +DB_USER=radiususer +DB_PASSWORD=radiuspass + +# Only used by the MariaDB container MARIADB_ROOT_PASSWORD=rootpassword -MARIADB_DATABASE=radius -MARIADB_USER=radiususer -MARIADB_PASSWORD=radiuspass # MAC Lookup API OUI_API_KEY= # only required if you want to increase the OUI limits diff --git a/db/init/init-schema.sql b/db/init/init-schema.sql index 25c180a..b8c3e2c 100644 --- a/db/init/init-schema.sql +++ b/db/init/init-schema.sql @@ -1,5 +1,16 @@ --- init-schema.sql +-- Create the database if it doesn't exist +CREATE DATABASE IF NOT EXISTS radius; USE radius; + +-- Create the user if it doesn't exist +CREATE USER IF NOT EXISTS 'radiususer'@'%' IDENTIFIED BY 'radiuspass'; + +-- Grant permissions to the user +GRANT ALL PRIVILEGES ON radius.* TO 'radiususer'@'%'; + +-- Apply the changes +FLUSH PRIVILEGES; + -- Table for registered users (MAC-based auth) CREATE TABLE IF NOT EXISTS users ( mac_address CHAR(12) NOT NULL PRIMARY KEY CHECK (mac_address REGEXP '^[0-9A-Fa-f]{12}$'),