Update Dockerfile and server.js to handle setup and user configurations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-03-27 18:49:08 +01:00
parent a1bf5d9f2f
commit 96466073a5
2 changed files with 19 additions and 2 deletions

View File

@@ -12,9 +12,9 @@ RUN [ ! -f cdn-files ] && touch cdn-files || true
RUN [ ! -f report ] && touch report || true
RUN [ ! -f user.json ] && touch user.json || true
RUN [ ! -f setup.json ] && echo '{}' > setup.json || true
RUN [ ! -f file_info.json ] && touch file_info.json || true
RUN [ ! -f user.json ] && echo '{}' > user.json || true
EXPOSE 5053

View File

@@ -13,6 +13,13 @@ const fs = require('fs');
const SystemReport = require('./models/reportManager.js');
let setup = {};
try {
if (fs.existsSync('setup.json')) {
setup = JSON.parse(fs.readFileSync('setup.json', 'utf8'));
}
} catch (err) {
console.error('Error reading setup.json:', err);
}
try {
setup = JSON.parse(fs.readFileSync('setup.json', 'utf8'));
} catch (err) {
@@ -27,6 +34,16 @@ if (setup.ldap !== undefined) {
require('./models/Passport-ActiveDirectory.js');
}
let user = {};
try {
if (fs.existsSync('user.json')) {
const data = fs.readFileSync('user.json', 'utf8');
user = data ? JSON.parse(data) : {};
}
} catch (err) {
console.error('Error reading user.json:', err);
}
app.use(express.static(path.join(__dirname, 'public')));
app.get(['/user.json', '/file_info.json', '/setup.json'], (req, res) => {