Skip to content

Commit

Permalink
Update openvpn (enkore#567)
Browse files Browse the repository at this point in the history
* Update openvpn

openvpn 2.4 has changed their services API so the clients are called openvpn-client now

* auto select service name based on openvpn version

default is the old service names, and if version is 2.4, switched to the new service names

* oops remove whitespace

* Add a config to use new openvpn service names

* remove extra comment

* change the variable name

* oops 😅 forgot to change the option name in settings

* update option description
  • Loading branch information
erfanio authored and facetoe committed Apr 27, 2017
1 parent 811ade8 commit 0ddaa6f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion i3pystatus/openvpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class OpenVPN(IntervalModule):
status_up = '▲'
status_down = '▼'
format = "{vpn_name} {status}"
status_command = "bash -c 'systemctl show openvpn@%(vpn_name)s | grep ActiveState=active'"

use_new_service_name = False
status_command = "bash -c 'systemctl show openvpn@%(vpn_name)s | grep ActiveState=active'"
vpn_up_command = "sudo /bin/systemctl start openvpn@%(vpn_name)s.service"
vpn_down_command = "sudo /bin/systemctl stop openvpn@%(vpn_name)s.service"

Expand All @@ -46,6 +47,7 @@ class OpenVPN(IntervalModule):
("status_down", "Symbol to display when down"),
("status_up", "Symbol to display when up"),
("vpn_name", "Name of VPN"),
("use_new_service_name", "Use new openvpn service names (openvpn 2.4^)"),
("vpn_up_command", "Command to bring up the VPN - default requires editing /etc/sudoers"),
("vpn_down_command", "Command to bring up the VPN - default requires editing /etc/sudoers"),
("status_command", "command to find out if the VPN is active"),
Expand All @@ -55,6 +57,11 @@ def init(self):
if not self.vpn_name:
raise Exception("vpn_name is required")

if self.use_new_service_name:
self.status_command = "bash -c 'systemctl show openvpn-client@%(vpn_name)s | grep ActiveState=active'"
self.vpn_up_command = "sudo /bin/systemctl start openvpn-client@%(vpn_name)s.service"
self.vpn_down_command = "sudo /bin/systemctl stop openvpn-client@%(vpn_name)s.service"

def toggle_connection(self):
if self.connected:
command = self.vpn_down_command
Expand Down

0 comments on commit 0ddaa6f

Please sign in to comment.