#!/usr/bin/perl use 5.028; use strict; use warnings; use lib "$ENV{HOME}/src/dotfiles/perl5"; use Fcntl qw(LOCK_EX LOCK_NB); use File::Path qw(make_path); use File::Spec::Functions qw(catfile splitpath); use Local::Homedir::Mail qw(expand_mbox); # CONFIG our $mboxes = "$ENV{HOME}/annex/mail"; our $expanded = "$ENV{HOME}/.fmail/annex"; # CODE # flock ourselves to ensure that only one copy of this script is ever running open our $us, "<", $0 or die $!; exit 0 unless flock $us, LOCK_EX|LOCK_NB; make_path($expanded); open my $touch_fh, '>', "$expanded/.duplicity-ignore"; close $touch_fh; foreach my $mbox (glob "$mboxes/*.gz") { # $mbox might be a dangling symlink on this machine next unless -e $mbox; my (undef, undef, $name) = splitpath($mbox); $name =~ s/\.gz$//; expand_mbox($mbox, catfile($expanded, $name)); }