mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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 <sunil@medhas.org>
This commit is contained in:
parent
e63197ee2e
commit
ad3420823d
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
# 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 <<EOF
|
|
||||||
<?php
|
|
||||||
\$AUTOCONFIG = array(
|
|
||||||
'directory' => '/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
|
|
||||||
@ -1 +0,0 @@
|
|||||||
plinth.modules.owncloud
|
|
||||||
@ -56,11 +56,11 @@ firewall-cmd --set-default-zone=external
|
|||||||
# following is then for essential services and services that are not
|
# following is then for essential services and services that are not
|
||||||
# yet configurable from Plinth.
|
# yet configurable from Plinth.
|
||||||
|
|
||||||
# HTTP (JWChat, ownCloud)
|
# HTTP (JWChat)
|
||||||
firewall-cmd --zone=external --permanent --add-service=http
|
firewall-cmd --zone=external --permanent --add-service=http
|
||||||
firewall-cmd --zone=internal --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=external --permanent --add-service=https
|
||||||
firewall-cmd --zone=internal --permanent --add-service=https
|
firewall-cmd --zone=internal --permanent --add-service=https
|
||||||
|
|
||||||
|
|||||||
@ -23,14 +23,6 @@ from django import forms
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
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):
|
class ServiceForm(forms.Form):
|
||||||
"""Generic configuration form for a service."""
|
"""Generic configuration form for a service."""
|
||||||
is_enabled = forms.BooleanField(
|
is_enabled = forms.BooleanField(
|
||||||
|
|||||||
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
|
||||||
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 <a href="/owncloud">/owncloud</a> 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)
|
|
||||||
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
{% load bootstrap %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block configuration %}
|
|
||||||
|
|
||||||
<div class="alert alert-danger" role="alert">
|
|
||||||
<span class="glyphicon glyphicon-exclamation-sign"
|
|
||||||
aria-hidden="true"></span>
|
|
||||||
<span class="sr-only">Error:</span>
|
|
||||||
{% blocktrans trimmed %}
|
|
||||||
ownCloud is no longer supported by {{ box_name }} due it's
|
|
||||||
removal from Debian. Please migrate your data to an alternative
|
|
||||||
solution or manage ownCloud manually from the command line.
|
|
||||||
{% endblocktrans %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% include "diagnostics_button.html" with module="owncloud" %}
|
|
||||||
|
|
||||||
<h3>{% trans "Configuration" %}</h3>
|
|
||||||
|
|
||||||
<form class="form" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
{{ form|bootstrap }}
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary btn-md"
|
|
||||||
value="{% trans "Apply changes" %}"/>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
|
||||||
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'),
|
|
||||||
]
|
|
||||||
@ -123,84 +123,6 @@ class ServiceView(FormView):
|
|||||||
return context
|
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):
|
class SetupView(TemplateView):
|
||||||
"""View to prompt and setup applications."""
|
"""View to prompt and setup applications."""
|
||||||
template_name = 'setup.html'
|
template_name = 'setup.html'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user