You are not logged in.
Hi,
i want to run a bash script at boot that looks like :
#!/bin/bash
sudo openvpn --config "/PATH.ovpn" --auth-user-pass "/PATH/auth-user-pass.txt"
exit
i've tried crontab and creating a desktop file in ~/user/.config/autostart/
but nothign seems working.
If i run the file from terminal it works perfectly.
Any clue?
Offline
Generally speaking you want to redirect your stderr and stdout to something and check for errors there, for example
0 0 * * * bin/dropbox start >/tmp/stdout.log 2>/tmp/stderr.log
'sudo' certainly won't work, you need root cron, but again generally speaking if you need root cron, then you are probably doing something wrong.
edit: perhaps worth reading https://askubuntu.com/questions/464264/ … ly-at-boot
Last edited by brontosaurusrex (2018-01-15 21:58:19)
Offline
crontab looks a bit different:
@reboot sh PATH/VPN.sh
I would think anything triggered from crontab is sudo? Am I wrong? I'll try the logs , thanks.
Offline
I've never used openvpn but the package supplies some systemd unit files — have you tried enabling them?
sudo systemctl enable openvpn
Or perhaps:
sudo systemctl enable openvpn@wlan0
There is also the user option:
systemctl --user enable openvpn
But I've never used a VPN of any type so perhaps you should await the advice of somebody who has.
Offline
I have it half working if i add gksu to the .desktop file from .config/autostart folder but it asks for sudo credentials(as supposed to).
is there a way to grant sudo execution without entering passwords? sorry, noob here.
Offline
is there a way to grant sudo execution without entering passwords?
Yes, try putting "grant sudo execution without entering password" into any half-decent search engine and you should find a good link.
I really don't think that is how it is supposed to be done though.
Offline
you should really go the systemd route outlined in post #4.
also, installing new software, it is always advisable to read its documentation.
Offline
Thanks for all the tips! i'll test the suggestion from post 4 and take it from there.
Offline