aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2014-01-19 14:22:36 +0100
committerDavid Runge <david.runge@frqrec.com>2014-01-19 14:22:36 +0100
commit1f715e04f84e4bafbb0073599dd4e217052450d5 (patch)
tree9af625aed7702eb788c200d266b3b2257c09bfe2 /bin
parent79a200cbb460d69b58f025da70b0e3753a227a5e (diff)
downloaddotfiles-1f715e04f84e4bafbb0073599dd4e217052450d5.tar.gz
dotfiles-1f715e04f84e4bafbb0073599dd4e217052450d5.tar.bz2
dotfiles-1f715e04f84e4bafbb0073599dd4e217052450d5.tar.xz
dotfiles-1f715e04f84e4bafbb0073599dd4e217052450d5.zip
Script for rolling back a profile from a backup location.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rollback-profile69
1 files changed, 69 insertions, 0 deletions
diff --git a/bin/rollback-profile b/bin/rollback-profile
new file mode 100755
index 0000000..499d13d
--- /dev/null
+++ b/bin/rollback-profile
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# Rollback a thunderbird or firefox profile backup from store location while gpg decrypting
+#
+
+# Checking if firefox and/ or thunderbird are running.
+firefoxPID=`ps -C firefox -o pid=`
+thunderbirdPID=`ps -C thunderbird -o pid=`
+
+firefoxTMP=/tmp/firefox.tgz
+thunderbirdTMP=/tmp/thunderbird.tgz
+firefoxIF=~/.mozilla/firefox/
+thunderbirdIF=~/.thunderbird/
+profileName=dvzrv
+backupEND=-rollback
+OF=~/Dropbox/sync/
+gpgEND=.gpg
+tgzEND=.tgz
+
+case $1 in
+ "thunderbird")
+ if [[ -z "$thunderbirdPID" ]]
+ then
+ echo "Thunderbird is not running."
+ echo "Rolling back profile backup."
+ echo "Copying backup to /tmp and moving old profile to rollback location."
+ cp $OF$1$tgzEND$gpgEND $thunderbirdTMP$gpgEND
+ mv $thunderbirdIF$profileName $thunderbirdIF$profileName$backupEND
+ echo "Decrypting file."
+ gpg -o $thunderbirdTMP -d $thunderbirdTMP$gpgEND
+ echo "Extracting files from tar."
+ tar xzvf $thunderbirdTMP -C $thunderbirdIF
+ echo "Cleaning up."
+ rm $thunderbirdTMP $thunderbirdTMP$gpgEND
+ echo "Done."
+ else
+ echo "Thunderbird is still running."
+ echo "Skipping rollback."
+ fi
+ ;;
+ "firefox")
+ if [[ -z "$firefoxPID" ]]
+ then
+ echo "Firefox is not running."
+ psdStopped=`systemctl status psd |grep inactive`
+ if [[ ! -z "$psdStopped" ]]; then
+ echo "Psd daemon is inactive."
+ echo "Rolling back profile backup."
+ echo "Copying backup to /tmp and moving old profile to rollback location."
+ cp $OF$1$tgzEND$gpgEND $firefoxTMP$gpgEND
+ mv $firefoxIF$profileName $firefoxIF$profileName$backupEND
+ echo "Decrypting file."
+ gpg -o $firefoxTMP -d $firefoxTMP$gpgEND
+ echo "Extracting files from tar."
+ tar xzvf $firefoxTMP -C $firefoxIF
+ echo "Cleaning up."
+ rm $firefoxTMP $firefoxTMP$gpgEND
+ echo "Done."
+ else
+ echo "Psd service is still running!"
+ echo "Disable it using: 'systemctl stop psd'."
+ echo "Skipping rollback."
+ fi
+ else
+ echo "Firefox is still running."
+ echo "Skipping rollback."
+ fi
+ ;;
+esac