I have a working bash script that starts the easyvpn snap with a working config file. I want to run this script on boot so that my ubuntu core device autoconnects to my vpn on boot.
My Bash Script in /home/alexlanganke/:
#!/bin/bash echo "easy-openvpn.connect-server /home/alexlanganke/vpnconfig.ovpn" | bash This file is naturally been made executable and has been tested successfully on its own.
My systemd Service file in /etc/systemd/system/:
[Unit] Description=VPN Autostart [Service] ExecStart=/home/alexlanganke/autostart_vpn.sh [Install] WantedBy=multi-user.target The Systemd service has been started and enabled. Do you by chance see what I am doing wrong or missing?
journalctl -u output:
Mar 27 16:50:14 localhost.localdomain autostart_vpn.sh[1373]: bash: line 1: easy-openvpn.connect-server: command not found Looks to me as if the easyvpn command is not known to bash when run via systemd. Wrong path?
2 Answers
The Problem arises because SystemD is run as root. The easyvpn command mentioned above is not known systemwide.
The Path can be corrected by changing the bash command to:
#!/bin/bash echo "snap run easy-openvpn.connect-server /home/alexlanganke/vpnconfig.ovpn" | bash Found the Solution with better explanation here: How to run a command in a snap package
In terminal type nm-connection-editor, open the wired/wireless connection profile where you wish to use VPN, and edit the following... changing "default_openvpn" to the path/name of your openvpn connection script...
