move astroid config to separate folder
This commit is contained in:
103
astroid/scripts/move-tag.sh
Executable file
103
astroid/scripts/move-tag.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script moves tagged mails to their respective folders if they are still lying around in INBOX
|
||||
# It also moved mails tagged with "del" to the Trash folder, "archive" to Archive, and "spam" to Spam folder
|
||||
|
||||
CURDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
CSV="$CURDIR"/tag-list.csv # Table of tags/folders
|
||||
MAILDIR="$HOME/Mails/FSFE" # Maildir
|
||||
TRASHTAG="del" # Tag of trashed mails
|
||||
TRASHFOL="Trash" # Trash bin folder
|
||||
SPAMTAG="spam" # Tag of spam mails
|
||||
SPAMFOL="INBOX.Junk" # Spam folder
|
||||
ARCHTAG="archive" # Archive tag
|
||||
ARCHFOL="ARCHIVE" # Archive folder
|
||||
LOG="$CURDIR"/move-tag.log # Location of logfile
|
||||
USETAGS="P\.[[:alnum:]]+?|org-de|staff|ticket|del|spam|archive" # List of tags which shall be moved
|
||||
THREADTAG="P\.[[:alnum:]]+?|org-de|staff|ticket" # List of tags for which single, but connected messages in INBOX shall be tagged
|
||||
|
||||
BLACKLIST=
|
||||
touch "$LOG" # Create logfile or update time stamp
|
||||
|
||||
|
||||
function pdate {
|
||||
DATE=$(date +%y-%m-%d_%H:%M:%S)
|
||||
echo "[$DATE]"
|
||||
}
|
||||
|
||||
function logrun {
|
||||
# Write command itself to log, and pipe errors to log
|
||||
echo "$(pdate) $@" >> "$LOG"
|
||||
eval "$@" 2>> "$LOG"
|
||||
}
|
||||
|
||||
while read line; do
|
||||
TAG=$(echo $line | cut -d";" -f1)
|
||||
FOL=$(echo $line | cut -d";" -f2)
|
||||
|
||||
if ! $(echo $BLACKLIST | grep -q "$TAG,") && $(echo $TAG | grep -qE "$USETAGS"); then
|
||||
BLACKLIST="$TAG,$BLACKLIST" # Add current tag to list of tags which do not have to be searched for another time
|
||||
|
||||
# TRASH tag "del"
|
||||
if [ "$TAG" = "$TRASHTAG" ]; then
|
||||
HITFILES=$(notmuch search --output=files --exclude=false tag:$TRASHTAG and not path:$TRASHFOL/**) # Files which are tagged with "del" but not in Trash bin
|
||||
FOL="$TRASHFOL" # Set destination folder to Trash
|
||||
|
||||
# SPAM tag "spam"
|
||||
elif [ "$TAG" = "$SPAMTAG" ]; then
|
||||
HITFILES=$(notmuch search --output=files --exclude=false tag:$SPAMTAG and not path:$SPAMFOL/**) # Files which are tagged with "spam" but not in Spam folder
|
||||
FOL="$SPAMFOL" # Set destination folder to INBOX.Junk
|
||||
|
||||
# ARCHIVE tag "archive"
|
||||
elif [ "$TAG" = "$ARCHTAG" ]; then
|
||||
HITFILES=$(notmuch search --output=files --exclude=false tag:$ARCHTAG and not path:$ARCHFOL/**) # Files which are tagged with "archive" but not in ARCHIVE folder
|
||||
# Folder will be derived from the current position later
|
||||
|
||||
# DEFAULT
|
||||
else
|
||||
# For some tags, also tag its threads
|
||||
if $(echo $TAG | grep -qE "$THREADTAG"); then
|
||||
# If one file is tagged (except del, spam, archive), also tag the other mails of its thread respectively, IF they are located in INBOX [TODO: is this the best approach?]. Only then they can be moved by this script
|
||||
|
||||
# 1. Get thread ids of all entries with the searched tag
|
||||
THREADS=$(notmuch search --exclude=false tag:$TAG and date:$(date -d "-2 months" +%Y-%m-%d)..$(date -d "+1 year" +%Y-%m-%d) | cut -d" " -f1 | cut -d":" -f2)
|
||||
|
||||
# 2. Get message ids of all messages in these threads
|
||||
MID=
|
||||
for t in $THREADS; do
|
||||
MID="$MID "$(notmuch search --output=messages --exclude=false thread:$t)
|
||||
# MID consists of many something like "id:5XXX0CD1.305516@fsfe.org"
|
||||
done
|
||||
|
||||
# 3. Tag all message ids of messages which are still in INBOX
|
||||
for m in $MID; do
|
||||
if $(notmuch search --exclude=false --output=files "$m" | grep -q "$MAILDIR/INBOX"); then
|
||||
logrun notmuch tag +"$TAG" -- "$m"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Search for these lone messages in INBOX
|
||||
HITFILES=$(notmuch search --output=files --exclude=false path:INBOX/** and tag:$TAG | grep "$MAILDIR/INBOX")
|
||||
fi
|
||||
|
||||
# Move files to their destination folders
|
||||
for m in $HITFILES; do
|
||||
|
||||
# Destination folder is derived from the current location
|
||||
if [ "$TAG" = "$ARCHTAG" ]; then
|
||||
SUBFOL=$(echo $m | sed -E "s|($MAILDIR)/(.+?)/cur/.*|\2|g")
|
||||
FOL="$ARCHFOL/$SUBFOL"
|
||||
fi
|
||||
DESTFOL="$MAILDIR/$FOL/cur"
|
||||
if [ ! -e "$DESTFOL" ]; then
|
||||
logrun mkdir -p "$DESTFOL"
|
||||
#logrun echo "mkdir -p" "$DESTFOL"
|
||||
fi
|
||||
logrun mv "$m" "$DESTFOL"
|
||||
#logrun echo "mv" "$m" "$DESTFOL"
|
||||
done
|
||||
fi
|
||||
|
||||
done < "$CSV"
|
||||
40
astroid/scripts/tag-folder-rules.sh
Executable file
40
astroid/scripts/tag-folder-rules.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
notmuch tag +P.clt -- path:Aktionen.CLT/**
|
||||
notmuch tag +P.rd -- path:Aktionen.Funkrichtlinie/**
|
||||
notmuch tag +P.rd -- path:Aktionen.FCC/**
|
||||
notmuch tag +ML -- path:Aktionen.FCC/**
|
||||
notmuch tag +P.rd -- path:Aktionen.Funkrichtlinie.Battlemesh/**
|
||||
notmuch tag +ML -- path:Aktionen.Funkrichtlinie.Battlemesh/**
|
||||
notmuch tag +P.froscon -- path:Aktionen.FrOSCon/**
|
||||
notmuch tag +P.fundraising -- path:Aktionen.Fundraising/**
|
||||
notmuch tag +P.ilovefs -- path:Aktionen.IloveFS/**
|
||||
notmuch tag +P.pm -- path:Aktionen.PublicMoney/**
|
||||
notmuch tag +P.rz -- path:Aktionen.Routerzwang/**
|
||||
notmuch tag +P.fosdem -- path:Aktionen.FOSDEM/**
|
||||
notmuch tag +P.ccc -- path:Aktionen.CCC/**
|
||||
notmuch tag +P.orr -- path:Aktionen.OpenRR/**
|
||||
notmuch tag +draft -- path:Drafts/**
|
||||
notmuch tag +android -- path:Lists.Android/**
|
||||
notmuch tag +coord -- path:Lists.Coordinators/**
|
||||
notmuch tag +de -- path:Lists.DACH/**
|
||||
notmuch tag +org-de -- path:Lists.DACH.Coord/**
|
||||
notmuch tag +de -- path:Lists.DACH.Coord/**
|
||||
notmuch tag +discuss -- path:Lists.Discussion/**
|
||||
notmuch tag +eufoss -- path:Lists.FOSS-Policy/**
|
||||
notmuch tag +fsfede -- path:Lists.FSFE-de/**
|
||||
notmuch tag +rheinland -- path:Lists.Rheinland/**
|
||||
notmuch tag +suedde -- path:Lists.Sueddeutschland/**
|
||||
notmuch tag +syshackers -- path:Lists.SystemHackers/**
|
||||
notmuch tag +team -- path:Lists.Team/**
|
||||
notmuch tag +trans -- path:Lists.Translators/**
|
||||
notmuch tag +web -- path:Lists.Web/**
|
||||
notmuch tag +legal-licence -- path:Lists.Legal.Licence/**
|
||||
notmuch tag +press -- path:Press-FSFE/**
|
||||
notmuch tag +press -- path:Press-FSFE.Draft/**
|
||||
notmuch tag +press -- path:Press-FSFE.Inquiry/**
|
||||
notmuch tag +staff -- path:Staff/**
|
||||
notmuch tag +ticket -- path:Staff.Tickets/**
|
||||
notmuch tag +git -- path:Git/**
|
||||
notmuch tag +spam -- path:INBOX.Junk/**
|
||||
notmuch tag +del -- path:Trash/**
|
||||
notmuch tag +archive -- path:ARCHIVE/**
|
||||
notmuch tag +de-outreach -- path:Lists.Outreach-de/**
|
||||
28
astroid/scripts/tag-folder.sh
Executable file
28
astroid/scripts/tag-folder.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
CSV=$CURDIR/tag-list.csv
|
||||
OUT=$CURDIR/tag-folder-rules.sh
|
||||
|
||||
> $OUT # reset
|
||||
|
||||
function notmuch_rule {
|
||||
F_TAG=$1
|
||||
F_FOL=$2
|
||||
|
||||
echo "notmuch tag +${F_TAG} -- path:${F_FOL}/**"
|
||||
}
|
||||
|
||||
while read line; do
|
||||
|
||||
TAG=$(echo $line | cut -d";" -f1)
|
||||
FOL=$(echo $line | cut -d";" -f2)
|
||||
|
||||
NOTAG=$(echo $TAG | grep -o "," | wc -l)
|
||||
NOTAG=$(expr $NOTAG + 1)
|
||||
for ((i = 1; i <= $NOTAG; i++)); do
|
||||
notmuch_rule $(echo $TAG | cut -d"," -f${i}) $FOL >> $OUT
|
||||
done
|
||||
|
||||
done < "$CSV"
|
||||
37
astroid/scripts/tag-list.csv
Normal file
37
astroid/scripts/tag-list.csv
Normal file
@@ -0,0 +1,37 @@
|
||||
P.clt;Aktionen.CLT
|
||||
P.rd;Aktionen.Funkrichtlinie
|
||||
P.rd,ML;Aktionen.FCC
|
||||
P.rd,ML;Aktionen.Funkrichtlinie.Battlemesh
|
||||
P.froscon;Aktionen.FrOSCon
|
||||
P.fundraising;Aktionen.Fundraising
|
||||
P.ilovefs;Aktionen.IloveFS
|
||||
P.pm;Aktionen.PublicMoney
|
||||
P.rz;Aktionen.Routerzwang
|
||||
P.fosdem;Aktionen.FOSDEM
|
||||
P.ccc;Aktionen.CCC
|
||||
P.orr;Aktionen.OpenRR
|
||||
draft;Drafts
|
||||
android;Lists.Android
|
||||
coord;Lists.Coordinators
|
||||
de;Lists.DACH
|
||||
org-de,de;Lists.DACH.Coord
|
||||
discuss;Lists.Discussion
|
||||
eufoss;Lists.FOSS-Policy
|
||||
fsfede;Lists.FSFE-de
|
||||
rheinland;Lists.Rheinland
|
||||
suedde;Lists.Sueddeutschland
|
||||
syshackers;Lists.SystemHackers
|
||||
team;Lists.Team
|
||||
trans;Lists.Translators
|
||||
web;Lists.Web
|
||||
legal-licence;Lists.Legal.Licence
|
||||
press;Press-FSFE
|
||||
press;Press-FSFE.Draft
|
||||
press;Press-FSFE.Inquiry
|
||||
staff;Staff
|
||||
ticket;Staff.Tickets
|
||||
git;Git
|
||||
spam;INBOX.Junk
|
||||
del;Trash
|
||||
archive;ARCHIVE
|
||||
de-outreach;Lists.Outreach-de
|
||||
|
28
astroid/scripts/tag-thread.sh
Executable file
28
astroid/scripts/tag-thread.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
CSV=$CURDIR/tag-list.csv
|
||||
OUT=$CURDIR/tag-thread-rules.sh
|
||||
|
||||
> $OUT # reset
|
||||
|
||||
function notmuch_rule {
|
||||
F_TAG=$1
|
||||
F_FOL=$2
|
||||
|
||||
echo "notmuch tag +${F_TAG} -- thread:${F_FOL}/**"
|
||||
}
|
||||
|
||||
while read line; do
|
||||
|
||||
TAG=$(echo $line | cut -d";" -f1)
|
||||
FOL=$(echo $line | cut -d";" -f2)
|
||||
|
||||
NOTAG=$(echo $TAG | grep -o "," | wc -l)
|
||||
NOTAG=$(expr $NOTAG + 1)
|
||||
for ((i = 1; i <= $NOTAG; i++)); do
|
||||
notmuch_rule $(echo $TAG | cut -d"," -f${i}) $FOL >> $OUT
|
||||
done
|
||||
|
||||
done < "$CSV"
|
||||
Reference in New Issue
Block a user