init
This commit is contained in:
45
api/controllers/ApiController.js
Normal file
45
api/controllers/ApiController.js
Normal 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});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user