mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
transmission: Use new setup mechanism
This commit is contained in:
parent
ac558568ba
commit
065d6c4c0a
@ -20,27 +20,51 @@ Plinth module to configure Transmission server
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
import json
|
||||||
|
|
||||||
|
from plinth import actions
|
||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth import service as service_module
|
from plinth import service as service_module
|
||||||
|
|
||||||
|
|
||||||
|
version = 1
|
||||||
|
|
||||||
depends = ['apps']
|
depends = ['apps']
|
||||||
|
|
||||||
|
title = _('BitTorrent (Transmission)')
|
||||||
|
|
||||||
|
description = [
|
||||||
|
_('BitTorrent is a peer-to-peer file sharing protocol. '
|
||||||
|
'Transmission daemon handles Bitorrent file sharing. Note that '
|
||||||
|
'BitTorrent is not anonymous.')
|
||||||
|
]
|
||||||
|
|
||||||
service = None
|
service = None
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Intialize the Transmission module."""
|
"""Intialize the Transmission module."""
|
||||||
menu = cfg.main_menu.get('apps:index')
|
menu = cfg.main_menu.get('apps:index')
|
||||||
menu.add_urlname(_('BitTorrent (Transmission)'), 'glyphicon-save',
|
menu.add_urlname(title, 'glyphicon-save', 'transmission:index', 300)
|
||||||
'transmission:index', 300)
|
|
||||||
|
|
||||||
global service
|
global service
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
'transmission', _('Transmission BitTorrent'), ['http', 'https'],
|
'transmission', title, ['http', 'https'], is_external=True,
|
||||||
is_external=True, enabled=is_enabled())
|
enabled=is_enabled())
|
||||||
|
|
||||||
|
|
||||||
|
def setup(helper, old_version=None):
|
||||||
|
"""Install and configure the module."""
|
||||||
|
helper.install(['transmission-daemon'])
|
||||||
|
|
||||||
|
new_configuration = {'rpc-whitelist-enabled': False}
|
||||||
|
helper.call('post', actions.superuser_run, 'transmission',
|
||||||
|
['merge-configuration'],
|
||||||
|
input=json.dumps(new_configuration).encode())
|
||||||
|
|
||||||
|
helper.call('post', actions.superuser_run, 'transmission', ['enable'])
|
||||||
|
helper.call('post', service.notify_enabled, None, True)
|
||||||
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "app.html" %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
#
|
#
|
||||||
# This file is part of Plinth.
|
# This file is part of Plinth.
|
||||||
@ -21,17 +21,7 @@
|
|||||||
{% load bootstrap %}
|
{% load bootstrap %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block configuration %}
|
||||||
|
|
||||||
<h2>{% trans "BitTorrent (Transmission)" %}</h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{% blocktrans trimmed %}
|
|
||||||
BitTorrent is a peer-to-peer file sharing protocol.
|
|
||||||
Transmission daemon handles Bitorrent file sharing. Note that
|
|
||||||
BitTorrent is not anonymous.
|
|
||||||
{% endblocktrans %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import socket
|
|||||||
|
|
||||||
from .forms import TransmissionForm
|
from .forms import TransmissionForm
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import package
|
|
||||||
from plinth.modules import transmission
|
from plinth.modules import transmission
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -36,17 +35,6 @@ logger = logging.getLogger(__name__)
|
|||||||
TRANSMISSION_CONFIG = '/etc/transmission-daemon/settings.json'
|
TRANSMISSION_CONFIG = '/etc/transmission-daemon/settings.json'
|
||||||
|
|
||||||
|
|
||||||
def on_install():
|
|
||||||
"""Enable transmission as soon as it is installed."""
|
|
||||||
new_configuration = {'rpc-whitelist-enabled': False}
|
|
||||||
actions.superuser_run('transmission', ['merge-configuration'],
|
|
||||||
input=json.dumps(new_configuration).encode())
|
|
||||||
|
|
||||||
actions.superuser_run('transmission', ['enable'])
|
|
||||||
transmission.service.notify_enabled(None, True)
|
|
||||||
|
|
||||||
|
|
||||||
@package.required(['transmission-daemon'], on_install=on_install)
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Serve configuration page."""
|
"""Serve configuration page."""
|
||||||
status = get_status()
|
status = get_status()
|
||||||
@ -64,7 +52,8 @@ def index(request):
|
|||||||
form = TransmissionForm(initial=status, prefix='transmission')
|
form = TransmissionForm(initial=status, prefix='transmission')
|
||||||
|
|
||||||
return TemplateResponse(request, 'transmission.html',
|
return TemplateResponse(request, 'transmission.html',
|
||||||
{'title': _('BitTorrent (Transmission)'),
|
{'title': transmission.title,
|
||||||
|
'description': transmission.description,
|
||||||
'status': status,
|
'status': status,
|
||||||
'form': form})
|
'form': form})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user