I have a route-up script that checks for dnsleaks via the ipleak.net/json api and if everything is fine then starts another script that should run qbittorrent on my Kubuntu 20.04 VirtualBox. I had a few problems with starting qbittorrent because a few environment variables were missing but I managed to find them using `env` and then just apply them inside the script. The script now runs fine whenever OpenVPN is started via the following command:
Code: Select all
sudo openvpn --config /etc/openvp/file.conf
When I configured /etc/default/openvpn to start the .conf file and restarted the machine or just ran
I have noticed that qbittorrent has not started and decided to check /var/log/syslog. To my surprise the script couldn't open qbittorrent because /home/vbox doesn't exist when the script runs. I checked it by adding the following to the script:
The directory exists when I check it via Konsole/Terminal and start openvpn via --config, but it doesn't when OpenVPN is started as a service.
The following lines are shown in syslog
Code: Select all
Apr 1 11:47:28 vbox openvpn[3770]: /bin/ls: cannot access '/home/vbox': No such file or directory
Apr 1 11:47:28 vbox openvpn[3772]: sudo: unable to change directory to /home/vbox: Permission denied
Apr 1 11:47:28 vbox openvpn[3771]: sudo: unable to execute /bin/bash: Permission denied
The first error is when I run the /bin/ls command to check if the directory exist and the two other are when the qbittorrent start-up script is supposed to start as the user via the following command:
Code: Select all
sudo -i -u vbox /etc/openvpn/qbit-startup &
/etc/openvpn/qbit-startup:
Code: Select all
#!/bin/bash
# This script starts qbittorrent as vbox user from root executed script (OpenVPN)
# It has to be started as the user via `sudo -i -u USER`
echo "Starting qbittorrent"
export XDG_RUNTIME_DIR=/run/user/1000
export DISPLAY=:0
export KDE_FULL_SESSION=true
setsid qbittorrent &>/dev/null
This script doesn't run at all. Would anyone know why /home/vbox does not exist in the script when OpenVPN is started as a service?