From ad3420823d0d06963128f91e33980717fe309839 Mon Sep 17 00:00:00 2001 From: morrme Date: Tue, 25 Apr 2017 01:10:52 -0500 Subject: [PATCH] owncloud: Remove module (Closes: #818) It is believed that ownCloud is unlikely to return to Debian in near future. Removing module to ease maintenance. Reviewed-by: Sunil Mohan Adapa --- actions/owncloud-setup | 98 -------------- data/etc/plinth/modules-enabled/owncloud | 1 - .../lib/freedombox/first-run.d/90_firewall | 4 +- plinth/forms.py | 8 -- plinth/modules/owncloud/__init__.py | 120 ------------------ .../modules/owncloud/templates/owncloud.html | 50 -------- plinth/modules/owncloud/tests/__init__.py | 0 plinth/modules/owncloud/urls.py | 30 ----- plinth/views.py | 78 ------------ 9 files changed, 2 insertions(+), 387 deletions(-) delete mode 100755 actions/owncloud-setup delete mode 100644 data/etc/plinth/modules-enabled/owncloud delete mode 100644 plinth/modules/owncloud/__init__.py delete mode 100644 plinth/modules/owncloud/templates/owncloud.html delete mode 100644 plinth/modules/owncloud/tests/__init__.py delete mode 100644 plinth/modules/owncloud/urls.py diff --git a/actions/owncloud-setup b/actions/owncloud-setup deleted file mode 100755 index dc3401834..000000000 --- a/actions/owncloud-setup +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -# -# This file is part of Plinth. -# -# 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 . -# - -# See also -# http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_automation.html - -grep -q "^\s*['\"]dbtype['\"]" /etc/owncloud/config.php 2> /dev/null -db_in_config=$(( ! $? )) - -grep -q "^\s*['\"]dbtype['\"]" /etc/owncloud/autoconfig.php 2> /dev/null -db_in_autoconfig=$(( ! $? )) - -if [ -e /etc/apache2/conf-enabled/owncloud.conf ] && \ - [ $db_in_config -ne 0 -o $db_in_autoconfig -ne 0 ] ; then - owncloud_enable_cur=true -else - owncloud_enable_cur=false -fi - - -while [ "$1" ] ; do - arg="$1" - shift - case "$arg" in - enable|noenable) # Not using disable for consistency with other options - if [ 'enable' = "$arg" ] ; then - owncloud_enable=true - else - owncloud_enable=false - fi - ;; - status) - printstatus() { - if "$2" ; then - echo "$1" - else - echo no"$1" - fi - } - printstatus enable $owncloud_enable_cur - exit 0 - ;; - *) - ;; - esac -done - -if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then - if $owncloud_enable ; then - # Keep existing configuration if it exist - if [ $db_in_config -eq 0 -a $db_in_autoconfig -eq 0 ] ; then - # Set up postgresql database and user - dbpwd=$(pwgen -1 30) - su - postgres -c "psql -c \"CREATE USER owncloud WITH NOCREATEDB NOCREATEUSER\"" \ - 2>&1 | logger -t owncloud-setup - su - postgres -c "psql -c \"ALTER USER owncloud ENCRYPTED PASSWORD '$dbpwd'\"" \ - 2>&1 | logger -t owncloud-setup - su - postgres -c "createdb --owner owncloud owncloud" \ - 2>&1 | logger -t owncloud-setup - - cat > /etc/owncloud/autoconfig.php < '/usr/share/owncloud/data', - 'dbtype' => 'pgsql', - 'dbname' => 'owncloud', - 'dbuser' => 'owncloud', - 'dbpass' => '$dbpwd', - 'dbhost' => 'localhost', - 'dbtableprefix' => 'oc_', - - 'installed' => false, -); -EOF - fi - - a2enconf owncloud 2>&1 | logger -t owncloud-setup - else - a2disconf owncloud 2>&1 | logger -t owncloud-setup - fi - - service apache2 reload 2>&1 | logger -t owncloud-setup -fi diff --git a/data/etc/plinth/modules-enabled/owncloud b/data/etc/plinth/modules-enabled/owncloud deleted file mode 100644 index c3596a2c4..000000000 --- a/data/etc/plinth/modules-enabled/owncloud +++ /dev/null @@ -1 +0,0 @@ -plinth.modules.owncloud diff --git a/data/usr/lib/freedombox/first-run.d/90_firewall b/data/usr/lib/freedombox/first-run.d/90_firewall index d895be4da..2c9d2b454 100755 --- a/data/usr/lib/freedombox/first-run.d/90_firewall +++ b/data/usr/lib/freedombox/first-run.d/90_firewall @@ -56,11 +56,11 @@ firewall-cmd --set-default-zone=external # following is then for essential services and services that are not # yet configurable from Plinth. -# HTTP (JWChat, ownCloud) +# HTTP (JWChat) firewall-cmd --zone=external --permanent --add-service=http firewall-cmd --zone=internal --permanent --add-service=http -# HTTPS (Plinth, JWChat, ownCloud) +# HTTPS (Plinth, JWChat) firewall-cmd --zone=external --permanent --add-service=https firewall-cmd --zone=internal --permanent --add-service=https diff --git a/plinth/forms.py b/plinth/forms.py index 896581975..b9aca6c7b 100644 --- a/plinth/forms.py +++ b/plinth/forms.py @@ -23,14 +23,6 @@ from django import forms from django.utils.translation import ugettext_lazy as _ -# TODO: remove this form once owncloud is removed (it's the last using it). -class ConfigurationForm(forms.Form): - """Generic configuration form for simple modules.""" - enabled = forms.BooleanField( - label=_('Enable application'), - required=False) - - class ServiceForm(forms.Form): """Generic configuration form for a service.""" is_enabled = forms.BooleanField( diff --git a/plinth/modules/owncloud/__init__.py b/plinth/modules/owncloud/__init__.py deleted file mode 100644 index 9bb344341..000000000 --- a/plinth/modules/owncloud/__init__.py +++ /dev/null @@ -1,120 +0,0 @@ -# -# This file is part of Plinth. -# -# 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 . -# - -""" -Plinth module to configure ownCloud -""" - -from django.utils.translation import ugettext_lazy as _ -from functools import partial -import os - -from plinth import actions -from plinth import action_utils -from plinth import cfg -from plinth import service as service_module - -version = 1 - -depends = ['apps'] - -managed_packages = ['postgresql', 'php5-pgsql', 'owncloud', 'php-dropbox', - 'php-google-api-php-client'] - -title = _('File Hosting (ownCloud)') - -description = [ - _('ownCloud gives you universal access to your files through a web ' - 'interface or WebDAV. It also provides a platform to easily view ' - '& sync your contacts, calendars and bookmarks across all your ' - 'devices and enables basic editing right on the web. Installation ' - 'has minimal server requirements, doesn\'t need special ' - 'permissions and is quick. ownCloud is extendable via a simple ' - 'but powerful API for applications and plugins.'), - - _('When enabled, the ownCloud installation will be available ' - 'from /owncloud path on the web server. ' - 'Visit this URL to set up the initial administration account for ' - 'ownCloud.') -] - -service = None - - -def init(): - """Initialize the ownCloud module""" - # XXX: ownCloud has been removed from Debian - if not os.path.isfile('/etc/owncloud/config.php') and \ - not os.path.isfile('/etc/owncloud/autoconfig.php'): - return - - menu = cfg.main_menu.get('apps:index') - menu.add_urlname(title, 'glyphicon-picture', 'owncloud:index') - - global service - setup_helper = globals()['setup_helper'] - if setup_helper.get_state() != 'needs-setup': - service = service_module.Service( - 'owncloud', title, ports=['http', 'https'], is_external=True, - is_enabled=is_enabled, enable=_enable, disable=_disable) - - -def setup(helper, old_version=None): - """Install and configure the module.""" - helper.install(managed_packages) - helper.call('post', actions.superuser_run, 'owncloud-setup', ['enable']) - global service - if service is None: - service = service_module.Service( - 'owncloud', title, ports=['http', 'https'], is_external=True, - is_enabled=is_enabled, enable=_enable, disable=_disable) - helper.call('post', service.notify_enabled, None, True) - - -def get_status(): - """Return the current status""" - return {'enabled': is_enabled()} - - -def is_enabled(): - """Return whether the module is enabled.""" - output = actions.run('owncloud-setup', ['status']) - return 'enable' in output.split() - - -def enable(should_enable): - """Enable/disable the module.""" - option = 'enable' if should_enable else 'noenable' - actions.superuser_run('owncloud-setup', [option]) - - # Send a signal to other modules that the service is - # enabled/disabled - service.notify_enabled(None, should_enable) - - -def diagnose(): - """Run diagnostics and return the results.""" - results = [] - - results.extend(action_utils.diagnose_url_on_all( - 'https://{host}/owncloud', check_certificate=False)) - - return results - - -_enable = partial(enable, True) -_disable = partial(enable, False) diff --git a/plinth/modules/owncloud/templates/owncloud.html b/plinth/modules/owncloud/templates/owncloud.html deleted file mode 100644 index ee1979538..000000000 --- a/plinth/modules/owncloud/templates/owncloud.html +++ /dev/null @@ -1,50 +0,0 @@ -{% extends "simple_service.html" %} -{% comment %} -# -# This file is part of Plinth. -# -# 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 . -# -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} - -{% block configuration %} - - - - {% include "diagnostics_button.html" with module="owncloud" %} - -

{% trans "Configuration" %}

- -
- {% csrf_token %} - - {{ form|bootstrap }} - - -
- -{% endblock %} diff --git a/plinth/modules/owncloud/tests/__init__.py b/plinth/modules/owncloud/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/plinth/modules/owncloud/urls.py b/plinth/modules/owncloud/urls.py deleted file mode 100644 index 7f215357b..000000000 --- a/plinth/modules/owncloud/urls.py +++ /dev/null @@ -1,30 +0,0 @@ -# -# This file is part of Plinth. -# -# 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 . -# - -""" -URLs for the ownCloud module -""" - -from django.conf.urls import url - -from plinth.views import ConfigurationView - - -urlpatterns = [ - url(r'^apps/owncloud/$', ConfigurationView.as_view(module_name='owncloud'), - name='index'), -] diff --git a/plinth/views.py b/plinth/views.py index 72b35d314..4ce9747ba 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -123,84 +123,6 @@ class ServiceView(FormView): return context -# TODO: remove this view once owncloud is gone. -class ConfigurationView(FormView): - """A generic view for configuring simple modules.""" - form_class = forms.ConfigurationForm - module_name = None - - def __init__(self, module_name=None, *args, **kwargs): - """Set the module name on which this configuration view operates.""" - self.instance_module_name = module_name - - def get_module_name(self): - """Return the name of the module associated with the view.""" - if not self.instance_module_name and not self.module_name: - raise ImproperlyConfigured( - 'Using ConfigurationView without the "module_name" class ' - 'attribute or intialization attribute is prohibited.') - else: - return self.instance_module_name or self.module_name - - def get_module(self): - """Return the module associated with the view.""" - return plinth.module_loader.loaded_modules[self.get_module_name()] - - def get_initial(self): - """Return the status of the module to fill in the form.""" - return self.get_module().get_status() - - def get_prefix(self): - """Return prefix for form used in the view.""" - return self.get_module_name() - - def get_template_names(self): - """Return the list of template names for the view.""" - return [self.get_module_name() + '.html'] - - def get_context_data(self, **kwargs): - """Return the context data for rendering the template view.""" - if 'title' not in kwargs: - kwargs['title'] = getattr(self.get_module(), 'title', None) - - if 'description' not in kwargs: - kwargs['description'] = \ - getattr(self.get_module(), 'description', None) - - context = super().get_context_data(**kwargs) - - if 'status' not in context: - context['status'] = context['form'].initial - - return context - - def form_valid(self, form): - """Perform operation when the form submission is valid.""" - old_status = form.initial - new_status = form.cleaned_data - - modified = self.apply_changes(old_status, new_status) - if not modified: - messages.info(self.request, _('Setting unchanged')) - - context = self.get_context_data() - return self.render_to_response(context) - - def apply_changes(self, old_status, new_status): - """Apply the changes submitted in the form.""" - if old_status['enabled'] == new_status['enabled']: - return False - - should_enable = new_status['enabled'] - self.get_module().enable(should_enable) - if should_enable: - messages.success(self.request, _('Application enabled')) - else: - messages.success(self.request, _('Application disabled')) - - return True - - class SetupView(TemplateView): """View to prompt and setup applications.""" template_name = 'setup.html'