📡 Make user-data directory configurable

This commit is contained in:
Alicia Sykes 2024-04-10 22:59:35 +01:00
parent a32e76935e
commit b66ce53669
3 changed files with 4 additions and 4 deletions

View File

@ -18,6 +18,7 @@ const history = require('connect-history-api-fallback');
/* Kick of some basic checks */ /* Kick of some basic checks */
require('./services/update-checker'); // Checks if there are any updates available, prints message require('./services/update-checker'); // Checks if there are any updates available, prints message
let config = {}; // setup the config let config = {}; // setup the config
config = require('./services/config-validator'); // Include and kicks off the config file validation script config = require('./services/config-validator'); // Include and kicks off the config file validation script
@ -74,9 +75,8 @@ const app = express()
// Load SSL redirection middleware // Load SSL redirection middleware
.use(sslServer.middleware) .use(sslServer.middleware)
// Serves up static files // Serves up static files
.use(express.static(path.join(__dirname, 'user-data')))
.use(express.static(path.join(__dirname, 'dist'))) .use(express.static(path.join(__dirname, 'dist')))
.use(express.static(path.join(__dirname, 'user-data'))) .use(express.static(path.join(__dirname, process.env.USER_DATA_DIR || 'user-data')))
.use(express.static(path.join(__dirname, 'public'), { index: 'initialization.html' })) .use(express.static(path.join(__dirname, 'public'), { index: 'initialization.html' }))
// Load middlewares for parsing JSON, and supporting HTML5 history routing // Load middlewares for parsing JSON, and supporting HTML5 history routing
.use(express.json({ limit: '1mb' })) .use(express.json({ limit: '1mb' }))

View File

@ -101,7 +101,7 @@ const printFileReadError = (e) => {
let config = {}; let config = {};
try { // Try to open and parse the YAML file try { // Try to open and parse the YAML file
config = yaml.load(fs.readFileSync('./user-data/conf.yml', 'utf8')); config = yaml.load(fs.readFileSync(`./${process.env.USER_DATA_DIR || 'user-data'}/conf.yml`, 'utf8'));
validate(config); validate(config);
} catch (e) { // Something went very wrong... } catch (e) { // Something went very wrong...
setIsValidVariable(false); setIsValidVariable(false);

View File

@ -18,7 +18,7 @@ module.exports = async (newConfig, render) => {
// Define constants for the config file // Define constants for the config file
const settings = { const settings = {
defaultLocation: './user-data/', defaultLocation: process.env.USER_DATA_DIR || './user-data/',
defaultFile: 'conf.yml', defaultFile: 'conf.yml',
filename: 'conf', filename: 'conf',
backupDenominator: '.backup.yml', backupDenominator: '.backup.yml',