diff --git a/plinth/modules/infinoted/__init__.py b/plinth/modules/infinoted/__init__.py index 315b18161..e70d684f6 100644 --- a/plinth/modules/infinoted/__init__.py +++ b/plinth/modules/infinoted/__init__.py @@ -6,7 +6,6 @@ FreedomBox app for infinoted. 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 @@ -15,7 +14,7 @@ from plinth.modules.firewall.components import Firewall from plinth.package import Packages from plinth.utils import format_lazy -from . import manifest +from . import manifest, privileged _description = [ _('infinoted is a server for Gobby, a collaborative text editor.'), @@ -77,5 +76,5 @@ class InfinotedApp(app_module.App): def setup(self, old_version): """Install and configure the app.""" super().setup(old_version) - actions.superuser_run('infinoted', ['setup']) + privileged.setup() self.enable() diff --git a/actions/infinoted b/plinth/modules/infinoted/privileged.py old mode 100755 new mode 100644 similarity index 85% rename from actions/infinoted rename to plinth/modules/infinoted/privileged.py index aef33246a..9675030a1 --- a/actions/infinoted +++ b/plinth/modules/infinoted/privileged.py @@ -1,10 +1,6 @@ -#!/usr/bin/python3 # SPDX-License-Identifier: AGPL-3.0-or-later -""" -Configuration helper for infinoted. -""" +"""Configure infinoted.""" -import argparse import grp import os import pwd @@ -13,6 +9,7 @@ import subprocess import time from plinth import action_utils +from plinth.actions import privileged DATA_DIR = '/var/lib/infinoted' KEY_DIR = '/etc/infinoted' @@ -103,17 +100,6 @@ WantedBy=multi-user.target ''' -def parse_arguments(): - """Return parsed command line arguments as dictionary.""" - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') - - subparsers.add_parser('setup', help='Configure infinoted after install') - - subparsers.required = True - return parser.parse_args() - - def _kill_daemon(): """Try to kill the infinoted daemon for upto 5 minutes.""" end_time = time.time() + 300 @@ -127,7 +113,8 @@ def _kill_daemon(): time.sleep(1) -def subcommand_setup(_): +@privileged +def setup(): """Configure infinoted after install.""" if not os.path.isfile(CONF_PATH): with open(CONF_PATH, 'w', encoding='utf-8') as file_handle: @@ -180,16 +167,3 @@ def subcommand_setup(_): group='infinoted') action_utils.service_enable('infinoted') - - -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()