update: itscreen + ui + env changes
This commit is contained in:
parent
d2e56c201e
commit
ac66e6d2f6
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
|
LOG="/var/log/iomatex-pulse-rollback.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
|
||||||
|
}
|
||||||
|
|
||||||
|
require_root() {
|
||||||
|
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
|
||||||
|
echo "Run as root: sudo bash $0" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
latest_backup() {
|
||||||
|
local pattern="$1"
|
||||||
|
ls -1t $pattern 2>/dev/null | head -n1 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
backup_current() {
|
||||||
|
local path="$1"
|
||||||
|
[ -f "$path" ] || return 0
|
||||||
|
cp -a "$path" "${path}.rollback.$(date +%F-%H%M%S)" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_from_backup() {
|
||||||
|
local target="$1"
|
||||||
|
local pattern="$2"
|
||||||
|
local src=""
|
||||||
|
|
||||||
|
src="$(latest_backup "$pattern")"
|
||||||
|
if [ -n "$src" ]; then
|
||||||
|
backup_current "$target"
|
||||||
|
cp -a "$src" "$target"
|
||||||
|
log "Restored $target from backup: $src"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "No backup found for $target matching: $pattern"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
manual_partial_rollback_default_pa() {
|
||||||
|
local pa="/etc/pulse/default.pa"
|
||||||
|
[ -f "$pa" ] || { log "Missing $pa, skipping manual rollback"; return 0; }
|
||||||
|
|
||||||
|
backup_current "$pa"
|
||||||
|
|
||||||
|
sed -i -E 's@^([[:space:]]*)#[[:space:]]*(set-default-(sink|source)[[:space:]]+.*es8388.*)$@\1\2@g' "$pa"
|
||||||
|
sed -i -E 's@^([[:space:]]*)#[[:space:]]*(load-module[[:space:]]+module-rescue-streams([[:space:]]|$).*)$@\1\2@g' "$pa"
|
||||||
|
|
||||||
|
if grep -Eq '^[[:space:]]*load-module[[:space:]]+module-native-protocol-unix[[:space:]]*$' "$pa"; then
|
||||||
|
log "default.pa has plain module-native-protocol-unix entry. Original socket=/tmp/pulse-socket parameters cannot be reconstructed without backup."
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Applied manual partial rollback to $pa"
|
||||||
|
}
|
||||||
|
|
||||||
|
manual_partial_rollback_client_conf() {
|
||||||
|
local conf="/etc/pulse/client.conf"
|
||||||
|
[ -f "$conf" ] || { log "Missing $conf, skipping manual rollback"; return 0; }
|
||||||
|
|
||||||
|
backup_current "$conf"
|
||||||
|
sed -i -E 's@^([[:space:]]*)#[[:space:]]*(default-server[[:space:]]*=[[:space:]]*unix:/tmp/pulse-socket[[:space:]]*)$@\1\2@g' "$conf"
|
||||||
|
log "Applied manual partial rollback to $conf"
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_audio_stack() {
|
||||||
|
if command -v systemctl >/dev/null 2>&1; then
|
||||||
|
systemctl restart pulseaudio.service >/dev/null 2>&1 || true
|
||||||
|
systemctl restart pipewire.service >/dev/null 2>&1 || true
|
||||||
|
systemctl restart wireplumber.service >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if id itscreen >/dev/null 2>&1; then
|
||||||
|
pkill -u itscreen pulseaudio >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
pkill pulseaudio >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
log "Triggered audio service restart where available"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_summary() {
|
||||||
|
local pa="/etc/pulse/default.pa"
|
||||||
|
local conf="/etc/pulse/client.conf"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Current PulseAudio-related lines:"
|
||||||
|
[ -f "$pa" ] && grep -nE 'es8388|module-rescue-streams|module-native-protocol-unix' "$pa" || true
|
||||||
|
[ -f "$conf" ] && grep -nE 'default-server' "$conf" || true
|
||||||
|
echo
|
||||||
|
echo "If audio still does not recover, reboot the device:"
|
||||||
|
echo " sudo reboot"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
require_root
|
||||||
|
log "Starting PulseAudio rollback"
|
||||||
|
|
||||||
|
if ! restore_from_backup /etc/pulse/default.pa '/etc/pulse/default.pa.bak.*'; then
|
||||||
|
manual_partial_rollback_default_pa
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! restore_from_backup /etc/pulse/client.conf '/etc/pulse/client.conf.bak.*'; then
|
||||||
|
manual_partial_rollback_client_conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
restart_audio_stack
|
||||||
|
show_summary
|
||||||
|
log "PulseAudio rollback finished"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
25
stage_env/stage_env_install.sh → stage_env/stage_env_install_no_pulse.sh
Executable file → Normal file
25
stage_env/stage_env_install.sh → stage_env/stage_env_install_no_pulse.sh
Executable file → Normal file
|
|
@ -338,29 +338,6 @@ apt_install_missing \
|
||||||
network-manager \
|
network-manager \
|
||||||
policykit-1
|
policykit-1
|
||||||
|
|
||||||
# -------------------------
|
|
||||||
# Step 4.5: PulseAudio config sanitation
|
|
||||||
# -------------------------
|
|
||||||
step "PulseAudio: sanitize default.pa (ES8388 + rescue-streams + tmp socket override) + client.conf tmp socket"
|
|
||||||
fix_pulseaudio_defaults() {
|
|
||||||
local pa="/etc/pulse/default.pa"
|
|
||||||
[ -f "$pa" ] || { log "PulseAudio default.pa not found, skip"; return 0; }
|
|
||||||
|
|
||||||
cp -a "$pa" "${pa}.bak.$(date +%F-%H%M%S)" 2>/dev/null || true
|
|
||||||
|
|
||||||
sed -i -E 's@^([[:space:]]*)(set-default-(sink|source)[[:space:]]+.*es8388.*)$@\1# \2@g' "$pa"
|
|
||||||
sed -i -E 's@^([[:space:]]*)load-module[[:space:]]+module-rescue-streams([[:space:]]|$).*@\1# load-module module-rescue-streams@g' "$pa"
|
|
||||||
sed -i -E 's@^([[:space:]]*)load-module[[:space:]]+module-native-protocol-unix.*socket=/tmp/pulse-socket.*$@\1load-module module-native-protocol-unix@g' "$pa"
|
|
||||||
|
|
||||||
if [ -f /etc/pulse/client.conf ]; then
|
|
||||||
cp -a /etc/pulse/client.conf "/etc/pulse/client.conf.bak.$(date +%F-%H%M%S)" 2>/dev/null || true
|
|
||||||
sed -i -E 's@^([[:space:]]*default-server[[:space:]]*=[[:space:]]*unix:/tmp/pulse-socket[[:space:]]*)$@# \1@g' /etc/pulse/client.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "PulseAudio config sanitized: $pa (+ client.conf)"
|
|
||||||
}
|
|
||||||
fix_pulseaudio_defaults
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Step 5: Timezone Asia/Dubai
|
# Step 5: Timezone Asia/Dubai
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
@ -427,7 +404,7 @@ ensure_group_membership "$IOM_USER" sudo adm systemd-journal video input render
|
||||||
ensure_user "$ITS_USER" "/usr/sbin/nologin" "-m"
|
ensure_user "$ITS_USER" "/usr/sbin/nologin" "-m"
|
||||||
ensure_user "$Z2M_USER" "/usr/sbin/nologin" "-m"
|
ensure_user "$Z2M_USER" "/usr/sbin/nologin" "-m"
|
||||||
|
|
||||||
ensure_group_membership "$ITS_USER" video input render dialout || true
|
ensure_group_membership "$ITS_USER" video input render dialout audio || true
|
||||||
ensure_group_membership "$Z2M_USER" dialout plugdev netdev || true
|
ensure_group_membership "$Z2M_USER" dialout plugdev netdev || true
|
||||||
|
|
||||||
ensure_gui_home_state() {
|
ensure_gui_home_state() {
|
||||||
Binary file not shown.
|
|
@ -9,15 +9,20 @@ ITS_USER="itscreen"
|
||||||
ITS_GROUP="itscreen"
|
ITS_GROUP="itscreen"
|
||||||
ITS_BINARY="/opt/itscreen/bin/itscreen"
|
ITS_BINARY="/opt/itscreen/bin/itscreen"
|
||||||
ITS_WRAPPER="/usr/local/bin/itscreen-run"
|
ITS_WRAPPER="/usr/local/bin/itscreen-run"
|
||||||
|
ITS_SESSION_SCRIPT="/usr/local/bin/itscreen-session"
|
||||||
|
ITS_X11_LAUNCHER="/usr/local/bin/itscreen-x11-launch"
|
||||||
|
ITS_X11_CLEANUP="/usr/local/bin/itscreen-x11-cleanup"
|
||||||
ITS_SERVICE="itscreen-x11.service"
|
ITS_SERVICE="itscreen-x11.service"
|
||||||
LIGHTDM_SERVICE="lightdm.service"
|
LIGHTDM_SERVICE="lightdm.service"
|
||||||
|
DISPLAY_MANAGER_SERVICE="display-manager.service"
|
||||||
NM_WAIT_SERVICE="NetworkManager-wait-online.service"
|
NM_WAIT_SERVICE="NetworkManager-wait-online.service"
|
||||||
IOM_USER="iomatex"
|
|
||||||
SUDOERS_FILE="/etc/sudoers.d/90-itscreen-power"
|
SUDOERS_FILE="/etc/sudoers.d/90-itscreen-power"
|
||||||
|
LIGHTDM_AUTOLOGIN_DROPIN="/etc/lightdm/lightdm.conf.d/90-iomatex-autologin.conf"
|
||||||
XSESSION_HOOK="/etc/X11/Xsession.d/99-iomatex-allow-itscreen"
|
XSESSION_HOOK="/etc/X11/Xsession.d/99-iomatex-allow-itscreen"
|
||||||
XWRAPPER_CONFIG="/etc/X11/Xwrapper.config"
|
XWRAPPER_CONFIG="/etc/X11/Xwrapper.config"
|
||||||
ITS_UNIT_FILE="/etc/systemd/system/${ITS_SERVICE}"
|
ITS_UNIT_FILE="/etc/systemd/system/${ITS_SERVICE}"
|
||||||
LOCK_DIR="/run/itscreen"
|
ITS_RUN_DIR="/run/itscreen"
|
||||||
|
LOCK_DIR="/var/lib/itscreen"
|
||||||
LOCK_FILE="${LOCK_DIR}/itscreen.lock"
|
LOCK_FILE="${LOCK_DIR}/itscreen.lock"
|
||||||
DEVICE_ID_FILE="/userdata/device-id"
|
DEVICE_ID_FILE="/userdata/device-id"
|
||||||
DEVICE_ID_RE='^g-box-[a-f0-9]{8}$'
|
DEVICE_ID_RE='^g-box-[a-f0-9]{8}$'
|
||||||
|
|
@ -139,6 +144,11 @@ enable_service_safe() {
|
||||||
systemctl enable "$unit" >/dev/null 2>&1 || true
|
systemctl enable "$unit" >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disable_service_safe() {
|
||||||
|
local unit="$1"
|
||||||
|
systemctl disable "$unit" >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
service_is_masked() {
|
service_is_masked() {
|
||||||
local unit="$1"
|
local unit="$1"
|
||||||
local state
|
local state
|
||||||
|
|
@ -158,7 +168,7 @@ restart_service_safe() {
|
||||||
spinner() {
|
spinner() {
|
||||||
local pid="$1"
|
local pid="$1"
|
||||||
local msg="${2:-Working}"
|
local msg="${2:-Working}"
|
||||||
local spin='|/-\'
|
local spin='|/-\\'
|
||||||
local i=0
|
local i=0
|
||||||
|
|
||||||
if command -v tput >/dev/null 2>&1 && [[ -t 1 ]]; then
|
if command -v tput >/dev/null 2>&1 && [[ -t 1 ]]; then
|
||||||
|
|
@ -282,7 +292,16 @@ install_base_packages() {
|
||||||
require_cmd id
|
require_cmd id
|
||||||
|
|
||||||
run_long "APT update" 900 apt-get update
|
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
|
soft_run "Ensure base packages" 600 apt-get install -y procps util-linux x11-xserver-utils xinit psmisc sudo
|
||||||
|
if ! command -v Xorg >/dev/null 2>&1; then
|
||||||
|
soft_run "Ensure Xorg core" 900 apt-get install -y xserver-xorg-core
|
||||||
|
fi
|
||||||
|
|
||||||
|
require_cmd pkill
|
||||||
|
require_cmd setpriv
|
||||||
|
require_cmd xinit
|
||||||
|
require_cmd Xorg
|
||||||
|
require_cmd fuser
|
||||||
|
|
||||||
id "$ITS_USER" >/dev/null 2>&1 || { echo "Run Stage_0 first"; exit 2; }
|
id "$ITS_USER" >/dev/null 2>&1 || { echo "Run Stage_0 first"; exit 2; }
|
||||||
}
|
}
|
||||||
|
|
@ -303,7 +322,7 @@ ensure_runtime_directories() {
|
||||||
ensure_dir /etc/X11/Xsession.d 0755 root root
|
ensure_dir /etc/X11/Xsession.d 0755 root root
|
||||||
ensure_dir /etc/systemd/system 0755 root root
|
ensure_dir /etc/systemd/system 0755 root root
|
||||||
ensure_dir /usr/local/bin 0755 root root
|
ensure_dir /usr/local/bin 0755 root root
|
||||||
ensure_dir "$LOCK_DIR" 0755 root root
|
ensure_dir "$ITS_RUN_DIR" 0755 root root
|
||||||
}
|
}
|
||||||
|
|
||||||
install_qt_packages() {
|
install_qt_packages() {
|
||||||
|
|
@ -320,7 +339,7 @@ install_qt_packages() {
|
||||||
libqt5serialbus5
|
libqt5serialbus5
|
||||||
|
|
||||||
install_packages_best_effort "Install Qt extras" 1800 \
|
install_packages_best_effort "Install Qt extras" 1800 \
|
||||||
gedit lxterminal clang qtcreator \
|
gedit lxterminal clang qtcreator openbox \
|
||||||
libqt5serialbus5-bin \
|
libqt5serialbus5-bin \
|
||||||
qtpositioning5-dev qml-module-qtpositioning \
|
qtpositioning5-dev qml-module-qtpositioning \
|
||||||
libqt5texttospeech5-dev \
|
libqt5texttospeech5-dev \
|
||||||
|
|
@ -335,31 +354,28 @@ install_qt_packages() {
|
||||||
ldconfig
|
ldconfig
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_lightdm_autologin() {
|
cleanup_legacy_lightdm_boot_path() {
|
||||||
step "LightDM autologin for iomatex"
|
step "Disable LightDM boot path"
|
||||||
if ! id "$IOM_USER" >/dev/null 2>&1; then
|
|
||||||
warn "User ${IOM_USER} not found; skipping LightDM autologin"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f /etc/lightdm/lightdm.conf ]]; then
|
rm -f "$LIGHTDM_AUTOLOGIN_DROPIN"
|
||||||
warn "LightDM config not found: /etc/lightdm/lightdm.conf"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qE '^[[:space:]]*autologin-user[[:space:]]*=' /etc/lightdm/lightdm.conf; then
|
if [[ -f /etc/lightdm/lightdm.conf ]]; then
|
||||||
sed -i -E "s@^[[:space:]]*autologin-user[[:space:]]*=.*@autologin-user=${IOM_USER}@g" /etc/lightdm/lightdm.conf
|
sed -i -E \
|
||||||
else
|
-e '/^[[:space:]]*autologin-user[[:space:]]*=[[:space:]]*iomatex[[:space:]]*$/d' \
|
||||||
if ! grep -qE '^\[Seat:\*\]' /etc/lightdm/lightdm.conf; then
|
-e '/^[[:space:]]*autologin-user-timeout[[:space:]]*=[[:space:]]*0[[:space:]]*$/d' \
|
||||||
printf "\n[Seat:*]\n" >> /etc/lightdm/lightdm.conf
|
/etc/lightdm/lightdm.conf || true
|
||||||
fi
|
|
||||||
echo "autologin-user=${IOM_USER}" >> /etc/lightdm/lightdm.conf
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if grep -qE '^[[:space:]]*autologin-user-timeout[[:space:]]*=' /etc/lightdm/lightdm.conf; then
|
cleanup_legacy_x11_hacks() {
|
||||||
sed -i -E "s@^[[:space:]]*autologin-user-timeout[[:space:]]*=.*@autologin-user-timeout=0@g" /etc/lightdm/lightdm.conf
|
step "Remove legacy X11 sharing hacks"
|
||||||
else
|
|
||||||
echo "autologin-user-timeout=0" >> /etc/lightdm/lightdm.conf
|
rm -f "$XSESSION_HOOK"
|
||||||
|
|
||||||
|
if [[ -f "$XWRAPPER_CONFIG" ]] \
|
||||||
|
&& grep -qx 'allowed_users=anybody' "$XWRAPPER_CONFIG" 2>/dev/null \
|
||||||
|
&& grep -qx 'needs_root_rights=yes' "$XWRAPPER_CONFIG" 2>/dev/null; then
|
||||||
|
rm -f "$XWRAPPER_CONFIG"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -381,20 +397,6 @@ EOF
|
||||||
visudo -cf "$SUDOERS_FILE" >/dev/null
|
visudo -cf "$SUDOERS_FILE" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
install_x11_access_files() {
|
|
||||||
step "X11 access for itscreen (xhost)"
|
|
||||||
write_file "$XSESSION_HOOK" 0755 root root <<'EOF'
|
|
||||||
#!/bin/sh
|
|
||||||
DISPLAY=${DISPLAY:-:0} xhost +SI:localuser:itscreen >/dev/null 2>&1 || true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
step "FIX A: X11 permission for system services (Xwrapper)"
|
|
||||||
write_file "$XWRAPPER_CONFIG" 0644 root root <<'EOF'
|
|
||||||
allowed_users=anybody
|
|
||||||
needs_root_rights=yes
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
install_wrapper() {
|
install_wrapper() {
|
||||||
step "Wrapper with flock"
|
step "Wrapper with flock"
|
||||||
write_file "$ITS_WRAPPER" 0755 root root <<EOF
|
write_file "$ITS_WRAPPER" 0755 root root <<EOF
|
||||||
|
|
@ -404,32 +406,121 @@ LOCK="${LOCK_FILE}"
|
||||||
export XDG_CONFIG_HOME=/var/lib/itscreen/config
|
export XDG_CONFIG_HOME=/var/lib/itscreen/config
|
||||||
export XDG_DATA_HOME=/var/lib/itscreen/data
|
export XDG_DATA_HOME=/var/lib/itscreen/data
|
||||||
export ITSCREEN_LOG_DIR=/var/lib/itscreen/logs
|
export ITSCREEN_LOG_DIR=/var/lib/itscreen/logs
|
||||||
exec flock -n "\$LOCK" /opt/itscreen/bin/itscreen "\$@"
|
exec flock -n "\$LOCK" /opt/itscreen/bin/itscreen fullscreen "\$@"
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
install_x11_session_scripts() {
|
||||||
|
step "Install dedicated X11 session helpers"
|
||||||
|
|
||||||
|
write_file "$ITS_SESSION_SCRIPT" 0755 root root <<'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export HOME=/var/lib/itscreen
|
||||||
|
export USER=itscreen
|
||||||
|
export LOGNAME=itscreen
|
||||||
|
export QT_QPA_PLATFORM=xcb
|
||||||
|
export XDG_CONFIG_HOME=/var/lib/itscreen/config
|
||||||
|
export XDG_DATA_HOME=/var/lib/itscreen/data
|
||||||
|
export XDG_RUNTIME_DIR=/run/itscreen/xdg
|
||||||
|
export ITSCREEN_LOG_DIR=/var/lib/itscreen/logs
|
||||||
|
|
||||||
|
session_cmd='openbox & exec /usr/local/bin/itscreen-run'
|
||||||
|
if ! command -v openbox >/dev/null 2>&1; then
|
||||||
|
echo "openbox is required for dedicated X11 fullscreen mode" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /usr/bin/setpriv --reuid itscreen --regid itscreen --init-groups \
|
||||||
|
/usr/bin/env \
|
||||||
|
HOME="$HOME" \
|
||||||
|
USER="$USER" \
|
||||||
|
LOGNAME="$LOGNAME" \
|
||||||
|
DISPLAY="${DISPLAY:-:0}" \
|
||||||
|
XAUTHORITY="${XAUTHORITY:?XAUTHORITY is required}" \
|
||||||
|
QT_QPA_PLATFORM="$QT_QPA_PLATFORM" \
|
||||||
|
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
|
||||||
|
XDG_CONFIG_HOME="$XDG_CONFIG_HOME" \
|
||||||
|
XDG_DATA_HOME="$XDG_DATA_HOME" \
|
||||||
|
ITSCREEN_LOG_DIR="$ITSCREEN_LOG_DIR" \
|
||||||
|
/usr/bin/dbus-run-session -- /bin/sh -lc "$session_cmd"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
write_file "$ITS_X11_CLEANUP" 0755 root root <<'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
/usr/bin/pkill -u itscreen -x itscreen >/dev/null 2>&1 || true
|
||||||
|
/usr/bin/pkill -u itscreen -f '/usr/local/bin/itscreen-run' >/dev/null 2>&1 || true
|
||||||
|
/usr/bin/pkill -f '(^|/)(Xorg|X)([[:space:]].*)?[[:space:]]:0([[:space:]]|$)' >/dev/null 2>&1 || true
|
||||||
|
/usr/bin/pkill -f '/usr/bin/xinit /usr/local/bin/itscreen-session' >/dev/null 2>&1 || true
|
||||||
|
/usr/bin/fuser -k /tmp/.X11-unix/X0 >/dev/null 2>&1 || true
|
||||||
|
rm -f /tmp/.X0-lock /tmp/.X11-unix/X0 /run/itscreen/Xauthority
|
||||||
|
EOF
|
||||||
|
|
||||||
|
write_file "$ITS_X11_LAUNCHER" 0755 root root <<'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# default = appliance mode with itscreen on a dedicated Xorg session
|
||||||
|
DISPLAY_NUM="${ITSCREEN_DISPLAY:-:0}"
|
||||||
|
VT_NAME="${ITSCREEN_VT:-vt7}"
|
||||||
|
XORG_BIN="$(command -v Xorg || true)"
|
||||||
|
|
||||||
|
[[ -n "$XORG_BIN" && -x "$XORG_BIN" ]] || {
|
||||||
|
echo "Xorg binary not found" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
install -d -m 0755 -o root -g root /run/itscreen
|
||||||
|
install -d -m 0700 -o itscreen -g itscreen /run/itscreen/xdg
|
||||||
|
rm -f /run/itscreen/Xauthority
|
||||||
|
: >/run/itscreen/Xauthority
|
||||||
|
chown itscreen:itscreen /run/itscreen/Xauthority
|
||||||
|
chmod 0600 /run/itscreen/Xauthority
|
||||||
|
|
||||||
|
export DISPLAY="$DISPLAY_NUM"
|
||||||
|
export XAUTHORITY=/run/itscreen/Xauthority
|
||||||
|
export XDG_RUNTIME_DIR=/run/itscreen/xdg
|
||||||
|
|
||||||
|
exec /usr/bin/xinit /usr/local/bin/itscreen-session -- \
|
||||||
|
"$XORG_BIN" "$DISPLAY_NUM" "$VT_NAME" -keeptty -nolisten tcp -noreset
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
install_systemd_unit() {
|
install_systemd_unit() {
|
||||||
step "Systemd services (X11 ONLY)"
|
step "Systemd service (dedicated X11 session)"
|
||||||
write_file "$ITS_UNIT_FILE" 0644 root root <<'EOF'
|
write_file "$ITS_UNIT_FILE" 0644 root root <<'EOF'
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=ITSCREEN X11 (requires LightDM)
|
Description=ITSCREEN dedicated X11 session
|
||||||
After=lightdm.service
|
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
After=NetworkManager.service network-online.target
|
After=NetworkManager.service network-online.target systemd-user-sessions.service
|
||||||
|
Conflicts=lightdm.service display-manager.service
|
||||||
|
Before=lightdm.service display-manager.service
|
||||||
StartLimitIntervalSec=300
|
StartLimitIntervalSec=300
|
||||||
StartLimitBurst=3
|
StartLimitBurst=3
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=itscreen
|
Type=simple
|
||||||
|
User=root
|
||||||
WorkingDirectory=/opt/itscreen
|
WorkingDirectory=/opt/itscreen
|
||||||
RuntimeDirectory=itscreen
|
RuntimeDirectory=itscreen
|
||||||
ExecStartPre=-/usr/bin/pkill -u itscreen -x itscreen
|
RuntimeDirectoryMode=0755
|
||||||
|
Environment=ITSCREEN_DISPLAY=:0
|
||||||
|
Environment=ITSCREEN_VT=vt7
|
||||||
ExecStartPre=/usr/bin/nm-online -s -q --timeout=45
|
ExecStartPre=/usr/bin/nm-online -s -q --timeout=45
|
||||||
Environment=DISPLAY=:0
|
ExecStartPre=/usr/local/bin/itscreen-x11-cleanup
|
||||||
Environment=QT_QPA_PLATFORM=xcb
|
ExecStart=/usr/local/bin/itscreen-x11-launch
|
||||||
ExecStart=/usr/local/bin/itscreen-run
|
ExecStopPost=/usr/local/bin/itscreen-x11-cleanup
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=2
|
RestartSec=2
|
||||||
|
TimeoutStopSec=15
|
||||||
|
KillMode=mixed
|
||||||
|
StandardInput=tty
|
||||||
|
TTYPath=/dev/tty7
|
||||||
|
TTYReset=yes
|
||||||
|
TTYVHangup=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
@ -448,18 +539,18 @@ enable_managed_services() {
|
||||||
enable_service_safe "$NM_WAIT_SERVICE"
|
enable_service_safe "$NM_WAIT_SERVICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enable_service_safe "$LIGHTDM_SERVICE"
|
disable_service_safe "$LIGHTDM_SERVICE"
|
||||||
if ! systemctl is-active --quiet "$LIGHTDM_SERVICE"; then
|
systemctl stop "$LIGHTDM_SERVICE" >/dev/null 2>&1 || true
|
||||||
systemctl start "$LIGHTDM_SERVICE"
|
systemctl stop "$DISPLAY_MANAGER_SERVICE" >/dev/null 2>&1 || true
|
||||||
fi
|
|
||||||
|
|
||||||
enable_service_safe "$ITS_SERVICE"
|
enable_service_safe "$ITS_SERVICE"
|
||||||
|
systemctl reset-failed "$ITS_SERVICE" >/dev/null 2>&1 || true
|
||||||
restart_service_safe "$ITS_SERVICE"
|
restart_service_safe "$ITS_SERVICE"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_summary() {
|
print_summary() {
|
||||||
echo
|
echo
|
||||||
echo "Stage_3 ready (X11 ONLY)."
|
echo "Stage_3 ready (dedicated X11 appliance mode)."
|
||||||
echo "Binary path:"
|
echo "Binary path:"
|
||||||
echo " ${ITS_BINARY}"
|
echo " ${ITS_BINARY}"
|
||||||
echo "Runtime/config/data/log directories:"
|
echo "Runtime/config/data/log directories:"
|
||||||
|
|
@ -468,17 +559,18 @@ print_summary() {
|
||||||
echo " /var/lib/itscreen/data"
|
echo " /var/lib/itscreen/data"
|
||||||
echo " /var/lib/itscreen/logs"
|
echo " /var/lib/itscreen/logs"
|
||||||
echo " /var/log/itscreen"
|
echo " /var/log/itscreen"
|
||||||
echo " ${LOCK_DIR}"
|
echo " ${ITS_RUN_DIR}"
|
||||||
echo "Managed files written by installer:"
|
echo "Managed files written by installer:"
|
||||||
echo " ${ITS_BINARY}"
|
echo " ${ITS_BINARY}"
|
||||||
echo " ${SUDOERS_FILE}"
|
echo " ${SUDOERS_FILE}"
|
||||||
echo " ${XSESSION_HOOK}"
|
|
||||||
echo " ${XWRAPPER_CONFIG}"
|
|
||||||
echo " ${ITS_WRAPPER}"
|
echo " ${ITS_WRAPPER}"
|
||||||
|
echo " ${ITS_SESSION_SCRIPT}"
|
||||||
|
echo " ${ITS_X11_LAUNCHER}"
|
||||||
|
echo " ${ITS_X11_CLEANUP}"
|
||||||
echo " ${ITS_UNIT_FILE}"
|
echo " ${ITS_UNIT_FILE}"
|
||||||
echo "Enabled services:"
|
echo "Services after install:"
|
||||||
echo " ${LIGHTDM_SERVICE}"
|
echo " ${LIGHTDM_SERVICE}: disabled"
|
||||||
echo " ${ITS_SERVICE}"
|
echo " ${ITS_SERVICE}: enabled"
|
||||||
echo "Main log file:"
|
echo "Main log file:"
|
||||||
echo " ${LOG}"
|
echo " ${LOG}"
|
||||||
echo "Quick verification commands:"
|
echo "Quick verification commands:"
|
||||||
|
|
@ -486,6 +578,12 @@ print_summary() {
|
||||||
echo " systemctl status ${LIGHTDM_SERVICE} --no-pager"
|
echo " systemctl status ${LIGHTDM_SERVICE} --no-pager"
|
||||||
echo " journalctl -u ${ITS_SERVICE} -n 80 --no-pager"
|
echo " journalctl -u ${ITS_SERVICE} -n 80 --no-pager"
|
||||||
echo " ls -l ${ITS_BINARY} ${ITS_WRAPPER} ${ITS_UNIT_FILE}"
|
echo " ls -l ${ITS_BINARY} ${ITS_WRAPPER} ${ITS_UNIT_FILE}"
|
||||||
|
echo "Manual desktop mode via SSH:"
|
||||||
|
echo " systemctl stop ${ITS_SERVICE}"
|
||||||
|
echo " systemctl start ${LIGHTDM_SERVICE}"
|
||||||
|
echo "Return to appliance mode:"
|
||||||
|
echo " systemctl stop ${LIGHTDM_SERVICE}"
|
||||||
|
echo " systemctl start ${ITS_SERVICE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
@ -493,17 +591,18 @@ main() {
|
||||||
ensure_dir /var/log 0755 root root
|
ensure_dir /var/log 0755 root root
|
||||||
touch "$LOG" >/dev/null 2>&1 || true
|
touch "$LOG" >/dev/null 2>&1 || true
|
||||||
|
|
||||||
log "=== IOMATEX STAGE_3 ITSCREEN (X11 ONLY) START ==="
|
log "=== IOMATEX STAGE_3 ITSCREEN (DEDICATED X11) START ==="
|
||||||
|
|
||||||
install_base_packages
|
install_base_packages
|
||||||
ensure_edge_name
|
ensure_edge_name
|
||||||
ensure_runtime_directories
|
ensure_runtime_directories
|
||||||
install_qt_packages
|
install_qt_packages
|
||||||
|
cleanup_legacy_lightdm_boot_path
|
||||||
|
cleanup_legacy_x11_hacks
|
||||||
install_itscreen_binary
|
install_itscreen_binary
|
||||||
install_sudoers
|
install_sudoers
|
||||||
install_x11_access_files
|
|
||||||
configure_lightdm_autologin
|
|
||||||
install_wrapper
|
install_wrapper
|
||||||
|
install_x11_session_scripts
|
||||||
install_systemd_unit
|
install_systemd_unit
|
||||||
enable_managed_services
|
enable_managed_services
|
||||||
print_summary
|
print_summary
|
||||||
|
|
|
||||||
|
|
@ -822,6 +822,79 @@ def get_cpu_cores():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def read_uptime_seconds():
|
||||||
|
raw = read_text("/proc/uptime").strip()
|
||||||
|
if raw:
|
||||||
|
first = raw.split()[0]
|
||||||
|
try:
|
||||||
|
value = float(first)
|
||||||
|
if value >= 0:
|
||||||
|
return value
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
rc, stdout, _ = run(["uptime", "-s"], timeout=4)
|
||||||
|
if rc == 0 and stdout:
|
||||||
|
text = stdout.strip()
|
||||||
|
for fmt in ("%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M"):
|
||||||
|
try:
|
||||||
|
started_at = datetime.strptime(text, fmt)
|
||||||
|
return max(0.0, time.time() - started_at.timestamp())
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
|
rc, stdout, _ = run(["who", "-b"], timeout=4)
|
||||||
|
if rc == 0 and stdout:
|
||||||
|
match = re.search(r"(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})(?::(\d{2}))?", stdout)
|
||||||
|
if match:
|
||||||
|
stamp = f"{match.group(1)} {match.group(2)}:{match.group(3) or '00'}"
|
||||||
|
try:
|
||||||
|
started_at = datetime.strptime(stamp, "%Y-%m-%d %H:%M:%S")
|
||||||
|
return max(0.0, time.time() - started_at.timestamp())
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def format_uptime_human(seconds):
|
||||||
|
try:
|
||||||
|
total = int(max(0, float(seconds)))
|
||||||
|
except Exception:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
if total < 60:
|
||||||
|
return "less than 1 min"
|
||||||
|
|
||||||
|
minutes_total = total // 60
|
||||||
|
days, rem_minutes = divmod(minutes_total, 24 * 60)
|
||||||
|
hours, minutes = divmod(rem_minutes, 60)
|
||||||
|
|
||||||
|
parts = []
|
||||||
|
if days:
|
||||||
|
parts.append(f"{days} d")
|
||||||
|
if hours:
|
||||||
|
parts.append(f"{hours} h")
|
||||||
|
if minutes or not parts:
|
||||||
|
parts.append(f"{minutes} min")
|
||||||
|
return " ".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def get_runtime_status():
|
||||||
|
uptime_seconds = read_uptime_seconds()
|
||||||
|
if uptime_seconds is None:
|
||||||
|
return {
|
||||||
|
"last_boot_at": None,
|
||||||
|
"uptime_human": "unknown",
|
||||||
|
}
|
||||||
|
|
||||||
|
last_boot_at = int(max(0.0, time.time() - uptime_seconds) * 1000)
|
||||||
|
return {
|
||||||
|
"last_boot_at": last_boot_at,
|
||||||
|
"uptime_human": format_uptime_human(uptime_seconds),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_health_summary():
|
def get_health_summary():
|
||||||
sensors = read_thermal_sensors()
|
sensors = read_thermal_sensors()
|
||||||
disk = get_disk_usage()
|
disk = get_disk_usage()
|
||||||
|
|
@ -833,6 +906,7 @@ def get_health_summary():
|
||||||
"load_average": get_load_average(),
|
"load_average": get_load_average(),
|
||||||
"disk": disk,
|
"disk": disk,
|
||||||
"temperatures": sensors,
|
"temperatures": sensors,
|
||||||
|
**get_runtime_status(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ h1{margin:0;font-size:34px;line-height:1.02;font-weight:650;letter-spacing:-.03e
|
||||||
.meta{display:grid;grid-template-columns:140px 1fr;gap:8px 10px;margin-top:16px;font-size:13px}
|
.meta{display:grid;grid-template-columns:140px 1fr;gap:8px 10px;margin-top:16px;font-size:13px}
|
||||||
.compactMeta{margin-top:0}
|
.compactMeta{margin-top:0}
|
||||||
.splitMeta{
|
.splitMeta{
|
||||||
display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-top:16px;
|
display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-top:16px;
|
||||||
}
|
}
|
||||||
.splitMeta section{min-width:0}
|
.splitMeta section{min-width:0}
|
||||||
.meta .key{color:var(--muted)}
|
.meta .key{color:var(--muted)}
|
||||||
|
|
|
||||||
|
|
@ -583,6 +583,16 @@
|
||||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatHealthLastStart(value) {
|
||||||
|
const formatted = formatTimestamp(value);
|
||||||
|
return formatted === "—" ? "unknown" : formatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatHealthUptime(value) {
|
||||||
|
const text = textValue(value, "").trim();
|
||||||
|
return text || "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
function formatInterval(value, disabledLabel = "Disabled") {
|
function formatInterval(value, disabledLabel = "Disabled") {
|
||||||
const seconds = Number(value);
|
const seconds = Number(value);
|
||||||
if (!Number.isFinite(seconds)) return "—";
|
if (!Number.isFinite(seconds)) return "—";
|
||||||
|
|
@ -665,7 +675,7 @@
|
||||||
return `${token.slice(0, 10)}…${token.slice(-6)}`;
|
return `${token.slice(0, 10)}…${token.slice(-6)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderHealthOverviewPanel(metrics, temps) {
|
function renderHealthOverviewPanel(metrics, runtimeRows, temps) {
|
||||||
const thermalRows = temps.length
|
const thermalRows = temps.length
|
||||||
? temps.map((item) => ({ label: item.name, value: item.label || "not available" }))
|
? temps.map((item) => ({ label: item.name, value: item.label || "not available" }))
|
||||||
: [{ label: "Sensors", value: "not available" }];
|
: [{ label: "Sensors", value: "not available" }];
|
||||||
|
|
@ -682,6 +692,10 @@
|
||||||
<div class="listTitle">Summary</div>
|
<div class="listTitle">Summary</div>
|
||||||
<div class="meta compactMeta">${renderKeyValueRows(metrics)}</div>
|
<div class="meta compactMeta">${renderKeyValueRows(metrics)}</div>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<div class="listTitle">Runtime</div>
|
||||||
|
<div class="meta compactMeta">${renderKeyValueRows(runtimeRows)}</div>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<div class="listTitle">Thermals</div>
|
<div class="listTitle">Thermals</div>
|
||||||
<div class="meta compactMeta">${renderKeyValueRows(thermalRows)}</div>
|
<div class="meta compactMeta">${renderKeyValueRows(thermalRows)}</div>
|
||||||
|
|
@ -1093,6 +1107,10 @@
|
||||||
renderLoadAverageMetric(health),
|
renderLoadAverageMetric(health),
|
||||||
{ label: "Disk usage", value: health.disk && health.disk.used_percent !== undefined ? `${health.disk.used_percent}% used` : "Not available" }
|
{ label: "Disk usage", value: health.disk && health.disk.used_percent !== undefined ? `${health.disk.used_percent}% used` : "Not available" }
|
||||||
];
|
];
|
||||||
|
const runtimeRows = [
|
||||||
|
{ label: "Last start", value: formatHealthLastStart(health.last_boot_at) },
|
||||||
|
{ label: "Uptime", value: formatHealthUptime(health.uptime_human) }
|
||||||
|
];
|
||||||
const temps = Array.isArray(health.temperatures) ? health.temperatures : [];
|
const temps = Array.isArray(health.temperatures) ? health.temperatures : [];
|
||||||
const serviceCards = (payload.services || [])
|
const serviceCards = (payload.services || [])
|
||||||
.filter((card) => card.id !== "access_point")
|
.filter((card) => card.id !== "access_point")
|
||||||
|
|
@ -1116,7 +1134,7 @@
|
||||||
return `
|
return `
|
||||||
<section class="tabPanel">
|
<section class="tabPanel">
|
||||||
<div class="cards">
|
<div class="cards">
|
||||||
${renderHealthOverviewPanel(metrics, temps)}
|
${renderHealthOverviewPanel(metrics, runtimeRows, temps)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sectionHead">
|
<div class="sectionHead">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue