Setting OpenConnect to autoconnect at startup

hi this is my first post in OSMC’s forums so first i wanna thank the devs for this great OS goodjob guys keep it up :smiley:
now as u migt know openconnect is client to connect to cisco’s vpn server (similar to anyconnect on windows and mac) . i installed this software via apt-get and its working good now my problem is i wanna set this to auto connect at system startup. i wrote and saved an one-line script which when u run openconnect connects to server and everything works i tried to make it run at startup using
#1 init.d and udpate-rc.d and
#2 systemd and systemctl
#3 putting the script in rc.local
but no luck so far… what shoud i do

On recent Linux systems you need to use systemd.

Create file /etc/systemd/system/my_vpn.service with following contents:

Description=Connect to my VPN

ExecStart=/bin/sh -c 'echo $password | sudo openconnect -u username --passwd-on-stdin vpn.server.tld'


Then execute:

sudo systemctl daemon-reload
sudo systemctl enable my_vpn
sudo systemctl start my_vpn

You’re done!

1 Like

Perfect working; additional benefit, this automatically reconnects.
Thank you, highly appreciated!

I didn’t found much about Openconnect & osmc, but it is working fine for me now. And this was the last puzzle step I needed. Would be great to have this as part of a how-to…