diff --git a/actions/transmission b/actions/transmission
index 1290b3d62..4ea429f10 100755
--- a/actions/transmission
+++ b/actions/transmission
@@ -79,10 +79,14 @@ def subcommand_enable(_):
"""Start Transmission service."""
set_service_enable(enable=True)
subprocess.call(['service', 'transmission-daemon', 'start'])
+ subprocess.call(['a2enconf', 'transmission-plinth'])
+ subprocess.call(['service', 'apache2', 'reload'])
def subcommand_disable(_):
"""Stop Transmission service."""
+ subprocess.call(['a2disconf', 'transmission-plinth'])
+ subprocess.call(['service', 'apache2', 'reload'])
subprocess.call(['service', 'transmission-daemon', 'stop'])
set_service_enable(enable=False)
diff --git a/data/etc/apache2/conf-available/transmission-plinth.conf b/data/etc/apache2/conf-available/transmission-plinth.conf
new file mode 100644
index 000000000..9d0c2abcc
--- /dev/null
+++ b/data/etc/apache2/conf-available/transmission-plinth.conf
@@ -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
+##
+
+ 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
+
diff --git a/data/usr/lib/firewalld/services/transmission-rpcplinth.xml b/data/usr/lib/firewalld/services/transmission-rpcplinth.xml
deleted file mode 100644
index ecfbcb235..000000000
--- a/data/usr/lib/firewalld/services/transmission-rpcplinth.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- Transmission Web Interface
- 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.
-
-
diff --git a/plinth/modules/transmission/__init__.py b/plinth/modules/transmission/__init__.py
index 30928c633..664874ff1 100644
--- a/plinth/modules/transmission/__init__.py
+++ b/plinth/modules/transmission/__init__.py
@@ -42,5 +42,5 @@ def init():
global service
service = service_module.Service(
- 'transmission-rpcplinth', _('Transmission BitTorrent'),
+ 'transmission', _('Transmission BitTorrent'), ['http', 'https'],
is_external=True, enabled=enabled)
diff --git a/plinth/modules/transmission/forms.py b/plinth/modules/transmission/forms.py
index dc51f69d8..41c773814 100644
--- a/plinth/modules/transmission/forms.py
+++ b/plinth/modules/transmission/forms.py
@@ -20,16 +20,7 @@ Plinth module for configuring Transmission.
"""
from django import forms
-from django.core.validators import RegexValidator
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
@@ -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 \
password is shown in a hashed format. To set a new password, enter the \
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.*.* .'))
diff --git a/plinth/modules/transmission/templates/transmission.html b/plinth/modules/transmission/templates/transmission.html
index 927cd71c4..fa4736e16 100644
--- a/plinth/modules/transmission/templates/transmission.html
+++ b/plinth/modules/transmission/templates/transmission.html
@@ -28,9 +28,7 @@
daemon handles Bitorrent file sharing. Note that BitTorrent is not
anonymous.
-Access the web interface at
-
- http://{{ status.hostname }}:{{ status.rpc_port }}
+
Access the web interface at /transmission
Status
diff --git a/plinth/modules/transmission/views.py b/plinth/modules/transmission/views.py
index 71c5b85af..5111d900d 100644
--- a/plinth/modules/transmission/views.py
+++ b/plinth/modules/transmission/views.py
@@ -37,8 +37,13 @@ logger = logging.getLogger(__name__)
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
-@package.required(['transmission-daemon'])
+@package.required(['transmission-daemon'], on_install=on_install)
def index(request):
"""Serve configuration page."""
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 \
old_status['rpc_username'] != new_status['rpc_username'] or \
- old_status['rpc_password'] != new_status['rpc_password'] or \
- old_status['rpc_whitelist'] != new_status['rpc_whitelist']:
+ old_status['rpc_password'] != new_status['rpc_password']:
new_configuration = {
'download-dir': new_status['download_dir'],
'rpc-username': new_status['rpc_username'],
'rpc-password': new_status['rpc_password'],
- 'rpc-whitelist': new_status['rpc_whitelist']
}
actions.superuser_run('transmission', ['merge-configuration',
diff --git a/setup.py b/setup.py
index 5d89f4fe3..537b438f4 100755
--- a/setup.py
+++ b/setup.py
@@ -129,9 +129,10 @@ setuptools.setup(
['data/usr/lib/freedombox/setup.d/86_plinth']),
('/usr/lib/freedombox/first-run.d',
['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',
- ['data/etc/apache2/sites-available/plinth.conf',
- 'data/etc/apache2/sites-available/plinth-ssl.conf']),
+ glob.glob('data/etc/apache2/sites-available/*.conf')),
('/etc/sudoers.d', ['data/etc/sudoers.d/plinth']),
('/lib/systemd/system',
['data/lib/systemd/system/plinth.service']),