diff --git a/src/freedombone-archive-mail b/src/freedombone-archive-mail index c746244b..bfdb3064 100755 --- a/src/freedombone-archive-mail +++ b/src/freedombone-archive-mail @@ -50,9 +50,16 @@ for d in /home/*/ ; do # add the archive to .muttrc if needed if [ -f $MUTTRC ]; then MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC) - BACKUP_DIRECTORY=archive-$(date +"%Y") + YR=$(date +"%Y") + PREV_YR=$((YR - 1)) + BACKUP_DIRECTORY=archive-$YR + PREV_BACKUP_DIRECTORY=archive-$PREV_YR if [[ $MUTT_MAILBOXES != *$BACKUP_DIRECTORY* ]]; then - sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$BACKUP_DIRECTORY|g" $MUTTRC + if [[ $MUTT_MAILBOXES == *$PREV_BACKUP_DIRECTORY* ]]; then + sed -i "s|$PREV_BACKUP_DIRECTORY|$PREV_BACKUP_DIRECTORY =$BACKUP_DIRECTORY|g" $MUTTRC + else + sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$BACKUP_DIRECTORY|g" $MUTTRC + fi chown $USERNAME:$USERNAME $MUTTRC fi fi