X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=573078841cf8072127002fa4143d377e0077c061;hb=0cc08a73110c15c4e7bbb8c8233a6c122c27490e;hp=c3b11d8109ea7577b1d2315f7e55104af8180bba;hpb=b857462732e15f455e41f26e3048a390d7b399c0;p=distro-setup diff --git a/mail-setup b/mail-setup index c3b11d8..5730788 100755 --- a/mail-setup +++ b/mail-setup @@ -15,10 +15,18 @@ set -x # See the License for the specific language governing permissions and # limitations under the License. +# todo: make quick backups of maildir, or deliver to multiple hosts. + 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 < /dev/null; then debconf-set-selections < /etc/mailname + # MAIN_HARDCODE_PRIMARY_HOSTNAME might mess up the # smarthost config type, not sure. all other settings # would be unused in that config type. - cat >$exim_main_dir/000_localmacros </etc/exim4/conf.d/main/000_localmacros <$d/override.conf <<'EOF' +[Service] +Restart=always +# time to sleep before restarting a service +RestartSec=1 + +[Unit] +# StartLimitIntervalSec in recent systemd versions +StartLimitInterval=0 +EOF systemctl enable offlineimapsync.timer systemctl start offlineimapsync.timer @@ -714,14 +735,17 @@ EOF # # would only exist because I wrote it i the previous condition, # it\'s not part of exim - rm -f $exim_main_dir/000_localmacros + rm -f /etc/exim4/conf.d/main/000_localmacros debconf-set-selections < /etc/mailname fi # end $HOSTNAME != $MAIL_HOST @@ -737,11 +761,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 ||: