mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
janus: Convert action to privileged
Tests: Run functional tests for janus. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
7fc3ce7c20
commit
6ede12da25
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Configuration helper for Janus server.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
||||
from plinth import action_utils
|
||||
|
||||
JANUS_CONF_PATH = '/etc/janus/janus.jcfg'
|
||||
|
||||
|
||||
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 Janus server')
|
||||
subparsers.required = True
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def subcommand_setup(_):
|
||||
"""Configure Janus server."""
|
||||
with open(JANUS_CONF_PATH, 'r', encoding='utf-8') as config_file:
|
||||
config_lines = config_file.readlines()
|
||||
|
||||
with open(JANUS_CONF_PATH, 'w', encoding='utf-8') as config_file:
|
||||
for line in config_lines:
|
||||
if '#rtp_port_range' in line:
|
||||
config_file.write("\trtp_port_range = \"50176-51199\"\n")
|
||||
else:
|
||||
config_file.write(line)
|
||||
|
||||
action_utils.service_try_restart('janus')
|
||||
|
||||
|
||||
def main():
|
||||
arguments = parse_arguments()
|
||||
sub_command = arguments.subcommand.replace('-', '_')
|
||||
sub_command_method = globals()['subcommand_' + sub_command]
|
||||
sub_command_method(arguments)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -6,7 +6,6 @@ FreedomBox app for janus.
|
||||
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 frontpage, menu
|
||||
from plinth.daemon import Daemon
|
||||
@ -17,7 +16,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 = [
|
||||
_('Janus is a lightweight WebRTC server.'),
|
||||
@ -90,5 +89,5 @@ class JanusApp(app_module.App):
|
||||
def setup(self, old_version):
|
||||
"""Install and configure the app."""
|
||||
super().setup(old_version)
|
||||
actions.superuser_run('janus', ['setup'])
|
||||
privileged.setup()
|
||||
self.enable()
|
||||
|
||||
25
plinth/modules/janus/privileged.py
Normal file
25
plinth/modules/janus/privileged.py
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Configure Janus server.
|
||||
"""
|
||||
|
||||
from plinth import action_utils
|
||||
from plinth.actions import privileged
|
||||
|
||||
JANUS_CONF_PATH = '/etc/janus/janus.jcfg'
|
||||
|
||||
|
||||
@privileged
|
||||
def setup():
|
||||
"""Setup Janus server."""
|
||||
with open(JANUS_CONF_PATH, 'r', encoding='utf-8') as config_file:
|
||||
config_lines = config_file.readlines()
|
||||
|
||||
with open(JANUS_CONF_PATH, 'w', encoding='utf-8') as config_file:
|
||||
for line in config_lines:
|
||||
if '#rtp_port_range' in line:
|
||||
config_file.write("\trtp_port_range = \"50176-51199\"\n")
|
||||
else:
|
||||
config_file.write(line)
|
||||
|
||||
action_utils.service_try_restart('janus')
|
||||
Loading…
x
Reference in New Issue
Block a user