diff --git a/server.js b/server.js index ce15e88b..e3a9f5d5 100644 --- a/server.js +++ b/server.js @@ -18,6 +18,7 @@ const history = require('connect-history-api-fallback'); /* Kick of some basic checks */ require('./services/update-checker'); // Checks if there are any updates available, prints message + let config = {}; // setup the config 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 .use(sslServer.middleware) // 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, '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' })) // Load middlewares for parsing JSON, and supporting HTML5 history routing .use(express.json({ limit: '1mb' })) diff --git a/services/config-validator.js b/services/config-validator.js index eeb58a3b..f7786e0e 100644 --- a/services/config-validator.js +++ b/services/config-validator.js @@ -101,7 +101,7 @@ const printFileReadError = (e) => { let config = {}; 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); } catch (e) { // Something went very wrong... setIsValidVariable(false); diff --git a/services/save-config.js b/services/save-config.js index 07f62f3f..f946be54 100644 --- a/services/save-config.js +++ b/services/save-config.js @@ -18,7 +18,7 @@ module.exports = async (newConfig, render) => { // Define constants for the config file const settings = { - defaultLocation: './user-data/', + defaultLocation: process.env.USER_DATA_DIR || './user-data/', defaultFile: 'conf.yml', filename: 'conf', backupDenominator: '.backup.yml',