From e6c43c8de68ea81947e2c12dc1f4df6de9657549 Mon Sep 17 00:00:00 2001 From: nocci Date: Wed, 31 Dec 2025 10:44:28 +0000 Subject: [PATCH] fix: fallback writable firefox profile --- docker-entrypoint.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index e604e7c..51084c9 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -17,23 +17,32 @@ fi # https://bugs.chromium.org/p/chromium/issues/detail?id=367048 rm -f /fgc/data/browser/SingletonLock 2>/dev/null || true +# Firefox profile directory (persistent if writable; fallback to cache when bind-mount is read-only). +BROWSER_DIR=/fgc/data/browser +if [ ! -w "$BROWSER_DIR" ]; then + echo "Warning: $BROWSER_DIR not writable; using fallback profile at /home/fgc/.cache/browser" + BROWSER_DIR=/home/fgc/.cache/browser + mkdir -p "$BROWSER_DIR" + chown 1000:1000 "$BROWSER_DIR" 2>/dev/null || true +fi +mkdir -p "$BROWSER_DIR" +# clean up stale firefox locks that can trigger "already running" +rm -f "$BROWSER_DIR"/parent.lock "$BROWSER_DIR"/lock "$BROWSER_DIR"/.parentlock 2>/dev/null || true # Firefox preferences are stored in $BROWSER_DIR/pref.js and can be overridden by a file user.js # Since this file has to be in the volume (data/browser), we can't do this in Dockerfile. -mkdir -p /fgc/data/browser -# clean up stale firefox locks that can trigger "already running" -rm -f /fgc/data/browser/parent.lock /fgc/data/browser/lock /fgc/data/browser/.parentlock 2>/dev/null || true # fix for 'Incorrect response' after solving a captcha correctly - https://github.com/vogler/free-games-claimer/issues/261#issuecomment-1868385830 # Only write the prefs file when the volume is writable (container runs as non-root). -if [ -w /fgc/data/browser ] && { [ ! -e /fgc/data/browser/user.js ] || [ -w /fgc/data/browser/user.js ] || rm -f /fgc/data/browser/user.js 2>/dev/null; }; then - cat << 'EOT' > /fgc/data/browser/user.js +if [ -w "$BROWSER_DIR" ] && { [ ! -e "$BROWSER_DIR/user.js" ] || [ -w "$BROWSER_DIR/user.js" ] || rm -f "$BROWSER_DIR/user.js" 2>/dev/null; }; then + cat << 'EOT' > "$BROWSER_DIR/user.js" user_pref("privacy.resistFingerprinting", true); // user_pref("privacy.resistFingerprinting.letterboxing", true); // user_pref("browser.contentblocking.category", "strict"); // user_pref("webgl.disabled", true); EOT else - echo "Warning: /fgc/data/browser not writable; skipping user.js creation." + echo "Warning: $BROWSER_DIR not writable; skipping user.js creation." fi +export BROWSER_DIR # TODO disable session restore message? # Remove X server display lock, fix for `docker compose up` which reuses container which made it fail after initial run, https://github.com/vogler/free-games-claimer/issues/31