[SOLVED] Postfix differences when installing on LXC vs KVM

johnha

Well-Known Member
Jan 1, 2018
34
5
48
Just a strange thing I found when installing postfix on kvm vs lxc. I tested this with debian 10 and ubuntu 20.04, installed using the container templates, and bare bones installations using the ISOs on KVM.

When installing postfix, on the KVM it runs the reconfigure script, but on LXC it doesn't.

I only noticed it because I have a little script I use to install postfix on my instances and mostly I try to use LXC containers to capture the extra speed advantage, but sometimes I need KVMs. When I ran my script recently on VM it ran the reconfigure screens twice because my script had `dpkg-reconfigure postfix` in it. This caused me to investigate why, and I noticed this difference.

So two questions:
1) Why does this behavior happen? And is it limited to postfix, or could it cause a similar issue with other packages
2) Is there a way to detect LXC vs KVM so that I can modify my bash script to run `dpkg-reconfigure postfix` on LXC but skip it on KVM?

Thanks all!
 
the LXC templates provided by Proxmox do have postfix directly installed (with no configuration set) - the KVM (depending on how you install it usually does not have it installed.

2) Is there a way to detect LXC vs KVM so that I can modify my bash script to run `dpkg-reconfigure postfix` on LXC but skip it on KVM?
try `systemd-detect-virt` (see its manpage)

I hope this helps!
 
Stoiko, thank you so much for the information! I didn't realize that postfix was installed in the LXC template. I'll report back if any issues - thank you for taking the time to help :)
 
  • Like
Reactions: Stoiko Ivanov
Glad that helped :)

please edit the thread and mark it as 'SOLVED' - this helps other users - Thanks!
 
  • Like
Reactions: johnha
On second thought, I think it's better to solve it generically (cobbled together from a stackoverflow post):

Code:
# Install postfix only if not already installed:
if [ $(dpkg-query -W -f='${Status}' postfix 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
  DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install postfix;
fi
 
  • Like
Reactions: Stoiko Ivanov

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!