From bc85050b472d97f5c9e1ed6e2b1ebf07dbb0a82c Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 21 Sep 2025 20:54:49 +0200 Subject: [PATCH 1/3] Fix FlareSolverr Chromium startup on HA OS --- flaresolverr/CHANGELOG.md | 4 +++ flaresolverr/config.json | 2 +- .../cont-init.d/02-fix-chromium-dev-shm.sh | 29 +++++++++++++++++++ flaresolverr/updater.json | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 flaresolverr/rootfs/etc/cont-init.d/02-fix-chromium-dev-shm.sh diff --git a/flaresolverr/CHANGELOG.md b/flaresolverr/CHANGELOG.md index a2636fe4b..b808b5a56 100644 --- a/flaresolverr/CHANGELOG.md +++ b/flaresolverr/CHANGELOG.md @@ -1,4 +1,8 @@ +## 3.4.1-1 (21-09-2025) + +- Fix Chromium startup by hardening the shared memory helper for large reported sizes (thanks to community reports) + ## 3.4.1 (20-09-2025) - Update to latest version from FlareSolverr/FlareSolverr (changelog : https://github.com/FlareSolverr/FlareSolverr/releases) ## 3.4.0 (26-08-2025) diff --git a/flaresolverr/config.json b/flaresolverr/config.json index 2883daaa6..b11cf8bc4 100644 --- a/flaresolverr/config.json +++ b/flaresolverr/config.json @@ -80,6 +80,6 @@ "slug": "flaresolverr", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons", - "version": "3.3.25", + "version": "3.4.1-1", "webui": "[PROTO:ssl]://[HOST]:[PORT:8191]" } diff --git a/flaresolverr/rootfs/etc/cont-init.d/02-fix-chromium-dev-shm.sh b/flaresolverr/rootfs/etc/cont-init.d/02-fix-chromium-dev-shm.sh new file mode 100755 index 000000000..2bc3e5342 --- /dev/null +++ b/flaresolverr/rootfs/etc/cont-init.d/02-fix-chromium-dev-shm.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +set -euo pipefail + +fix_file="/etc/chromium.d/dev-shm" + +if [ -f "${fix_file}" ]; then + bashio::log.info "Patching Chromium shared memory helper for reliable startup" + cat <<'PATCH' > "${fix_file}" +# shellcheck shell=sh +# Patched by alexbelgium/hassio-addons to avoid arithmetic errors with large values on some shells. +shm_avail=$(findmnt -bnr -o avail -T /dev/shm 2>/dev/null) + +if python3 - "${shm_avail}" <<'PY' +import re +import sys + +raw = sys.argv[1] if len(sys.argv) > 1 else '' +match = re.search(r'\d+', raw) +value = int(match.group(0)) if match else 0 +LIMIT = 4080218931 +sys.exit(0 if value < LIMIT else 1) +PY +then + export CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --disable-dev-shm-usage" +fi +PATCH + chmod 0644 "${fix_file}" +fi diff --git a/flaresolverr/updater.json b/flaresolverr/updater.json index ec201f137..2ab9b4eec 100644 --- a/flaresolverr/updater.json +++ b/flaresolverr/updater.json @@ -1,5 +1,5 @@ { - "last_update": "20-09-2025", + "last_update": "21-09-2025", "repository": "alexbelgium/hassio-addons", "slug": "flaresolverr", "source": "github", From 4c77ae03970a1b4fa73c5791061a1daf5518557e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:12:32 +0200 Subject: [PATCH 2/3] Refactor 99-run.sh to improve logging and compatibility --- flaresolverr/rootfs/etc/cont-init.d/99-run.sh | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/flaresolverr/rootfs/etc/cont-init.d/99-run.sh b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh index e25b51762..bd129a13a 100755 --- a/flaresolverr/rootfs/etc/cont-init.d/99-run.sh +++ b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh @@ -1,8 +1,49 @@ -#!/usr/bin/env bashio +#!/bin/bash # shellcheck shell=bash -set -euo pipefail +set +eu -bashio::log.warning "Warning - minimum configuration recommended: 2 CPU cores and 4 GB of memory. Otherwise the system may become unresponsive or crash." +echo "Warning - minimum configuration recommended: 2 CPU cores and 4 GB of memory. Otherwise the system may become unresponsive or crash." + +fix_file="/etc/chromium.d/dev-shm" + +if [ -f "${fix_file}" ]; then + bashio::log.info "Patching Chromium shared memory helper for reliable startup" + cat <<'PATCH' > "${fix_file}" +# shellcheck shell=sh +# Patched by alexbelgium/hassio-addons to avoid arithmetic errors with large values on some shells. +shm_avail=$(findmnt -bnr -o avail -T /dev/shm 2>/dev/null) + +if python3 - "${shm_avail}" <<'PY' +import re +import sys + +raw = sys.argv[1] if len(sys.argv) > 1 else '' +match = re.search(r'\d+', raw) +value = int(match.group(0)) if match else 0 +LIMIT = 4080218931 +sys.exit(0 if value < LIMIT else 1) +PY +then + export CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --disable-dev-shm-usage" +fi +PATCH + chmod 0644 "${fix_file}" +fi + +chromium_wrapper="/usr/bin/chromium" + +if [[ -f "${chromium_wrapper}" ]]; then + if [[ ! -x /bin/bash ]]; then + bashio::log.warning "Chromium wrapper patch skipped: /bin/bash is not available." + else + if grep -q '^#!/bin/sh' "${chromium_wrapper}"; then + if grep -q '==' "${chromium_wrapper}"; then + bashio::log.info "Adjusting Chromium wrapper to use bash for compatibility with Chromium 140." + sed -i '1s|/bin/sh|/bin/bash|' "${chromium_wrapper}" + fi + fi + fi +fi ############## # LAUNCH APP # From bf0e7243e505967193acb9d2e341e20e158c0d2e Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:14:38 +0200 Subject: [PATCH 3/3] Update 99-run.sh --- flaresolverr/rootfs/etc/cont-init.d/99-run.sh | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/flaresolverr/rootfs/etc/cont-init.d/99-run.sh b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh index bd129a13a..49aaf2dea 100755 --- a/flaresolverr/rootfs/etc/cont-init.d/99-run.sh +++ b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh @@ -4,32 +4,6 @@ set +eu echo "Warning - minimum configuration recommended: 2 CPU cores and 4 GB of memory. Otherwise the system may become unresponsive or crash." -fix_file="/etc/chromium.d/dev-shm" - -if [ -f "${fix_file}" ]; then - bashio::log.info "Patching Chromium shared memory helper for reliable startup" - cat <<'PATCH' > "${fix_file}" -# shellcheck shell=sh -# Patched by alexbelgium/hassio-addons to avoid arithmetic errors with large values on some shells. -shm_avail=$(findmnt -bnr -o avail -T /dev/shm 2>/dev/null) - -if python3 - "${shm_avail}" <<'PY' -import re -import sys - -raw = sys.argv[1] if len(sys.argv) > 1 else '' -match = re.search(r'\d+', raw) -value = int(match.group(0)) if match else 0 -LIMIT = 4080218931 -sys.exit(0 if value < LIMIT else 1) -PY -then - export CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --disable-dev-shm-usage" -fi -PATCH - chmod 0644 "${fix_file}" -fi - chromium_wrapper="/usr/bin/chromium" if [[ -f "${chromium_wrapper}" ]]; then