diff --git a/src/freedombone-app-bdsmail b/src/freedombone-app-bdsmail index f88ef423..5a756e3e 100755 --- a/src/freedombone-app-bdsmail +++ b/src/freedombone-app-bdsmail @@ -245,6 +245,9 @@ function remove_bdsmail { if [ -d $BDSMAIL_DIR ]; then rm -rf $BDSMAIL_DIR fi + rm /usr/bin/bdsmail_domain + sed -i '/bdsmail_distribute/d' /etc/crontab + rm /usr/bin/bdsmail_distribute } function install_bdsmail { @@ -342,6 +345,26 @@ function install_bdsmail { systemctl enable bdsmail systemctl start bdsmail + echo '#!/bin/bash' > /usr/bin/bdsmail_distribute + echo 'BDSMAIL_DIR=/etc/bdsmail' >> /usr/bin/bdsmail_distribute + echo "MAIL_DIR=\$BDSMAIL_DIR/$(cat \$BDSMAIL_DIR/config.ini | grep 'maildir =' | awk -F ' ' '{print \$3}')" >> /usr/bin/bdsmail_distribute + echo 'if [ ! -d $MAIL_DIR/postmaster/new ]; then' >> /usr/bin/bdsmail_distribute + echo ' exit 0' >> /usr/bin/bdsmail_distribute + echo 'fi' >> /usr/bin/bdsmail_distribute + echo 'for filename in $MAIL_DIR/postmaster/new/*; do' >> /usr/bin/bdsmail_distribute + echo ' to_line=$(cat $filename | grep "To: " | head -n 1)' >> /usr/bin/bdsmail_distribute + echo " to_username=\$(echo \"\$to_line\" | awk -F ' ' '{print \$2}' | awk -F '@' '{print \$1}')" >> /usr/bin/bdsmail_distribute + echo ' if [ -d /home/$to_username/Maildir/i2p/new ]; then' >> /usr/bin/bdsmail_distribute + echo ' chown $to_username:$to_username $filename' >> /usr/bin/bdsmail_distribute + echo ' mv $filename /home/$to_username/Maildir/i2p/new' >> /usr/bin/bdsmail_distribute + echo ' fi' >> /usr/bin/bdsmail_distribute + echo 'done' >> /usr/bin/bdsmail_distribute + chmod +x /usr/bin/bdsmail_distribute + + if ! grep -q 'bdsmail_distribute' /etc/crontab; then + echo '*/1 * * * * root /usr/bin/bdsmail_distribute 2> /dev/null' >> /etc/crontab + fi + echo '#!/bin/bash' > /usr/bin/bdsmail_domain echo "cd $BDSMAIL_DIR" >> /usr/bin/bdsmail_domain echo 'if [ ! -f bdsmail-privkey.dat ]; then' >> /usr/bin/bdsmail_domain