From 22549da790825c4a8ce542745c61d2c78986f08d Mon Sep 17 00:00:00 2001 From: Ruben Barkow-Kuder Date: Wed, 8 Jul 2020 14:55:05 +0200 Subject: [PATCH] enhance thunderbird-patch script - abort if Thunderbird is running - add verbosity and interactivity to copy commands - add time to backup file --- thunderbird-patch | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) mode change 100644 => 100755 thunderbird-patch diff --git a/thunderbird-patch b/thunderbird-patch old mode 100644 new mode 100755 index 3af0e146..a8b313a0 --- a/thunderbird-patch +++ b/thunderbird-patch @@ -37,12 +37,20 @@ fi echo Thunderbird dir is: $THUNDERBIRDDIR +echo checking if $THUNDERBIRDDIR/thunderbird is running ... +pgrep thunderbird -la|grep $THUNDERBIRDDIR/thunderbird; +if [ $? -eq 0 ]; then + echo 'thunderbird is still running!' + exit 1 +fi + realomnipath=$THUNDERBIRDDIR/omni.ja OMNITMPDIR=/tmp/omni +BACKUP_OMNI=thunderbird-omni.ja.backup-$(date +%Y-%m-%d_%H:%m:%S).ja -# if needed BACKUP_OMNI=$THUNDERBIRDDIR/mailer-omni-backup.ja -BACKUP_OMNI=$HOME/mailer-omni-backup-$(date +%Y-%m-%d).ja +U=${SUDO_USER:-$USER} +HOMEDIR=/home/$U echo "Making directory $OMNITMPDIR ..." mkdir $OMNITMPDIR @@ -78,11 +86,12 @@ echo "Repackaging ..." # repackage omni.ja: - if startup is slow remove the 9 compression and replace it with 0 zip -qr9XD /tmp/newomni.ja * - -echo "Backing up original to $BACKUP_OMNI" -cp $THUNDERBIRDDIR/omni.ja $BACKUP_OMNI +echo "Backing up original $THUNDERBIRDDIR/omni.ja to $HOMEDIR/$BACKUP_OMNI" +cp -v $THUNDERBIRDDIR/omni.ja $HOMEDIR/$BACKUP_OMNI echo "Trying to copy /tmp/newomni.ja to $realomnipath" echo "If this doesn't work, try sudo cp /tmp/newomni.ja $realomnipath" echo -cp /tmp/newomni.ja $realomnipath && echo "Copied new omni.ja into $realomnipath" +cp -iv /tmp/newomni.ja $realomnipath + +echo 'done!'