mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
transmission: Run from behind Apache
- Introduce Apache configuration for plinth. - Remove Transmission service file for firewalld. - Enable transmission on install. - Enable/disable Apache configuration on Transmission on enable/disable. - Remove IP address whilelisting as 127.0.0.1 is the default setting and is sufficient for Apache to reverse proxy. - Update UI URL.
This commit is contained in:
parent
f94d0d5414
commit
69adf1cfc5
@ -79,10 +79,14 @@ def subcommand_enable(_):
|
|||||||
"""Start Transmission service."""
|
"""Start Transmission service."""
|
||||||
set_service_enable(enable=True)
|
set_service_enable(enable=True)
|
||||||
subprocess.call(['service', 'transmission-daemon', 'start'])
|
subprocess.call(['service', 'transmission-daemon', 'start'])
|
||||||
|
subprocess.call(['a2enconf', 'transmission-plinth'])
|
||||||
|
subprocess.call(['service', 'apache2', 'reload'])
|
||||||
|
|
||||||
|
|
||||||
def subcommand_disable(_):
|
def subcommand_disable(_):
|
||||||
"""Stop Transmission service."""
|
"""Stop Transmission service."""
|
||||||
|
subprocess.call(['a2disconf', 'transmission-plinth'])
|
||||||
|
subprocess.call(['service', 'apache2', 'reload'])
|
||||||
subprocess.call(['service', 'transmission-daemon', 'stop'])
|
subprocess.call(['service', 'transmission-daemon', 'stop'])
|
||||||
set_service_enable(enable=False)
|
set_service_enable(enable=False)
|
||||||
|
|
||||||
|
|||||||
15
data/etc/apache2/conf-available/transmission-plinth.conf
Normal file
15
data/etc/apache2/conf-available/transmission-plinth.conf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
##
|
||||||
|
## On all sites, provide Transmission on a default path: /transmission
|
||||||
|
##
|
||||||
|
## Requires the following Apache modules to be enabled:
|
||||||
|
## mod_headers
|
||||||
|
## mod_proxy
|
||||||
|
## mod_proxy_http
|
||||||
|
##
|
||||||
|
<Location /transmission>
|
||||||
|
ProxyPass http://localhost:9091/transmission
|
||||||
|
## Send the scheme from user's request to enable Transmission to
|
||||||
|
## redirect URLs, set cookies, set absolute URLs (if any)
|
||||||
|
## properly.
|
||||||
|
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
|
||||||
|
</Location>
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<service>
|
|
||||||
<short>Transmission Web Interface</short>
|
|
||||||
<description>Transmission is a client for BitTorrent, the peer-to-peer file sharing protocol. Transmission can run as a GUI client or as a daemon process running in the background. Both provide a web interface allowing themselves to be controlled using a web browser. Also, both can be controlled using a command line interface. Enable this if you wish to control Transmission BitTorrent GUI or daemon using its web interface or the command line utility.</description>
|
|
||||||
<port protocol="tcp" port="9091"/>
|
|
||||||
</service>
|
|
||||||
@ -42,5 +42,5 @@ def init():
|
|||||||
|
|
||||||
global service
|
global service
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
'transmission-rpcplinth', _('Transmission BitTorrent'),
|
'transmission', _('Transmission BitTorrent'), ['http', 'https'],
|
||||||
is_external=True, enabled=enabled)
|
is_external=True, enabled=enabled)
|
||||||
|
|||||||
@ -20,16 +20,7 @@ Plinth module for configuring Transmission.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.validators import RegexValidator
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
ipv4_wildcard_re = r'(25[0-5]|2[0-4]\d|[0-1]?\d?\d)' \
|
|
||||||
r'(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d|\*)){3}'
|
|
||||||
|
|
||||||
multiple_ips_re = re.compile(r'^({ipv4})(\s*,\s*{ipv4})*$'.format(ipv4=ipv4_wildcard_re))
|
|
||||||
ip_validator = RegexValidator(multiple_ips_re)
|
|
||||||
|
|
||||||
|
|
||||||
class TransmissionForm(forms.Form): # pylint: disable=W0232
|
class TransmissionForm(forms.Form): # pylint: disable=W0232
|
||||||
@ -53,10 +44,3 @@ default directory, ensure that the new directory exists and is writable by \
|
|||||||
help_text=_('Password to login to the web interface. Current \
|
help_text=_('Password to login to the web interface. Current \
|
||||||
password is shown in a hashed format. To set a new password, enter the \
|
password is shown in a hashed format. To set a new password, enter the \
|
||||||
password in plain text.'))
|
password in plain text.'))
|
||||||
|
|
||||||
rpc_whitelist = forms.CharField(
|
|
||||||
label=_('IP addresses to allow'),
|
|
||||||
validators=[ip_validator],
|
|
||||||
help_text=_('A comma separated list of IP addresses that will be \
|
|
||||||
allowed to connect to the web interface. IP addresses may use wild cards, \
|
|
||||||
such as 192.168.*.* .'))
|
|
||||||
|
|||||||
@ -28,9 +28,7 @@
|
|||||||
daemon handles Bitorrent file sharing. Note that BitTorrent is not
|
daemon handles Bitorrent file sharing. Note that BitTorrent is not
|
||||||
anonymous.</p>
|
anonymous.</p>
|
||||||
|
|
||||||
<p>Access the web interface at
|
<p>Access the web interface at <a href="/transmission">/transmission</a></p>
|
||||||
<a href="http://{{ status.hostname }}:{{ status.rpc_port }}">
|
|
||||||
http://{{ status.hostname }}:{{ status.rpc_port }}</a>
|
|
||||||
|
|
||||||
<h3>Status</h3>
|
<h3>Status</h3>
|
||||||
|
|
||||||
|
|||||||
@ -37,8 +37,13 @@ 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."""
|
||||||
|
actions.superuser_run('transmission', ['enable'])
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@package.required(['transmission-daemon'])
|
@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()
|
||||||
@ -92,13 +97,11 @@ def _apply_changes(request, old_status, new_status):
|
|||||||
|
|
||||||
if old_status['download_dir'] != new_status['download_dir'] or \
|
if old_status['download_dir'] != new_status['download_dir'] or \
|
||||||
old_status['rpc_username'] != new_status['rpc_username'] or \
|
old_status['rpc_username'] != new_status['rpc_username'] or \
|
||||||
old_status['rpc_password'] != new_status['rpc_password'] or \
|
old_status['rpc_password'] != new_status['rpc_password']:
|
||||||
old_status['rpc_whitelist'] != new_status['rpc_whitelist']:
|
|
||||||
new_configuration = {
|
new_configuration = {
|
||||||
'download-dir': new_status['download_dir'],
|
'download-dir': new_status['download_dir'],
|
||||||
'rpc-username': new_status['rpc_username'],
|
'rpc-username': new_status['rpc_username'],
|
||||||
'rpc-password': new_status['rpc_password'],
|
'rpc-password': new_status['rpc_password'],
|
||||||
'rpc-whitelist': new_status['rpc_whitelist']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.superuser_run('transmission', ['merge-configuration',
|
actions.superuser_run('transmission', ['merge-configuration',
|
||||||
|
|||||||
5
setup.py
5
setup.py
@ -129,9 +129,10 @@ setuptools.setup(
|
|||||||
['data/usr/lib/freedombox/setup.d/86_plinth']),
|
['data/usr/lib/freedombox/setup.d/86_plinth']),
|
||||||
('/usr/lib/freedombox/first-run.d',
|
('/usr/lib/freedombox/first-run.d',
|
||||||
['data/usr/lib/freedombox/first-run.d/90_firewall']),
|
['data/usr/lib/freedombox/first-run.d/90_firewall']),
|
||||||
|
('/etc/apache2/conf-available',
|
||||||
|
glob.glob('data/etc/apache2/conf-available/*.conf')),
|
||||||
('/etc/apache2/sites-available',
|
('/etc/apache2/sites-available',
|
||||||
['data/etc/apache2/sites-available/plinth.conf',
|
glob.glob('data/etc/apache2/sites-available/*.conf')),
|
||||||
'data/etc/apache2/sites-available/plinth-ssl.conf']),
|
|
||||||
('/etc/sudoers.d', ['data/etc/sudoers.d/plinth']),
|
('/etc/sudoers.d', ['data/etc/sudoers.d/plinth']),
|
||||||
('/lib/systemd/system',
|
('/lib/systemd/system',
|
||||||
['data/lib/systemd/system/plinth.service']),
|
['data/lib/systemd/system/plinth.service']),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user