X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=ffd6f8ca90a0374fd4af11b53b72e21d60e5c8f9;hb=622ab146bf7fb89d8fbc58add1b955f8f9b34fd0;hp=819aa8d0623cd48420bd7dfac345f88b046a794c;hpb=7002af6b587b8d66d1f3b58ae77f09fa3d794d15;p=distro-setup diff --git a/mail-setup b/mail-setup index 819aa8d..ffd6f8c 100755 --- a/mail-setup +++ b/mail-setup @@ -73,11 +73,8 @@ smarthost="$host::587" # exim # it might work in /etc/aliases, but this seems more proper. e $forward > ~/.forward e $forward | s tee /root/.forward - -# linode image has a root alias. completely useless, remove it. -sudo sed -i '/^root:/d' /etc/aliases - -s newaliases +# exim log complains about 664 permissions. +s chmod 644 ~/.forward /root/.forward # offlineimap uses this too, it is much easier to use one location than to @@ -87,7 +84,7 @@ case $distro in *) : esac -read -r domain pass < <(s cat /etc/mailpass) +read -r domain pass < <(s cat /etc/mailpass) # format: domain user:pass if postfix; then # dunno why, but debian installed postfix with builddep emacs # but I will just explicitly install it here since @@ -136,7 +133,7 @@ EOF f=/etc/postfix/sasl_passwd s touch $f s chmod 600 $f - echo "[$domain]:587 ${pass/@/#}" | s dd of=/etc/postfix/sasl_passwd >/dev/null + printf "[%s]:587 %s" "$domain" "${pass/@/#}" | s dd of=/etc/postfix/sasl_passwd 2>/dev/null s postmap hash:/etc/postfix/sasl_passwd s service postfix reload else @@ -163,8 +160,10 @@ EOF f=/etc/exim4/passwd.client s touch $f - s chmod 600 $f # make it 600 before writing sensitive info - echo "$domain:${pass/:/::}" | s dd of=$f >/dev/null + s chmod 640 $f # before writing sensitive info + s chown root:Debian-exim $f + # reference: exim4_passwd_client(5) + printf "%s:%s" "$domain" "$pass" | s dd of=$f 2>/dev/null # https://blog.dhampir.no/content/make-exim4-on-debian-respect-forward-and-etcaliases-when-using-a-smarthost # i only need .forwards, so just doing that one. cd /etc/exim4/conf.d/router @@ -173,13 +172,19 @@ EOF tmp=$(mktemp) of=175_$b # sed to make the router name unique - sed -r s/^\\S+:/$b:/ 600_exim4-config_$a >$tmp - if diff -q >/dev/null $tmp $of; then + sed -r s/^\\S+:/$b:/ 600_exim4-config_$a | s dd of=$tmp 2>/dev/null + if ! diff -q >/dev/null $tmp $of; then s dd if=$tmp of=$of >/dev/null ser restart exim4 fi fi +# linode image has a root alias. completely useless, remove it. +sudo sed -i '/^root:/d' /etc/aliases + +s newaliases + + # based on http://www.postfix.org/qmgr.8.html and my notes in gnus dir=/nocow/$type sdir=/var/spool/$type