diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-19 23:41:17 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-03-20 15:01:21 -0700 |
commit | 9a3c37c21e9a1502a7b98705617cc4d5adeeeff1 (patch) | |
tree | fafe26b455fbde90aa38dc7b94ab2b9379bb73d0 /scripts | |
parent | 4fd9b0282d7289ea993eefa22d497617a7dd5333 (diff) | |
download | dotfiles-9a3c37c21e9a1502a7b98705617cc4d5adeeeff1.tar.gz |
rename annexfmail out of PATH
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/mail/archive-fmail-to-annex | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/mail/archive-fmail-to-annex b/scripts/mail/archive-fmail-to-annex new file mode 100755 index 00000000..b18008fe --- /dev/null +++ b/scripts/mail/archive-fmail-to-annex @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +use 5.028; +use strict; +use warnings; +use lib "$ENV{HOME}/src/dotfiles/perl5"; + +use Local::Homedir::Mail qw(archive_to_mbox); +use File::Spec::Functions qw(catfile); +use POSIX qw(strftime); + +# CONFIG + +our $maildirs = "$ENV{HOME}/.fmail"; +our $mboxes = "$ENV{HOME}/annex/mail"; +our $expanded_mboxes = "$ENV{HOME}/.fmail/annex"; +our %names = (inbox => 'archive', sent => 'sent', lists => 'lists'); +our @annex_sync_remotes = qw(origin cloud); + +# CODE + +# might use Proc::Find from CPAN instead of this +system "pgrep -u $ENV{USER} mbsync"; +die "mbsync is running" if $? == 0; + +die "no source!" unless -d $maildirs; +die "no dest!" unless -d $mboxes; +die "no expansion dest!" unless -d $expanded_mboxes; + +system "movemymail"; +system "touch $ENV{HOME}/.nomovemymail"; + +my $suffix = lc strftime("-%b-%Y", localtime); +my @gzipped_mboxes; +foreach my $name (keys %names) { + my $target = $names{$name} . $suffix; + archive_to_mbox( + catfile($maildirs, $name), + catfile($mboxes, $target), + catfile($expanded_mboxes, $target)); + push @gzipped_mboxes, $target . ".gz"; +} + +chdir $mboxes; +system "git annex add @gzipped_mboxes"; +system "git annex sync @annex_sync_remotes -C ."; + +unlink "$ENV{HOME}/.nomovemymail"; +system "notmuch new"; |