Skip to content

Commit

Permalink
Add possibility to change Webserver and tftp applications
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMEEE committed Jan 14, 2025
1 parent 899921a commit 5593bc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ io.on('connection', function(socket){
///////////////////////////
// When dashboard info is requested send to client
socket.on('getdash', function(){
var tftpcmd = '/usr/sbin/dnsmasq --version | head -n1';
var nginxcmd = '/usr/sbin/nginx -v';
var tftpcmd = process.env.TFTPCOMMAND || '/usr/sbin/dnsmasq --version | head -n1';
var webservercmd = process.env.WEBSERVERCOMMAND || '/usr/sbin/nginx -v';
var dashinfo = {};
dashinfo['webversion'] = version;
dashinfo['menuversion'] = fs.readFileSync(datapath + '/config/menuversion.txt', 'utf8');
Expand All @@ -80,8 +80,8 @@ io.on('connection', function(socket){
dashinfo['CPUpercent'] = currentLoad.currentload_user;
exec(tftpcmd, function (err, stdout) {
dashinfo['tftpversion'] = stdout;
exec(nginxcmd, function (err, stdout, stderr) {
dashinfo['nginxversion'] = stderr;
exec(webservercmd, function (err, stdout, stderr) {
dashinfo['webserverversion'] = stdout;
io.sockets.in(socket.id).emit('renderdash',dashinfo);
});
});
Expand Down Expand Up @@ -156,7 +156,7 @@ io.on('connection', function(socket){
var remotemenuversion = fs.readFileSync(datapath + '/config/menuversion.txt', 'utf8');
var endpointsfile = fs.readFileSync(datapath + '/config/endpoints.yml');
var endpoints = yaml.load(endpointsfile);
var localfiles = await readdirp.promise('/assets/.');
var localfiles = await readdirp.promise(datapath + '/assets/.');
var assets = [];
if (localfiles.length != 0){
for (var i in localfiles){
Expand All @@ -175,10 +175,10 @@ io.on('connection', function(socket){
socket.on('deletelocal', function(dlfiles){
for (var i in dlfiles){
var file = dlfiles[i];
fs.unlinkSync('/assets' + file);
fs.unlinkSync(datapath + '/assets' + file);
console.log('Deleted /assets' + file);
if (fs.existsSync('/assets' + file + '.part2')) {
fs.unlinkSync('/assets' + file + '.part2');
if (fs.existsSync(datapath + '/assets' + file + '.part2')) {
fs.unlinkSync(datapath + '/assets' + file + '.part2');
console.log('Deleted /assets' + file + '.part2');
}
}
Expand Down
4 changes: 2 additions & 2 deletions public/netbootxyz-web.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function renderdash(){
}
socket.on('renderdash', function(response){
var tftpversion = response.tftpversion;
var nginxversion = response.nginxversion;
var webserverversion = response.webserverversion;
var webversion = response.webversion;
var menuversion = response.menuversion;
var remotemenuversion = response.remotemenuversion;
Expand Down Expand Up @@ -61,7 +61,7 @@ socket.on('renderdash', function(response){
<div class="card-body">\
<table class="table table-hover">\
<tr><td>TFTP:</td><td>' + tftpversion + '</td></tr>\
<tr><td>WebServer:</td><td>' + nginxversion + '</td></tr>\
<tr><td>WebServer:</td><td>' + webserverversion + '</td></tr>\
</table>\
</div>\
</div>\
Expand Down

0 comments on commit 5593bc9

Please sign in to comment.