From 9028204286279ddceefacb341fdd3f4980fd1f0f Mon Sep 17 00:00:00 2001 From: Andrei Smaliak Date: Sat, 14 Mar 2026 08:01:59 +0400 Subject: [PATCH] rename stage3_x11_only.sh to stage_itscreen_install.sh and remove legacy files --- stage_itscreen_install/IOMATEX_stage_1.md | 66 ---- .../old_stage3.sh (x11+eglfs) | 293 ------------------ ..._x11_only.sh => stage_itscreen_install.sh} | 0 3 files changed, 359 deletions(-) delete mode 100755 stage_itscreen_install/IOMATEX_stage_1.md delete mode 100755 stage_itscreen_install/old_stage3.sh (x11+eglfs) rename stage_itscreen_install/{stage3_x11_only.sh => stage_itscreen_install.sh} (100%) diff --git a/stage_itscreen_install/IOMATEX_stage_1.md b/stage_itscreen_install/IOMATEX_stage_1.md deleted file mode 100755 index e099cb4..0000000 --- a/stage_itscreen_install/IOMATEX_stage_1.md +++ /dev/null @@ -1,66 +0,0 @@ -# IOMATEX Desktop Toggle --- Engineer Cheat Sheet - -## Purpose - -Switch device between **production kiosk (EGLFS)** and **engineer -desktop (X11)** modes. - ------------------------------------------------------------------------- - -## iomatex-desktop-off --- Production mode (EGLFS) - -Actions: 1. Stops engineer services: - itscreen-x11 - lightdm 2. Resets -EGLFS failures 3. Starts: - itscreen-eglfs - -Result: - Kiosk mode - Minimal resource usage - Autostarts after reboot - ------------------------------------------------------------------------- - -## iomatex-desktop-on --- Engineer mode (X11) - -Actions: 1. Stops production kiosk: - itscreen-eglfs 2. Starts -desktop: - lightdm 3. Waits for X display :0 4. Starts: - itscreen-x11 -(runs as user iomatex) - -Result: - Desktop environment available - Chromium and tools usable - -itscreen runs via X11 - ------------------------------------------------------------------------- - -## Key architecture rules - -- Single runtime user: iomatex -- Shared registration: /var/lib/itscreen -- No dual app launches -- Default after reboot: EGLFS production mode - ------------------------------------------------------------------------- - -## Engineer commands - -Switch modes: - - iomatex-desktop-on - iomatex-desktop-off - -Check services: - - systemctl status itscreen-eglfs - systemctl status itscreen-x11 - -Logs: - - journalctl -u itscreen-eglfs -n 100 - journalctl -u itscreen-x11 -n 100 - ------------------------------------------------------------------------- - -## System meaning - -This is a runtime UI mode switch: - -- DRM/EGLFS → kiosk OS -- X11 → engineer workstation - -Controls: - display stack - systemd services - Qt runtime environment - -WebView execution mode diff --git a/stage_itscreen_install/old_stage3.sh (x11+eglfs) b/stage_itscreen_install/old_stage3.sh (x11+eglfs) deleted file mode 100755 index c1f0169..0000000 --- a/stage_itscreen_install/old_stage3.sh (x11+eglfs) +++ /dev/null @@ -1,293 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -export DEBIAN_FRONTEND=noninteractive - -LOG="/var/log/iomatex-stage1-itscreen.log" -mkdir -p /var/log >/dev/null 2>&1 || true - -log() { - local line="[$(date -u +'%F %T UTC')] $*" - echo "$line" - echo "$line" >>"$LOG" 2>/dev/null || true -} - -step_n=0 -step() { step_n=$((step_n+1)); echo; echo "=== Step ${step_n}: $* ==="; log "STEP ${step_n}: $*"; } - -spinner() { - local pid="$1" - local msg="${2:-Working}" - local spin='|/-\' - local i=0 - command -v tput >/dev/null 2>&1 && tput civis || true - while kill -0 "$pid" 2>/dev/null; do - i=$(( (i+1) % 4 )) - printf "\r[%c] %s..." "${spin:$i:1}" "$msg" - sleep 0.2 - done - printf "\r[✓] %s. \n" "$msg" - command -v tput >/dev/null 2>&1 && tput cnorm || true -} - -run_long() { - local msg="$1"; shift - local timeout_s="$1"; shift - log "RUN: $msg :: $*" - ( timeout "$timeout_s" "$@" >>"$LOG" 2>&1 ) & - local pid=$! - spinner "$pid" "$msg" - wait "$pid" -} - -soft_run() { - local msg="$1"; shift - local timeout_s="$1"; shift - if run_long "$msg" "$timeout_s" "$@"; then return 0; else return 0; fi -} - -# root -if [ "${EUID:-$(id -u)}" -ne 0 ]; then exec sudo -E /bin/bash "$0" "$@"; fi - -log "=== IOMATEX STAGE_3 ITSCREEN (EGLFS or TRUE-HEADLESS) START ===" - -step "Preflight" -run_long "APT update" 900 apt-get update -soft_run "Ensure base packages" 600 apt-get install -y procps util-linux x11-xserver-utils sudo - -id itscreen >/dev/null || { echo "Run Stage_0 first"; exit 2; } - -# shared runtime dirs -install -d -m 0770 -o itscreen -g itscreen /var/lib/itscreen/{config,data,logs} -install -d -m 0755 -o itscreen -g itscreen /var/log/itscreen - -# ------------------------- -step "Install Qt runtime (exact list)" -run_long "Install Qt runtime" 1800 apt-get install -y \ - libqt5webview5 \ - libqt5websockets5 \ - libqt5texttospeech5 \ - libqt5serialbus5 - -soft_run "Install Qt extras" 1800 apt-get install -y \ - gedit lxterminal clang qtcreator \ - libqt5serialbus5-bin \ - qtpositioning5-dev qml-module-qtpositioning \ - libqt5texttospeech5-dev \ - qml-module-qtquick-virtualkeyboard qtvirtualkeyboard-plugin \ - libqt5webview5-dev qml-module-qtwebview \ - qml-module-qt-labs-settings qml-module-qtquick-xmllistmodel \ - libqt5serialbus5-dev \ - qml-module-qtquick-controls2 \ - qml-module-qt-websockets libqt5websockets5-dev \ - qml-module-qt-labs-platform - -ldconfig - -# ------------------------- -step "Install itscreen binary" -if [ -f ./itscreen ]; then SRC=./itscreen; -elif [ -f /home/iomatex/Downloads/itscreen ]; then SRC=/home/iomatex/Downloads/itscreen; -else echo "Binary not found"; exit 2; fi - -install -m0755 "$SRC" /opt/itscreen/bin/itscreen -chown itscreen:itscreen /opt/itscreen/bin/itscreen - -# ------------------------- -step "Grant power actions (reboot/shutdown) to itscreen (sudoers)" -cat >/etc/sudoers.d/90-itscreen-power <<'EOF' -Defaults:itscreen !requiretty -itscreen ALL=(root) NOPASSWD: /sbin/reboot, /usr/sbin/reboot, /bin/systemctl reboot, /usr/bin/systemctl reboot -itscreen ALL=(root) NOPASSWD: /sbin/poweroff, /usr/sbin/poweroff, /bin/systemctl poweroff, /usr/bin/systemctl poweroff -itscreen ALL=(root) NOPASSWD: /sbin/shutdown, /usr/sbin/shutdown, /bin/systemctl halt, /usr/bin/systemctl halt -EOF -chmod 0440 /etc/sudoers.d/90-itscreen-power -visudo -cf /etc/sudoers.d/90-itscreen-power >/dev/null - -# ------------------------- -step "X11 access for itscreen (xhost)" -cat >/etc/X11/Xsession.d/99-iomatex-allow-itscreen <<'EOF' -#!/bin/sh -DISPLAY=${DISPLAY:-:0} xhost +SI:localuser:itscreen >/dev/null 2>&1 || true -EOF -chmod +x /etc/X11/Xsession.d/99-iomatex-allow-itscreen - -# ------------------------- -step "Wrapper with flock" -cat >/usr/local/bin/itscreen-run <<'EOF' -#!/usr/bin/env bash -set -euo pipefail -LOCK="/run/itscreen/itscreen.lock" -export XDG_CONFIG_HOME=/var/lib/itscreen/config -export XDG_DATA_HOME=/var/lib/itscreen/data -export ITSCREEN_LOG_DIR=/var/lib/itscreen/logs -exec flock -n "$LOCK" /opt/itscreen/bin/itscreen "$@" -EOF -chmod +x /usr/local/bin/itscreen-run - -# ------------------------- -step "Systemd services (EGLFS + TRUE-HEADLESS)" - -cat >/etc/systemd/system/itscreen-eglfs.service <<'EOF' -[Unit] -Description=ITSCREEN EGLFS -Wants=network-online.target -After=NetworkManager.service network-online.target systemd-user-sessions.service -Conflicts=itscreen-headless.service itscreen-x11.service lightdm.service - -[Service] -User=itscreen -WorkingDirectory=/opt/itscreen -RuntimeDirectory=itscreen -ExecStartPre=-/usr/bin/pkill -u itscreen -x itscreen -ExecStartPre=/usr/bin/nm-online -s -q --timeout=45 -Environment=QT_QPA_PLATFORM=eglfs -ExecStart=/usr/local/bin/itscreen-run -Restart=always -RestartSec=2 - -[Install] -WantedBy=multi-user.target -EOF - -# TRUE headless requires updated client that supports backend-only mode. -# It must NOT initialize QML/OpenGL/WebEngine. It should run on QCoreApplication. -cat >/etc/systemd/system/itscreen-headless.service <<'EOF' -[Unit] -Description=ITSCREEN TRUE Headless (backend-only) -Wants=network-online.target -After=NetworkManager.service network-online.target -Conflicts=itscreen-eglfs.service itscreen-x11.service lightdm.service - -[Service] -User=itscreen -WorkingDirectory=/opt/itscreen -RuntimeDirectory=itscreen -ExecStartPre=-/usr/bin/pkill -u itscreen -x itscreen -ExecStartPre=/usr/bin/nm-online -s -q --timeout=45 -Environment=ITSCREEN_HEADLESS=1 -ExecStart=/usr/local/bin/itscreen-run --headless -Restart=always -RestartSec=2 -StartLimitIntervalSec=300 -StartLimitBurst=3 - -[Install] -WantedBy=multi-user.target -EOF - -cat >/etc/systemd/system/itscreen-x11.service <<'EOF' -[Unit] -Description=ITSCREEN X11 (requires LightDM) -After=lightdm.service -Conflicts=itscreen-eglfs.service itscreen-headless.service - -[Service] -User=itscreen -WorkingDirectory=/opt/itscreen -RuntimeDirectory=itscreen -ExecStartPre=-/usr/bin/pkill -u itscreen -x itscreen -Environment=DISPLAY=:0 -Environment=QT_QPA_PLATFORM=xcb -ExecStart=/usr/local/bin/itscreen-run -Restart=always -RestartSec=2 - -[Install] -WantedBy=multi-user.target -EOF - -systemctl daemon-reload -systemctl enable NetworkManager-wait-online.service || true - -# ------------------------- -step "Boot-mode selector (no hotplug): HDMI -> EGLFS, no HDMI -> TRUE-HEADLESS" - -cat >/usr/local/sbin/iomatex-itscreen-bootmode <<'EOF' -#!/usr/bin/env bash -set -euo pipefail - -has_display=0 -if ls /sys/class/drm/card*-*/status >/dev/null 2>&1; then - if grep -q "^connected$" /sys/class/drm/card*-*/status 2>/dev/null; then - has_display=1 - fi -fi - -systemctl stop itscreen-eglfs.service itscreen-x11.service itscreen-headless.service 2>/dev/null || true - -if [ "$has_display" -eq 1 ]; then - logger -t iomatex-itscreen-bootmode "HDMI connected -> start EGLFS" - systemctl start itscreen-eglfs.service -else - logger -t iomatex-itscreen-bootmode "No HDMI -> start TRUE-HEADLESS" - systemctl start itscreen-headless.service -fi -EOF -chmod +x /usr/local/sbin/iomatex-itscreen-bootmode - -cat >/etc/systemd/system/iomatex-itscreen-bootmode.service <<'EOF' -[Unit] -Description=IOMATEX ITSCREEN boot-mode selector (EGLFS if HDMI else TRUE-HEADLESS) -After=multi-user.target NetworkManager.service -Wants=network-online.target -After=network-online.target - -[Service] -Type=oneshot -ExecStart=/usr/local/sbin/iomatex-itscreen-bootmode - -[Install] -WantedBy=multi-user.target -EOF - -systemctl daemon-reload -systemctl enable --now iomatex-itscreen-bootmode.service - -# Avoid double-start on boot: selector decides. -systemctl disable itscreen-eglfs.service itscreen-headless.service itscreen-x11.service 2>/dev/null || true -systemctl disable --now lightdm.service 2>/dev/null || true - -# ------------------------- -step "Toggle scripts (manual)" - -cat >/usr/local/bin/iomatex-desktop-on <<'EOF' -#!/usr/bin/env bash -set -euo pipefail -systemctl stop itscreen-eglfs.service itscreen-headless.service 2>/dev/null || true -systemctl start lightdm.service -sleep 5 -systemctl start itscreen-x11.service -EOF - -cat >/usr/local/bin/iomatex-desktop-off <<'EOF' -#!/usr/bin/env bash -set -euo pipefail -systemctl stop itscreen-x11.service 2>/dev/null || true -systemctl stop lightdm.service 2>/dev/null || true -systemctl start itscreen-eglfs.service -EOF - -cat >/usr/local/bin/iomatex-headless-on <<'EOF' -#!/usr/bin/env bash -set -euo pipefail -systemctl stop itscreen-x11.service itscreen-eglfs.service 2>/dev/null || true -systemctl stop lightdm.service 2>/dev/null || true -systemctl start itscreen-headless.service -EOF - -chmod +x /usr/local/bin/iomatex-desktop-on /usr/local/bin/iomatex-desktop-off /usr/local/bin/iomatex-headless-on - -# Apply boot-mode now (useful after install without reboot) -systemctl start iomatex-itscreen-bootmode.service >/dev/null 2>&1 || true - -echo -echo "Stage_3 ready." -echo "Mode at boot (no hotplug): HDMI -> EGLFS, no HDMI -> TRUE-HEADLESS (requires updated client)." -echo "itscreen can sudo reboot/shutdown (NOPASSWD)." -echo "Manual:" -echo " X11 engineer mode : iomatex-desktop-on" -echo " EGLFS production : iomatex-desktop-off" -echo " Headless backend : iomatex-headless-on" -echo "Logs:" -echo " journalctl -t iomatex-itscreen-bootmode -n 50 --no-pager" diff --git a/stage_itscreen_install/stage3_x11_only.sh b/stage_itscreen_install/stage_itscreen_install.sh similarity index 100% rename from stage_itscreen_install/stage3_x11_only.sh rename to stage_itscreen_install/stage_itscreen_install.sh