Public and private email folders

This commit is contained in:
Bob Mottram 2016-02-11 12:12:35 +00:00
parent 604b83cfa6
commit f3fdfab0a1
4 changed files with 43 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -37,10 +37,11 @@ export TEXTDOMAINDIR="/usr/share/locale"
MYUSERNAME=$USER
EMAILADDRESS=
GROUP_NAME=
PUBLIC='no'
function show_help {
echo ''
echo $"${PROJECT_NAME}-addemail -u [username] -e [email address] -g [group name]"
echo $"${PROJECT_NAME}-addemail -u [username] -e [email address] -g [group name] --public [yes|no]"
echo ''
exit 0
}
@ -65,6 +66,10 @@ case $key in
shift
GROUP_NAME="$1"
;;
-p|--public)
shift
PUBLIC="$1"
;;
*)
# unknown option
;;
@ -88,7 +93,18 @@ if [ ! -d "$LISTDIR" ]; then
fi
chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
if ! grep -q "Email rule for $EMAILADDRESS -> $GROUP_NAME" $PM; then
if ! grep -q "\# encrypt" $PM; then
if [[ $PUBLIC != "yes" ]]; then
# private emails go after the encryption stage
echo '' >> $PM
echo "# Email rule for $EMAILADDRESS -> $GROUP_NAME" >> $PM
echo ":0" >> $PM
echo " * ^From:.*$EMAILADDRESS" >> $PM
echo "$LISTDIR/new" >> $PM
echo "# End of rule" >> $PM
else
# public emails are copied before hte encryption stage
if ! grep -q '# encrypt' $PM; then
echo '' >> $PM
echo "# Email rule for $EMAILADDRESS -> $GROUP_NAME" >> $PM
echo ":0" >> $PM
echo " * ^From:.*$EMAILADDRESS" >> $PM
@ -98,6 +114,7 @@ if ! grep -q "Email rule for $EMAILADDRESS -> $GROUP_NAME" $PM; then
filter=$(echo "# Email rule for $EMAILADDRESS -> $GROUP_NAME\n:0\n * ^From:.*$EMAILADDRESS\n$LISTDIR/new\n# End of rule\n")
sed -i "/# encrypt/i ${filter}" $PM
fi
fi
chown $MYUSERNAME:$MYUSERNAME $PM
fi
if [ ! -f "$MUTTRC" ]; then

View File

@ -38,10 +38,11 @@ MYUSERNAME=$USER
MAILINGLIST=
SUBJECTTAG=
LIST_ADDRESS=
PUBLIC='yes'
function show_help {
echo ''
echo $"${PROJECT_NAME}-addlist -u [username] -l [mailing list name] -s [subject tag] -e [list email address]"
echo $"${PROJECT_NAME}-addlist -u [username] -l [mailing list name] -s [subject tag] -e [list email address] --public [yes|no]"
echo ''
exit 0
}
@ -70,6 +71,10 @@ case $key in
shift
LIST_ADDRESS="$1"
;;
-p|--public)
shift
PUBLIC="$1"
;;
*)
# unknown option
;;
@ -100,7 +105,19 @@ fi
chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then
if ! grep -q "\# encrypt" $PM; then
if [[ $PUBLIC != "yes" ]]; then
# private emails go after the encryption stage
filter="
# Email rule for $MAILINGLIST subject [$SUBJECTTAG]
:0
* ^Subject:.*()\[$SUBJECTTAG\]
$LISTDIR/new
# End of rule
"
echo "$filter" >> $PM
else
# public emails are copied before hte encryption stage
if ! grep -q '# encrypt' $PM; then
filter="
# Email rule for $MAILINGLIST subject [$SUBJECTTAG]
:0
@ -113,6 +130,7 @@ $LISTDIR/new
filter=$(echo "# Email rule for $MAILINGLIST subject [$SUBJECTTAG]\n:0\n * ^Subject:.*()\\\[$SUBJECTTAG\\\]\n$LISTDIR/new\n# End of rule\n")
sed -i "/# encrypt/i ${filter}" $PM
fi
fi
chown $MYUSERNAME:$MYUSERNAME $PM
fi