From fe33c348b4d15052d44df83989cbbee1d9c79cb3 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Mon, 23 Sep 2013 15:14:32 +0200 Subject: [PATCH] First draft to add owncloud support. --- actions/owncloud-setup | 48 +++++++++++++++++++++++++++++++++ modules/installed/apps/apps.py | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100755 actions/owncloud-setup diff --git a/actions/owncloud-setup b/actions/owncloud-setup new file mode 100755 index 000000000..0394c2e23 --- /dev/null +++ b/actions/owncloud-setup @@ -0,0 +1,48 @@ +#!/bin/sh + +if [ -e /etc/apache2/conf-enabled/owncloud.conf ] ; then + owncloud_enable=true +else + owncloud_enable=false +fi +owncloud_enable_cur=$owncloud_enable +export owncloud_enable + + +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 + export owncloud_enable + ;; + 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 + apt-get install -y owncloud + a2enconf owncloud + else + a2disconf owncloud + fi + service apache2 restart +fi diff --git a/modules/installed/apps/apps.py b/modules/installed/apps/apps.py index 83b977e28..ef82a01de 100644 --- a/modules/installed/apps/apps.py +++ b/modules/installed/apps/apps.py @@ -1,6 +1,9 @@ import cherrypy +from gettext import gettext as _ from modules.auth import require from plugin_mount import PagePlugin +from forms import Form +from privilegedactions import privilegedaction_run import cfg class Apps(PagePlugin): @@ -9,6 +12,7 @@ class Apps(PagePlugin): self.register_page("apps") self.menu = cfg.main_menu.add_item("Apps", "icon-download-alt", "/apps", 80) self.menu.add_item("Photo Gallery", "icon-picture", "/apps/photos", 35) + self.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35) @cherrypy.expose def index(self): @@ -33,3 +37,48 @@ investment in the sentimental value of your family snaps? Keep those photos local, backed up, easily accessed and free from the whims of some other websites business model.

""") + + @cherrypy.expose + @require() + def owncloud(self, submitted=False, **kwargs): + checkedinfo = { + 'enable' : False, + } + + if submitted: + opts = [] + for k in kwargs.keys(): + if 'on' == kwargs[k]: + shortk = k.split("owncloud_").pop() + cfg.log.info('found: %s, short %s ' % (k, shortk)) + checkedinfo[shortk] = True + + for key in checkedinfo.keys(): + if checkedinfo[key]: + opts.append(key) + else: + opts.append('no'+key) + privilegedaction_run("owncloud-setup", opts) + + output, error = privilegedaction_run("owncloud-setup", ['status']) + if error: + raise Exception("something is wrong: " + error) + for option in output.split(): + checkedinfo[option] = True + + main=""" +""" + form = Form(title="Configuration", + action="/apps/owncloud", + name="configure_owncloud", + message='') + form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=checkedinfo['enable']) + form.hidden(name="submitted", value="True") + form.html(_("

When enabled, the owncloud installation will be available from /owncloud/ on the web server.

")) + form.submit(_("Update setup")) + main += form.render() + sidebar_right=""" +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. +

+""" + return self.fill_template(title="Owncloud", main=main, sidebar_right=sidebar_right)