Command for adding a mailing list rule
This commit is contained in:
parent
9901cdcbb4
commit
4b4fb4e5e5
4
Makefile
4
Makefile
|
@ -17,6 +17,7 @@ install:
|
||||||
install -m 755 src/${APP}-config ${DESTDIR}${PREFIX}/bin
|
install -m 755 src/${APP}-config ${DESTDIR}${PREFIX}/bin
|
||||||
install -m 755 src/${APP}-sec ${DESTDIR}${PREFIX}/bin
|
install -m 755 src/${APP}-sec ${DESTDIR}${PREFIX}/bin
|
||||||
install -m 755 src/${APP}-addcert ${DESTDIR}${PREFIX}/bin
|
install -m 755 src/${APP}-addcert ${DESTDIR}${PREFIX}/bin
|
||||||
|
install -m 755 src/${APP}-addlist ${DESTDIR}${PREFIX}/bin
|
||||||
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
|
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
install -m 644 man/${APP}-prep.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/${APP}-prep.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
|
@ -25,6 +26,7 @@ install:
|
||||||
install -m 644 man/${APP}-config.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/${APP}-config.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
install -m 644 man/${APP}-sec.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/${APP}-sec.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
install -m 644 man/${APP}-addcert.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
install -m 644 man/${APP}-addcert.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
|
install -m 644 man/${APP}-addlist.1.gz ${DESTDIR}${PREFIX}/share/man/man1
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f ${PREFIX}/share/man/man1/${APP}.1.gz
|
rm -f ${PREFIX}/share/man/man1/${APP}.1.gz
|
||||||
rm -f ${PREFIX}/share/man/man1/${APP}-prep.1.gz
|
rm -f ${PREFIX}/share/man/man1/${APP}-prep.1.gz
|
||||||
|
@ -33,6 +35,7 @@ uninstall:
|
||||||
rm -f ${PREFIX}/share/man/man1/${APP}-config.1.gz
|
rm -f ${PREFIX}/share/man/man1/${APP}-config.1.gz
|
||||||
rm -f ${PREFIX}/share/man/man1/${APP}-sec.1.gz
|
rm -f ${PREFIX}/share/man/man1/${APP}-sec.1.gz
|
||||||
rm -f ${PREFIX}/share/man/man1/${APP}-addcert.1.gz
|
rm -f ${PREFIX}/share/man/man1/${APP}-addcert.1.gz
|
||||||
|
rm -f ${PREFIX}/share/man/man1/${APP}-addlist.1.gz
|
||||||
rm -rf ${PREFIX}/share/${APP}
|
rm -rf ${PREFIX}/share/${APP}
|
||||||
rm -f ${PREFIX}/bin/${APP}
|
rm -f ${PREFIX}/bin/${APP}
|
||||||
rm -f ${PREFIX}/bin/${APP}-prep
|
rm -f ${PREFIX}/bin/${APP}-prep
|
||||||
|
@ -41,6 +44,7 @@ uninstall:
|
||||||
rm -f ${PREFIX}/bin/${APP}-config
|
rm -f ${PREFIX}/bin/${APP}-config
|
||||||
rm -f ${PREFIX}/bin/${APP}-sec
|
rm -f ${PREFIX}/bin/${APP}-sec
|
||||||
rm -f ${PREFIX}/bin/${APP}-addcert
|
rm -f ${PREFIX}/bin/${APP}-addcert
|
||||||
|
rm -f ${PREFIX}/bin/${APP}-addlist
|
||||||
clean:
|
clean:
|
||||||
rm -f \#* \.#* debian/*.substvars debian/*.log
|
rm -f \#* \.#* debian/*.substvars debian/*.log
|
||||||
rm -fr deb.* debian/${APP}
|
rm -fr deb.* debian/${APP}
|
||||||
|
|
|
@ -5,3 +5,4 @@ man/freedombone-remote.1.gz
|
||||||
man/freedombone-config.1.gz
|
man/freedombone-config.1.gz
|
||||||
man/freedombone-sec.1.gz
|
man/freedombone-sec.1.gz
|
||||||
man/freedombone-addcert.1.gz
|
man/freedombone-addcert.1.gz
|
||||||
|
man/freedombone-addlist.1.gz
|
||||||
|
|
Binary file not shown.
|
@ -5887,66 +5887,6 @@ function email_archiving {
|
||||||
echo 'email_archiving' >> $COMPLETION_FILE
|
echo 'email_archiving' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
function folders_for_mailing_lists {
|
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_NONMAILBOX" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if grep -Fxq "folders_for_mailing_lists" $COMPLETION_FILE; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
echo '#!/bin/bash' > /usr/bin/addmailinglist
|
|
||||||
echo 'MYUSERNAME=$1' >> /usr/bin/addmailinglist
|
|
||||||
echo 'MAILINGLIST=$2' >> /usr/bin/addmailinglist
|
|
||||||
echo 'SUBJECTTAG=$3' >> /usr/bin/addmailinglist
|
|
||||||
echo 'MUTTRC=/home/$MYUSERNAME/.muttrc' >> /usr/bin/addmailinglist
|
|
||||||
echo 'PM=/home/$MYUSERNAME/.procmailrc' >> /usr/bin/addmailinglist
|
|
||||||
echo 'LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo '# Exit if the list was already added' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if grep -q "=$MAILINGLIST" $MUTTRC; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' exit 1' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if ! [[ $MYUSERNAME && $MAILINGLIST && $SUBJECTTAG ]]; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' echo "addmailinglist [user name] [mailing list name] [subject tag]"' >> /usr/bin/addmailinglist
|
|
||||||
echo ' exit 1' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if [ ! -d "$LISTDIR" ]; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' mkdir -m 700 $LISTDIR' >> /usr/bin/addmailinglist
|
|
||||||
echo ' mkdir -m 700 $LISTDIR/tmp' >> /usr/bin/addmailinglist
|
|
||||||
echo ' mkdir -m 700 $LISTDIR/new' >> /usr/bin/addmailinglist
|
|
||||||
echo ' mkdir -m 700 $LISTDIR/cur' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR' >> /usr/bin/addmailinglist
|
|
||||||
echo 'echo "" >> $PM' >> /usr/bin/addmailinglist
|
|
||||||
echo 'echo ":0" >> $PM' >> /usr/bin/addmailinglist
|
|
||||||
echo 'echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM' >> /usr/bin/addmailinglist
|
|
||||||
echo 'echo "$LISTDIR/new" >> $PM' >> /usr/bin/addmailinglist
|
|
||||||
echo 'chown $MYUSERNAME:$MYUSERNAME $PM' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if [ ! -f "$MUTTRC" ]; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' cp /etc/Muttrc $MUTTRC' >> /usr/bin/addmailinglist
|
|
||||||
echo ' chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'PROCMAILLOG=/home/$MYUSERNAME/log' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if [ ! -d $PROCMAILLOG ]; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' mkdir $PROCMAILLOG' >> /usr/bin/addmailinglist
|
|
||||||
echo ' chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo '' >> /usr/bin/addmailinglist
|
|
||||||
echo 'MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC)' >> /usr/bin/addmailinglist
|
|
||||||
echo 'if [[ $MUTT_MAILBOXES != *$MAILINGLIST* ]]; then' >> /usr/bin/addmailinglist
|
|
||||||
echo ' sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$MAILINGLIST|g" $MUTTRC' >> /usr/bin/addmailinglist
|
|
||||||
echo ' chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/addmailinglist
|
|
||||||
echo 'fi' >> /usr/bin/addmailinglist
|
|
||||||
echo 'exit 0' >> /usr/bin/addmailinglist
|
|
||||||
chmod +x /usr/bin/addmailinglist
|
|
||||||
echo 'folders_for_mailing_lists' >> $COMPLETION_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure that the from field is correct when sending email from Mutt
|
# Ensure that the from field is correct when sending email from Mutt
|
||||||
function email_from_address {
|
function email_from_address {
|
||||||
if grep -Fxq "email_from_address" $COMPLETION_FILE; then
|
if grep -Fxq "email_from_address" $COMPLETION_FILE; then
|
||||||
|
@ -6109,7 +6049,7 @@ function create_public_mailing_list {
|
||||||
echo "cleartext email to $PUBLIC_MAILING_LIST+subscribe@$DEFAULT_DOMAIN_NAME" >> /home/$MY_USERNAME/README
|
echo "cleartext email to $PUBLIC_MAILING_LIST+subscribe@$DEFAULT_DOMAIN_NAME" >> /home/$MY_USERNAME/README
|
||||||
fi
|
fi
|
||||||
|
|
||||||
addmailinglist $MY_USERNAME "$PUBLIC_MAILING_LIST" "$PUBLIC_MAILING_LIST"
|
freedombone-addlist -u $MY_USERNAME -l "$PUBLIC_MAILING_LIST" -s "$PUBLIC_MAILING_LIST"
|
||||||
|
|
||||||
echo 'create_public_mailing_list' >> $COMPLETION_FILE
|
echo 'create_public_mailing_list' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
@ -9012,7 +8952,6 @@ email_client
|
||||||
email_archiving
|
email_archiving
|
||||||
email_from_address
|
email_from_address
|
||||||
configure_firewall_for_email
|
configure_firewall_for_email
|
||||||
folders_for_mailing_lists
|
|
||||||
folders_for_email_addresses
|
folders_for_email_addresses
|
||||||
create_public_mailing_list
|
create_public_mailing_list
|
||||||
#create_private_mailing_list
|
#create_private_mailing_list
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Adds a mailing list to the email configuration
|
||||||
|
|
||||||
|
# License
|
||||||
|
# =======
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
MYUSERNAME=$USER
|
||||||
|
MAILINGLIST=
|
||||||
|
SUBJECTTAG=
|
||||||
|
|
||||||
|
function show_help {
|
||||||
|
echo ''
|
||||||
|
echo 'freedombone-addlist -u [username] -l [mailing list name] -s [subject tag]'
|
||||||
|
echo ''
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# > 1 ]]
|
||||||
|
do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
;;
|
||||||
|
-u|--user)
|
||||||
|
shift
|
||||||
|
MYUSERNAME="$1"
|
||||||
|
;;
|
||||||
|
-l|--list)
|
||||||
|
shift
|
||||||
|
MAILINGLIST="$1"
|
||||||
|
;;
|
||||||
|
-s|--subject)
|
||||||
|
shift
|
||||||
|
SUBJECTTAG="$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! [[ $MYUSERNAME && $MAILINGLIST && $SUBJECTTAG ]]; then
|
||||||
|
show_help
|
||||||
|
fi
|
||||||
|
|
||||||
|
MUTTRC=/home/$MYUSERNAME/.muttrc
|
||||||
|
PM=/home/$MYUSERNAME/.procmailrc
|
||||||
|
LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
|
||||||
|
|
||||||
|
# Exit if the list was already added
|
||||||
|
if grep -q "=$MAILINGLIST" $MUTTRC; then
|
||||||
|
exit 54678
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$LISTDIR" ]; then
|
||||||
|
mkdir -m 700 $LISTDIR
|
||||||
|
mkdir -m 700 $LISTDIR/tmp
|
||||||
|
mkdir -m 700 $LISTDIR/new
|
||||||
|
mkdir -m 700 $LISTDIR/cur
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
|
||||||
|
echo "" >> $PM
|
||||||
|
echo ":0" >> $PM
|
||||||
|
echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM
|
||||||
|
echo "$LISTDIR/new" >> $PM
|
||||||
|
chown $MYUSERNAME:$MYUSERNAME $PM
|
||||||
|
|
||||||
|
if [ ! -f "$MUTTRC" ]; then
|
||||||
|
cp /etc/Muttrc $MUTTRC
|
||||||
|
chown $MYUSERNAME:$MYUSERNAME $MUTTRC
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROCMAILLOG=/home/$MYUSERNAME/log
|
||||||
|
if [ ! -d $PROCMAILLOG ]; then
|
||||||
|
mkdir $PROCMAILLOG
|
||||||
|
chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG
|
||||||
|
fi
|
||||||
|
|
||||||
|
MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC)
|
||||||
|
if [[ $MUTT_MAILBOXES != *$MAILINGLIST* ]]; then
|
||||||
|
sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$MAILINGLIST|g" $MUTTRC
|
||||||
|
chown $MYUSERNAME:$MYUSERNAME $MUTTRC
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue