Rafficer / linux-cli-community

Linux command-line client for ProtonVPN. Written in Python.
https://protonvpn.com
GNU General Public License v3.0
1.31k stars 198 forks source link

ProtonVPN causes slow shutdown on Linux - how to auto-disconnect on KDE logout/shutdown? #240

Closed SpectrumDT closed 4 years ago

SpectrumDT commented 4 years ago

Hi! I am running Kubuntu 20.04 (Linux) and the command-line ProtonVPN client. I am trying to automatically disconnect from ProtonVPN when I shut down.

I have this problem: On shutdown, I get the message: "A stop job is running for session (number) of user (name)". This takes 90 seconds to time out, and I have no option of killing it. I don't want shutdown to take an extra 90 seconds.

This appears to be caused by ProtonVPN. If I disconnect from ProtonVPN before shutting down, the problem is gone:

$ sudo protonvpn d

I have added this application to my sudoers so I can sudo it without having to enter my password. This works fine for my startup script, at least.

What I want to do: Set up a script that disconnects from VPN (by running "sudo protonvpn d") automatically upon logout. Surely others have done this before. Somehow I cannot get it to work.

So I've written a script containing this (and nothing else):

sudo protonvpn d > ~/protonvpn.txt

I pipe the output into a file purely in order to verify that the script gets run. I've set execution permissions on the script file so it can run:

-rwxrwxr-x 1 spectrum spectrum 35 Sep 24 18:48 shutdown.sh*

I can run the script manually from the command line and it generates the file ~/protonvpn.txt.

I've set up the script in System Settings -> Startup and Shutdown -> Autostart to run on logout. A symlink to the script appears in ~/.config/plasma-workspace/shutdown/. But when I log out, the file ~/protonvpn.txt does not get generated. And if I shut down while having VPN connected, I still get the 90 second timeout.

Do you have any advice for how to get ProtonVPN to disconnect upon shutdown?

Thanks in advance!

SpectrumDT commented 4 years ago

It turns out I need to use full paths in my script:

    #!/bin/bash
    sudo /usr/local/bin/protonvpn d

... or, if I want the text file output:

    #!/bin/bash
    sudo /usr/local/bin/protonvpn d > /home/$USER/protonvpn.txt

Now it seems to work.

Credit to koffeinfriedhof at forum.kde.org for this solution.