Somehow new to Linux, have used it in the past, though not as extensively as now.
What I am trying to achieve here is to start a openvpn service as soon as the computer boots. I have partially achieved this. I have several .ovpn files that are configured to connect to different countries. I have first created a script that asks which country that I want to connect to, then makes the connection.
What now I want to do is make it automatic, so that everytime that I boot into my user, I want the service to prompt me for input and then run it. The issue here is that I can not manage to force the service to prompt me for input.
Bash code:
#!/bin/bash
echo Which server do you want to connect
read -p 'Server(pt, se, nl, es, no, is, ch, de, ca, au, at): ' server
echo "You selected " $server
sudo openvpn /opt/ProtonVPN/$server.protonvpn.com.udp.ovpn
This code works great by itself.
To create a service I followed the following article: How do I create a service for a shell script so I can start and stop it like a daemon?
So my service file looks like this:
[Unit]
Description=Connect to ProtonVPN
[Service]
Type=simple
ExecStart=/home/{user}/bin/proton-run.sh
I then restarted the daemon with: systemctl daemon-reload
I tried to run the service with: sudo systemctl start proton-run.service
, but I never get prompted for a input, so the script crashes, screenshot attached:
Any help ? I have read about systemd-ask-password but I don't think that it is what I need.