Make browser prefs creation non-fatal when unwritable
All checks were successful
build-and-push / lint (push) Successful in 4s
build-and-push / sonar (push) Successful in 11s
build-and-push / docker (push) Successful in 1m11s

This commit is contained in:
nocci 2025-12-30 16:58:22 +00:00
parent e3e6a6f36c
commit 6f2e1e5b22

View file

@ -10,22 +10,24 @@ echo "Build: $NOW"
# When running in docker and then killing it, on the next run chromium displayed a dialog to unlock the profile which made the script time out. # When running in docker and then killing it, on the next run chromium displayed a dialog to unlock the profile which made the script time out.
# Maybe due to changed hostname of container or due to how the docker container kills playwright - didn't check. # Maybe due to changed hostname of container or due to how the docker container kills playwright - didn't check.
# https://bugs.chromium.org/p/chromium/issues/detail?id=367048 # https://bugs.chromium.org/p/chromium/issues/detail?id=367048
rm -f /fgc/data/browser/SingletonLock rm -f /fgc/data/browser/SingletonLock 2>/dev/null || true
# Firefox preferences are stored in $BROWSER_DIR/pref.js and can be overridden by a file user.js # 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. # Since this file has to be in the volume (data/browser), we can't do this in Dockerfile.
mkdir -p /fgc/data/browser mkdir -p /fgc/data/browser
# fix for 'Incorrect response' after solving a captcha correctly - https://github.com/vogler/free-games-claimer/issues/261#issuecomment-1868385830 # 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). # Only write the prefs file when the volume is writable (container runs as non-root).
if [ -w /fgc/data/browser ]; then if [ -w /fgc/data/browser ] && ( [ ! -e /fgc/data/browser/user.js ] || [ -w /fgc/data/browser/user.js ] ); then
cat << EOT > /fgc/data/browser/user.js if ! cat << 'EOT' > /fgc/data/browser/user.js; then
echo "Warning: failed to write /fgc/data/browser/user.js (permission issue?)." >&2
fi
user_pref("privacy.resistFingerprinting", true); user_pref("privacy.resistFingerprinting", true);
// user_pref("privacy.resistFingerprinting.letterboxing", true); // user_pref("privacy.resistFingerprinting.letterboxing", true);
// user_pref("browser.contentblocking.category", "strict"); // user_pref("browser.contentblocking.category", "strict");
// user_pref("webgl.disabled", true); // user_pref("webgl.disabled", true);
EOT EOT
else else
echo "Warning: /fgc/data/browser is not writable; skipping user.js creation." echo "Warning: /fgc/data/browser not writable; skipping user.js creation."
fi fi
# TODO disable session restore message? # TODO disable session restore message?