From 672a770ac1dbe737fe5c411209b088cf48e08901 Mon Sep 17 00:00:00 2001 From: Tobias Hopp Date: Mon, 28 Nov 2022 22:13:52 +0100 Subject: [PATCH] Update scripts and seconds --- ToDo.md | 4 ++- doc/installPi.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++---- doc/start.sh | 20 +++++++++++- src/iTender.ts | 2 +- 4 files changed, 99 insertions(+), 10 deletions(-) diff --git a/ToDo.md b/ToDo.md index 0e99a3e..4d320af 100644 --- a/ToDo.md +++ b/ToDo.md @@ -2,5 +2,7 @@ - [ ] Behälter unten rechts anzeigen - [ ] Status für Netzwerk oben neben Uhrzeit -- [ ] Fix Fehler wenn keine Getränke hinzugefügt worden sind +- [ ] Fix Fehler, wenn keine Getränke hinzugefügt worden sind +- [ ] Schriftarten Lokal machen +- [x] Probleme beim Laden der Container im Setup - \ No newline at end of file diff --git a/doc/installPi.sh b/doc/installPi.sh index 3f9e2e2..bdb960b 100644 --- a/doc/installPi.sh +++ b/doc/installPi.sh @@ -1,22 +1,26 @@ #!/bin/bash -if [ "$EUID" -ne 0 ] -then +if [ "$EUID" -ne 0 ]; then echo "Please run as root!" exit fi +echo "Updating indexes" apt update +echo "Installing xserver xinit openbox ufw xserver-xorg x11 unclutter make chromium-browser crontab cmake g++ gcc and git..." 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 +apt install git gcc g++ make cmake chromium-browser unclutter crontab -y +echo "Try to uninstall node and npm... (Can fail)" +apt purge node -y || true +apt purge npm -y || true +echo "Setup xserver..." # XServer echo "allowed_users=anybody" >/etc/X11/Xwrapper.config -cp autostart.config /etc/xdg/openbox/autostart - +#no-uncomment cp autostart.config /etc/xdg/openbox/autostart +echo "Adding apt keys..." # Keys and stuff --- # Nodejs curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash @@ -31,19 +35,84 @@ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb # End Keys and stuff --- - +echo "Updating firewall..." # Firewall ufw allow ssh ufw allow 3000/tcp ufw allow 3015/tcp ufw --force enable +echo "Updating indexes and installing mongodb and yarn..." # Final update apt update apt install nodejs yarn mongodb-org -y apt upgrade -y +echo "Activating systemctl daemons..." systemctl daemon-reload systemctl enable mongod +echo "Installing autostart..." +# Autostart +cat <>/etc/xdg/openbox/autostart +xset s off +xset s noblank +xset -dpms + +setxkbmap -option terminate:ctrl_alt_bksp + +/home/itender/start.sh +EOT + +DIR="/home/itender/itender/" +if [ -d "$DIR" ]; then + # Take action if $DIR exists. # + cd "$DIR" + echo "Updating..." + git pull +else + echo "Cloning..." + sudo git config --global credential.helper store + git clone "https://tobiash:!IwedwrimmVeudiweN!@git.gaminggeneration.de/tobiash/itender.git" --quiet + cd "$DIR" + yarn install +fi +cd "$DIR" +echo "Compiling..." +yarn run compile + +echo "Updating Cron..." +# Add line to cron +echo "@reboot /usr/bin/yarn run start &" >/tmp/currentCron +#install new cron file +crontab /tmp/currentCron + +echo "Backing up /boot/config.txt to /root/config.txt.bak" +cp /boot/config.txt /root/config.txt.bak +echo "Updating Boot config..." +if ! grep -w "hdmi_group=2" /boot/config.txt; then + echo "hdmi_group=2" >>/boot/config.txt +fi +if ! grep -w "hdmi_mode=87" /boot/config.txt; then + echo "hdmi_mode=87" >>/boot/config.txt +fi +if ! grep -w "hdmi_cvt 1024 600 60 0 0 0 0" /boot/config.txt; then + echo "hdmi_cvt 1024 600 60 0 0 0 0" >>/boot/config.txt +fi +if ! grep -w "hdmi_drive=1" /boot/config.txt; then + echo "hdmi_drive=1" >>/boot/config.txt +fi +if ! grep -w "disable_splash=1" /boot/config.txt; then + echo "disable_splash=1" >>/boot/config.txt +fi + +echo "Setting no-logo..." +systemctl disable getty@tty3 +if ! grep -w "logo.nologo" /boot/cmdline.txt; then + echo "Backing up /boot/cmdline.txt to /root/cmdline.txt.bak" + cp /boot/cmdline.txt /root/cmdline.txt.bak + sed -i '1 s_$_ logo.nologo disable\_splash=1 quiet_' /boot/cmdline.txt + #cp /tmp/cmdline.txt /boot/cmdline.txt +fi + reboot now diff --git a/doc/start.sh b/doc/start.sh index e0c0f49..4433fa4 100644 --- a/doc/start.sh +++ b/doc/start.sh @@ -1,3 +1,21 @@ #!/bin/bash +cd /home/itender/ +sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State' +sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences -/usr/bin/startx /usr/bin/chromium-browser --kiosk --incognito --disable-pinch --overscroll-history-navigation=0 http://192.168.1.186:3000/ \ No newline at end of file +address="" +if ping -c1 -W1 192.168.1.186; then + address="192.168.1.186" +fi +if ping -c1 -W1 192.168.208.15; then + address="192.168.208.15" +fi +if ping -c1 -W1 10.10.0.5; then + address="10.10.0.5" +fi +address="localhost" + +echo "Waiting 5 seconds to start chromium..." +sleep 5 +/usr/bin/chromium-browser --disable-infobars --kiosk --incognito --disable-pinch --overscroll-history-navigation=0 "http://${address}:3000/" +#/usr/bin/startx /usr/bin/chromium-browser --kiosk --incognito --disable-pinch --overscroll-history-navigation=0 http://192.168.1.186:3000/ \ No newline at end of file diff --git a/src/iTender.ts b/src/iTender.ts index 02d94d7..6f0831a 100644 --- a/src/iTender.ts +++ b/src/iTender.ts @@ -28,7 +28,7 @@ const log = debug("itender:station"); const mixLog = debug("itender:mix"); export class iTender { - private static secondsPer100ml: number = 10; + private static secondsPer100ml: number = 35.3335; static get drinks(): IDrink[] { return this._drinks;