0

I'm trying to automate the connection of a VPN tunnel via cron upon system boot.
I have a bash-script triggered by roots cron sudo crontab -e (because some other commands needs elevation).

I'd be fine using piactl (cli), but when trying to connect I get a message saying the client needs to be started, so...
One of the steps I'd like to perform is to start an GUI application (pia-client) on my non-root users display.

The following command works directly from terminal:

sudo su
runuser -l $username -c 'DISPLAY=:0 /opt/piavpn/bin/pia-client &> /dev/null &'

However, when I put that into my script is doesn't work.
The script is executable chmod +x /path/to/script.sh and other commands in the same script is working.

Anyone have a solution here?

0

1 Answer 1

0

This is embarrassing as I've already asked this exact question only days ago. Didn't even realize...

The solution is to add full path-to-command as the command is not in cron's PATH.
Changed the code to:

sudo su
/sbin/runuser -l $username -c 'DISPLAY=:0 /opt/piavpn/bin/pia-client &> /dev/null &'

Source/credit: @steeldriver's comment on this question

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .