I'm trying to set up a Systemd service that would restart my VPN connection (ProtonVPN) after resuming from suspend.
The command that does what I need is sudo protonvpn r
.
So here is what I did: I created a service /etc/systemd/system/protonvpn-restart.service
, containing the following:
[Unit]
Description=Restart ProtonVPN after suspend
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
[Service]
ExecStart=/bin/pvpn-resume
User=root
[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
and a script /bin/pvpn-resume
(I made sure it was executable) containing the following:
#!/bin/sh
protonvpn r
Then I ran sudo systemctl start protonvpn-restart.service && sudo systemctl enable protonvpn-restart.service
.
But in the end, when I suspend and come back, the VPN doesn't restart and I my Internet won't work until I run manually sudo protonvpn r
.
Can anyone help?