Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a script

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
riahc3
OpenVPN User
Posts: 46
Joined: Tue Jun 26, 2012 9:04 am

Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a script

Post by riahc3 » Mon Mar 04, 2013 8:45 am

Hello

I have the OpenVPN client installed with the GUI thats next to the clock where you right click on the network connections, it appears, and you connect to the VPN. Now, I want that after I click on it to make a connection, and the connection is successful, to run a script Ive made as root (so it doesnt ask me for my password and it is automatic). How can I configure this?

Thank you

riahc3
OpenVPN User
Posts: 46
Joined: Tue Jun 26, 2012 9:04 am

Re: Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a scri

Post by riahc3 » Tue Mar 05, 2013 8:11 am

Someone has had to do this one time at least...

riahc3
OpenVPN User
Posts: 46
Joined: Tue Jun 26, 2012 9:04 am

Re: Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a scri

Post by riahc3 » Tue Mar 05, 2013 11:11 am

Found this:

https://wiki.archlinux.org/index.php/Ne ... dispatcher

Do I just throw the script inside the folder?

riahc3
OpenVPN User
Posts: 46
Joined: Tue Jun 26, 2012 9:04 am

Re: Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a scri

Post by riahc3 » Tue Mar 05, 2013 4:19 pm

Ok Im getting somewhere....

When I throw a script inside there Im running something like this:

#!/bin/sh
interface=$1 status=$2
case $status in
up)
echo hi
;;
down)

;;
esac


Before that case, Im going to do a "if" that searches for the name of my vpn which I would get using

nmcli con status

Lets say my vpn is called "helloworld"

How would I do a (pseudocode):

If in nmcli con status I find the text "helloworld" do
actions
end if

In a shell script?

riahc3
OpenVPN User
Posts: 46
Joined: Tue Jun 26, 2012 9:04 am

Re: Ubuntu: Autoconnect OpenVPN client (GUI) THEN run a scri

Post by riahc3 » Wed Mar 06, 2013 8:32 am

Again, I find it hard to believe that noone has even thought of trying something like this...

Post Reply