mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-25 09:21:10 +00:00
openvpn: Handle shortcut properly when enabling/disabling
This commit is contained in:
parent
2a3381415e
commit
05908d1680
@ -19,7 +19,7 @@
|
||||
Plinth module to configure OpenVPN server.
|
||||
"""
|
||||
|
||||
from django.urls import resolve, reverse_lazy
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
@ -76,9 +76,8 @@ def setup(helper, old_version=None):
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['openvpn'], is_external=True)
|
||||
|
||||
helper.call('post', add_shortcut)
|
||||
managed_services[0], title, ports=['openvpn'], is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
@ -98,6 +97,18 @@ def is_setup():
|
||||
return actions.superuser_run('openvpn', ['is-setup']).strip() == 'true'
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('openvpn')
|
||||
|
||||
|
||||
def diagnose():
|
||||
"""Run diagnostics and return the results."""
|
||||
return [action_utils.diagnose_port_listening(1194, 'udp4')]
|
||||
|
||||
@ -72,6 +72,8 @@ def setup(request):
|
||||
if not openvpn.is_setup() and not setup_process:
|
||||
setup_process = actions.superuser_run('openvpn', ['setup'], async=True)
|
||||
|
||||
openvpn.add_shortcut()
|
||||
|
||||
return redirect('openvpn:index')
|
||||
|
||||
|
||||
@ -131,9 +133,10 @@ def _apply_changes(request, old_status, new_status):
|
||||
|
||||
if old_status['enabled'] != new_status['enabled']:
|
||||
if new_status['enabled']:
|
||||
openvpn.service.enable()
|
||||
openvpn.enable()
|
||||
else:
|
||||
openvpn.service.disable()
|
||||
openvpn.disable()
|
||||
|
||||
modified = True
|
||||
|
||||
if modified:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user