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: ```text journalctl -b -u Dispatcher failed: (32) Unit dbus-org.freedesktop.nm-dispatcher.service failed to load: No such file or directory.


* If you see line about dispatcher service - enable it manually by running `systemctl enable NetworkManager-dispatcher.service`.
* By default NetworkManager will store VPN password in keyring, to start VPN without keyring dependencies update VPN connection configuration with following changes:

`/etc/NetworkManager/system-connections/MY-CONNECTION-NAME`:
```text
...
[vpn]
password-flags=0
...
[vpn-secrets]
password=MY-VPN-PASSWORD

And now everything should work like a charm!