2020-12-04 14:56:09 +01:00
|
|
|
#!/bin/sh
|
2021-03-16 12:10:07 +01:00
|
|
|
export USER="$(whoami)"
|
|
|
|
export HOME=/home/"$USER"
|
|
|
|
export DISPLAY=":0"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-12-04 14:56:09 +01:00
|
|
|
# Split outbox emails
|
2021-03-17 09:59:47 +01:00
|
|
|
mlist -d /data/mail/outbox | mpick -t 'from =~~ "posteo"' | mflag -F | mrefile /data/mail/posteo/Sent
|
|
|
|
mlist -d /data/mail/outbox | mpick -t 'from =~~ "ugent"' | mflag -F | mrefile /data/mail/ugent/Sent
|
|
|
|
mlist -d /data/mail/outbox | mpick -t 'from =~~ "gmail"' | mflag -F | mrefile /data/mail/gmail/Sent
|
2020-12-04 14:56:09 +01:00
|
|
|
|
2021-03-16 12:10:07 +01:00
|
|
|
# check for internet connection
|
|
|
|
ip route ls | grep -q '.'
|
|
|
|
|
|
|
|
# check if the gpg-agent is running
|
|
|
|
pgrep gpg-agent > /dev/null
|
2020-12-13 00:38:48 +01:00
|
|
|
|
2020-12-04 14:56:09 +01:00
|
|
|
# Sync email
|
2022-01-04 00:27:11 +01:00
|
|
|
mbsync -a -q || true
|
2020-12-04 14:56:09 +01:00
|
|
|
|
|
|
|
# No further processing if there are no new mails
|
|
|
|
if ! mdirs /data/mail | mlist -N | grep -q .; then
|
2021-03-16 12:10:07 +01:00
|
|
|
exec sleep 1m
|
2020-12-04 14:56:09 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Incorporate new mails and store them in the temp sequence
|
2021-03-16 10:47:31 +01:00
|
|
|
s="$(mktemp)"
|
2021-03-17 09:59:47 +01:00
|
|
|
trap "rm '$s'" EXIT KILL
|
2021-03-16 10:47:31 +01:00
|
|
|
minc $(mdirs /data/mail) > "$s"
|
2020-12-04 14:56:09 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
# Ignores
|
2021-03-16 10:47:31 +01:00
|
|
|
mpick -t 'to =~ "unipept@ugent.be" && subject ~~ "*Mysql2::Error::ConnectionError*"' < "$s"
|
2021-04-26 13:40:19 +02:00
|
|
|
mpick -t 'to =~ "unipept@ugent.be" && subject =~ "elixir_logo.*not present"' < "$s"
|
2021-05-24 15:03:20 +02:00
|
|
|
mpick -t 'to =~ "unipept@ugent.be" && subject ~~ "*ActiveRecord::NoDatabaseError*Unknown database *unipept*"' < "$s"
|
2021-03-16 10:47:31 +01:00
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && from =~ "logcheck system account"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "A request took"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "Onderwijsinstelling aangemaakt voor"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "Een gebruiker kon niet inloggen"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "Invalid or unknown LTI provider"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "Faraday::ConnectionFailed"' < "$s"
|
|
|
|
mpick -t 'to =~ "dodona@ugent.be" && subject =~ "internal error"' < "$s" \
|
2021-04-26 13:40:19 +02:00
|
|
|
| xargs rg --files-without-match 'judge=>"(java12|haskell|biopythia)"'
|
2021-03-16 10:47:31 +01:00
|
|
|
mpick -t 'subject =~ "\[hackers\] \[slstatus\]"' < "$s"
|
2021-04-26 13:40:19 +02:00
|
|
|
mpick -t 'subject =~ "\[hackers\] \[svkdb\]"' < "$s"
|
2021-05-06 23:59:42 +02:00
|
|
|
mpick -t 'subject ~~ "*Bump * from * to *" && "cc" !~~ "Felix*"' < "$s"
|
2021-10-13 17:16:03 +02:00
|
|
|
mpick -t 'from =~ "dodona@ugent.be" && subject ~~ "* vraagt om lesgeversrechten"' < "$s"
|
|
|
|
mpick -t 'from =~ "dodona@ugent.be" && subject ~~ "* Je vraag naar lesgeversrechten werd goedgekeurd"' < "$s"
|
|
|
|
mpick -t 'from =~ "dodona@ugent.be" && subject ~~ "* Your request for teacher rights was granted"' < "$s"
|
2020-12-04 14:56:09 +01:00
|
|
|
|
|
|
|
# Muted mails
|
|
|
|
for muted in $(cat ~/.mblaze/muted); do
|
2021-03-16 10:47:31 +01:00
|
|
|
mpick -t '"references" =~~ "'"$muted"'"' < "$s"
|
2020-12-04 14:56:09 +01:00
|
|
|
done
|
2021-03-16 12:10:07 +01:00
|
|
|
} | sort | uniq | mflag -Sf > /dev/null
|
2020-12-04 14:56:09 +01:00
|
|
|
|
|
|
|
# Clear muted sequence
|
|
|
|
#mseq -f < ~/.mblaze/muted | mpick -t 'date < "'"$(date -I -d '1 month ago')"'"' | sponge ~/.mblaze/muted
|