networkmanager-helpers: automate NM actions like connect to vpn after connecting to access point



Hi,

I needed/wanted to automate NetworkManager actions like connecting to
my "Office VPN"
when I connect to my wireless access point at home and I wrote some
dispatcher scripts which
did this for me.

You can find it on: https://github.com/lora/networkmanager-helpers

I would appreciate some comments if you test it.


There is one script called nm_helpers which does all the job and you
have only to write a
a small configuration file like this:

IF_CONNECTION=("Home AP")
DO_CONNECTION=("Office VPN")

and that will get you connected to "Office VPN" after connecting to "Home AP".
and if you put more than one entry in DO_CONNECTION a random entry will be
chosen:
DO_CONNECTION=("Office VPN 1" "Office VPN 2")



or you can start a SSH tunnel when you connect to "Office VPN":

IF_CONNECTION=("Office VPN")
SSH_SERVER=("my.server.com -l user username")

enter more than one SSH server and a random server will be chosen:
SSH_SERVER=("my.server.com -l user username" "new.server.com -l new_username")



or you can start rsync backup when you connect to your home AP:

IF_CONNECTION=("Home AP")
up() {
    rsync -avz /home user@server:/backup/home
}


You can also match your connections' names with UUIDs to avoid wrong actions.
IF_CONNECTION=("4d2c8947-4093-4fef-a929-bc8d92b77bc7")



and you can even use regular expressions to match connections' names by
putting ~ before the name like this:
IF_CONNECTION=("~Office") will match any connection with the word Office in it.


This script grew more and more and it offers others features like addons and
custom callback functions.  Pretty much all info are in README in
https://github.com/lora/networkmanager-helpers


Please report if you find bugs or have some ideas to improve it. Thanks.


Best regards

Lora G.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]