On Wed, Feb 10, 2021 at 09:53:02AM -0500, Wietse Venema wrote: > Chris Green: > > On Wed, Feb 10, 2021 at 03:14:11PM +0100, Matus UHLAR - fantomas wrote: > > > On 10.02.21 13:57, Chris Green wrote: > > > > It would be really handy if I could get postfix to use the value > > > > returned by the dnsdomainname command for its mydomain value as I > > > > could then use the same main.cf file in several headless 'send only' > > > > systems where postfix is used solely for sending error messages from > > > > cron and similar. > > > > > > > > There isn't an 'include' type directive in postfix configuration so I > > > > can't see any way of doing this by capturing the output of > > > > dnsdomainname at startup and then including this in main.cf. > > > > > > > > Has anyone else wanted to do anything like this and come up with a > > > > solution? > > > > > > > > > the default is get from your myhostname, can't you set up that one? > > > > > > btw are you sure you dont mean myorigin instead of mydomain? > > > > > Apart from the TLS/SASL bits the main.cf for all these headless > > systems is:- > > > > mydomain = zbmc.eu > > myorigin = $mydomain > > relayhost = [mail.gandi.net]:465 > > luser_relay = ch...@isbd.co.uk > > local_recipient_maps = > > # > > # > > # We don't accept any incoming connections > > # > > mydestination = > > inet_interfaces = loopback-only > > > > So myhostname isn't explicitly set. > > > > Having 'mydomain = zbmc.eu' worked until now because the systems in > > question were on a LAN which is zbmc.eu. However I'd now rather like > > to use the same main.cf on some systems which aren't on the same LAN. > > It does need to be set so that one can tell easily where messages come > > from. > > First, there is no requirement to SET myhostname. Postfix uses the SYSTEM > HOSTNAME by default. Postfix will automatically append $mydomain > if the SYSTEM HOSTNAME is not in FQDN form. > Yes, OK, that's exactly what I'm seeing.
> Second, please don't run sed on main.cf or master.cf. Use postconf > commands instead. > > For example: > > postconf "myhostname = $(dnsdomainname)" > postfix start > OK, I was just explaining why I didn't particularly want to do this sort of thing, sed was just the first thing that came to mind. These systems are all systemd'ed so I can't just run postfix as above. However will 'postconf "myhostname = $(dnsdomainname)"' actually change/set the myhostname value in main.cf? If so then simply putting the postconf command in /etc/rc.local will do all I need, especially after one reboot. > Not all the world is LINUX, and most systems get along with the > defaults just fine. > Yes, I know, I'm from a mixed background of Sun Solaris and Dec Ultrix in days gone by. I just get my ?nix fix by running Linux on all my own systems! :-) -- Chris Green