On Mon, 23 Mar 2020 16:22:40 -0400 (EDT) Wietse Venema <wie...@porcupine.org> wrote:
> Ranjan Maitra: > > So, I am wondering if I it is possible to have a setup whereby > > postfix is delayed unless/until VPN is up and running. If VPN is > > down, then I would like postfix to be delayed until such time as > > it comes up. If it is possible, how do I go about doing this? Other > > ideas? > > Wietse: > > Before VPN goes down: > > > > # postconf defer_transports=smtp > > # postfix reload > > > > After VPN comes up: > > > > # postconf -X defer_transports > > # postfix reload > > Ranjan Maitra: > > Thank you for this! I am very new to this so would like some more > > advice. Where do I put this? Also, I have control over it going > > up but not always over it going down (which appears to be sometimes > > arbitrary). How do I do that? > > If you want to automatically execute those commands, then you need > to run a program that periodically determines if the VPN is up, and > that invokes the above commands when the VPN status changes. > > In your case, it may be sufficient to query the VPN network device > status. > > Totally untested code follows: > > #!/bin/sh > > while : > do > ifconfig xxx | egrep 'UP|DOWN' > sleep 2 > done | while read status > case "$status" in > *UP*) if [ "$prev" -ne up ] > then > prev=up > postconf -X defer_transports > postfix reload > fi;; > *) if [ "$prev" -ne down ] > then > prev=down > postconf defer_transports=smtp > postfix reload > fi;; > esac > Thank you! I presume that this should go in as a cron job. I will try this out and let you know, but at least it is a good place for me to at least start if not more. Many thanks again and best wishes, Ranjan Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses.