X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=mail-setup;h=04e96617a20a85c64b1b550dea1e51673f13717f;hp=a0bba6db2b78082d78f54ceffc983b53f482e0b2;hb=f0a35267f28e274ef3c2f63ffc20a26ca864e37c;hpb=866a0cbd9127386520def96ff49bdc8424df8112 diff --git a/mail-setup b/mail-setup index a0bba6d..04e9661 100755 --- a/mail-setup +++ b/mail-setup @@ -186,6 +186,18 @@ postconfin() { postconf -ev "${MAPFILE[@]}" } e() { printf "%s\n" "$*"; } +pi() { # package install + local s f + if dpkg -s -- "$@" &> /dev/null; then + return 0; + fi; + while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done + f=/var/cache/apt/pkgcache.bin; + if [[ ! -r $f ]] || (( $(( $(date +%s) - $(stat -c %Y $f ) )) > 60*60*12 )); then + apt-get update + fi + apt-get -y install --purge --auto-remove "$@" +} postmaster=$u mxhost=mail.iankelling.org @@ -234,9 +246,10 @@ postfix postfix/relayhost string $relayhost postfix postfix/root_address string $postmaster EOF if dpkg -s postfix &>/dev/null; then + while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done dpkg-reconfigure -u -fnoninteractive postfix else - apt-get -y install --purge --auto-remove postfix + pi postfix fi else source /a/bin/distro-functions/src/package-manager-abstractions @@ -285,9 +298,7 @@ EOF else # begin exim. has debian specific stuff for now - if ! dpkg -s openvpn &>/dev/null; then - apt-get -y install --purge --auto-remove openvpn - fi + pi openvpn if [[ -e /p/c/filesystem ]]; then # allow failure of these commands when our internet is down, they are likely not needed, @@ -609,8 +620,7 @@ EOF # sieve has the benefit of being supported in postfix and # proprietary/weird environments, so there is more examples on the # internet. I was torn about whether to do this or not, meh. - apt-get -y install --purge --auto-remove \ - dovecot-core dovecot-imapd dovecot-sieve dovecot-lmtpd + pi dovecot-core dovecot-imapd dovecot-sieve dovecot-lmtpd # if we changed 90-sieve.conf and removed the active part of the # sieve option, we wouldn\'t need this, but I\'d rather not modify a @@ -720,6 +730,7 @@ EOF # gotta remove this, otherwise the set-selections are completely # ignored. It woulda been nice if this was documented somewhere! rm -f /etc/exim4/update-exim4.conf.conf + while fuser /var/lib/dpkg/lock &>/dev/null; do sleep 1; done dpkg-reconfigure -u -fnoninteractive exim4-config fi @@ -742,7 +753,7 @@ EOF fi # light version of exim does not have sasl auth support. - apt-get -y install --purge --auto-remove exim4-daemon-heavy spamassassin + pi exim4-daemon-heavy spamassassin