Make ownCloud work with service framework

- This allows firewall to manage ports automatically
This commit is contained in:
Sunil Mohan Adapa 2014-04-18 12:54:42 +05:30
parent 32144e96ef
commit f7dd63c0a6

View File

@ -5,6 +5,7 @@ from plugin_mount import PagePlugin, FormPlugin
from forms import Form from forms import Form
import actions import actions
import cfg import cfg
import service
from util import Message from util import Message
class Owncloud(PagePlugin, FormPlugin): class Owncloud(PagePlugin, FormPlugin):
@ -15,13 +16,22 @@ class Owncloud(PagePlugin, FormPlugin):
self.register_page("apps.owncloud") self.register_page("apps.owncloud")
cfg.html_root.apps.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35) cfg.html_root.apps.menu.add_item("Owncloud", "icon-picture", "/apps/owncloud", 35)
self.service = service.Service('owncloud', _('ownCloud'),
['http', 'https'],
enabled=self.is_enabled)
def is_enabled(self):
"""Return whether ownCloud is enabled"""
output, error = actions.run('owncloud-setup', 'status')
if error:
raise Exception('Error getting ownCloud status: %s' % error)
return 'enable' in output.split()
@cherrypy.expose @cherrypy.expose
@require() @require()
def index(self, **kwargs): def index(self, **kwargs):
output, error = actions.run("owncloud-setup", 'status') owncloud_enable = self.is_enabled()
if error:
raise Exception("something is wrong: " + error)
owncloud_enable = "enable" in output.split()
if 'submitted' in kwargs: if 'submitted' in kwargs:
owncloud_enable = self.process_form(kwargs) owncloud_enable = self.process_form(kwargs)
@ -64,4 +74,8 @@ class Owncloud(PagePlugin, FormPlugin):
opts.append('no'+key) opts.append('no'+key)
actions.superuser_run("owncloud-setup", opts, async=True) actions.superuser_run("owncloud-setup", opts, async=True)
# Send a signal to other modules that the service is
# enabled/disabled
self.service.notify_enabled(self, checkedinfo['enable'])
return checkedinfo['enable'] return checkedinfo['enable']