tons of misc updates
[distro-setup] / mail-setup
index c3b11d8109ea7577b1d2315f7e55104af8180bba..9e867c85b38085bc90ac03470b52452ee360e632 100755 (executable)
@@ -19,6 +19,12 @@ set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
+if [[ ! $SUDO_USER ]]; then
+  echo "$0: error: requires running as nonroot or sudo"
+  exit 1
+fi
+u=$SUDO_USER
+
 
 usage() {
   cat <<EOF
@@ -49,10 +55,6 @@ if ! exim && ! postfix; then
   usage 1
 fi
 
-if [[ ! $SUDO_USER ]]; then
-  echo "$0: error: requires running as nonroot or sudo"
-fi
-u=$SUDO_USER
 
 
 ####### begin perstent password instructions ######
@@ -482,7 +484,7 @@ exim4-config exim4/mailname string mail.iankelling.org
 
 # Please enter a semicolon-separated list of recipient domains for which this machine
 # should consider itself the final destination. These domains are commonly called
-# 'local domains'. The local hostname (treetowl.lan) and 'localhost' are always added
+# 'local domains'. The local hostname (kd.lan) and 'localhost' are always added
 # to the list given here.
 
 # By default all local domains will be treated identically. If both a.example and
@@ -569,12 +571,12 @@ DKIM_PRIVATE_KEY= \${if exists{/etc/exim4/\${dkim_domain}-private.pem} {/etc/exi
 
 
 # failing message on mail-tester.com:
-# We check if there is a server (A Record) behind your hostname treetowl.
-# You may want to publish a DNS record (A type) for the hostname treetowl or use a different hostname in your mail software
+# We check if there is a server (A Record) behind your hostname kd.
+# You may want to publish a DNS record (A type) for the hostname kd or use a different hostname in your mail software
 # https://serverfault.com/questions/46545/how-do-i-change-exim4s-primary-hostname-on-a-debian-box
 # and this one seemed appropriate from grepping config.
 # I originally set this to li.iankelling.org, but then ended up with errors when li tried to send
-# mail to treetowl, so this should basically be a name that no host has as their
+# mail to kd, so this should basically be a name that no host has as their
 # canonical hostname since the actual host sits behind a nat and changes.
 # Seems logical for this to be the same as mailname.
 MAIN_HARDCODE_PRIMARY_HOSTNAME = mail.iankelling.org
@@ -737,11 +739,11 @@ EOF
   # i have the spool directory be common to distro multi-boot, so
   # we need the uid to be the same. 608 cuz it's kind of in the middle
   # of the free system uids.
-  IFS=:; read _ _ uid _ < <(getent passwd Debian-exim ); unset IFS
-  IFS=:; read _ _ gid _ < <(getent group Debian-exim ); unset IFS
+  IFS=:; read _ _ uid _ < <(getent passwd Debian-exim ||:) ||:; unset IFS
+  IFS=:; read _ _ gid _ < <(getent group Debian-exim ||:) ||:; unset IFS
   if [[ ! $uid ]]; then
     # from /var/lib/dpkg/info/exim4-base.postinst, plus uid and gid options
-    adduser --uid 608 --gid 608 --system --group --quiet --home /var/spool/exim4 \
+    adduser --uid 608 --system --group --quiet --home /var/spool/exim4 \
            --no-create-home --disabled-login --force-badname Debian-exim
   elif [[ $uid != 608 ]]; then
     systemctl stop exim4 ||: