#!/bin/sh
set -e

if [ -n "$EX4DEBUG" ]; then
  echo "now debugging $0 $@"
  set -x
fi


# regenerate $EXIM4_SPOOLDIR/gnutls-params
# As this can take _very_ long on machines with little entropy, we limit
# the maximum runtime to 2*$CERTTOOLTIMEOUT seconds and keep using the
# old file otherwise.

# Only do anything if exim4 is actually installed
if [ ! -x /usr/lib/exim4/exim4 ]; then
  exit 0
fi

# Only do anyting if TLS is enabled in exim
if [ -z "$(/usr/lib/exim4/exim4 -bP tls_advertise_hosts | sed 's/.*=[[:space:]]\(.*\)/\1/')" ]; then 
  # TLS disabled
  exit 0
fi

TIMEOUT=${1:-1800}

EXIM4_SPOOLDIR="${EXIM4_SPOOLDIR:-XIM4_SPOOLDIR="${EXIM4_SPOO }
      elsif (defined $new_address)
        {
        $$hash{"driver"} = "redirect";
        $$hash{"data"} = $new_address;
        $$hash{"allow_defer"} = "true";
        $$hash{"allow_fail"} = "true";
        delete $$hash{"new_address"};
        }
      else     # Includes the case of neither set (verify_only)
        {
        $$hash{"driver"} = "accept";
        if (defined $$hash{"rewrite"})
          {
          &rubric();
          print STDERR "\n" .
"** The Exim 3 configuration contains a setting of the 'rewrite' option on\n".
"   a smartuser director called '$name', but this director does not have\n".
"   a setting of 'new_address', so 'rewrite' has no effect. The director\n".
"   has been turned into an 'accept' router, and 'rewrite' has been discarded.";
          delete $$hash{"rewrite"};
          }
        }
      }


    # ------------------------------------