Relocating Firefox profile and cache to tmpfs

To reduce disk IO I’m mount Firefox profile to tmpfs.

.mozilla/firefox/dj8vbpx8.default


But some time ago Mozilla developer splitted cache and profile.

.cache/mozilla/firefox/dj8vbpx8.default


So here is modified script for running Firefox:

cat bin/firefox-sync
#!/bin/sh

static=main
link=dj8vbpx8.default
volatile=/dev/shm/firefox-$USER
cache=/dev/shm/firefox-cache-$USER

IFS=
set -efu

cd ~/.mozilla/firefox

if [ ! -r $volatile ]; then
mkdir -m0700 $volatile
fi

if [ "$(readlink $link)" != "$volatile" ]; then
mv $link $static
ln -s $volatile $link
fi

if [ -e $link/.unpacked ]; then
rsync -av --delete --exclude .unpacked ./$link/ ./$static/
else
rsync -av ./$static/ ./$link/
touch $link/.unpacked
fi

cd ~/.cache/mozilla/firefox

if [ ! -r $cache ]; then
mkdir -m0700 $cache
fi

if [ "$(readlink $link)" != "$cache" ]; then
mv $link $static
ln -s $cache $link
fi

if [ -e $link/.unpacked ]; then
rsync -av --delete --exclude .unpacked ./$link/ ./$static/
else
rsync -av ./$static/ ./$link/
touch $link/.unpacked
fi


Enjoy!

Relocating Firefox profile and cache to tmpfs