From e738e875bbfd59d57ab644c34f4f10d14a564404 Mon Sep 17 00:00:00 2001 From: Otto Seiskari Date: Tue, 26 Nov 2019 22:04:52 +0200 Subject: [PATCH] work around profile creation issues in a recent Firefox versions with an ugly hack --- files/start.sh | 28 ++++++++++++++++++++-------- run.sh | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/files/start.sh b/files/start.sh index afa7548..319dea1 100644 --- a/files/start.sh +++ b/files/start.sh @@ -3,13 +3,6 @@ set -e COMMAND="$1" echo "$COMMAND" -# If no profile ... -if [ ! -d "$HOME/.mozilla" ]; then - # create the default Firefox profile and put some settings there - firefox -CreateProfile default - mv $HOME/user.js `find $HOME/.mozilla/firefox -type d | grep .default` -fi - OPENVPN_CONF='/etc/openvpn/openvpn.conf' if [ -f "$OPENVPN_CONF" ]; then "$HOME/start-openvpn-blocking.sh" "$OPENVPN_CONF" @@ -31,5 +24,24 @@ if [ ! -z ${ASSERT_COUNTRY+x} ]; then fi fi -# Start firefox +# If no profile ... +if [ $COMMAND == "firefox" ]; then + # create the default Firefox profile and put some settings there + firefox & + FIREFOX_PID=$! + # Since some recent Firefox version, calling CreateProfile and copying + # user.js stopped working on the first use for reasons I could not find on + # Google and do not frankly care about. This is the workaround + set +e + while [ `find $HOME/.mozilla/firefox -type f | grep prefs.js | wc -l` == "0" ]; + do + echo "... waiting for Firefox to start the first time" + sleep 1 + done + set -e + echo "killing Firefox and copying settings" + kill $FIREFOX_PID + mv $HOME/user.js `find $HOME/.mozilla/firefox -maxdepth 1 -type d | grep .default-release` +fi + $COMMAND diff --git a/run.sh b/run.sh index ccbbb8b..d5dced8 100755 --- a/run.sh +++ b/run.sh @@ -6,6 +6,7 @@ docker run -ti --rm -e DISPLAY \ -v `pwd`/openvpn:/etc/openvpn \ -v `pwd`/shared:/home/user/Downloads \ -e ASSERT_COUNTRY \ + --name docker-vpn-browser-container \ --dns 1.1.1.1 \ docker-vpn-browser \ "$@"