Example #1
0
 def get_initial(self):
     """Return the current status"""
     return {
         'hostname': config.get_hostname(),
         'domainname': config.get_domainname(),
         'homepage': config.get_home_page(),
         'advanced_mode': config.get_advanced_mode(),
     }
Example #2
0
    def post_init(self):
        """Perform post initialization operations."""
        if self.is_enabled():
            domain_added.send_robust(sender='avahi',
                                     domain_type='domain-type-local',
                                     name=get_hostname() + '.local',
                                     services='__all__')

        post_hostname_change.connect(on_post_hostname_change)
def init():
    """Initialize the service discovery module."""
    global app
    app = AvahiApp()
    if app.is_enabled():
        domain_added.send_robust(sender='avahi',
                                 domain_type='domain-type-local',
                                 name=get_hostname() + '.local',
                                 services='__all__')
        app.set_enabled(True)

    post_hostname_change.connect(on_post_hostname_change)
Example #4
0
def profile(request):
    """Provide the user's profile for download."""
    username = request.user.username
    domainname = config.get_domainname()

    if not config.get_domainname():
        domainname = config.get_hostname()

    profile_string = actions.superuser_run(
        'openvpn', ['get-profile', username, domainname])

    response = HttpResponse(profile_string,
                            content_type='application/x-openvpn-profile')
    response['Content-Disposition'] = \
        'attachment; filename={username}.ovpn'.format(username=username)

    return response
Example #5
0
def profile(request):
    """Provide the user's profile for download."""
    username = request.user.username
    domainname = config.get_domainname()

    if not config.get_domainname():
        domainname = config.get_hostname()

    profile_string = actions.superuser_run(
        'openvpn', ['get-profile', username, domainname])

    response = HttpResponse(profile_string,
                            content_type='application/x-openvpn-profile')
    response['Content-Disposition'] = \
        'attachment; filename={username}.ovpn'.format(username=username)

    return response
Example #6
0
    def __init__(self):
        """Create components for the app."""
        super().__init__()

        info = app_module.Info(app_id=self.app_id,
                               version=version,
                               name=_('Service Discovery'),
                               icon='fa-compass',
                               description=_description,
                               manual_page='ServiceDiscovery')
        self.add(info)

        menu_item = menu.Menu('menu-avahi',
                              info.name,
                              None,
                              info.icon,
                              'avahi:index',
                              parent_url_name='system')
        self.add(menu_item)

        domain_type = DomainType('domain-type-local',
                                 _('Local Network Domain'),
                                 'config:index',
                                 can_have_certificate=False)
        self.add(domain_type)

        firewall = Firewall('firewall-avahi',
                            info.name,
                            ports=['mdns'],
                            is_external=False)
        self.add(firewall)

        daemon = Daemon('daemon-avahi', managed_services[0])
        self.add(daemon)

        backup_restore = BackupRestore('backup-restore-avahi',
                                       **manifest.backup)
        self.add(backup_restore)

        if self.is_enabled():
            domain_added.send_robust(sender='avahi',
                                     domain_type='domain-type-local',
                                     name=get_hostname() + '.local',
                                     services='__all__')

        post_hostname_change.connect(on_post_hostname_change)
Example #7
0
def set_hostname(hostname):
    """Sets machine hostname to hostname"""
    old_hostname = config.get_hostname()
    domainname = config.get_domainname()

    # Hostname should be ASCII. If it's unicode but passed our
    # valid_hostname check, convert
    hostname = str(hostname)

    pre_hostname_change.send_robust(sender='config', old_hostname=old_hostname,
                                    new_hostname=hostname)

    LOGGER.info('Changing hostname to - %s', hostname)
    actions.superuser_run('hostname-change', [hostname])

    LOGGER.info('Setting domain name after hostname change - %s', domainname)
    actions.superuser_run('domainname-change', [domainname])

    post_hostname_change.send_robust(sender='config',
                                     old_hostname=old_hostname,
                                     new_hostname=hostname)
Example #8
0
def get_status(request):
    """Return the current status"""
    return {
        'hostname': config.get_hostname(),
        'domainname': config.get_domainname(),
    }