pguerin
Posts: 6
Joined: Sat Nov 28, 2015 8:39 am

openvpn at startup in raspberry 1 running raspbian weezee

Sun Nov 29, 2015 10:07 am

Hello
Could some me expert help me to make openvpn work at startup?
I'm following the instructions found in:
https://dotslashnotes.wordpress.com/201 ... -pi-linux/
But at the end I get an error message: /etc/init.d/VPNConnection: 26: /etc/init.d/VPNConnection: stop}?: not found
I'm not an expert in linux but I can follow step by step instructions. ;)
Regards
Pguerin

gerdesj
Posts: 24
Joined: Sun Nov 29, 2015 1:52 pm

Re: openvpn at startup in raspberry 1 running raspbian weeze

Sun Nov 29, 2015 2:02 pm

Type this and hit enter:

Code: Select all

ls -l /etc/init.d
You will get a listing of all the files in that directory. If you do not see one that is called VPNConnection then you need to create that file. You may find that you have mistyped its name in some way. Note that Linux is case sensitive so VPNconnection is not the same as VPNConnection.

Cheers
Jon

pguerin
Posts: 6
Joined: Sat Nov 28, 2015 8:39 am

Re: openvpn at startup in raspberry 1 running raspbian weeze

Sun Nov 29, 2015 7:24 pm

Hi
Thank you for this quick answer but this doesn-t seem to be the problem . I have the same issue with another connexion called vpn-paris.
Regards

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: openvpn at startup in raspberry 1 running raspbian weeze

Sun Nov 29, 2015 10:22 pm

I do have my wheezy openvpn working but. I do have to go outside for a couples of days and I set another Pi with Jessie.

I didn't take me long to configure openVPN on jessie Lite.

I follow this method I the only thing I did is to start on root first. sudo bash .

https://www.digitalocean.com/community/ ... n-debian-8

Also I use build-key-pass to create my client key. I prefer enter a password in case my equipment is stolen.


N.B. I used tun because It is for my Mac and My Android tablets. I know it is way easier with tap on a Window machine.

pguerin
Posts: 6
Joined: Sat Nov 28, 2015 8:39 am

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Nov 30, 2015 9:37 am

Thank you.
I mean, I've been able to make it work. What I would like now is to make it initiate when booting, in stead of typing the command in a terminal screen.
I have found a script that explains how to run automatically openvpn during the system startup and I'm trying to adapt it to my own network and device. But I get an error message and I wonder if the problem is:
- syntax
- misplaced
- privileges
To avoid transcription problems I have given the script the same name of the example (VPNConnection).
Then the only change to introduce in the example to fit with my openvpn configuration is at the line:
sudo openvpn config-filename-goes-here.ovpn
Since my openvpn config file name is proxpn.ovpn, this example line has been changed to:
sudo openvpn proxpn.ovpn.
The error message I get when running the script should explain what's wrong, but I'm not an expert. I only know a few very basic commands and I'm not able to understand what's wrong. :oops:
Could it be that the openvpn config file is misplaced?
I have pasted the script at the end of this post.
I test it with: sudo /etc/init.d/VPNConnection start
And I get: /etc/init.d/VPNConnection: 26: /etc/init.d/VPNConnection: stop}?: not found

#! /bin/sh
# /etc/init.d/VPNConnection

### BEGIN INIT INFO

# Short-Description: Simple script to start a program at boot
# Description: A simple script from http://www.stuffaboutcode.com which will start / stop a program a boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case “$1” in
start)
echo “Starting VPN Connection”
# Connect to the VPN
cd /etc/openvpn
sudo openvpn config-filename-goes-here.ovpn
;;
stop)
echo “Stopping VPN Connection”
# Disconnect
killall openvpn
;;
*)
echo “Usage: /etc/init.d/VPNConnection {start|stop}”
exit 1
;;
esac

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Nov 30, 2015 12:19 pm

If the file /etc/init.d/openvpn exist ?

Normally after an sudo apt-get install openvpn on wheezy it should!

Be sure that it is executable.

I don't understand why you have to do another script like VPNConnection. A least did you make it executable.

sudo chmod +x VPNConnection

Maybe I'm wrong since I did it more than 2 years ago on wheezy.

Why not upgrading your system to Jessie? I know that systemd suck sometimes but we have to get use to it.

pguerin
Posts: 6
Joined: Sat Nov 28, 2015 8:39 am

Re: openvpn at startup in raspberry 1 running raspbian weeze

Tue Dec 01, 2015 9:29 am

The file /etc/init.d/openvpn exists and it is executable.
I need a script to make openvpn run at startup. Otherwise I must type again the sudo openvpn command each time I boot the system.

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: openvpn at startup in raspberry 1 running raspbian weeze

Tue Dec 01, 2015 12:09 pm

is the script set to be executable ?

Check which service will run at startup (On wheezy)

Code: Select all

sudo service --status-all
you should have + at openvpn. If yes and it doesn't work check the log!


if the file is not executable please make it so . No x display when you do (ls -l /etc/init.d/openvpn)

Code: Select all

sudo chmod + x /etc/init.d/openvpn 

There is another setting that could prevent that

in /etc/default/openvpn be sure that AUTOSTART="all" or is remark.


For Jessie is different because of systemd.

bxlouis
Posts: 3
Joined: Mon Dec 28, 2015 5:07 pm

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Dec 28, 2015 5:11 pm

danjperron wrote:is the script set to be executable ?

Check which service will run at startup (On wheezy)

Code: Select all

sudo service --status-all
you should have + at openvpn. If yes and it doesn't work check the log!


if the file is not executable please make it so . No x display when you do (ls -l /etc/init.d/openvpn)

Code: Select all

sudo chmod + x /etc/init.d/openvpn 

There is another setting that could prevent that

in /etc/default/openvpn be sure that AUTOSTART="all" or is remark.


For Jessie is different because of systemd.
Hi danjperron, I have the same issue !
There is a - at openvpn. How do I turn it to + ?

I tried

Code: Select all

sudo chmod + x /etc/init.d/openvpn
but I get an error

Code: Select all

chmod: cannot access `x': No such file or directory
Thanks !

bxlouis
Posts: 3
Joined: Mon Dec 28, 2015 5:07 pm

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Dec 28, 2015 10:41 pm

Solved!
It turned to + after I set the network settings as static instead of dhcp.
I read on another forum that the openvpn service won't start on boot because the network settings are not ready when using dhcp. As soon as I set the eth0 interface to static, the service turned to + !

danjperron
Posts: 3502
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Dec 28, 2015 10:54 pm

For Jessie ,

there is a option in raspi-config to wait until the network is ready.

Maybe this what you need if you are in dchp.

bxlouis
Posts: 3
Joined: Mon Dec 28, 2015 5:07 pm

Re: openvpn at startup in raspberry 1 running raspbian weeze

Tue Dec 29, 2015 2:18 am

All right, I'll give it a try. Thanks though!

So to my understanding, you cannot set manually the + and - in service status ? It all depends on other settings?

Also, how can I know if I use Jessie, Raspbian, etc? I installed Domoticz through a custom SD image. So I don't know exactly what's under the hood.

Thank you for your help!

piman78912
Posts: 1
Joined: Mon Jul 11, 2016 4:28 pm

Re: openvpn at startup in raspberry 1 running raspbian weeze

Mon Jul 11, 2016 4:30 pm

I got the same error. It's one of these things that's so minute and dumb that it's infuriating that it's a problem at all.

Open up the script using nano and delete each of the quotation marks and retype them. For some reason, when you copy and paste the script form that site, they're not recognized as quotation marks so the script doesn't recognize the strings.

Mongolor
Posts: 1
Joined: Thu Aug 10, 2017 1:42 am

Re: openvpn at startup in raspberry 1 running raspbian weezee

Thu Aug 10, 2017 1:43 am

I made this account just to thank you for finding the Quote problem. Saved me the same head smashing frustration. Cheers.

Return to “Beginners”