Update openvpn (#567)
* 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
This commit is contained in:
parent
811ade8160
commit
0ddaa6f984
@ -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"
|
||||
|
||||
@ -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"),
|
||||
@ -55,6 +57,11 @@ class OpenVPN(IntervalModule):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user