2017-04-13 12:28:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2018-07-05 17:55:29 +02:00
|
|
|
start=`date +%s`
|
|
|
|
|
|
2017-04-13 12:28:53 +02:00
|
|
|
CURDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
|
|
|
TMP=/tmp/status
|
|
|
|
|
source "$TMP"
|
|
|
|
|
|
|
|
|
|
# If offline mode, do a quick sync
|
|
|
|
|
if [ "$var_conn" == "off" ]; then
|
|
|
|
|
echo "[INFO] Offline mode enabled. Do a quick sync"
|
|
|
|
|
offlineimap -q
|
|
|
|
|
else
|
2017-05-10 20:41:00 +02:00
|
|
|
echo "[INFO] Do a normal sync."
|
2017-04-13 12:28:53 +02:00
|
|
|
offlineimap
|
|
|
|
|
fi
|
2018-02-05 17:50:17 +01:00
|
|
|
|
2018-07-05 17:55:29 +02:00
|
|
|
sync=`date +%s`
|
|
|
|
|
|
2018-02-05 17:50:17 +01:00
|
|
|
# Index new mails which will be tagged with notmuch's new.tags
|
2017-05-10 20:41:00 +02:00
|
|
|
echo "[DEBUG] Sync notmuch database with new mails"
|
2017-04-13 12:28:53 +02:00
|
|
|
notmuch new
|
|
|
|
|
|
2018-02-05 17:50:17 +01:00
|
|
|
# Move selectedly tagged mails to folders if they are only in INBOX
|
|
|
|
|
echo "[DEBUG] Move tagged mails in INBOX to folders (move-tag.sh)"
|
|
|
|
|
bash $CURDIR/scripts/move-tag.sh ${var_conn}
|
|
|
|
|
|
|
|
|
|
# Index again after mails have been moved
|
|
|
|
|
echo "[DEBUG] Update notmuch database with possibly moved mails"
|
|
|
|
|
notmuch new
|
2017-04-13 12:28:53 +02:00
|
|
|
|
|
|
|
|
### Sort emails
|
|
|
|
|
|
|
|
|
|
# Archiv
|
2017-05-10 20:41:00 +02:00
|
|
|
echo "[DEBUG] Tag mails in offline ARCHIVE folder"
|
2017-04-13 12:28:53 +02:00
|
|
|
notmuch tag +archive -- path:ARCHIVE/**
|
|
|
|
|
|
2017-11-14 14:11:11 +01:00
|
|
|
# Inbox
|
|
|
|
|
echo "[DEBUG] Tag mails in in INBOX folder"
|
|
|
|
|
notmuch tag +inbox -- path:INBOX/**
|
|
|
|
|
|
2017-04-13 12:28:53 +02:00
|
|
|
# Automatic tagging based on location of mails in folders
|
2017-08-18 13:29:46 +02:00
|
|
|
echo "[DEBUG] Tag mails based on their folder (tag-folder.sh)"
|
2017-04-13 12:28:53 +02:00
|
|
|
bash $CURDIR/scripts/tag-folder.sh # generates commands from tag-folder.csv
|
|
|
|
|
bash $CURDIR/scripts/tag-folder-rules.sh # executes generated commands
|
2017-05-10 20:41:00 +02:00
|
|
|
|
2017-08-18 13:29:46 +02:00
|
|
|
# Mark mails in certain folders read
|
|
|
|
|
echo "[DEBUG] Mark mails in trash folders read"
|
|
|
|
|
notmuch tag -unread -- path:Trash/**
|
|
|
|
|
notmuch tag -unread -- path:Trash.ignore-mod/**
|
|
|
|
|
|
2018-02-19 09:11:57 +01:00
|
|
|
# Remove "new" tag
|
|
|
|
|
echo "[DEBUG] Remove the 'new' tag"
|
|
|
|
|
notmuch tag -new -- tag:new
|
2017-08-18 13:29:46 +02:00
|
|
|
|
2018-07-05 17:55:29 +02:00
|
|
|
end=`date +%s`
|
|
|
|
|
echo "[DEBUG] poll.sh exited after $((end-start))s ($((sync-start))s download)"
|