From 1f715e04f84e4bafbb0073599dd4e217052450d5 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 19 Jan 2014 14:22:36 +0100 Subject: Script for rolling back a profile from a backup location. --- bin/rollback-profile | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 bin/rollback-profile (limited to 'bin/rollback-profile') 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 -- cgit v1.2.3-70-g09d2