Update v1.0.3
Took 54 minutes
This commit is contained in:
parent
641120f7cc
commit
6ec0f82356
@ -1,19 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
apt update
|
||||
apt install
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then
|
||||
echo "Please run as root!"
|
||||
exit
|
||||
fi
|
||||
|
||||
apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox -y
|
||||
apt purge nodejs npm -y
|
||||
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo bash -
|
||||
apt install -y nodejs
|
||||
apt install gcc g++ make -y
|
||||
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
|
||||
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
apt update
|
||||
apt install yarn git cmake make chromium-browser unclutter -y
|
||||
apt upgrade -y
|
||||
|
||||
apt install --no-install-recommends ufw xserver-xorg x11-xserver-utils xinit openbox -y
|
||||
apt install git gcc g++ make cmake chromium-browser unclutter -y
|
||||
apt purge nodejs npm -y
|
||||
|
||||
# XServer
|
||||
echo "allowed_users=anybody" >/etc/X11/Xwrapper.config
|
||||
cp autostart.config /etc/xdg/openbox/autostart
|
||||
|
||||
|
||||
# Keys and stuff ---
|
||||
# Nodejs
|
||||
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash
|
||||
|
||||
# Yarn
|
||||
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
|
||||
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
# MongoDB
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
|
||||
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
|
||||
|
||||
# End Keys and stuff ---
|
||||
|
||||
|
||||
# Firewall
|
||||
ufw allow ssh
|
||||
ufw allow 3000/tcp
|
||||
ufw allow 3015/tcp
|
||||
ufw --force enable
|
||||
|
||||
# Final update
|
||||
apt update
|
||||
apt install nodejs yarn mongodb-org -y
|
||||
apt upgrade -y
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable mongod
|
||||
|
||||
reboot now
|
||||
|
@ -1,6 +1,7 @@
|
||||
#settings {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, calc(90% / 4));
|
||||
grid-template-rows: repeat(5, calc(90% / 5));
|
||||
grid-gap: 10% 5%;
|
||||
grid-template-columns: repeat(4, calc(85% / 4));
|
||||
grid-template-rows: repeat(4, calc(85% / 4));
|
||||
grid-gap: 5% 5%;
|
||||
width: 100%;
|
||||
}
|
@ -5,4 +5,5 @@ export enum RequestType {
|
||||
JOB = "JOB",
|
||||
STARTFILL = "STARTFILL",
|
||||
STOPFILL = "STOPFILL",
|
||||
DOWNLOAD_DRINKS = "DOWNLOAD_DRINKS"
|
||||
}
|
17
src/Utils.ts
17
src/Utils.ts
@ -1,6 +1,7 @@
|
||||
import * as dns from "dns";
|
||||
import * as fs from "fs";
|
||||
import * as https from 'https';
|
||||
import path from "path";
|
||||
|
||||
export class Utils {
|
||||
public static checkInternet(): Promise<boolean> {
|
||||
@ -22,7 +23,14 @@ export class Utils {
|
||||
}
|
||||
|
||||
static downloadImage(url, filepath) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
if (!fs.existsSync(path.dirname(filepath)))
|
||||
fs.mkdirSync(path.dirname(filepath));
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
https.get(url, (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
res.pipe(fs.createWriteStream(filepath))
|
||||
@ -38,19 +46,16 @@ export class Utils {
|
||||
});
|
||||
}
|
||||
|
||||
static deleteImage( id )
|
||||
{
|
||||
static deleteImage(id) {
|
||||
try {
|
||||
fs.unlinkSync("./public/images/" + id + ".png");
|
||||
} catch( e )
|
||||
{
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static checkForImage( id )
|
||||
{
|
||||
static checkForImage(id) {
|
||||
return fs.existsSync("./public/images/" + id + ".png");
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ export class Database {
|
||||
public static connect(): Promise<void> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
await Mongoose.connect("mongodb://localhost:27017/iTender?retryWrites=true");
|
||||
await Mongoose.connect("mongodb://127.0.0.1:27017/iTender?retryWrites=true");
|
||||
log("Connected to Database");
|
||||
/*if (Mongoose.connection.readyState == Mongoose.ConnectionStates.connected) {
|
||||
resolve();
|
||||
|
@ -357,11 +357,12 @@ export class iTender {
|
||||
|
||||
// Download thumbnail
|
||||
if (!Utils.checkForImage(remote._id)) {
|
||||
let url = "https://itender.iif.li/images/" + remote._id + ".png";
|
||||
try {
|
||||
await Utils.downloadImage("https://itender.iif.li/images/" + remote._id + ".png", "./public/images/" + drink._id + ".png")
|
||||
await Utils.downloadImage(url, "./public/images/" + drink._id + ".png")
|
||||
log("Drink " + remote.name + "'s Thumbnail downloaded");
|
||||
} catch (e) {
|
||||
log("Drink " + remote.name + " failed to download thumbnail!\n" + e);
|
||||
log("Drink " + remote.name + " failed to download thumbnail! (" + url + ") | " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,11 @@ router.ws('/', async (ws, req, next) => {
|
||||
WebSocketHandler.answerRequest(msg.data["type"] as RequestType, iTender.currentJob);
|
||||
break;
|
||||
}
|
||||
case RequestType.DOWNLOAD_DRINKS: {
|
||||
await iTender.refreshFromServer();
|
||||
WebSocketHandler.answerRequest(msg.data["type"] as RequestType, "ok");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -102,6 +102,13 @@ function setupOnClickEvents() {
|
||||
|
||||
WebWebSocketHandler.request(RequestType.CONTAINERS).then(Setup.onContainerUpdate);
|
||||
|
||||
|
||||
// Settings Btns
|
||||
const downloadDrinks = document.getElementById("settings_refreshDrinks") as HTMLButtonElement;
|
||||
downloadDrinks.onclick = () => {
|
||||
WebWebSocketHandler.request(RequestType.DOWNLOAD_DRINKS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function load() {
|
||||
|
@ -54,5 +54,6 @@ block settings
|
||||
button.btn.btn-primary#settings_refreshDrinks Getränke herunterladen
|
||||
|
||||
|
||||
|
||||
block main
|
||||
// Main is build dynamically
|
||||
|
Loading…
x
Reference in New Issue
Block a user