update
Took 2 hours 2 minutes
This commit is contained in:
parent
3d58d934e7
commit
564c3f78c0
@ -7,6 +7,9 @@ fi
|
|||||||
|
|
||||||
echo "Creating user if not exists"
|
echo "Creating user if not exists"
|
||||||
useradd -p $(openssl passwd -1 iTender2022) itender || true
|
useradd -p $(openssl passwd -1 iTender2022) itender || true
|
||||||
|
mkdir /home/itender/
|
||||||
|
usermod -d /home/itender/ itender || true
|
||||||
|
chown itender:itender /home/itender
|
||||||
|
|
||||||
echo "Updating indexes"
|
echo "Updating indexes"
|
||||||
apt update
|
apt update
|
||||||
@ -52,6 +55,10 @@ echo "Installing mongodb and yarn..."
|
|||||||
apt install nodejs yarn mongodb-org -y
|
apt install nodejs yarn mongodb-org -y
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
|
|
||||||
|
adduser itender gpio
|
||||||
|
adduser itender sudo
|
||||||
|
chown itender:itender /home/itender/ -R
|
||||||
|
|
||||||
# V2: Arduino CLI
|
# V2: Arduino CLI
|
||||||
echo "Installing arduino-cli..."
|
echo "Installing arduino-cli..."
|
||||||
sudo -u itender mkdir -p /home/itender/bin
|
sudo -u itender mkdir -p /home/itender/bin
|
||||||
@ -61,8 +68,6 @@ sudo -u itender /home/itender/bin/arduino-cli core update-index || true
|
|||||||
sudo -u itender /home/itender/bin/arduino-cli lib install ArduinoJson || true
|
sudo -u itender /home/itender/bin/arduino-cli lib install ArduinoJson || true
|
||||||
sudo -u itender /home/itender/bin/arduino-cli lib install HX711 || true
|
sudo -u itender /home/itender/bin/arduino-cli lib install HX711 || true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "Installing autostart..."
|
echo "Installing autostart..."
|
||||||
# Autostart
|
# Autostart
|
||||||
cat <<EOT >/etc/xdg/openbox/autostart
|
cat <<EOT >/etc/xdg/openbox/autostart
|
||||||
@ -85,7 +90,6 @@ echo "Installing bashrc"
|
|||||||
echo "clear" >>/home/itender/.bashrc
|
echo "clear" >>/home/itender/.bashrc
|
||||||
echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && startx -- -nocursor >/dev/null 2>&1" >>/home/itender/.bashrc
|
echo "[[ -z \$DISPLAY && \$XDG_VTNR -eq 1 ]] && startx -- -nocursor >/dev/null 2>&1" >>/home/itender/.bashrc
|
||||||
|
|
||||||
|
|
||||||
DIR="/home/itender/itender/"
|
DIR="/home/itender/itender/"
|
||||||
if [ -d "$DIR" ]; then
|
if [ -d "$DIR" ]; then
|
||||||
# Take action if $DIR exists. #
|
# Take action if $DIR exists. #
|
||||||
@ -136,7 +140,6 @@ WantedBy=multi-user.target
|
|||||||
EOT
|
EOT
|
||||||
#sh -c "git pull --quiet || true"
|
#sh -c "git pull --quiet || true"
|
||||||
|
|
||||||
|
|
||||||
echo "Activating systemctl daemons..."
|
echo "Activating systemctl daemons..."
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable mongod
|
systemctl enable mongod
|
||||||
@ -176,7 +179,6 @@ if ! grep -w "gpu_freq=700" /boot/config.txt; then
|
|||||||
echo "gpu_freq=700" >>/boot/config.txt
|
echo "gpu_freq=700" >>/boot/config.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Setting no-logo..."
|
echo "Setting no-logo..."
|
||||||
systemctl disable getty@tty1.service
|
systemctl disable getty@tty1.service
|
||||||
|
|
||||||
@ -186,19 +188,17 @@ if ! grep -w "logo.nologo" /boot/cmdline.txt; then
|
|||||||
sed -i '1 s_$_ loglevel=3 logo.nologo disable\_splash=1 splash quiet plymouth.ignore-serial-consoles logo.nologo vt.global\_cursor_default=0_' /boot/cmdline.txt
|
sed -i '1 s_$_ loglevel=3 logo.nologo disable\_splash=1 splash quiet plymouth.ignore-serial-consoles logo.nologo vt.global\_cursor_default=0_' /boot/cmdline.txt
|
||||||
#cp /tmp/cmdline.txt /boot/cmdline.txt
|
#cp /tmp/cmdline.txt /boot/cmdline.txt
|
||||||
sed -i "1 s|$| vt.global_cursor_default=0|" /boot/cmdline.txt
|
sed -i "1 s|$| vt.global_cursor_default=0|" /boot/cmdline.txt
|
||||||
sed -i '1 i\avoid_warnings=1' /boot/config.txt
|
|
||||||
sed -i 's/console=tty0/console=tty3/' /boot/cmdline.txt
|
sed -i 's/console=tty0/console=tty3/' /boot/cmdline.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "iTender© 2022-2023
|
echo "iTender© 2022-2023 - Official licensed software
|
||||||
Programmed by Tobias Hopp" >/etc/motd
|
Programmed by Tobias Hopp" >/etc/motd
|
||||||
|
|
||||||
echo "[Service]
|
echo "[Service]
|
||||||
ExecStart=/usr/sbin/dhcpcd -q" >/etc/systemd/system/dhcpcd.service.d/wait.conf
|
ExecStart=/usr/sbin/dhcpcd -q" >/etc/systemd/system/dhcpcd.service.d/wait.conf
|
||||||
|
|
||||||
chown itender:itender -R /home/itender/
|
chown itender:itender -R /home/itender/
|
||||||
adduser itender gpio
|
|
||||||
adduser itender sudo
|
|
||||||
|
|
||||||
echo "Installation finished!"
|
echo "Installation finished!"
|
||||||
|
|
||||||
|
11
src/Mixer.ts
11
src/Mixer.ts
@ -47,6 +47,7 @@ export class Mixer {
|
|||||||
*/
|
*/
|
||||||
static async startFill(job: IJob) {
|
static async startFill(job: IJob) {
|
||||||
this._jobTimers = [];
|
this._jobTimers = [];
|
||||||
|
|
||||||
job.startedAt = new Date();
|
job.startedAt = new Date();
|
||||||
await job.populate([{path: "amounts.ingredient"}, {path: "amounts.container"}, {path: "drink"}]);
|
await job.populate([{path: "amounts.ingredient"}, {path: "amounts.container"}, {path: "drink"}]);
|
||||||
log("New fill job " + job.drink.name + " will take " + job.estimatedTime + "s");
|
log("New fill job " + job.drink.name + " will take " + job.estimatedTime + "s");
|
||||||
@ -88,11 +89,6 @@ export class Mixer {
|
|||||||
//mixLog(x.ingredient + " takes " + (waitTime / 1000) + "s for " + x.amount + "ml");
|
//mixLog(x.ingredient + " takes " + (waitTime / 1000) + "s for " + x.amount + "ml");
|
||||||
let timer = setTimeout(async () => {
|
let timer = setTimeout(async () => {
|
||||||
// Remove from list of timers
|
// Remove from list of timers
|
||||||
let arr: NodeJS.Timer[] = [];
|
|
||||||
for (let i = 0; i < this._jobTimers.length; i++) {
|
|
||||||
if (this._jobTimers[i] != timer)
|
|
||||||
arr.push(this._jobTimers[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
log(`Stopping output of pump ${x.container.pumpPin}`);
|
log(`Stopping output of pump ${x.container.pumpPin}`);
|
||||||
// Stop pump here
|
// Stop pump here
|
||||||
@ -124,7 +120,7 @@ export class Mixer {
|
|||||||
await x.container.save();
|
await x.container.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._jobTimers = arr;
|
this._jobTimers.splice(this._jobTimers.indexOf(timer),1);
|
||||||
|
|
||||||
}, waitTime);
|
}, waitTime);
|
||||||
this._jobTimers.push(timer);
|
this._jobTimers.push(timer);
|
||||||
@ -140,9 +136,8 @@ export class Mixer {
|
|||||||
clearInterval(this._jobEndCheckInterval);
|
clearInterval(this._jobEndCheckInterval);
|
||||||
job.endAt = new Date();
|
job.endAt = new Date();
|
||||||
job.successful = true;
|
job.successful = true;
|
||||||
|
|
||||||
await job.save();
|
|
||||||
log("Job successful");
|
log("Job successful");
|
||||||
|
await job.save();
|
||||||
setTimeout(() => iTender.setStatus(iTenderStatus.READY), 2500);
|
setTimeout(() => iTender.setStatus(iTenderStatus.READY), 2500);
|
||||||
|
|
||||||
await ContainerHelper.measureContainers();
|
await ContainerHelper.measureContainers();
|
||||||
|
@ -9,4 +9,5 @@ export enum RequestType {
|
|||||||
TARE = "TARE",
|
TARE = "TARE",
|
||||||
CHECK = "CHECK",
|
CHECK = "CHECK",
|
||||||
UPDATE = "UPDATE",
|
UPDATE = "UPDATE",
|
||||||
|
INFO = "INFO",
|
||||||
}
|
}
|
@ -15,6 +15,9 @@ import {IContainer} from "../../database/IContainer";
|
|||||||
import {Mixer} from "../../Mixer";
|
import {Mixer} from "../../Mixer";
|
||||||
import {ArduinoProxy} from "../../ArduinoProxy";
|
import {ArduinoProxy} from "../../ArduinoProxy";
|
||||||
import {ContainerHelper} from "../../ContainerHelper";
|
import {ContainerHelper} from "../../ContainerHelper";
|
||||||
|
import * as os from "os";
|
||||||
|
import {promisify} from "util";
|
||||||
|
const exec = promisify(require('child_process').exec)
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
@ -269,6 +272,7 @@ router.ws('/', async (ws, req, next) => {
|
|||||||
WebSocketHandler.answerRequest(type, {success: true, msg: "OK"});
|
WebSocketHandler.answerRequest(type, {success: true, msg: "OK"});
|
||||||
}
|
}
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,6 +284,37 @@ router.ws('/', async (ws, req, next) => {
|
|||||||
- (arduino update?)
|
- (arduino update?)
|
||||||
- reboot
|
- reboot
|
||||||
*/
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RequestType.INFO: {
|
||||||
|
let nets = os.networkInterfaces();
|
||||||
|
let net = nets["wlan0"];
|
||||||
|
if(!net)
|
||||||
|
net = nets["wlp0s20f3"];
|
||||||
|
let ipAddr : string = "";
|
||||||
|
if( net )
|
||||||
|
for( let addr of net )
|
||||||
|
{
|
||||||
|
if( addr.family == "IPv4" && addr.address && addr.address !== "127.0.0.1" )
|
||||||
|
ipAddr = addr.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
let packageJson = require('../../../package.json');
|
||||||
|
|
||||||
|
let wifi = (await exec("iwgetid")).stdout
|
||||||
|
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
"internet": iTender.internetConnection,
|
||||||
|
"ip": ipAddr,
|
||||||
|
"network": wifi.substring(wifi.indexOf('"')+1,wifi.length-2),
|
||||||
|
"uptime": (await exec("uptime -p")).stdout.substring(3),
|
||||||
|
"version": packageJson.version
|
||||||
|
}
|
||||||
|
|
||||||
|
return WebSocketHandler.answerRequest(msg.data["type"] as RequestType, data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,70 @@
|
|||||||
|
import {WebWebSocketHandler} from "./WebWebSocketHandler";
|
||||||
|
import {RequestType} from "../RequestType";
|
||||||
|
import {Modal} from "./Modal";
|
||||||
|
import {ButtonType} from "./ButtonType";
|
||||||
|
|
||||||
export class Settings {
|
export class Settings {
|
||||||
|
public static addListeners() {
|
||||||
|
// Settings Btns
|
||||||
|
const downloadDrinks = document.getElementById("settings_refreshDrinks") as HTMLButtonElement;
|
||||||
|
downloadDrinks.onclick = () => this.onClickRefreshDrinks();
|
||||||
|
const getInfo = document.getElementById("settings_getInfo") as HTMLButtonElement;
|
||||||
|
getInfo.onclick = () => this.onClickInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static onClickRefreshDrinks() {
|
||||||
|
WebWebSocketHandler.request(RequestType.DOWNLOAD_DRINKS).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static onClickUpdate() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static onClickInfo() {
|
||||||
|
WebWebSocketHandler.request(RequestType.INFO, null).then((payload) => {
|
||||||
|
let modal = new Modal("info", "Systeminformationen");
|
||||||
|
|
||||||
|
let table = document.createElement("table");
|
||||||
|
table.style.marginLeft = "auto";
|
||||||
|
table.style.marginRight = "auto";
|
||||||
|
|
||||||
|
let th = document.createElement("th");
|
||||||
|
table.append(th);
|
||||||
|
|
||||||
|
let tdTh1 = document.createElement("td");
|
||||||
|
tdTh1.innerText = "";
|
||||||
|
let tdTh2 = document.createElement("td");
|
||||||
|
tdTh2.innerText = "";
|
||||||
|
|
||||||
|
th.append(tdTh1, tdTh2);
|
||||||
|
|
||||||
|
let x = [["internet","Internet-Konnektivität"], ["ip","IP-Adresse"], ["network","WiFi-Netzwerk"], ["uptime","Gerät aktiv seit"], ["version", "Version"]];
|
||||||
|
for( let y of x )
|
||||||
|
{
|
||||||
|
let tr = document.createElement("tr");
|
||||||
|
let td1 = document.createElement("td");
|
||||||
|
let td2 = document.createElement("td");
|
||||||
|
|
||||||
|
td1.innerText = y[1];
|
||||||
|
td1.style.fontWeight = "bold";
|
||||||
|
if( payload.data[y[0]] === true || payload.data[y[0]] === false )
|
||||||
|
{
|
||||||
|
td2.innerText = payload.data[y[0]] == true ? "Verbunden" : "Getrennt";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
td2.innerText = payload.data[y[0]];
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.append(td1,td2);
|
||||||
|
|
||||||
|
table.append(tr);
|
||||||
|
}
|
||||||
|
modal.addContent(table);
|
||||||
|
|
||||||
|
modal.addBR();
|
||||||
|
modal.addButton(ButtonType.PRIMARY, "Schließen", () => modal.close() );
|
||||||
|
modal.open();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import {Setup} from "./Setup";
|
|||||||
import {RequestType} from "../RequestType";
|
import {RequestType} from "../RequestType";
|
||||||
import container from "../database/Container";
|
import container from "../database/Container";
|
||||||
import {IContainer} from "../database/IContainer";
|
import {IContainer} from "../database/IContainer";
|
||||||
|
import {Settings} from "./Settings";
|
||||||
|
|
||||||
const main = document.getElementById("main");
|
const main = document.getElementById("main");
|
||||||
const time = document.getElementById("right");
|
const time = document.getElementById("right");
|
||||||
@ -37,6 +38,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
WebWebSocketHandler.registerForEvent(WebSocketEvent.CONTAINERS, (payload) => {
|
WebWebSocketHandler.registerForEvent(WebSocketEvent.CONTAINERS, (payload) => {
|
||||||
|
console.log("Updating container list...")
|
||||||
let container : IContainer;
|
let container : IContainer;
|
||||||
let bottomContainers = document.getElementById("menuContainers") as HTMLDivElement;
|
let bottomContainers = document.getElementById("menuContainers") as HTMLDivElement;
|
||||||
bottomContainers.innerHTML = "";
|
bottomContainers.innerHTML = "";
|
||||||
@ -154,11 +156,10 @@ function setupOnClickEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Settings Btns
|
Settings.addListeners();
|
||||||
const downloadDrinks = document.getElementById("settings_refreshDrinks") as HTMLButtonElement;
|
|
||||||
downloadDrinks.onclick = () => {
|
|
||||||
WebWebSocketHandler.request(RequestType.DOWNLOAD_DRINKS);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ block settings
|
|||||||
// Settings
|
// Settings
|
||||||
button.btn.btn-primary#settings_refreshDrinks Getränke herunterladen
|
button.btn.btn-primary#settings_refreshDrinks Getränke herunterladen
|
||||||
button.btn.btn-primary#settings_update System aktualisieren
|
button.btn.btn-primary#settings_update System aktualisieren
|
||||||
|
button.btn.btn-primary#settings_getInfo Systeminformationen
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user