diff --git a/actions/quassel b/actions/quassel deleted file mode 100755 index c22e14c5e..000000000 --- a/actions/quassel +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python3 -# SPDX-License-Identifier: AGPL-3.0-or-later -""" -Configuration helper for Quassel. -""" - -import argparse -import pathlib - - -def parse_arguments(): - """Return parsed command line arguments as dictionary.""" - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') - - subparser = subparsers.add_parser('set-domain', - help='Setup Quassel configuration') - subparser.add_argument('domain_name', help='Domain name to be allowed') - - subparsers.required = True - return parser.parse_args() - - -def subcommand_set_domain(arguments): - """Write a file containing domain name.""" - domain_file = pathlib.Path('/var/lib/quassel/domain-freedombox') - domain_file.write_text(arguments.domain_name, encoding='utf-8') - - -def main(): - """Parse arguments and perform all duties.""" - arguments = parse_arguments() - - subcommand = arguments.subcommand.replace('-', '_') - subcommand_method = globals()['subcommand_' + subcommand] - subcommand_method(arguments) - - -if __name__ == '__main__': - main() diff --git a/plinth/modules/quassel/__init__.py b/plinth/modules/quassel/__init__.py index 0405e9cb9..284e67642 100644 --- a/plinth/modules/quassel/__init__.py +++ b/plinth/modules/quassel/__init__.py @@ -1,14 +1,11 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" -FreedomBox app for Quassel. -""" +"""FreedomBox app for Quassel.""" import pathlib from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ -from plinth import actions from plinth import app as app_module from plinth import cfg, frontpage, menu from plinth.daemon import Daemon @@ -20,7 +17,7 @@ from plinth.modules.users.components import UsersAndGroups from plinth.package import Packages from plinth.utils import format_lazy -from . import manifest +from . import manifest, privileged _description = [ format_lazy( @@ -108,7 +105,7 @@ class QuasselApp(app_module.App): def set_domain(domain): """Set the TLS domain by writing a file to data directory.""" if domain: - actions.superuser_run('quassel', ['set-domain', domain]) + privileged.set_domain(domain) def get_domain(): diff --git a/plinth/modules/quassel/privileged.py b/plinth/modules/quassel/privileged.py new file mode 100644 index 000000000..bab66e9dd --- /dev/null +++ b/plinth/modules/quassel/privileged.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Configure Quassel.""" + +import pathlib + +from plinth.actions import privileged + + +@privileged +def set_domain(domain_name: str): + """Write a file containing domain name.""" + domain_file = pathlib.Path('/var/lib/quassel/domain-freedombox') + domain_file.write_text(domain_name, encoding='utf-8')