mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
dynamicdns: Add/remove domains when app is enabled/disabled
This seems to be the most useful function for enabling/disabling dynamic DNS. This is also what users are likely to expect. Tests: - Disable app. The domains will be removed from list of domains in Names app. Installed applications will be reconfigured. - Enable app. The domains will be added to list of domains in Names app. Installed applications will be reconfigured. - When app is disabled. Adding/removing domain does not trigger app configuration apps. Domains are not added to Names app. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
ca5f547c02
commit
a660194308
@ -98,6 +98,21 @@ class DynamicDNSApp(app_module.App):
|
||||
# Check every 5 minutes to perform dynamic DNS updates.
|
||||
glib.schedule(300, update_dns)
|
||||
|
||||
def enable(self):
|
||||
"""Send domain signals after enabling the app."""
|
||||
super().enable()
|
||||
config = get_config()
|
||||
for domain_name in config['domains']:
|
||||
notify_domain_added(domain_name)
|
||||
|
||||
def disable(self):
|
||||
"""Send domain signals before disabling the app."""
|
||||
config = get_config()
|
||||
for domain_name in config['domains']:
|
||||
notify_domain_removed(domain_name)
|
||||
|
||||
super().disable()
|
||||
|
||||
def setup(self, old_version):
|
||||
"""Install and configure the app."""
|
||||
super().setup(old_version)
|
||||
@ -269,13 +284,15 @@ def set_config(config):
|
||||
|
||||
def notify_domain_added(domain_name):
|
||||
"""Send a signal that domain has been added."""
|
||||
domain_added.send_robust(sender='dynamicdns',
|
||||
domain_type='domain-type-dynamic',
|
||||
name=domain_name, services='__all__')
|
||||
if app_module.App.get('dynamicdns').is_enabled():
|
||||
domain_added.send_robust(sender='dynamicdns',
|
||||
domain_type='domain-type-dynamic',
|
||||
name=domain_name, services='__all__')
|
||||
|
||||
|
||||
def notify_domain_removed(domain_name):
|
||||
"""Send a signal that domain has been removed."""
|
||||
domain_removed.send_robust(sender='dynamicdns',
|
||||
domain_type='domain-type-dynamic',
|
||||
name=domain_name)
|
||||
if app_module.App.get('dynamicdns').is_enabled():
|
||||
domain_removed.send_robust(sender='dynamicdns',
|
||||
domain_type='domain-type-dynamic',
|
||||
name=domain_name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user