Last active
August 29, 2015 14:04
-
-
Save alepez/b1e63e529ddb57115ef8 to your computer and use it in GitHub Desktop.
sync browser profile (saves ssd)
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 | |
BROWSER=$2 | |
PERMANENT_DIR=$3 | |
function resume { | |
rm ${PERMANENT_DIR} | |
mv ${PERMANENT_DIR}.backup ${PERMANENT_DIR} | |
} | |
function start { | |
if [ -e /tmp/${USER}-${BROWSER} ]; then echo "Already started"; exit 1; fi | |
if [ -L ${PERMANENT_DIR} ]; then echo "Not cleanly stopped. Resuming..."; resume; fi | |
cp -a ${PERMANENT_DIR} /tmp/${USER}-${BROWSER} | |
mv ${PERMANENT_DIR} ${PERMANENT_DIR}.backup | |
ln -s /tmp/${USER}-${BROWSER} ${PERMANENT_DIR} | |
} | |
function stop { | |
if [ ! -e /tmp/${USER}-${BROWSER} ]; then echo "Not started"; exit 1; fi | |
m ${PERMANENT_DIR} | |
mv /tmp/${USER}-${BROWSER} ${PERMANENT_DIR} | |
rm -r ${PERMANENT_DIR}.backup | |
} | |
case $1 in | |
start) start;; | |
stop) stop;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment