Bladeren bron

Avoid adding mailing lists multiple times

Bob Mottram 10 jaren geleden
bovenliggende
commit
d8afb27c95
1 gewijzigde bestanden met toevoegingen van 15 en 4 verwijderingen
  1. 15
    4
      install-freedombone.sh

+ 15
- 4
install-freedombone.sh Bestand weergeven

@@ -1569,37 +1569,48 @@ function folders_for_mailing_lists {
1569 1569
   echo 'MUTTRC=/home/$MYUSERNAME/.muttrc' >> /usr/bin/mailinglistrule
1570 1570
   echo 'PM=/home/$MYUSERNAME/.procmailrc' >> /usr/bin/mailinglistrule
1571 1571
   echo 'LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST' >> /usr/bin/mailinglistrule
1572
-
1572
+  echo '' >> /usr/bin/mailinglistrule
1573
+  echo '# Exit if the list was already added' >> /usr/bin/mailinglistrule
1574
+  echo 'if grep -Fxq "=$MAILINGLIST" $MUTTRC; then' >> /usr/bin/mailinglistrule
1575
+  echo '  exit 1' >> /usr/bin/mailinglistrule
1576
+  echo 'fi' >> /usr/bin/mailinglistrule
1577
+  echo '' >> /usr/bin/mailinglistrule
1573 1578
   echo 'if ! [[ $MYUSERNAME && $MAILINGLIST && $SUBJECTTAG ]]; then' >> /usr/bin/mailinglistrule
1574 1579
   echo '  echo "mailinglistsrule [user name] [mailing list name] [subject tag]"' >> /usr/bin/mailinglistrule
1575 1580
   echo '  exit 1' >> /usr/bin/mailinglistrule
1576 1581
   echo 'fi' >> /usr/bin/mailinglistrule
1582
+  echo '' >> /usr/bin/mailinglistrule
1577 1583
   echo 'if [ ! -d "$LISTDIR" ]; then' >> /usr/bin/mailinglistrule
1578 1584
   echo '  mkdir -m 700 $LISTDIR' >> /usr/bin/mailinglistrule
1579 1585
   echo '  mkdir -m 700 $LISTDIR/tmp' >> /usr/bin/mailinglistrule
1580 1586
   echo '  mkdir -m 700 $LISTDIR/new' >> /usr/bin/mailinglistrule
1581 1587
   echo '  mkdir -m 700 $LISTDIR/cur' >> /usr/bin/mailinglistrule
1582 1588
   echo 'fi' >> /usr/bin/mailinglistrule
1589
+  echo '' >> /usr/bin/mailinglistrule
1583 1590
   echo 'chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR' >> /usr/bin/mailinglistrule
1584 1591
   echo 'echo "" >> $PM' >> /usr/bin/mailinglistrule
1585 1592
   echo 'echo ":0" >> $PM' >> /usr/bin/mailinglistrule
1586 1593
   echo 'echo "  * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM' >> /usr/bin/mailinglistrule
1587 1594
   echo 'echo "$LISTDIR/new" >> $PM' >> /usr/bin/mailinglistrule
1588 1595
   echo 'chown $MYUSERNAME:$MYUSERNAME $PM' >> /usr/bin/mailinglistrule
1596
+  echo '' >> /usr/bin/mailinglistrule
1589 1597
   echo 'if [ ! -f "$MUTTRC" ]; then' >> /usr/bin/mailinglistrule
1590 1598
   echo '  cp /etc/Muttrc $MUTTRC' >> /usr/bin/mailinglistrule
1591 1599
   echo '  chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/mailinglistrule
1592 1600
   echo 'fi' >> /usr/bin/mailinglistrule
1601
+  echo '' >> /usr/bin/mailinglistrule
1593 1602
   echo 'PROCMAILLOG=/home/$MYUSERNAME/log' >> /usr/bin/mailinglistrule
1594 1603
   echo 'if [ ! -d $PROCMAILLOG ]; then' >> /usr/bin/mailinglistrule
1595 1604
   echo '  mkdir $PROCMAILLOG' >> /usr/bin/mailinglistrule
1596 1605
   echo '  chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG' >> /usr/bin/mailinglistrule
1597 1606
   echo 'fi' >> /usr/bin/mailinglistrule
1607
+  echo '' >> /usr/bin/mailinglistrule
1598 1608
   echo 'MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC)' >> /usr/bin/mailinglistrule
1599 1609
   echo 'if [[ $MUTT_MAILBOXES != *$MAILINGLIST* ]]; then' >> /usr/bin/mailinglistrule
1600 1610
   echo '  sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$MAILINGLIST|g" $MUTTRC' >> /usr/bin/mailinglistrule
1601 1611
   echo '  chown $MYUSERNAME:$MYUSERNAME $MUTTRC' >> /usr/bin/mailinglistrule
1602 1612
   echo 'fi' >> /usr/bin/mailinglistrule
1613
+  echo 'exit 0' >> /usr/bin/mailinglistrule
1603 1614
   chmod +x /usr/bin/mailinglistrule
1604 1615
   echo 'folders_for_mailing_lists' >> $COMPLETION_FILE
1605 1616
 }
@@ -1695,10 +1706,10 @@ function create_public_mailing_list {
1695 1706
   echo 'mlmmj_router:' > /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1696 1707
   echo '  driver = accept' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1697 1708
   echo '  domains = +mlmmj_domains' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1698
-  echo '  require_files = MLMMJ_HOME/${lc::$local_part}' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1709
+  echo '  #require_files = MLMMJ_HOME/${lc::$local_part}' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1699 1710
   echo '  # Use this instead, if you dont want to give Exim rx rights to mlmmj spool.' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1700 1711
   echo '  # Exim will then spawn a new process running under the UID of "mlmmj".' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1701
-  echo '  #require_files = mlmmj:MLMMJ_HOME/${lc::$local_part}' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1712
+  echo '  require_files = mlmmj:MLMMJ_HOME/${lc::$local_part}' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1702 1713
   echo '  local_part_suffix = +*' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1703 1714
   echo '  local_part_suffix_optional' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
1704 1715
   echo '  headers_remove = Delivered-To' >> /etc/exim4/conf.d/router/750_exim4-config_mlmmj
@@ -1712,7 +1723,7 @@ function create_public_mailing_list {
1712 1723
   echo '  group = mlmmj' >> /etc/exim4/conf.d/transport/40_exim4-config_mlmmj
1713 1724
   echo '  home_directory = MLMMJ_HOME' >> /etc/exim4/conf.d/transport/40_exim4-config_mlmmj
1714 1725
   echo '  current_directory = MLMMJ_HOME' >> /etc/exim4/conf.d/transport/40_exim4-config_mlmmj
1715
-  echo '  command = /usr/local/bin/mlmmj-receive -F -L MLMMJ_HOME/${lc:$local_part}' >> /etc/exim4/conf.d/transport/40_exim4-config_mlmmj
1726
+  echo '  command = /usr/bin/mlmmj-receive -F -L MLMMJ_HOME/${lc:$local_part}' >> /etc/exim4/conf.d/transport/40_exim4-config_mlmmj
1716 1727
 
1717 1728
   if ! grep -q "MLMMJ_HOME=/var/spool/mlmmj" /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs; then
1718 1729
       sed -i '/MAIN CONFIGURATION SETTINGS/a\MLMMJ_HOME=/var/spool/mlmmj' /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs