You are not logged in.

#1 2022-11-05 03:30:11

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 519

[Solved] Autoconnect to ProtonVPN: systemd service

I have been trying to run '/usr/bin/protonvpn-cli connect -f' when I log in and I am connected to the Internet. This is what I've done so far:

Service definition (~/.config/systemd/user/auto-protonvpn.service):

[Unit]
Description=ProtonVPN Connection
After=network-online.target
BindsTo=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/protonvpn-cli connect -f
ExecStop=/usr/bin/protonvpn-cli disconnect
ExecReload=/usr/bin/protonvpn-cli reconnect
RemainAfterExit=yes
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target

- Make the `network-online.target` available for the user daemon: `systemctl --user link /usr/lib/systemd/system/network-online.target`
- Reload the daemon: `systemctl --user daemon-reload`
- Enable the service: `systemctl --user enable auto-protonvpn.service`
- Reboot

I see these logs (journalctl --user -u auto-protonvpn.service):

Nov 05 04:18:50 asus-arch-icar systemd[1129]: Started ProtonVPN Connection.
Nov 05 04:18:55 asus-arch-icar protonvpn-cli[3345]: Setting up Proton VPN.
Nov 05 04:18:55 asus-arch-icar protonvpn-cli[3345]: Connecting to Proton VPN on ES#21 with UDP.
Nov 05 04:18:55 asus-arch-icar protonvpn-cli[3345]: Successfully connected to Proton VPN.
Nov 05 04:20:39 asus-arch-icar systemd[1129]: Stopping ProtonVPN Connection...
Nov 05 04:20:40 asus-arch-icar protonvpn-cli[4119]: Attempting to disconnect from Proton VPN.
Nov 05 04:20:40 asus-arch-icar protonvpn-cli[4119]: [org.freedesktop.DBus.Error.NameHasNoOwner] ('Could not activate remote peer: activation request failed: a concurrent deactivation request is already in progress.',)
Nov 05 04:20:40 asus-arch-icar systemd[1129]: auto-protonvpn.service: Control process exited, code=exited, status=1/FAILURE
Nov 05 04:20:40 asus-arch-icar systemd[1129]: auto-protonvpn.service: Failed with result 'exit-code'.

I don't understand why it's trying to exit after activating, given that I set RemainAfterExit=yes... Also, I can 'systemctl --user start auto-protonvpn.service' and it works fine.

Last edited by icar (2022-11-06 20:39:27)

Offline

#2 2022-11-06 19:00:44

zpg443
Member
Registered: 2016-12-03
Posts: 300

Re: [Solved] Autoconnect to ProtonVPN: systemd service

The problem is "activation request failed: a concurrent deactivation request is already in progress."

Add StartLimitIntervalSec and StartLimitBurst directives in the [Unit] section, such as:

StartLimitIntervalSec=500
StartLimitBurst=5

This prevents a failing service from being restarted every 5 seconds. This will give it 5 attempts, if it still fails, systemd will stop trying to start the service. Note, either way your log should show an attempt to restart. In your case, it did not because the restart request was already in progress, so the control process failed.

Last edited by zpg443 (2022-11-06 19:01:44)

Offline

#3 2022-11-06 20:38:55

icar
Member
From: Catalunya
Registered: 2020-07-31
Posts: 519

Re: [Solved] Autoconnect to ProtonVPN: systemd service

I do want to try reconnecting and don't give up. I figured it out, anyway:

https://gist.github.com/juxuanu/4935b58 … 8dde70939f

This worked.

Last edited by icar (2022-11-20 20:34:10)

Offline

Board footer

Powered by FluxBB