예제 #1
0
def add_introducer(introducer):
    """Add an introducer to the storage node's list of introducers.
    Param introducer must be a tuple of (pet_name, furl)
    """
    actions.run_as_user(
        'tahoe-lafs', ['add-introducer', "--introducer", ",".join(introducer)],
        become_user='******')
예제 #2
0
def remove_introducer(pet_name):
    """Rename the introducer entry in the introducers.yaml file specified by
    the param pet_name.
    """
    actions.run_as_user('tahoe-lafs',
                        ['remove-introducer', '--pet-name', pet_name],
                        become_user='******')
예제 #3
0
def remove_introducer(pet_name):
    """Rename the introducer entry in the introducers.yaml file specified by
    the param pet_name.
    """
    actions.run_as_user('tahoe-lafs',
                        ['remove-introducer', '--pet-name', pet_name],
                        become_user='******')
예제 #4
0
def add_introducer(introducer):
    """Add an introducer to the storage node's list of introducers.
    Param introducer must be a tuple of (pet_name, furl)
    """
    actions.run_as_user('tahoe-lafs',
                        ['add-introducer',
                         "--introducer",
                         ",".join(introducer)],
                        become_user='******')
예제 #5
0
def post_setup(configured_domain_name):
    """Actions to be performed after installing tahoe-lafs package."""
    actions.superuser_run('tahoe-lafs',
                          ['setup', '--domain-name', configured_domain_name])
    actions.run_as_user('tahoe-lafs', ['create-introducer'],
                        become_user='******')
    actions.run_as_user('tahoe-lafs', ['create-storage-node'],
                        become_user='******')
    actions.superuser_run('tahoe-lafs', ['autostart'])
    app.enable()
예제 #6
0
    def __call__(self, value):
        """Validate a directory."""
        if not value.startswith('/'):
            raise ValidationError(_('Invalid directory name.'), 'invalid')

        command = ['validate-directory', '--path', value]
        if self.check_creatable:
            command.append('--check-creatable')
        elif self.check_writable:
            command.append('--check-writable')

        if self.username:
            output = actions.run_as_user('storage', command,
                                         become_user=self.username)
        else:
            output = actions.run('storage', command)

        if 'ValidationError' in output:
            error_nr = int(output.strip().split()[1])
            if error_nr == 1:
                raise ValidationError(_('Directory does not exist.'),
                                      'invalid')
            elif error_nr == 2:
                raise ValidationError(_('Path is not a directory.'), 'invalid')
            elif error_nr == 3:
                raise ValidationError(
                    _('Directory is not readable by the user.'), 'invalid')
            elif error_nr == 4:
                raise ValidationError(
                    _('Directory is not writable by the user.'), 'invalid')
예제 #7
0
def get_local_introducer():
    """Return the name and furl of the introducer created on this FreedomBox.
    """
    introducer = actions.run_as_user('tahoe-lafs', ['get-local-introducer'],
                                     become_user='******')

    return json.loads(introducer)
예제 #8
0
    def form_valid(self, form):
        """Apply new superuser password if it exists"""
        new_config = form.cleaned_data

        password = new_config.get('super_user_password')
        if password:
            actions.run_as_user(
                'mumble',
                ['create-password'],
                input=password.encode(),
                become_user="******",
            )
            messages.success(self.request,
                             _('SuperUser password successfully updated.'))

        return super().form_valid(form)
예제 #9
0
def get_local_introducer():
    """Return the name and furl of the introducer created on this FreedomBox.
    """
    introducer = actions.run_as_user('tahoe-lafs', ['get-local-introducer'],
                                     become_user='******')

    return json.loads(introducer)
예제 #10
0
def get_introducers():
    """Return a dictionary of all introducers and their furls added to the
    storage node running on this FreedomBox.
    """
    introducers = actions.run_as_user('tahoe-lafs', ['get-introducers'],
                                      become_user='******')

    return json.loads(introducers)
예제 #11
0
def get_introducers():
    """Return a dictionary of all introducers and their furls added to the
    storage node running on this FreedomBox.
    """
    introducers = actions.run_as_user('tahoe-lafs', ['get-introducers'],
                                      become_user='******')

    return json.loads(introducers)
예제 #12
0
    def form_valid(self, form):
        """Apply new superuser password if it exists"""
        new_config = form.cleaned_data

        if mumble.get_domain() != new_config['domain']:
            mumble.set_domain(new_config['domain'])
            mumble.app.get_component('letsencrypt-mumble').setup_certificates()
            messages.success(self.request, _('Configuration updated'))

        password = new_config.get('super_user_password')
        if password:
            actions.run_as_user(
                'mumble',
                ['create-password'],
                input=password.encode(),
                become_user="******",
            )
            messages.success(self.request,
                             _('SuperUser password successfully updated.'))

        return super().form_valid(form)
예제 #13
0
def post_setup(configured_domain_name):
    """Actions to be performed after installing tahoe-lafs package."""
    actions.superuser_run('tahoe-lafs',
                          ['setup', '--domain-name', configured_domain_name])
    actions.superuser_run('tahoe-lafs', ['enable'])
    actions.run_as_user('tahoe-lafs', ['create-introducer'],
                        become_user='******')
    actions.run_as_user('tahoe-lafs', ['create-storage-node'],
                        become_user='******')
    actions.superuser_run('tahoe-lafs', ['autostart'])

    global service
    if service is None:
        service = service_module.Service(managed_services[0],
                                         name,
                                         ports=['tahoe-plinth'],
                                         is_external=True,
                                         is_enabled=is_enabled,
                                         enable=enable,
                                         disable=disable,
                                         is_running=is_running)
    service.notify_enabled(None, True)
    add_shortcut()
예제 #14
0
def post_setup(configured_domain_name):
    """Actions to be performed after installing tahoe-lafs package."""
    actions.superuser_run('tahoe-lafs',
                          ['setup', '--domain-name', configured_domain_name])
    actions.superuser_run('tahoe-lafs', ['enable'])
    actions.run_as_user('tahoe-lafs', ['create-introducer'],
                        become_user='******')
    actions.run_as_user('tahoe-lafs', ['create-storage-node'],
                        become_user='******')
    actions.superuser_run('tahoe-lafs', ['autostart'])

    global service
    if service is None:
        service = service_module.Service(
            managed_services[0],
            name,
            ports=['tahoe-plinth'],
            is_external=True,
            is_enabled=is_enabled,
            enable=enable,
            disable=disable,
            is_running=is_running)
    service.notify_enabled(None, True)
    add_shortcut()