3

I need to setup exim4 on multiple servers however I was wondering if it's possible to create a script that will automatically go through the install process and set it up on exim4 with my hostname?

sudo dpkg-reconfigure exim4-config

Step 1 : Top option (Internet site; mail is sent and received directly using SMTP

Step 2 : hostname (default)

Step 3 : 127.0.0.1 ; ::1 (default)

Step 4 : hostname (default)

Step 5 : hostname

step 6 : hostname

step 7 : No

Step 8 : mbox format in /var/mail/

Step 9 : no

step 10 : root hostname

Any help greatly appreciated. Thanks!

masterq
  • 203
  • 1
  • 9
  • possible duplicate of [Handling input confirmations in Linux shell scripting](http://stackoverflow.com/questions/7410771/handling-input-confirmations-in-linux-shell-scripting) – tripleee Nov 21 '14 at 08:07

3 Answers3

4

The proper solution for Debian is to populate the Debconf database with your choices before running dpkg-reconfigure. Read man debconf-set-selections for details. There is a howto at https://www.debian-administration.org/article/394/Automating_new_Debian_installations_with_preseeding

tripleee
  • 139,311
  • 24
  • 207
  • 268
  • 3
    It's worth noting the two comments from the link above which relate specifically to Exim... `Problems preseeding exim where probably due to the fact that debconf gets it's answers from '/etc/exim4/update-exim4.conf.conf' (something like this also happens in 'locales'). In a script I'm using, I first replace the original 'update-exim4.conf.conf' before updating/installing the packages.` & `The preseed method isn't perfect. I had lots of trouble preseeding exim and eventually I replaced exim with postfix.` – Dogsbody Jan 05 '18 at 10:37
4

when I had this problem I did it like this using debconf-set-selections

debconf-set-selections <<CONF
exim4-config    exim4/dc_other_hostnames        string  $hostnames
exim4-config    exim4/dc_eximconfig_configtype  select  internet site; mail is sent and received directly using SMTP
exim4-config    exim4/no_config boolean true
# rest of the secret sauce omitted...
CONF
Jasen
  • 10,276
  • 2
  • 23
  • 40
  • 2
    Use `debconf-get-selections | grep exim4` on a system where exim4 is already installed to get a list of such settings. If you're missing the `debconf-get-selections` executable, you have to install `debconf-utils`. – jlh Jan 17 '17 at 19:28
  • This doesn't work on my Ubuntu server with Exim4 v4.92. For more info: https://stackoverflow.com/a/61518823/198219 – famzah Apr 30 '20 at 08:14
3

You need to create /etc/exim4/update-exim4.conf.conf with your local values and then install Exim4 non-interactively, as suggested by @Dogsbody:

export DEBIAN_FRONTEND=noninteractive
apt-get install -y exim4-daemon-light

If you already have Exim4 installed, you need to edit the config file and then execute the following, as suggested here:

dpkg-reconfigure -fnoninteractive exim4-config
famzah
  • 969
  • 10
  • 16