Made the openvpn module more flexible by allowing custom status commands, making it compatible with networkmanager based VPNs. Also changed the spelling of colour_down and colour_up to color so the module is the same as all of the others
This commit is contained in:
parent
8e3857ccd0
commit
8254eaf43e
@ -23,7 +23,7 @@ class OpenVPN(IntervalModule):
|
|||||||
status_up = '▲'
|
status_up = '▲'
|
||||||
status_down = '▼'
|
status_down = '▼'
|
||||||
format = "{vpn_name} {status}"
|
format = "{vpn_name} {status}"
|
||||||
status_command = "bash -c \"systemctl show openvpn@%(vpn_name)s | grep -oP 'ActiveState=\K(\w+)'\""
|
status_command = "bash -c \"systemctl show openvpn@%(vpn_name)s | grep 'ActiveState=active'"
|
||||||
|
|
||||||
label = ''
|
label = ''
|
||||||
vpn_name = ''
|
vpn_name = ''
|
||||||
@ -35,6 +35,7 @@ class OpenVPN(IntervalModule):
|
|||||||
("status_down", "Symbol to display when down"),
|
("status_down", "Symbol to display when down"),
|
||||||
("status_up", "Symbol to display when up"),
|
("status_up", "Symbol to display when up"),
|
||||||
("vpn_name", "Name of VPN"),
|
("vpn_name", "Name of VPN"),
|
||||||
|
("status_command", "command to find out if the VPN is active"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
@ -45,7 +46,7 @@ class OpenVPN(IntervalModule):
|
|||||||
command_result = run_through_shell(self.status_command % {'vpn_name': self.vpn_name}, enable_shell=True)
|
command_result = run_through_shell(self.status_command % {'vpn_name': self.vpn_name}, enable_shell=True)
|
||||||
output = command_result.out.strip()
|
output = command_result.out.strip()
|
||||||
|
|
||||||
if output == 'active':
|
if output:
|
||||||
color = self.color_up
|
color = self.color_up
|
||||||
status = self.status_up
|
status = self.status_up
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user