Last active
August 29, 2015 14:20
-
-
Save Trucido/d8296216a734a382e15d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/> | |
# Google and the Google Chrome browser are registered trademarks of Google Inc. | |
# This script moves google-chrome and google-chrome-beta cache directories to /tmp/cache, | |
# it should be run on user login. | |
# chromium support is a moot point since you can add add flags to ~/.chromium-browser.init | |
# such as this: | |
# CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disk-cache-dir=/tmp/chromium-cach" | |
CHROME_TMP_CACHE_DIR="/tmp/cache/google-chrome" | |
CHROME_CACHE_DIR="$HOME/.cache/google-chrome" | |
CHROME="`which "google-chrome"`" | |
CHROME_BETA="`which "google-chrome-beta"`" | |
function GC{ | |
# check if chrome is installed | |
if [[ -x $CHROME ]]; then | |
echo "google-chrome found." | |
# chrome not found, abandoning this function. | |
else echo "google-chrome not installed, skipping."; return | |
fi | |
# check if tmp cache exists, otherwise create it. | |
if [ ! -e $CHROME_TMP_CACHE_DIR ]; then | |
echo "/tmp/cache/google-chrome not found, creating it" | |
mkdir -p "$CHROME_TMP_CACHE_DIR" | |
# if tmp cache directory already exists, skip creating it | |
else | |
echo "/tmp/cache/google-chrome found, not creating it." | |
fi | |
# remove any remaining cache and symlink it | |
if [ -d $CHROME_CACHE_DIR ]; then | |
echo "existing ~/.cache/google-chrome found, deleting it." | |
rm -Rf "$CHROME_CACHE_DIR" | |
echo "symlinking /tmp/cache/google-chrome to ~/.cache/google-chrome" | |
ln -s "$CHROME_TMP_CACHE_DIR" "$CHROME_CACHE_DIR" | |
else | |
echo "existing ~/.cache/google-chrome not found, good to go! symlinking /tmp/cache/google-chrome to ~/.cache/google-chrome" | |
fi | |
} | |
function GCB{ | |
# check if chrome beta is installed | |
if [[ -x $CHROME_BETA ]]; then | |
echo "google-chrome-beta found." | |
# chrome beta not found, abandoning this function. | |
else echo "google-chrome-beta not installed, skipping"; return | |
fi | |
# check if tmp cache exists, otherwise create it. | |
if [ ! -e $CHROME_TMP_CACHE_DIR-beta ]; then | |
echo "/tmp/cache/google-chrome-beta not found, creating it" | |
mkdir -p "$CHROME_TMP_CACHE_DIR-beta" | |
# if tmp cache directory already exists, skip creating it | |
else | |
echo "/tmp/cache/google-chrome-beta found, not creating it." | |
fi | |
# remove any remaining cache and symlink it | |
if [ -d $CHROME_CACHE_DIR-beta ]; then | |
echo "existing ~/.cache/google-chrome-beta found, deleting it." | |
rm -Rf "$CHROME_CACHE_DIR-beta" | |
echo "symlinking /tmp/cache/google-chrome-beta to ~/.cache/google-chrome-beta" | |
ln -s "$CHROME_TMP_CACHE_DIR-beta" "$CHROME_CACHE_DIR-beta" | |
else | |
echo "existing ~/.cache/google-chrome-beta not found, good to go! symlinking /tmp/cache/google-chrome-beta to ~/.cache/google-chrome-beta" | |
ln -s "$CHROME_TMP_CACHE_DIR-beta" "$CHROME_CACHE_DIR-beta" | |
fi | |
} | |
# functions loaded, running them! | |
GC | |
GCB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment