You are not logged in.

#1 2017-08-31 07:14:37

ap
Member
Registered: 2017-08-09
Posts: 47

[SOLVED] run vpnc automatically at startup

Hi All,
as network connection manager I use wicd. I basically always use a vpn connection with vpnc; so I have created a myvpn.conf file for vpnc and I launch my vpn by

sudo vpnc myvpn

after which of course I need to input my sudo password. I would like this process to be automatically run at startup without having to type in the command and the password all the time.

Using network-manager one can select to automatically connect to a vpn for a specific network, however I would like this to be done for all connections. Furthermore, I have had various problems with network-manager in the past and have abandoned it in favour of wicd and I am looking for a solution using wicd...

Do you have any suggestions on how to do this?
Thanks in advance for your help!

PS: Always more amazed by BL the more I use it...seems like I've found my distro :-D

Last edited by ap (2017-08-31 08:45:59)

Offline

#2 2017-08-31 07:21:27

damo
....moderator....
Registered: 2015-08-20
Posts: 6,701

Re: [SOLVED] run vpnc automatically at startup

You can run sudo applications without a password by editing the sudoers file. Always edit this file with

sudo visudo

Add something like this to the bottom of the file...

YOURNAME ALL = NOPASSWD: /path/to/executable

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#3 2017-08-31 08:08:13

twoion
一期一会
Registered: 2015-08-10
Posts: 3,317

Re: [SOLVED] run vpnc automatically at startup

ap wrote:

Hi All,
as network connection manager I use wicd. I basically always use a vpn connection with vpnc; so I have created a myvpn.conf file for vpnc and I launch my vpn by

sudo vpnc myvpn

after which of course I need to input my sudo password. I would like this process to be automatically run at startup without having to type in the command and the password all the time.

Using network-manager one can select to automatically connect to a vpn for a specific network, however I would like this to be done for all connections. Furthermore, I have had various problems with network-manager in the past and have abandoned it in favour of wicd and I am looking for a solution using wicd...

Do you have any suggestions on how to do this?
Thanks in advance for your help!

PS: Always more amazed by BL the more I use it...seems like I've found my distro :-D

Arch comes with this vpnc service file, /usr/lib/systemd/system/vpnc@.service:

[Unit]                                                                                                                                                                       
Description=VPNC connection to %i
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
ExecStart=/usr/bin/vpnc --pid-file=/run/vpnc@%i.pid /etc/vpnc/%i.conf
PIDFile=/run/vpnc@%i.pid

[Install]
WantedBy=multi-user.target

So, in order to have your VPN autostart from the configuration file /etc/vpnc/myvpn.conf, you'd do:

systemctl enable vpnc@myvpn
systemctl start vpnc@myvpn

Note: network-online.target only works correctly when used with a fitting network manager, IIRC this is only network-manager at the moment.

On my system, I always start it manually.

Online

#4 2017-08-31 08:36:21

ap
Member
Registered: 2017-08-09
Posts: 47

Re: [SOLVED] run vpnc automatically at startup

Thanks for the great help, I am not on arch but it's interesting to know that they provide that vpnc service file. However, following damo's suggestion this is now sorted :-D

I have added YOURNAME ALL = NOPASSWD: /path/to/executable to my sudoers file and then add a .desktop entry to autostart the script and it works as requested.

I have a further question, how can I delay the execution of the script, say for example of 5 seconds? Wicd takes a bunch of seconds to connect and I need to wait for it to be connected, so how can I autostart my vpn after wicd is connected?

Thanks!

Offline

#5 2017-08-31 08:45:23

ap
Member
Registered: 2017-08-09
Posts: 47

Re: [SOLVED] run vpnc automatically at startup

Ok, sorted it myself...I have added "sleep 5" to the .sh script...I will change the thread as solved!

Offline

Board footer

Powered by FluxBB