This commit is contained in:
2020-05-22 14:53:57 +07:00
commit aecfe55df8
940 changed files with 159763 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
'use strict';
const util = require('util');
const fs = require('fs');
exports.ReadAPIConfig = async function (req, res) {
var text = fs.readFileSync('/root/monitor/setup/apiConfig.txt','utf8');
res.send(text);
};
exports.SaveAPIConfig = async function (req, res) {
fs.writeFileSync('/root/monitor/setup/apiConfig.txt', JSON.stringify(req.body));
const { execSync } = require('child_process');
execSync('sudo systemctl enable S905X_BI');
execSync('sudo systemctl start S905X_BI');
res.send(req.body);
};
exports.ReadEngineConfig = async function (req, res) {
var path = '/root/monitor/setup/engine.json';
if (fs.existsSync(path)) {
var text = fs.readFileSync(path,'utf8');
res.send({status:true,data:text});
} else {
res.send({status:false});
}
};
exports.SaveEngineConfig = async function (req, res) {
fs.writeFileSync(req.body.path + "/data/config.json", req.body.configEngine);
fs.writeFileSync('/root/monitor/setup/engine.json', JSON.stringify(req.body.config));
const { execSync } = require('child_process');
execSync('sudo systemctl restart S905X_BI');
res.send(req.body);
};
exports.ReadConfig = async function (req, res) {
var path = req.body.path + "/data/config.json";
if (fs.existsSync(path)) {
var text = fs.readFileSync(path,'utf8');
res.send({status:true,data:text});
} else {
res.send({status:false});
}
};