From b2b7173275b7597e5a204cc46b9fc8ff1dc2dd0c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:20:37 +0100 Subject: [PATCH] Enhance wrapped-chromium script functionality Refactor wrapped-chromium script for improved binary detection and user data directory handling. --- .../rootfs/etc/usr/bin/wrapped-chromium | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 browser_chromium/rootfs/etc/usr/bin/wrapped-chromium diff --git a/browser_chromium/rootfs/etc/usr/bin/wrapped-chromium b/browser_chromium/rootfs/etc/usr/bin/wrapped-chromium new file mode 100644 index 000000000..8c9dda75a --- /dev/null +++ b/browser_chromium/rootfs/etc/usr/bin/wrapped-chromium @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# shellcheck shell=bash + +set -Eeuo pipefail + +# Prefer the real chromium binary used by LSIO images; fall back safely. +if [[ -x /usr/lib/chromium/chromium ]]; then + BIN=/usr/lib/chromium/chromium +elif command -v chromium >/dev/null 2>&1; then + BIN="$(command -v chromium)" +else + echo "ERROR: chromium binary not found" >&2 + exit 127 +fi + +# Pick a deterministic profile dir (LSIO commonly sets HOME=/config). +HOME_DIR="${HOME:-/config}" +USER_DATA_DIR="${CHROME_USER_DATA_DIR:-${HOME_DIR}/.config/chromium}" + +mkdir -p "${USER_DATA_DIR}" + +# Cleanup stale singleton locks only if chromium is not running +if ! pgrep -f 'chromium' >/dev/null 2>&1; then + rm -f "${USER_DATA_DIR}/Singleton"* || true +fi + +# Detect seccomp mode properly (0=disabled). This is still a heuristic. +seccomp_mode="$(awk -F':' '/^Seccomp:/{gsub(/[[:space:]]/,"",$2); print $2}' /proc/1/status || echo "")" + +args=( + --no-first-run + --password-store=basic + "--simulate-outdated-no-au=Tue, 31 Dec 2099 23:59:59 GMT" + --start-maximized + "--user-data-dir=${USER_DATA_DIR}" +) + +# If seccomp is not disabled, sandboxing often breaks in containers; use no-sandbox. +if [[ "${seccomp_mode}" != "0" ]]; then + args+=( --no-sandbox --test-type ) +fi + +# IMPORTANT: do NOT redirect to /dev/null while debugging +exec "${BIN}" "${args[@]}" "$@"