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
        
I have not used VPN in years, so I don't have more specific examples.

        Wietse

Reply via email to