LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-18-2014, 04:27 PM   #1
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Rep: Reputation: 19
script stays on the desktop, because it doesn't finish.


The script that starts my VPN stays on the screen until it's finished, which is all of the time we are connected. The only way I know to shut it down is to shut town the VPN. Is there a way to hide the script? This is the script:

#!/bin/bash
sudo openvpn --config /etc/openvpn/littlejoe_darkwirevpn.com_USCA.ovpn

adding the ampersand only makes it hang, because it requires a password. gksu has a similar effect.
 
Old 12-18-2014, 04:50 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If the script needs to remain active then it will show on the desktop. Putting it into the background is a good idea but you say you cannot background it because you need to answer a password. So you want it to be on the foreground and at the same time invisible. This is the classic case of have the pudding and eat it at the same time.

Anyway, I am wondering how you ended up in this situation. Debian install OpenVPN and adds a startup script. The startup script takes care of automatic startup at boot time. Both server and client.

So what did you do to disable this mechanism, and why. The OpenVPN startup script uses a config file in a standard location with a standard name. No need to create your own startup script. And why didn't you use the standard key scheme as explained in the OpenVPN HowTo?

jlinkels
 
Old 12-18-2014, 05:31 PM   #3
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
At first I tried oneclickvpn from the internet. They have 'free install/free trial' offer. But I couldn't get it to working. Tried off and on for a long time. Then a friend of mine who lives a long way away, offered to help by means of BOMGAR. He also had a hard time with it. finally got it working with said script, But had to go on family business.

I'd guess that if there was a scriipt or setting in some config file, I probably deleted it or messed it up trying to get rid of the files installed by oneclickvpn

I really don't need to have that VPN up and running all the time. I pay for it by the Gb, so it would be nice to be able to turn it off when I don't need it - which I can do by rebooting.

Now connected with Darkwirevpn.
 
Old 12-19-2014, 03:41 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Store your script somewhere eg /usr/local/sbin/openvpn then (still as root user) create a file called /etc/sudoers.d/openvpn with this content:
Code:
username ALL=NOPASSWD: /usr/local/sbin/openvpn ""
 
Old 12-20-2014, 02:22 AM   #5
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
I tried it as you said,NevemTeve, but it doesn't have any effect on the behavior of the system. I inserted the file exactly named, and copied by 'cut-&-paste' and then deleted 'password' and inserted my password. Then I reset the permissions to 440.

When it didn't work, I went to the directory mentioned in the script, and discovered that /usr/local/sbin And that is an empty directory. There is no openvpn at that address. I wonder if mint17 put it somewhere else, - or if I should build it, or move it from some place else.
 
Old 12-20-2014, 03:32 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I have a hard feeling that you don't understand what you're doing. You should have a basic knowledge about unix before you could solve this problem.

First, create a script with name /usr/local/sbin/openvpn, owner=root, rights=0755, content:
Code:
#!/bin/sh
exec openvpn --config /etc/openvpn/littlejoe_darkwirevpn.com_USCA.ovpn
Done?

Then create a file by /etc/sudoers.d/openvpn content (replace 'littlejoe5' with your username):
Code:
littlejoe5 ALL=NOPASSWD: /usr/local/sbin/openvpn ""
Done?

Now try this (as littlejoe5 user):
Code:
sudo /usr/local/sbin/openvpn
It should work without asking for password.

Works?

Last edited by NevemTeve; 12-20-2014 at 04:06 AM.
 
Old 12-21-2014, 01:21 AM   #7
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by NevemTeve View Post
I have a hard feeling that you don't understand what you're doing. You should have a basic knowledge about unix before you could solve this problem.

You are right. I'm learning, but if I had that knowledge, I wouldn't be asking for help.

First, create a script with name /usr/local/sbin/openvpn, owner=root, rights=0755, content:
Code:
#!/bin/sh
exec openvpn --config /etc/openvpn/littlejoe_darkwirevpn.com_USCA.ovpn
Done? Done!

Then create a file by /etc/sudoers.d/openvpn content (replace 'littlejoe5' with your username):
Code:
littlejoe5 ALL=NOPASSWD: /usr/local/sbin/openvpn ""
Done? Done!


Now try this (as littlejoe5 user):
Code:
sudo /usr/local/sbin/openvpn
It should work without asking for password.

Works?
Still requires the password, but now won't even work with the password.

Last edited by littlejoe5; 12-21-2014 at 01:23 AM. Reason: typos and spelling
 
Old 12-21-2014, 05:11 AM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Set the rights of sudoer file to 0440 (do it as root):
Code:
chmod 0440 /etc/sudoers.d/openvpn
then try sudo /usr/local/sbin/openvpn again

Last edited by NevemTeve; 12-21-2014 at 06:28 AM.
 
Old 12-22-2014, 12:46 AM   #9
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
I have done exactly as you said here. Sure enough I had the permissions set wrong, but I have double and triple checked the wording of each file and it's permissions.

And It still will not even connect to the VPN. It's a weekend. Perhaps I can connect with Darkwirevpn in the morning and see what they say. The problem could be on their end.

In one of your messages you ask for the results of the command:
ls -ld /usr/local/sbin/openvpn /etc/sudoers.d /etc/sudoers.d/openvpn;
here it is after I corrected the permissions of:/etc/sudoers.d/openvpn

drwxr-xr-x 2 root root 4096 Dec 20 23:37 /etc/sudoers.d
-r--r----- 1 root root 53 Dec 21 23:20 /etc/sudoers.d/openvpn
-rwxr-xr-x 1 root root 83 Dec 21 00:30 /usr/local/sbin/openvpn

Quote:
Originally Posted by NevemTeve View Post
Set the rights of sudoer file to 0440 (do it as root):
Code:
chmod 0440 /etc/sudoers.d/openvpn
then try sudo /usr/local/sbin/openvpn again
 
Old 12-22-2014, 01:53 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
It's just occurred to me that we might have created a recursion... Correct /usr/local/sbin/openvpn like this:
Code:
#!/bin/sh
exec /usr/sbin/openvpn --config /etc/openvpn/littlejoe_darkwirevpn.com_USCA.ovpn

Last edited by NevemTeve; 12-22-2014 at 02:04 AM.
 
Old 12-22-2014, 11:57 AM   #11
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by NevemTeve View Post
It's just occurred to me that we might have created a recursion... Correct /usr/local/sbin/openvpn like this:
Code:
#!/bin/sh
exec /usr/sbin/openvpn --config /etc/openvpn/littlejoe_darkwirevpn.com_USCA.ovpn
I messed up somewhere here. After making the edit you suggest I run the script (as below) and get the immediate message below that. (running as user). (Tried running from administrative prompt, e.g. "# /usr/local/sbin/openvpn" and got the same result)
_______________________________
sudo /usr/local/sbin/openvpn
/usr/local/sbin/openvpn: 2: exec: /usr/sbin/openvpn: Permission denied

______________________________

here is a copy of /usr/sbin/openvpn
_____________________________
/usr/sbin/openvpn: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24,BuildID[sha1}=c9a4cb73d2d1c4c574aeac11d3b39cda59cba521, stripped
____________________________
at one point I got an error box (don't know for sure what I did to get it) with the message: Warning /usr/sbin/openvpn:no symbols
 
Old 12-22-2014, 12:10 PM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Hmmm... it's like as if 'sudo' didn't have any effected... compare the output of these two commands:
Code:
/usr/local/sbin/openvpn
sudo /usr/local/sbin/openvpn
(for more evidence you might insert command 'id -a' into the middle of /usr/local/sbin/openvpn')
 
Old 12-22-2014, 10:54 PM   #13
littlejoe5
Member
 
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Original Poster
Rep: Reputation: 19
Running as user:
__________________
/usr/local/sbin/openvpn
/usr/local/sbin/openvpn: 2: exec: /usr/sbin/openvpn: Permission denied
_____________________
still as user:
___________________
sudo /usr/local/sbin/openvpn
[sudo] password for m17:
/usr/local/sbin/openvpn: 2: exec: /usr/sbin/openvpn: Permission denied
 
Old 12-22-2014, 11:33 PM   #14
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
The content of your /etc/sudoers.d/init.d file should be:
Code:
m17 ALL=NOPASSWD: /usr/local/sbin/openvpn ""
 
  


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
Ghostview window stays in fixed location on desktop rtrees21 Linux - General 3 11-04-2010 10:10 AM
rsync doesn't finish if started remotely? abefroman Linux - Server 3 01-29-2010 04:46 AM
Hardy doesn't finish shutting down HP pavillian catholiclibertarian Linux - Desktop 1 10-29-2008 08:55 AM
how to get on redhat 7.2's desktop screen after installation finish laptop Red Hat 3 02-11-2005 08:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 PM.

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