mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
tahoe-lafs: Drop app as it is not being used
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Add to configuration file removal in Debian package and setup.py] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
621cb67527
commit
b0305746c8
@ -1,228 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Configuration helper for Tahoe-LAFS.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import grp
|
||||
import json
|
||||
import os
|
||||
import pwd
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import augeas
|
||||
import ruamel.yaml
|
||||
|
||||
from plinth.modules.tahoe import (introducer_furl_file, introducer_name,
|
||||
introducers_file, storage_node_name,
|
||||
tahoe_home)
|
||||
from plinth.modules.tahoe.errors import TahoeConfigurationError
|
||||
from plinth.utils import YAMLFile
|
||||
|
||||
domain_name_file = os.path.join(tahoe_home, 'domain_name')
|
||||
|
||||
DEFAULT_FILE = '/etc/default/tahoe-lafs'
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
"""Return parsed command line arguments as dictionary."""
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
setup = subparsers.add_parser('setup',
|
||||
help='Set domain name for Tahoe-LAFS')
|
||||
setup.add_argument('--domain-name',
|
||||
help='The domain name to be used by Tahoe-LAFS')
|
||||
subparsers.add_parser('create-introducer',
|
||||
help='Create and start the introducer node')
|
||||
subparsers.add_parser('create-storage-node',
|
||||
help='Create and start the storage node')
|
||||
subparsers.add_parser(
|
||||
'autostart', help='Automatically start all introducers and '
|
||||
'storage nodes on system startup')
|
||||
intro_parser_add = subparsers.add_parser(
|
||||
'add-introducer', help="Add an introducer to the storage node's list "
|
||||
'of introducers.')
|
||||
intro_parser_add.add_argument(
|
||||
'--introducer', help="Add an introducer to the storage node's list "
|
||||
'of introducers Param introducer must be a tuple '
|
||||
'of (pet_name, furl)')
|
||||
intro_parser_remove = subparsers.add_parser(
|
||||
'remove-introducer', help='Rename the introducer entry in the '
|
||||
'introducers.yaml file specified by the '
|
||||
'param')
|
||||
intro_parser_remove.add_argument(
|
||||
'--pet-name', help='The domain name that will be used by '
|
||||
'Tahoe-LAFS')
|
||||
subparsers.add_parser(
|
||||
'get-introducers', help='Return a dictionary of all introducers and '
|
||||
'their furls added to the storage node running '
|
||||
'on this FreedomBox.')
|
||||
subparsers.add_parser(
|
||||
'get-local-introducer',
|
||||
help='Return the name and furl of the introducer '
|
||||
'created on this FreedomBox')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def subcommand_setup(arguments):
|
||||
"""Actions to be performed after installing Tahoe-LAFS."""
|
||||
# Create tahoe group if needed.
|
||||
try:
|
||||
grp.getgrnam('tahoe-lafs')
|
||||
except KeyError:
|
||||
subprocess.run(['addgroup', 'tahoe-lafs'], check=True)
|
||||
|
||||
# Create tahoe user if needed.
|
||||
try:
|
||||
pwd.getpwnam('tahoe-lafs')
|
||||
except KeyError:
|
||||
subprocess.run([
|
||||
'adduser', '--system', '--ingroup', 'tahoe-lafs', '--home',
|
||||
'/var/lib/tahoe-lafs', '--gecos',
|
||||
'Tahoe-LAFS distributed file system', 'tahoe-lafs'
|
||||
], check=True)
|
||||
|
||||
if not os.path.exists(tahoe_home):
|
||||
os.makedirs(tahoe_home, mode=0o755)
|
||||
|
||||
shutil.chown(tahoe_home, user='tahoe-lafs', group='tahoe-lafs')
|
||||
|
||||
if not os.path.exists(domain_name_file):
|
||||
with open(domain_name_file, 'w') as dnf:
|
||||
dnf.write(arguments.domain_name)
|
||||
|
||||
|
||||
def subcommand_autostart(_):
|
||||
"""Automatically start all introducers and storage nodes on system startup.
|
||||
"""
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
aug.set('/augeas/load/Shellvars/incl[last() + 1]', DEFAULT_FILE)
|
||||
aug.load()
|
||||
|
||||
aug.set('/files' + DEFAULT_FILE + '/AUTOSTART', 'all')
|
||||
aug.save()
|
||||
|
||||
|
||||
def get_configured_domain_name():
|
||||
"""Extract and return the domain name from the domain name file.
|
||||
|
||||
Throws TahoeConfigurationError if the domain name file is not found.
|
||||
"""
|
||||
if not os.path.exists(domain_name_file):
|
||||
raise TahoeConfigurationError
|
||||
else:
|
||||
with open(domain_name_file) as dnf:
|
||||
return dnf.read().rstrip()
|
||||
|
||||
|
||||
def subcommand_create_introducer(_):
|
||||
"""Create a Tahoe-LAFS introducer on this FreedomBox."""
|
||||
os.chdir(tahoe_home)
|
||||
|
||||
if not os.path.exists(os.path.join(tahoe_home, introducer_name)):
|
||||
subprocess.check_call([
|
||||
'tahoe', 'create-introducer', '--port=3456',
|
||||
'--location=tcp:{}:3456'.format(get_configured_domain_name()),
|
||||
introducer_name
|
||||
])
|
||||
|
||||
subprocess.call(['tahoe', 'start', introducer_name])
|
||||
|
||||
|
||||
def subcommand_create_storage_node(_):
|
||||
"""Create a Tahoe-LAFS storage node on this FreedomBox."""
|
||||
os.chdir(tahoe_home)
|
||||
|
||||
if not os.path.exists(os.path.join(tahoe_home, storage_node_name)):
|
||||
subprocess.check_call([
|
||||
'tahoe', 'create-node', '--nickname=\"storage_node\"',
|
||||
'--webport=1234',
|
||||
'--hostname={}'.format(get_configured_domain_name()),
|
||||
storage_node_name
|
||||
])
|
||||
with open(
|
||||
os.path.join(tahoe_home, introducer_name, 'private',
|
||||
introducer_name + '.furl'), 'r') as furl_file:
|
||||
furl = furl_file.read().rstrip()
|
||||
conf_dict = {'introducers': {introducer_name: {'furl': furl}}}
|
||||
conf_yaml = ruamel.yaml.dump(conf_dict,
|
||||
Dumper=ruamel.yaml.RoundTripDumper)
|
||||
with open(
|
||||
os.path.join(tahoe_home, storage_node_name, 'private',
|
||||
'introducers.yaml'), 'w') as file_handle:
|
||||
file_handle.write(conf_yaml)
|
||||
|
||||
subprocess.call(['tahoe', 'start', storage_node_name])
|
||||
|
||||
|
||||
def subcommand_add_introducer(arguments):
|
||||
"""Add an introducer to the storage node's list of introducers.
|
||||
|
||||
Param introducer must be a tuple of (pet_name, furl).
|
||||
"""
|
||||
with YAMLFile(introducers_file) as conf:
|
||||
pet_name, furl = arguments.introducer.split(',')
|
||||
conf['introducers'][pet_name] = {'furl': furl}
|
||||
|
||||
restart_storage_node()
|
||||
|
||||
|
||||
def subcommand_remove_introducer(arguments):
|
||||
"""Rename the introducer entry in the introducers.yaml file specified
|
||||
by the param pet_name
|
||||
"""
|
||||
with YAMLFile(introducers_file) as conf:
|
||||
del conf['introducers'][arguments.pet_name]
|
||||
|
||||
restart_storage_node()
|
||||
|
||||
|
||||
def subcommand_get_introducers(_):
|
||||
"""Return a dictionary of all introducers and their furls.
|
||||
|
||||
The ones added to the storage node running on this FreedomBox.
|
||||
"""
|
||||
with open(introducers_file, 'r') as intro_conf:
|
||||
conf = ruamel.yaml.round_trip_load(intro_conf)
|
||||
|
||||
introducers = []
|
||||
for pet_name in conf['introducers'].keys():
|
||||
introducers.append((pet_name, conf['introducers'][pet_name]['furl']))
|
||||
|
||||
print(json.dumps(introducers))
|
||||
|
||||
|
||||
def subcommand_get_local_introducer(_):
|
||||
"""Return the name and furl of the introducer created on this FreedomBox
|
||||
"""
|
||||
with open(introducer_furl_file, 'r') as furl_file:
|
||||
furl = furl_file.read().rstrip()
|
||||
|
||||
print(json.dumps((introducer_name, furl)))
|
||||
|
||||
|
||||
def restart_storage_node():
|
||||
"""Called after exiting context of editing introducers file."""
|
||||
try:
|
||||
subprocess.run(['tahoe', 'restart', 'storage_node'], check=True)
|
||||
except subprocess.CalledProcessError as err:
|
||||
print('Failed to restart storage_node with new configuration: %s', err)
|
||||
|
||||
|
||||
def main():
|
||||
"""Parse arguments and perform all duties."""
|
||||
arguments = parse_arguments()
|
||||
|
||||
subcommand = arguments.subcommand.replace('-', '_')
|
||||
subcommand_method = globals()['subcommand_' + subcommand]
|
||||
subcommand_method(arguments)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
10
debian/copyright
vendored
10
debian/copyright
vendored
@ -248,16 +248,6 @@ Copyright: Jakob Borg and the Syncthing project
|
||||
Comment: https://commons.wikimedia.org/wiki/File:SyncthingLogoHorizontal.svg
|
||||
License: MPL-2.0
|
||||
|
||||
Files: static/themes/default/icons/tahoe-lafs.png
|
||||
Copyright: 2017 Kishan Raval
|
||||
Comment: https://github.com/thekishanraval/Logos
|
||||
License: GPL-3+
|
||||
|
||||
Files: static/themes/default/icons/tahoe-lafs.svg
|
||||
Copyright: 2006-2018 The Tahoe-LAFS Software Foundation
|
||||
Comment: https://github.com/tahoe-lafs/tahoe-lafs/blob/master/misc/build_helpers/icons/logo.svg
|
||||
License: GPL-2+
|
||||
|
||||
Files: static/themes/default/icons/tor.png
|
||||
static/themes/default/icons/tor.svg
|
||||
Copyright: The Tor Project, Inc.
|
||||
|
||||
1
debian/freedombox.maintscript
vendored
1
debian/freedombox.maintscript
vendored
@ -15,3 +15,4 @@ rm_conffile /etc/plinth/custom-shortcuts.json 20.12~
|
||||
rm_conffile /etc/plinth/modules-enabled/coquelicot 20.14~
|
||||
rm_conffile /etc/plinth/modules-enabled/diaspora 21.16~
|
||||
rm_conffile /etc/plinth/modules-enabled/monkeysphere 21.16~
|
||||
rm_conffile /etc/plinth/modules-enabled/tahoe 21.16~
|
||||
|
||||
@ -1,194 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
FreedomBox app to configure Tahoe-LAFS.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
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 cfg, frontpage, menu
|
||||
from plinth.daemon import Daemon
|
||||
from plinth.modules.apache.components import Webserver, diagnose_url
|
||||
from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.package import Packages
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
from . import manifest
|
||||
from .errors import TahoeConfigurationError
|
||||
|
||||
_description = [
|
||||
_('Tahoe-LAFS is a decentralized secure file storage system. '
|
||||
'It uses provider independent security to store files over a '
|
||||
'distributed network of storage nodes. Even if some of the nodes fail, '
|
||||
'your files can be retrieved from the remaining nodes.'),
|
||||
format_lazy(
|
||||
_('This {box_name} hosts a storage node and an introducer by default. '
|
||||
'Additional introducers can be added, which will introduce this '
|
||||
'node to the other storage nodes.'), box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
tahoe_home = '/var/lib/tahoe-lafs'
|
||||
introducer_name = 'introducer'
|
||||
storage_node_name = 'storage_node'
|
||||
domain_name_file = os.path.join(tahoe_home, 'domain_name')
|
||||
introducers_file = os.path.join(
|
||||
tahoe_home, '{}/private/introducers.yaml'.format(storage_node_name))
|
||||
introducer_furl_file = os.path.join(
|
||||
tahoe_home, '{0}/private/{0}.furl'.format(introducer_name))
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class TahoeApp(app_module.App):
|
||||
"""FreedomBox app for Tahoe LAFS."""
|
||||
|
||||
app_id = 'tahoe'
|
||||
|
||||
_version = 1
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=self._version,
|
||||
name=_('Tahoe-LAFS'),
|
||||
icon_filename='tahoe-lafs',
|
||||
short_description=_('Distributed File Storage'),
|
||||
description=_description)
|
||||
|
||||
self.add(info)
|
||||
|
||||
menu_item = menu.Menu('menu-tahoe', info.name, info.short_description,
|
||||
info.icon_filename, 'tahoe:index',
|
||||
parent_url_name='apps', advanced=True)
|
||||
self.add(menu_item)
|
||||
|
||||
shortcut = frontpage.Shortcut(
|
||||
'shortcut-tahoe', info.name,
|
||||
short_description=info.short_description, icon=info.icon_filename,
|
||||
description=info.description, url=None,
|
||||
configure_url=reverse_lazy('tahoe:index'), login_required=True)
|
||||
self.add(shortcut)
|
||||
|
||||
packages = Packages('packages-tahoe', ['tahoe-lafs'])
|
||||
self.add(packages)
|
||||
|
||||
firewall = Firewall('firewall-tahoe', info.name,
|
||||
ports=['tahoe-plinth'], is_external=True)
|
||||
self.add(firewall)
|
||||
|
||||
webserver = Webserver('webserver-tahoe', 'tahoe-plinth')
|
||||
self.add(webserver)
|
||||
|
||||
daemon = Daemon('daemon-tahoe', 'tahoe-lafs')
|
||||
self.add(daemon)
|
||||
|
||||
backup_restore = BackupRestore('backup-restore-tahoe',
|
||||
**manifest.backup)
|
||||
self.add(backup_restore)
|
||||
|
||||
def is_enabled(self):
|
||||
"""Return whether all the leader components are enabled.
|
||||
|
||||
Return True when there are no leader components and
|
||||
domain name is setup.
|
||||
"""
|
||||
return super().is_enabled() and is_setup()
|
||||
|
||||
def diagnose(self):
|
||||
"""Run diagnostics and return the results."""
|
||||
results = super().diagnose()
|
||||
results.extend([
|
||||
diagnose_url('http://localhost:5678', kind='4',
|
||||
check_certificate=False),
|
||||
diagnose_url('http://localhost:5678', kind='6',
|
||||
check_certificate=False),
|
||||
diagnose_url('http://{}:5678'.format(get_configured_domain_name()),
|
||||
kind='4', check_certificate=False)
|
||||
])
|
||||
return results
|
||||
|
||||
|
||||
class Shortcut(frontpage.Shortcut):
|
||||
"""Frontpage shortcut to use configured domain name for URL."""
|
||||
|
||||
def enable(self):
|
||||
"""Set the proper shortcut URL when enabled."""
|
||||
super().enable()
|
||||
self.url = 'https://{}:5678'.format(get_configured_domain_name())
|
||||
|
||||
|
||||
def is_setup():
|
||||
"""Check whether Tahoe-LAFS is setup"""
|
||||
return os.path.exists(domain_name_file)
|
||||
|
||||
|
||||
def get_configured_domain_name():
|
||||
"""Extract and return the domain name from the domain name file.
|
||||
Throws TahoeConfigurationError if the domain name file is not found.
|
||||
"""
|
||||
if not os.path.exists(domain_name_file):
|
||||
raise TahoeConfigurationError
|
||||
else:
|
||||
with open(domain_name_file) as dnf:
|
||||
return dnf.read().rstrip()
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
app.setup(old_version)
|
||||
|
||||
|
||||
def post_setup(configured_domain_name):
|
||||
"""Actions to be performed after installing tahoe-lafs package."""
|
||||
actions.superuser_run('tahoe-lafs',
|
||||
['setup', '--domain-name', configured_domain_name])
|
||||
actions.run_as_user('tahoe-lafs', ['create-introducer'],
|
||||
become_user='tahoe-lafs')
|
||||
actions.run_as_user('tahoe-lafs', ['create-storage-node'],
|
||||
become_user='tahoe-lafs')
|
||||
actions.superuser_run('tahoe-lafs', ['autostart'])
|
||||
app.enable()
|
||||
|
||||
|
||||
def add_introducer(introducer):
|
||||
"""Add an introducer to the storage node's list of introducers.
|
||||
Param introducer must be a tuple of (pet_name, furl)
|
||||
"""
|
||||
actions.run_as_user(
|
||||
'tahoe-lafs', ['add-introducer', "--introducer", ",".join(introducer)],
|
||||
become_user='tahoe-lafs')
|
||||
|
||||
|
||||
def remove_introducer(pet_name):
|
||||
"""Rename the introducer entry in the introducers.yaml file specified by
|
||||
the param pet_name.
|
||||
"""
|
||||
actions.run_as_user('tahoe-lafs',
|
||||
['remove-introducer', '--pet-name', pet_name],
|
||||
become_user='tahoe-lafs')
|
||||
|
||||
|
||||
def get_introducers():
|
||||
"""Return a dictionary of all introducers and their furls added to the
|
||||
storage node running on this FreedomBox.
|
||||
"""
|
||||
introducers = actions.run_as_user('tahoe-lafs', ['get-introducers'],
|
||||
become_user='tahoe-lafs')
|
||||
|
||||
return json.loads(introducers)
|
||||
|
||||
|
||||
def get_local_introducer():
|
||||
"""Return the name and furl of the introducer created on this FreedomBox.
|
||||
"""
|
||||
introducer = actions.run_as_user('tahoe-lafs', ['get-local-introducer'],
|
||||
become_user='tahoe-lafs')
|
||||
|
||||
return json.loads(introducer)
|
||||
@ -1,14 +0,0 @@
|
||||
# Tahoe-LAFS Storage Node web interface
|
||||
|
||||
Listen 5678
|
||||
|
||||
# XXX: SSL is not configured?
|
||||
# TODO: Use subdomain?
|
||||
<VirtualHost *:5678>
|
||||
<Location "/">
|
||||
Include includes/freedombox-auth-ldap.conf
|
||||
Require ldap-group cn=admin,ou=groups,dc=thisbox
|
||||
|
||||
ProxyPass http://localhost:1234/
|
||||
</Location>
|
||||
</VirtualHost>
|
||||
@ -1 +0,0 @@
|
||||
#plinth.modules.tahoe
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<service>
|
||||
<short>Tahoe-LAFS</short>
|
||||
<description>Tahoe-LAFS is a distributed file storage system</description>
|
||||
<port protocol="tcp" port="5678"/>
|
||||
<port protocol="tcp" port="3456"/>
|
||||
</service>
|
||||
@ -1,11 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Errors for Tahoe-LAFS module
|
||||
"""
|
||||
|
||||
from plinth.errors import PlinthError
|
||||
|
||||
|
||||
class TahoeConfigurationError(PlinthError):
|
||||
"""Tahoe-LAFS has not been configured for domain name."""
|
||||
pass
|
||||
@ -1,11 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Application manfiest for tahoe-lafs.
|
||||
"""
|
||||
|
||||
backup = {
|
||||
'secrets': {
|
||||
'directories': ['/var/lib/tahoe-lafs/']
|
||||
},
|
||||
'services': ['tahoe-lafs']
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
{% extends "app.html" %}
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load bootstrap %}
|
||||
|
||||
{% block description %}
|
||||
|
||||
{% for paragraph in description %}
|
||||
<p>{{ paragraph|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
{% url 'config:index' as index_url %}
|
||||
{% blocktrans trimmed with domain_name=domain_name %}
|
||||
The Tahoe-LAFS server domain is set to <b>{{ domain_name }}</b>.
|
||||
Changing the FreedomBox domain name needs a reinstall of
|
||||
Tahoe-LAFS and you WILL LOSE DATA. You can access Tahoe-LAFS at
|
||||
<a href="https://{{domain_name}}:5678">https://{{domain_name}}:5678</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
{% block configuration %}
|
||||
{{ block.super }}
|
||||
|
||||
<h4>{% trans "Local introducer" %}</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table local-introducers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Pet Name" %}</th>
|
||||
<th> furl </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="introducer-pet-name">{{ local_introducer.0 }}</td>
|
||||
<td class="introducer-furl">{{ local_introducer.1 }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<form class="form form-add-introducer" method="post"
|
||||
action="{% url 'tahoe:add-introducer' %}">
|
||||
{% csrf_token %}
|
||||
<h4>{% trans "Add new introducer" %}</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<label>{% trans "Pet Name" %}:</label>
|
||||
<input type="text" class="form-control" name="pet_name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>furl:</label>
|
||||
<textarea class="form-control" rows="5" name="furl"></textarea>
|
||||
</div>
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Add" %}"/>
|
||||
</form>
|
||||
|
||||
<br/>
|
||||
|
||||
<h4>{% trans "Connected introducers" %}</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table connected-introducers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Pet Name" %}</th>
|
||||
<th> furl </th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for introducer, furl in introducers %}
|
||||
<tr>
|
||||
<td class="introducer-pet-name">{{ introducer }}</td>
|
||||
<td class="introducer-furl">{{ furl }}</td>
|
||||
<td class="introducer-operations">
|
||||
<form class="form form-remove" method="post"
|
||||
action="{% url 'tahoe:remove-introducer' introducer %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">
|
||||
{% trans "Remove" %}
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@ -1,47 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% block pagetitle %}
|
||||
<h2>{{ title }}</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block description %}
|
||||
{% for paragraph in description %}
|
||||
<p>{{ paragraph|safe }}</p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
<p>
|
||||
{% url 'config:index' as index_url %}
|
||||
{% if domain_names|length == 0 %}
|
||||
No domain(s) are set. You can setup your domain on the system at
|
||||
<a href="{{ index_url }}">{% trans "Configure" %}</a> page.
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% block status %}
|
||||
{% endblock %}
|
||||
|
||||
{% block diagnostics %}
|
||||
{% endblock %}
|
||||
|
||||
{% block configuration %}
|
||||
{% if domain_names|length > 0 %}
|
||||
<h3>{% trans Configuration %}</h3>
|
||||
<form class="form form-configuration" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn btn-primary"
|
||||
value="{% trans "Update setup" %}"/>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
@ -1,92 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Functional, browser based tests for tahoe app.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from plinth.tests import functional
|
||||
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.tahoe, pytest.mark.skip]
|
||||
|
||||
# TODO: When tahoe-lafs is restarted, it leaves a .gnupg folder in
|
||||
# /var/lib/tahoe-lafs and failes to start in the next run. Enable tests after
|
||||
# this is fixed.
|
||||
|
||||
|
||||
class TestTahoeApp(functional.BaseAppTests):
|
||||
app_name = 'tahoe'
|
||||
has_service = True
|
||||
has_web = True
|
||||
|
||||
@pytest.fixture(scope='class', autouse=True)
|
||||
def fixture_setup(self, session_browser):
|
||||
"""Setup the app."""
|
||||
functional.login(session_browser)
|
||||
functional.set_advanced_mode(session_browser, True)
|
||||
functional.set_domain_name(session_browser, 'mydomain.example')
|
||||
functional.install(session_browser, self.app_name)
|
||||
functional.app_select_domain_name(session_browser, self.app_name,
|
||||
'mydomain.example')
|
||||
|
||||
def test_default_introducers(self, session_browser):
|
||||
"""Test default introducers."""
|
||||
assert _get_introducer(session_browser, 'mydomain.example', 'local')
|
||||
assert _get_introducer(session_browser, 'mydomain.example',
|
||||
'connected')
|
||||
|
||||
def test_add_remove_introducers(self, session_browser):
|
||||
"""Test add and remove introducers."""
|
||||
if _get_introducer(session_browser, 'anotherdomain.example',
|
||||
'connected'):
|
||||
_remove_introducer(session_browser, 'anotherdomain.example')
|
||||
|
||||
_add_introducer(session_browser, 'anotherdomain.example')
|
||||
assert _get_introducer(session_browser, 'anotherdomain.example',
|
||||
'connected')
|
||||
|
||||
_remove_introducer(session_browser, 'anotherdomain.example')
|
||||
assert not _get_introducer(session_browser, 'anotherdomain.example',
|
||||
'connected')
|
||||
|
||||
@pytest.mark.backups
|
||||
def test_backup_restore(self, session_browser):
|
||||
"""Test backup and restore of app data."""
|
||||
if not _get_introducer(session_browser, 'backupdomain.example',
|
||||
'connected'):
|
||||
_add_introducer(session_browser, 'backupdomain.example')
|
||||
functional.backup_create(session_browser, self.app_name, 'test_tahoe')
|
||||
|
||||
_remove_introducer(session_browser, 'backupdomain.example')
|
||||
functional.backup_restore(session_browser, self.app_name, 'test_tahoe')
|
||||
|
||||
assert functional.service_is_running(session_browser, self.app_name)
|
||||
assert _get_introducer(session_browser, 'backupdomain.example',
|
||||
'connected')
|
||||
|
||||
|
||||
def _get_introducer(browser, domain, introducer_type):
|
||||
"""Return an introducer element with a given type from tahoe-lafs."""
|
||||
functional.nav_to_module(browser, 'tahoe')
|
||||
css_class = '.{}-introducers .introducer-furl'.format(introducer_type)
|
||||
for furl in browser.find_by_css(css_class):
|
||||
if domain in furl.text:
|
||||
return furl.parent
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def _add_introducer(browser, domain):
|
||||
"""Add a new introducer into tahoe-lafs."""
|
||||
functional.nav_to_module(browser, 'tahoe')
|
||||
|
||||
furl = 'pb://ewe4zdz6kxn7xhuvc7izj2da2gpbgeir@tcp:{}:3456/' \
|
||||
'fko4ivfwgqvybppwar3uehkx6spaaou7'.format(domain)
|
||||
browser.fill('pet_name', 'testintroducer')
|
||||
browser.fill('furl', furl)
|
||||
functional.submit(browser, form_class='form-add-introducer')
|
||||
|
||||
|
||||
def _remove_introducer(browser, domain):
|
||||
"""Remove an introducer from tahoe-lafs."""
|
||||
introducer = _get_introducer(browser, domain, 'connected')
|
||||
functional.submit(browser, element=introducer.find_by_css('.form-remove'))
|
||||
@ -1,18 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
URLs for the Tahoe-LAFS module.
|
||||
"""
|
||||
|
||||
from django.urls import re_path
|
||||
|
||||
from . import views
|
||||
from .views import TahoeAppView, TahoeSetupView
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r'^apps/tahoe/setup/$', TahoeSetupView.as_view(), name='setup'),
|
||||
re_path(r'^apps/tahoe/add_introducer/$', views.add_introducer,
|
||||
name='add-introducer'),
|
||||
re_path(r'^apps/tahoe/remove_introducer/(?P<introducer>[0-9a-zA-Z_]+)/$',
|
||||
views.remove_introducer, name='remove-introducer'),
|
||||
re_path(r'^apps/tahoe/$', TahoeAppView.as_view(), name='index')
|
||||
]
|
||||
@ -1,64 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Views for the Tahoe-LAFS module
|
||||
"""
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
from plinth.forms import DomainSelectionForm
|
||||
from plinth.modules import names, tahoe
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
class TahoeSetupView(FormView):
|
||||
"""Show tahoe-lafs setup page."""
|
||||
template_name = 'tahoe-pre-setup.html'
|
||||
form_class = DomainSelectionForm
|
||||
success_url = reverse_lazy('tahoe:index')
|
||||
|
||||
def form_valid(self, form):
|
||||
domain_name = form.cleaned_data['domain_name']
|
||||
tahoe.post_setup(domain_name)
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['description'] = tahoe.app.info.description
|
||||
context['title'] = tahoe.app.info.name
|
||||
context['domain_names'] = names.components.DomainName.list_names(
|
||||
'tahoe-plinth')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class TahoeAppView(AppView):
|
||||
"""Show tahoe-lafs service page."""
|
||||
app_id = 'tahoe'
|
||||
template_name = 'tahoe-post-setup.html'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not tahoe.is_setup():
|
||||
return redirect('tahoe:setup')
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['domain_name'] = tahoe.get_configured_domain_name()
|
||||
context['introducers'] = tahoe.get_introducers()
|
||||
context['local_introducer'] = tahoe.get_local_introducer()
|
||||
|
||||
return context
|
||||
|
||||
|
||||
def add_introducer(request):
|
||||
if request.method == 'POST':
|
||||
tahoe.add_introducer((request.POST['pet_name'], request.POST['furl']))
|
||||
return redirect('tahoe:index')
|
||||
|
||||
|
||||
def remove_introducer(request, introducer):
|
||||
if request.method == 'POST':
|
||||
tahoe.remove_introducer(introducer)
|
||||
return redirect('tahoe:index')
|
||||
@ -59,7 +59,6 @@ markers = [
|
||||
"storage",
|
||||
"syncthing",
|
||||
"system",
|
||||
"tahoe",
|
||||
"tor",
|
||||
"transmission",
|
||||
"ttrss",
|
||||
|
||||
1
setup.py
1
setup.py
@ -47,6 +47,7 @@ DISABLED_APPS_TO_REMOVE = [
|
||||
'udiskie',
|
||||
'restore',
|
||||
'repro',
|
||||
'tahoe',
|
||||
]
|
||||
|
||||
REMOVED_FILES = [
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="512"
|
||||
height="512"
|
||||
preserveAspectRatio="xMidYMid"
|
||||
viewBox="-180 -180 512 512"
|
||||
id="svg3480"
|
||||
version="1.1"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||
sodipodi:docname="tahoe-lafs.svg">
|
||||
<metadata
|
||||
id="metadata3511">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title>Tahoe-LAFS logo</dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1704"
|
||||
inkscape:window-height="1396"
|
||||
id="namedview3509"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.921875"
|
||||
inkscape:cx="70.800001"
|
||||
inkscape:cy="114"
|
||||
inkscape:window-x="1639"
|
||||
inkscape:window-y="264"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg3480"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0" />
|
||||
<style
|
||||
type="text/css"
|
||||
id="style3482">
|
||||
.storage {
|
||||
fill: black;
|
||||
stroke: none;
|
||||
}
|
||||
.arrow {
|
||||
stroke: black;
|
||||
stroke-width: 2;
|
||||
marker-end: url(#arrowhead);
|
||||
}
|
||||
</style>
|
||||
<title
|
||||
id="title3484">Tahoe-LAFS logo</title>
|
||||
<desc
|
||||
id="desc3486">
|
||||
<h:p>A proposed logo for the Tahoe-LAFS Project.</h:p>
|
||||
<h:p><h:a
|
||||
rel="license"
|
||||
href="http://creativecommons.org/licenses/by/3.0/">
|
||||
<h:img
|
||||
alt="Creative Commons License"
|
||||
style="border-width:0"
|
||||
src="http://i.creativecommons.org/l/by/3.0/88x31.png" />
|
||||
</h:a>
|
||||
<h:br />
|
||||
<h:span
|
||||
href="http://purl.org/dc/dcmitype/StillImage"
|
||||
property="dct:title"
|
||||
rel="dct:type">Tahoe-LAFS Logo</h:span>
|
||||
|
||||
by <h:a
|
||||
href="http://switchb.org/kpreid/2009/tahoe/"
|
||||
property="cc:attributionName"
|
||||
rel="cc:attributionURL">Kevin Reid</h:a>
|
||||
|
||||
is licensed under a <h:a
|
||||
rel="license"
|
||||
href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</h:a>
|
||||
|
||||
.</h:p>
|
||||
</desc>
|
||||
<defs
|
||||
id="defs3488">
|
||||
<marker
|
||||
id="arrowhead"
|
||||
viewBox="0 -5 10 10"
|
||||
refX="2"
|
||||
refY="0"
|
||||
markerUnits="userSpaceOnUse"
|
||||
markerWidth="10"
|
||||
markerHeight="10"
|
||||
orient="auto">
|
||||
<path
|
||||
d="M 0,-3 9,0 0,3 Z"
|
||||
id="path3491"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
</defs>
|
||||
<g
|
||||
transform="matrix(7.5294118,0,0,7.5294118,76,256.70588)"
|
||||
id="g3493">
|
||||
<line
|
||||
class="arrow"
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="0"
|
||||
y2="-35"
|
||||
id="line3495"
|
||||
style="stroke:#000000;stroke-width:2;marker-end:url(#arrowhead)" />
|
||||
<line
|
||||
class="arrow"
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="-8"
|
||||
y2="-21"
|
||||
id="line3497"
|
||||
style="stroke:#000000;stroke-width:2;marker-end:url(#arrowhead)" />
|
||||
<line
|
||||
class="arrow"
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="8"
|
||||
y2="-21"
|
||||
id="line3499"
|
||||
style="stroke:#000000;stroke-width:2;marker-end:url(#arrowhead)" />
|
||||
<circle
|
||||
r="10"
|
||||
id="circle3501"
|
||||
cx="0"
|
||||
cy="0"
|
||||
style="fill:#ff0000" />
|
||||
<circle
|
||||
class="storage"
|
||||
r="8"
|
||||
cy="-50"
|
||||
id="circle3503"
|
||||
cx="0"
|
||||
style="fill:#000000;stroke:none" />
|
||||
<circle
|
||||
class="storage"
|
||||
r="8"
|
||||
cy="-35"
|
||||
cx="-14"
|
||||
id="circle3505"
|
||||
style="fill:#000000;stroke:none" />
|
||||
<circle
|
||||
class="storage"
|
||||
r="8"
|
||||
cy="-35"
|
||||
cx="14"
|
||||
id="circle3507"
|
||||
style="fill:#000000;stroke:none" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
Loading…
x
Reference in New Issue
Block a user