ikiwiki: Remove get-enabled from actions

This commit is contained in:
Sunil Mohan Adapa 2015-07-12 11:55:51 +05:30 committed by James Valleroy
parent 7cf47bbcb2
commit 48da6862b9
3 changed files with 15 additions and 30 deletions

View File

@ -28,7 +28,6 @@ import subprocess
from plinth import action_utils
CONFIG_ENABLE = '/etc/apache2/conf-enabled/ikiwiki-plinth.conf'
SETUP_WIKI = '/etc/ikiwiki/plinth-wiki.setup'
SETUP_BLOG = '/etc/ikiwiki/plinth-blog.setup'
SITE_PATH = '/var/www/ikiwiki'
@ -43,10 +42,6 @@ def parse_arguments():
# Setup ikiwiki site
subparsers.add_parser('setup', help='Perform first time setup operations')
# Get whether ikiwiki site is enabled
subparsers.add_parser('get-enabled',
help='Get whether ikiwiki site is enabled')
# Enable ikiwiki site
subparsers.add_parser('enable', help='Enable ikiwiki site')
@ -82,26 +77,14 @@ def subcommand_setup(_):
setup()
def subcommand_get_enabled(_):
"""Get whether ikiwiki site is enabled."""
try:
subprocess.check_output(['a2query', '-c', 'ikiwiki-plinth'],
stderr=subprocess.STDOUT)
print('yes')
except subprocess.CalledProcessError:
print('no')
def subcommand_enable(_):
"""Enable ikiwiki site."""
subprocess.check_call(['a2enconf', 'ikiwiki-plinth'])
action_utils.service_reload('apache2')
action_utils.webserver_enable('ikiwiki-plinth')
def subcommand_disable(_):
"""Disable ikiwiki site."""
subprocess.check_call(['a2disconf', 'ikiwiki-plinth'])
action_utils.service_reload('apache2')
action_utils.webserver_disable('ikiwiki-plinth')
def subcommand_get_sites(_):
@ -158,10 +141,10 @@ def setup():
if not os.path.exists(SITE_PATH):
os.makedirs(SITE_PATH)
subprocess.check_call(['a2enmod', 'cgi'])
subprocess.check_call(['a2enmod', 'authnz_ldap'])
subprocess.check_call(['a2enconf', 'ikiwiki-plinth'])
action_utils.service_restart('apache2')
with action_utils.WebserverChange() as webserver_change:
webserver_change.enable('cgi', kind='module')
webserver_change.enable('authnz_ldap', kind='module')
webserver_change.enable('ikiwiki-plinth')
def main():

View File

@ -22,6 +22,7 @@ Plinth module to configure ikiwiki
from gettext import gettext as _
from plinth import actions
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
@ -37,10 +38,12 @@ def init():
menu.add_urlname(_('Wiki & Blog (Ikiwiki)'), 'glyphicon-edit',
'ikiwiki:index', 38)
output = actions.run('ikiwiki', ['get-enabled'])
enabled = (output.strip() == 'yes')
global service
service = service_module.Service(
'ikiwiki', _('Ikiwiki wikis and blogs'), ['http', 'https'],
is_external=True, enabled=enabled)
is_external=True, enabled=is_enabled())
def is_enabled():
"""Return whether the module is enabled."""
return action_utils.webserver_is_enabled('ikiwiki-plinth')

View File

@ -27,6 +27,7 @@ from gettext import gettext as _
from .forms import IkiwikiForm, IkiwikiCreateForm
from plinth import actions
from plinth import action_utils
from plinth import package
from plinth.modules import ikiwiki
@ -76,9 +77,7 @@ def index(request):
def get_status():
"""Get the current setting."""
output = actions.run('ikiwiki', ['get-enabled'])
enabled = (output.strip() == 'yes')
return {'enabled': enabled}
return {'enabled': ikiwiki.is_enabled()}
def _apply_changes(request, old_status, new_status):