I'm trying to create a script that runs in terminal is automatically started in a raspberry pi 'screen' output. The problem here is that I need
sudo privileges inside the script, and that once the process is running I don't see the request for the password.
One example of the script is the following (if I get this to work I can adapt the script for other purposes):
1) go to a folder:
2) execute the service (this requires sudo privileges):
sudo openvpn ./pia_netherlands.conf
When I enter the code manually the script does run so there is no problem there, I just have a problem executing this inside a 'screen'.
I've set up the following script using some googling:
#!/bin/sh if [ -z "$STY" ]; then exec screen -dm -S pia /bin/bash "$0"; fi cd /etc/openvpn sudo openvpn ./pia_netherlands.conf
This script should check if there is a screen called 'pia' and if not create a screen called pia and run the script by firstly going to the folder and then run the openvpn file.
I've tried a second script that is a bit more straightforward but this also doesn’t work:
sudo bash screen -S pia cd /etc/openvpn openvpn ./pia_netherlands.conf
This script opens a bash screen called 'pia', goes to the folder, and executes the openvpn file.
Both methods are not working, and I really have difficulties finding out how to get it to run. Can anyone help me please?
I've also consulted the raspberry pi forums but no one replied, I guess because this is more of a linux question than a raspberry question.