#!/bin/bash # # Simple wrapper around getmail to fetch from all active accounts. # Alternative to the getmails(1) wrapper. # # Supports different config folders, including configurations stored # in subfolders of $HOME/.config/getmail. # # See http://pyropus.ca/software/getmail/configuration.html#running-commandline-options # # Parameters BASE_FOLDER="$HOME/.config/getmail" CONFIG_FOLDER="${1:-$BASE_FOLDER}" METADATA_FOLDER="$BASE_FOLDER/.metadata" GETMAIL="/usr/bin/getmail" # Check if [ ! -d "$CONFIG_FOLDER" ]; then exit fi # Metadata is stored in a separate folder mkdir -p $METADATA_FOLDER # Dispatch, block version #find $CONFIG_FOLDER -type f | grep -v 'oldmail-' | grep '@' | grep -v '.disabled$' | while read config; do # # Metadata is stored on each folder # folder="`dirname $config`" # $GETMAIL -g$folder --rcfile $config #done # Dispatch, old oneliner version #ls -1 $CONFIG_FOLDER | grep -v '^oldmail-' | grep '@' | grep -v '.disabled$' | xargs echo | sed -e 's/ / --rcfile /g' | xargs $GETMAIL -g$CONFIG_FOLDER --rcfile # Dispatch, new oneliner version, recursive and with data stored in the main folder #find $CONFIG_FOLDER -type f | grep -v 'oldmail-' | grep '@' | grep -v '.disabled$' | xargs echo | sed -e 's/ / --rcfile /g' | xargs $GETMAIL -g$CONFIG_FOLDER --rcfile # Dispatch, new oneliner version, recursive and with data stored in the metadata folder find $CONFIG_FOLDER -type f | grep -v 'oldmail-' | grep '@' | grep -v '.disabled$' | xargs echo | sed -e 's/ / --rcfile /g' | xargs $GETMAIL -g$METADATA_FOLDER --rcfile