diff options
-rwxr-xr-x | bin/rollback-profile | 69 |
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 |