Skip to content

Instantly share code, notes, and snippets.

@Trucido
Created June 10, 2015 20:07
Show Gist options
  • Save Trucido/2bec77745cad8c9a72cf to your computer and use it in GitHub Desktop.
Save Trucido/2bec77745cad8c9a72cf to your computer and use it in GitHub Desktop.
move firefox cache to /tmp/cache for tmpfs
#!/bin/bash
#
# Copyright (c) 2015 Tara Nupsumass
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# <http://www.gnu.org/licenses/>
#
# This script moves firefox browser cache directorie(s) to /tmp/cache/, it should be run on user login.
# define our directories
FF_CACHE="$HOME/.cache/mozilla/firefox"
FF_TMP_CACHE="/tmp/cache/mozilla/firefox"
FIREFOX="`which "firefox"`"
function FF
{
# check if exists and is executable
if [[ -x $FIREFOX ]]; then
echo "$FIREFOX found."
# not found, abandoning this function.
else echo "FIREFOX not installed, skipping."; return
fi
# check if tmp cache exists, otherwise create it.
if [ ! -e $FF_TMP_CACHE ]; then
echo "$FF_TMP_CACHE not found, creating it"
mkdir -p "$FF_TMP_CACHE"
# if tmp cache directory already exists, skip creating it
else
echo "$FF_TMP_CACHE found, not creating it."
fi
# remove any remaining cache and symlink it
if [ -d $FF_CACHE ]; then
echo "existing $FF_CACHE found, deleting it."
rm -Rf "$FF_CACHE"
echo "symlinking $FF_TMP_CACHE to $FF_CACHE"
ln -s "$FF_TMP_CACHE" "$FF_CACHE"
else
echo "existing $FF_CACHE not found, good to go! symlinking $FF_TMP_CACHE to $FF_CACHE"
ln -s "$FF_TMP_CACHE" "$FF_CACHE"
fi
}
# function(s) loaded, running them!
FF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment