LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2013, 02:04 AM   #1
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Rep: Reputation: 1
Ubuntu: Autoconnect OpenVPN client (GUI) THEN afterwards run a script (as root)


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
 
Old 03-05-2013, 01:54 AM   #2
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
Someone has had to do this one time at least...
 
Old 03-05-2013, 03:11 AM   #3
ncalsmitty1369
LQ Newbie
 
Registered: Feb 2010
Posts: 5

Rep: Reputation: 0
I don't use the gui manager for openvpn, but in /etc/openvpn there should be a conf file that you can add a up/down script option to:

script-security 2
up "path to your script"
down "path to your script"

If the openvpn process switches from root to normal user then you will need to use the following:

plugin /usr/lib/openvpn/openvpn-down-root.so "path to script"

Maybe this will help you.
 
Old 03-05-2013, 03:38 AM   #4
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by ncalsmitty1369 View Post
I don't use the gui manager for openvpn, but in /etc/openvpn there should be a conf file that you can add a up/down script option to:

script-security 2
up "path to your script"
down "path to your script"

If the openvpn process switches from root to normal user then you will need to use the following:

plugin /usr/lib/openvpn/openvpn-down-root.so "path to script"

Maybe this will help you.
In /etc/openvpn I have:

update-resolv-conf
up.sh
up.sh~

In the "up.sh" it seems back in the day I tried it by putting (this is a example script and not by any means what I do in the real script):

#!/bin/sh
echo hi

But I am sure it does not work
 
Old 03-05-2013, 03:39 AM   #5
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
The script I run MUST be executed as root so I dont know if that openvpn-down-root.so would work....
 
Old 03-05-2013, 05:11 AM   #6
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
Found this:

https://wiki.archlinux.org/index.php...ger_dispatcher

Do I just throw the script inside the folder?
 
Old 03-05-2013, 05:25 AM   #7
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
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?
 
Old 03-06-2013, 02:13 AM   #8
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
Again, I find it hard to believe that noone has even thought of trying something like this...
 
Old 03-11-2013, 03:34 AM   #9
riahc3
Member
 
Registered: Dec 2002
Posts: 223

Original Poster
Rep: Reputation: 1
Trying but its not working.......

My eth2 goes up automatically. Thats pretty obvious. I have to click on the network icon then click on my VPN so it can connect. Afterwards, I run a script.

I want to automate all of this bascially in case power goes out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make OpenVPN connect on Ubuntu startup and then when connected, run a script as su riahc3 Linux - Networking 3 10-05-2012 09:01 PM
GUI Installer can't run (Ubuntu client connected to SuSE Linux server) kartrait Linux - Newbie 2 06-26-2012 04:12 PM
[SOLVED] F14 NetworkManager to autoconnect OpenVPN at startup sergani Linux - Networking 4 07-06-2011 12:39 PM
Any OpenVPN gui Client for Centos turiyain Linux - Desktop 2 08-23-2010 12:51 AM
Error in openVPN client GUI about openssl sailershen Linux - Security 1 01-26-2006 07:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration