mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-04 08:13:38 +00:00
- Introduce base class for all apps that will contain components. With
unittests.
- Introduce base classes for components. With unittests.
- Turn Menu class into an app component.
- Further cleanup Menu class.
- Update tests.
- Maintain a global list of menu items and look them up easily. Generalize
such that subsubmenus can later be merged into Menu class.
- Cleanup scope of main menu initialization.
- Use None instead of empty strings for various values. Ensure that
printing short_description does not show 'None' in output.
- Use enable/disable instead of promote/demote.
- Use menu component in all apps.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
#
|
|
# This file is part of FreedomBox.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
"""
|
|
FreedomBox app for OpenSSH server.
|
|
"""
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from plinth import actions
|
|
from plinth import app as app_module
|
|
from plinth import cfg, menu
|
|
from plinth import service as service_module
|
|
from plinth.views import ServiceView
|
|
|
|
from .manifest import backup
|
|
|
|
version = 1
|
|
|
|
is_essential = True
|
|
|
|
managed_services = ['ssh']
|
|
|
|
managed_packages = ['openssh-server']
|
|
|
|
name = _('Secure Shell (SSH) Server')
|
|
|
|
description = [
|
|
_('A Secure Shell server uses the secure shell protocol to accept '
|
|
'connections from remote computers. An authorized remote computer '
|
|
'can perform administration tasks, copy files or run other services '
|
|
'using such connections.')
|
|
]
|
|
|
|
service = None
|
|
|
|
port_forwarding_info = [('TCP', 22)]
|
|
|
|
app = None
|
|
|
|
|
|
class SSHApp(app_module.App):
|
|
"""FreedomBox app for SSH."""
|
|
|
|
def __init__(self):
|
|
"""Create components for the app."""
|
|
super().__init__()
|
|
menu_item = menu.Menu('menu-ssh', name, None, 'fa-terminal',
|
|
'ssh:index', parent_url_name='system')
|
|
self.add(menu_item)
|
|
|
|
|
|
def init():
|
|
"""Intialize the ssh module."""
|
|
global app
|
|
app = SSHApp()
|
|
app.set_enabled(True)
|
|
|
|
global service
|
|
service = service_module.Service(managed_services[0], name, ports=['ssh'],
|
|
is_external=True)
|
|
|
|
|
|
def setup(helper, old_version=None):
|
|
"""Configure the module."""
|
|
actions.superuser_run('ssh', ['setup'])
|
|
|
|
|
|
class SshServiceView(ServiceView):
|
|
service_id = managed_services[0]
|
|
description = description
|
|
port_forwarding_info = port_forwarding_info
|