Autoconnect to NetworkManager VPN on systemd based system

Here is small post with instructions how to setup auto connect to VPN. Of course you can probably figure out all this yourself, but what if you are lazy?

Following was tested on OpenSuse 13.1.

/etc/NetworkManager/dispatcher.d/vpn-up:

#!/bin/sh

CONN="MY-CONNECTION-NAME"

nmcli con status id $CONN > /dev/null

rc=$?
if [[ $rc != 0 ]] ; then
    nmcli con up id $CONN
    sleep 5 # optional wait time
fi

NetworkManager:

<warn> Dispatcher failed: (32) Unit dbus-org.freedesktop.nm-dispatcher.service failed to load: No such file or directory.

/etc/NetworkManager/system-connections/MY-CONNECTION-NAME:

...
[vpn]
password-flags=0
...
[vpn-secrets]
password=MY-VPN-PASSWORD

And now everything should work like a charm!