diff --git a/Dockerfile b/Dockerfile index 77245b6..77631f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,13 @@ FROM jlesage/baseimage-gui:alpine-3.7-v3.3.4 # Define software versions. ARG FIREFOX_VERSION=58.0.1-r2 +ARG JSONLZ4_VERSION=c4305b8 +ARG LZ4_VERSION=1.8.1.2 #ARG PROFILE_CLEANER_VERSION=2.36 # Define software download URLs. +ARG JSONLZ4_URL=https://github.com/avih/dejsonlz4/archive/${JSONLZ4_VERSION}.tar.gz +ARG LZ4_URL=https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz #ARG PROFILE_CLEANER_URL=https://github.com/graysky2/profile-cleaner/raw/v${PROFILE_CLEANER_VERSION}/common/profile-cleaner.in # Define working directory. @@ -40,6 +44,29 @@ RUN \ echo 'pref("browser.download.dir", "/config/downloads");' >> "$CFG_FILE" && \ echo 'pref("browser.download.folderList", 2);' >> "$CFG_FILE" +# Install JSONLZ4 tools. +RUN \ + add-pkg --virtual build-dependencies \ + curl \ + build-base \ + && \ + mkdir jsonlz4 && \ + mkdir lz4 && \ + curl -# -L {$JSONLZ4_URL} | tar xz --strip 1 -C jsonlz4 && \ + curl -# -L {$LZ4_URL} | tar xz --strip 1 -C lz4 && \ + mv jsonlz4/src/ref_compress/*.c jsonlz4/src/ && \ + cp lz4/lib/lz4.* jsonlz4/src/ && \ + cd jsonlz4 && \ + gcc -Wall -o dejsonlz4 src/dejsonlz4.c src/lz4.c && \ + gcc -Wall -o jsonlz4 src/jsonlz4.c src/lz4.c && \ + strip dejsonlz4 jsonlz4 && \ + cp -v dejsonlz4 /usr/bin/ && \ + cp -v jsonlz4 /usr/bin/ && \ + cd .. && \ + # Cleanup. + del-pkg build-dependencies && \ + rm -rf /tmp/* /tmp/.[!.]* + # Install profile-cleaner. #RUN \ # add-pkg --virtual build-dependencies curl && \ diff --git a/rootfs/etc/cont-init.d/firefox.sh b/rootfs/etc/cont-init.d/firefox.sh index 64e68eb..94d7402 100755 --- a/rootfs/etc/cont-init.d/firefox.sh +++ b/rootfs/etc/cont-init.d/firefox.sh @@ -29,6 +29,29 @@ fi # env HOME=/config /usr/bin/profile-cleaner f #fi +# Fix window display size is session stores. +if [ -n "$(ls /config/profile/sessionstore-backups/*.jsonlz4 2>/dev/null)" ]; then + for FILE in /config/profile/sessionstore-backups/*.jsonlz4; do + WORKDIR="$(mktemp -d)" + + dejsonlz4 "$FILE" "$WORKDIR"/json + cp "$WORKDIR"/json "$WORKDIR"/json.orig + + sed -i 's/"width":[0-9]\+/"width":'$DISPLAY_WIDTH'/' "$WORKDIR"/json + sed -i 's/"height":[0-9]\+/"height":'$DISPLAY_HEIGHT'/' "$WORKDIR"/json + sed -i 's/"screenX":[0-9]\+/"screenX":0/' "$WORKDIR"/json + sed -i 's/"screenY":[0-9]\+/"screenY":0/' "$WORKDIR"/json + + if ! diff "$WORKDIR"/json "$WORKDIR"/json.orig >/dev/null; then + jsonlz4 "$WORKDIR"/json "$WORKDIR"/jsonlz4 + mv "$WORKDIR"/jsonlz4 "$FILE" + log "fixed display size in $FILE." + fi + + rm -r "$WORKDIR" + done +fi + # Make sure monitored log files exist. for LOG_FILE in /config/log/firefox/error.log do