switch to static
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
NODE_PORT=3000
|
||||
NODE_ENV=production
|
||||
NODE_IP=127.0.0.80
|
||||
+13
-8
@@ -112,6 +112,11 @@ services:
|
||||
subtitle: "192.168.10.6"
|
||||
url: "http://192.168.10.6"
|
||||
target: "_blank"
|
||||
- name: " Turn on PC"
|
||||
icon: "fas fa-ethernet"
|
||||
subtitle: "192.168.10.15"
|
||||
url: "/api/powerOnPc"
|
||||
target: "_blank"
|
||||
external:
|
||||
- name: "System"
|
||||
icon: "fas fa-heartbeat"
|
||||
@@ -119,35 +124,35 @@ external:
|
||||
- name: "System Status"
|
||||
icon: "fas fa-joint"
|
||||
subtitle: ""
|
||||
url: "/sysStatus"
|
||||
url: "/api/sysStatus"
|
||||
- name: "Icanhazip"
|
||||
icon: "fas fa-joint"
|
||||
subtitle: ""
|
||||
url: "/internetCheck"
|
||||
url: "/api/internetCheck"
|
||||
- name: "VPN"
|
||||
icon: "fas fa-joint"
|
||||
subtitle: ""
|
||||
url: "/vpnCheck"
|
||||
url: "/api/vpnCheck"
|
||||
- name: "VPN"
|
||||
icon: "fas fa-joint"
|
||||
subtitle: ""
|
||||
url: "/lancianoCheck"
|
||||
url: "/api/lancianoCheck"
|
||||
- name: "TV Status"
|
||||
icon: "fas fa-heartbeat"
|
||||
items:
|
||||
- name: "Tv Hat Frequency"
|
||||
icon: "fas fa-broadcast-tower"
|
||||
subtitle: ""
|
||||
url: "/dvbStatus?t=1"
|
||||
url: "/api/dvbStatus?t=1"
|
||||
- name: "Tv Hat Channel"
|
||||
icon: "fas fa-tv"
|
||||
subtitle: ""
|
||||
url: "/dvbChannel?t=1"
|
||||
url: "/api/dvbChannel?t=1"
|
||||
- name: "USB tuner Frequency"
|
||||
icon: "fas fa-broadcast-tower"
|
||||
subtitle: ""
|
||||
url: "/dvbStatus?t=0"
|
||||
url: "/api/dvbStatus?t=0"
|
||||
- name: "USB Tv Channel"
|
||||
icon: "fas fa-tv"
|
||||
subtitle: ""
|
||||
url: "/dvbChannel?t=0"
|
||||
url: "/api/dvbChannel?t=0"
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
const express = require('express');
|
||||
const compression = require('compression');
|
||||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const http = require("http");
|
||||
const ping = require('ping');
|
||||
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
const readFileAsync = util.promisify(fs.readFile);
|
||||
|
||||
const app = express(); // app is an instance of express
|
||||
|
||||
app.use(compression()); // enables gzip compression
|
||||
|
||||
app.options('*', (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
||||
'Access-Control-Allow-Headers': 'Content-Type',
|
||||
'Access-Control-Max-Age': 600
|
||||
})
|
||||
res.status(200).end();
|
||||
})
|
||||
|
||||
app.get('/dvbStatus', async (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
let tuner = 0;
|
||||
tuner = req.query.t;
|
||||
const { stdout, stderr } = await exec(`DTV2 -t ${tuner}`);
|
||||
const i = parseInt(stdout) * 1e-6; // i is in Hz; divide by 1M to have MHz
|
||||
res.send({
|
||||
"id": "dvb-t-status",
|
||||
"data": `Frontend Frequency: ${i} Mhz`,
|
||||
"stderr": stderr
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.get('/dvbChannel', async (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
let tuner = 0;
|
||||
tuner = req.query.t;
|
||||
const { stdout, stderr } = await exec(`DTV2 -t ${tuner}`);
|
||||
const i = parseInt(stdout) * 1e-6; // i is in Hz; divide by 1M to have MHz
|
||||
readFileAsync(path.join(__dirname,"frequencies.json"))
|
||||
.then(res2 => {
|
||||
const db = JSON.parse(res2);
|
||||
res.send({
|
||||
"id": `dvb-t-channel`,
|
||||
"name": db[i]["name"].toString(),
|
||||
"data": db[i]["channels"].toString(),
|
||||
"stderr": stderr
|
||||
});
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.get('/internetCheck', async (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
http.get('http://icanhazip.com', (httpRes) => {
|
||||
httpRes.setEncoding('utf8');
|
||||
httpRes.on('data', (body) => {
|
||||
res.send(
|
||||
{
|
||||
"id": "internet-check",
|
||||
"data": body,
|
||||
"stderr": ""
|
||||
}
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
app.get('/vpnCheck', async (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
let ifaces = os.networkInterfaces()
|
||||
if(ifaces.hasOwnProperty('tun0')){
|
||||
res.send(
|
||||
{
|
||||
"id": "vpn-check",
|
||||
"data": ifaces["tun0"][0]["cidr"],
|
||||
"stderr": ""
|
||||
})
|
||||
} else {
|
||||
res.send(
|
||||
{
|
||||
"id": "vpn-check",
|
||||
"data": "Not connected",
|
||||
"stderr": "VPN not connected"
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
app.get('/sysStatus', (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
readFileAsync('/sys/class/thermal/thermal_zone0/temp')
|
||||
.then(res2=>
|
||||
{
|
||||
res.send({
|
||||
"id": "sys-stats",
|
||||
"data": `${(parseFloat(res2)*1e-3).toFixed(2)} °C Load: ${os.loadavg().map(x=>x.toFixed(2)).toString()}`,
|
||||
"stderr": ""
|
||||
})
|
||||
})
|
||||
.catch(err=> {
|
||||
console.error(err)
|
||||
res.send({
|
||||
"id": "sys-stats",
|
||||
"data": `Load Avg: ${os.loadavg().map(x=>x.toFixed(2)).toString()}`,
|
||||
"stderr": err
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
app.get('/lancianoCheck', async (req, res) => {
|
||||
res.set({
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
});
|
||||
let hostRes='';
|
||||
let hosts = ["10.8.0.45","10.8.0.46"];
|
||||
let promArr=[];
|
||||
for(let host of hosts) {
|
||||
promArr.push(ping.promise.probe(host));
|
||||
}
|
||||
Promise.all(promArr)
|
||||
.then(function (res) {
|
||||
for (let item of res) {
|
||||
if(item.alive) {
|
||||
hostRes+=item.host+' alive ';
|
||||
}
|
||||
else{
|
||||
hostRes+=item.host+' dead ';
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(()=>{
|
||||
res.send({
|
||||
"id": "lanciano-check",
|
||||
"data": hostRes.toString(),
|
||||
"stderr": ""
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
app.use(express.static('/var/www/forbidden-fruit-dashboard')); // serve static build site
|
||||
|
||||
// app.get('*', (req, res) => {
|
||||
// res.sendFile(__dirname + '/public/index.html');
|
||||
// });
|
||||
|
||||
//app.listen(8000,"192.168.10.14", () => console.log('listen on 8000'));
|
||||
app.listen(process.env.NODE_PORT,process.env.NODE_IP, () => console.log(`Bind on ${process.env.NODE_IP}:${process.env.NODE_PORT}`));
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "forbidden-fruit-dashboard",
|
||||
"version": "3.0.0",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
"dependencies": {
|
||||
"compression": "^1.7.4",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"ping": "^0.3.0",
|
||||
"rpio": "^2.2.0",
|
||||
"passport": "^0.4.1",
|
||||
"passport-local": "^1.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user