Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openpyn not auto-starting after system boot #80

Closed
ghost opened this issue Jan 3, 2018 · 18 comments
Closed

openpyn not auto-starting after system boot #80

ghost opened this issue Jan 3, 2018 · 18 comments

Comments

@ghost
Copy link

ghost commented Jan 3, 2018

I have the systemd service installed, but after a system reboot, I need to manually run sudo systemctl start openpyn for the service to actually connect to nord.

If I check systemctl status openpyn, i get:

Jan 03 13:44:28 slash systemd[1]: Started NordVPN connection manager.
Jan 03 13:44:29 slash openpyn[541]: There was an ambiguous exception, Check Your Network Connection. forgot to flush iptables? 

Any idea how to fix this?

I am using Network Manager to connect to wifi.
I'm running on Arch with a cloned git version (AUR version did not work)

@jotyGill
Copy link
Owner

jotyGill commented Jan 4, 2018

This should fix it. and yeah Arch repo doesn't work. just don't have the time yet.

@ghost
Copy link
Author

ghost commented Jan 4, 2018

I'm not sure how to make that work. Here's what I tried:

cd ~/openpyn-nordvpn
git checkout test
sudo pythong setup.py install

openpyn --init
sudo openpyn -d uk

Then after a reboot, I still get the error. I'm not a pro at python, so maybe I missed something!

As for the arch repo, do you need any help?

@jotyGill
Copy link
Owner

jotyGill commented Jan 4, 2018

The commit is not pushed to the master branch yet. Grab the 'test' branch.

sudo pip3 uninstall openpyn
git clone --branch test https://github.com/jotyGill/openpyn-nordvpn.git
cd openpyn-nordvpn
sudo python3 setup.py install

I haven't had the time to learn about Arch repo upload,
Ubermensch85 had a go at it #58, if you want to have a look at that, that would be great.

@ghost
Copy link
Author

ghost commented Jan 4, 2018

I did as instructed, then I re-enabled openpyn, but still, after reboot, I get the same error!

I'll give the arch issue a look!

@jotyGill
Copy link
Owner

jotyGill commented Jan 6, 2018

First check if the running version is 2.1.4
openpyn -v

For some reason by the time systemd service starts your network isn't coming up. I am assuming that your PC auto connects to wifi, you don't have to manually connect to it.

@ghost
Copy link
Author

ghost commented Jan 6, 2018

I am indeed using version 2.1.4

Yes, my PC is set to auto connect to wifi. I had run nmcli dev set wlp0 autoconnect yes
So, the problem is that openpyn tried to connect, but network manager didn't have to connect yet.
When network manager did indeed complete connection, openpyn is in dead mode.

Maybe, i could create a network manager hook that would restart the openpyn service on connection?

@jotyGill
Copy link
Owner

jotyGill commented Jan 7, 2018

Try just adding some delay in the /etc/systemd/system/openpyn.service file.

Before "ExecStart"
ExecStartPre=/bin/sleep 10
remember it will be overwritten if you run openpyn with -d
If others report the same issue I'll hard code it.

@ghost
Copy link
Author

ghost commented Jan 9, 2018

I tried this on my other computer which is connected by ethernet, and still this did not work!

@ghost
Copy link
Author

ghost commented Jan 10, 2018

So, using openpyn from both master and test branch, was no longer generating a systemd service that was working for me at all, regardless if I was on ethernet or wifi.
So, after some fiddling, I came up with this simpler but different systemd configuration file. What do you think?

[Unit]
Description=Nord Service

[Service]
Type=oneshot
WorkingDirectory=/usr/share/openpyn
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/openpyn hk --max-load 70 --top-servers 4 --pings 5 --silent
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

@jotyGill
Copy link
Owner

Let me know if there's still any issue with the service file on Arch.

@ghost
Copy link
Author

ghost commented Jan 23, 2018

I've been using the custom script I pasted above and did not try anything new because the default openpyn script did not work even when doing openpyn -d. Is there an update that happened in the meantime?

@jotyGill
Copy link
Owner

yeah i added 10 second delay. and fixed the space issue

@ghost
Copy link
Author

ghost commented Feb 8, 2018

I reinstalled both from master and from test, and in both cases the systemctl daemon is just dead and won't even start.

* openpyn.service - NordVPN connection manager
   Loaded: loaded (/etc/systemd/system/openpyn.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

On the other hand, the script I use above does the job!

@jotyGill
Copy link
Owner

jotyGill commented Feb 9, 2018

that's weird, run this
sudo openpyn -d uk

and paste the output of
systemctl status openpyn
journalctl -xe

@ghost
Copy link
Author

ghost commented Feb 9, 2018

Actually, I realized that when I run the first command, it blocks the console. When I cancel it, I get an error. Not sure if that's of any value.

❯ sudo openpyn -d uk
The Following config has been saved in openpyn.service. You can Run it or/and Enable it with: 'sudo systemctl start openpyn', 'sudo systemctl enable openpyn' 

 [Unit]
Description=NordVPN connection manager
Wants=network-online.target
After=network-online.target
After=multi-user.target
[Service]
Type=simple
User=root
WorkingDirectory=/usr/share/openpyn/
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/openpyn uk --max-load 70 --top-servers 10 --pings 5 --silent
ExecStop=/usr/bin/openpyn --kill
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

Started Openpyn by running 'systemctl start openpyn'
To check VPN status, run 'systemctl status openpyn'
^CTraceback (most recent call last):
  File "/usr/bin/openpyn", line 11, in <module>
    load_entry_point('openpyn==2.4.2', 'console_scripts', 'openpyn')()
  File "/usr/lib/python3.6/site-packages/openpyn-2.4.2-py3.6.egg/openpyn/openpyn.py", line 133, in main
    args.skip_dns_patch, args.silent, args.nvram, args.openvpn_options)
  File "/usr/lib/python3.6/site-packages/openpyn-2.4.2-py3.6.egg/openpyn/openpyn.py", line 227, in run
    systemd.update_service(openpyn_options, run=True)
  File "/usr/lib/python3.6/site-packages/openpyn-2.4.2-py3.6.egg/openpyn/systemd.py", line 41, in update_service
    subprocess.run(["systemctl", "start", "openpyn"])
  File "/usr/lib/python3.6/subprocess.py", line 405, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib/python3.6/subprocess.py", line 835, in communicate
    self.wait()
  File "/usr/lib/python3.6/subprocess.py", line 1457, in wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.6/subprocess.py", line 1404, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt
❯ systemctl status openpyn
* openpyn.service - NordVPN connection manager
   Loaded: loaded (/etc/systemd/system/openpyn.service; dis
   Active: inactive (dead)

> journalctl -xe

-- Logs begin at Fri 2018-02-09 13:36:04 +07, end at Fri 2018-02-09 13:36:27 +07. --
Feb 09 13:36:04 slash sudo[3484]: pam_unix(sudo:session): session closed for user root
Feb 09 13:36:05 slash sudo[3525]:    orvad : TTY=pts/1 ; PWD=/var/lib/systemd/coredump ; USER=root ; COMMAND=/usr/bin/pacman -
Feb 09 13:36:05 slash sudo[3525]: pam_unix(sudo:session): session opened for user root by (uid=0)
Feb 09 13:36:05 slash sudo[3525]: pam_unix(sudo:session): session closed for user root
Feb 09 13:36:18 slash sudo[3613]:    orvad : TTY=pts/1 ; PWD=/var/lib/systemd/coredump ; USER=root ; COMMAND=/usr/bin/openpyn 
Feb 09 13:36:18 slash sudo[3613]: pam_unix(sudo:session): session opened for user root by (uid=0)
Feb 09 13:36:18 slash systemd[1]: Reloading.
Feb 09 13:36:19 slash sudo[3613]: pam_unix(sudo:session): session closed for user root
Feb 09 13:36:21 slash sudo[3672]:    orvad : TTY=pts/1 ; PWD=/var/lib/systemd/coredump ; USER=root ; COMMAND=/usr/bin/openpyn 
Feb 09 13:36:21 slash sudo[3672]: pam_unix(sudo:session): session opened for user root by (uid=0)
Feb 09 13:36:21 slash systemd[1]: Reloading.
Feb 09 13:36:27 slash sudo[3124]: pam_unix(sudo:session): session closed for user root

@jotyGill
Copy link
Owner

jotyGill commented Feb 9, 2018

The block should only be 10 seconds, the sleep time.
wait 10 seconds and see.

unless Arch doesn't work with network-online.target, I dont see why it should break.

@gelldur
Copy link

gelldur commented Aug 7, 2018

Hello there
I;m using version 2.2 from AUR and can't connect to NordVPN

$ sudo systemctl status openpyn 
● openpyn.service - NordVPN connection manager
   Loaded: loaded (/etc/systemd/system/openpyn.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Tue 2018-08-07 12:32:19 CEST; 2s ago
  Process: 1949 ExecStop=/bin/openpyn --kill (code=exited, status=0/SUCCESS)
  Process: 1940 ExecStart=/bin/openpyn pl --silent (code=exited, status=0/SUCCESS)
  Process: 1931 ExecStartPre=/usr/bin/sleep 10 (code=exited, status=0/SUCCESS)
 Main PID: 1940 (code=exited, status=0/SUCCESS)

sie 07 12:32:08 Gelldur-Dell systemd[1]: Starting NordVPN connection manager...
sie 07 12:32:18 Gelldur-Dell systemd[1]: Started NordVPN connection manager.
sie 07 12:32:19 Gelldur-Dell openpyn[1940]: There was an ambiguous exception, Check Your Network Connection. forgot to flush iptables? (openpyn -x)

@jotyGill
Copy link
Owner

jotyGill commented Aug 7, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants