Browse Source

Public and private email folders

jessie
Bob Mottram 6 years ago
parent
commit
f3fdfab0a1
  1. BIN
      man/freedombone-addemail.1.gz
  2. BIN
      man/freedombone-addlist.1.gz
  3. 25
      src/freedombone-addemail
  4. 26
      src/freedombone-addlist

BIN
man/freedombone-addemail.1.gz

Binary file not shown.

BIN
man/freedombone-addlist.1.gz

Binary file not shown.

25
src/freedombone-addemail

@ -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,15 +93,27 @@ 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
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
# 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
echo "$LISTDIR/new" >> $PM
echo "# End of rule" >> $PM
else
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

26
src/freedombone-addlist

@ -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,8 @@ 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
@ -110,8 +116,20 @@ $LISTDIR/new
"
echo "$filter" >> $PM
else
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
# public emails are copied before hte encryption stage
if ! grep -q '# encrypt' $PM; then
filter="
# Email rule for $MAILINGLIST subject [$SUBJECTTAG]
:0
* ^Subject:.*()\[$SUBJECTTAG\]
$LISTDIR/new
# End of rule
"
echo "$filter" >> $PM
else
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

Loading…
Cancel
Save