mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
ikiwiki: Remove get-enabled from actions
This commit is contained in:
parent
7cf47bbcb2
commit
48da6862b9
@ -28,7 +28,6 @@ import subprocess
|
|||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
|
|
||||||
|
|
||||||
CONFIG_ENABLE = '/etc/apache2/conf-enabled/ikiwiki-plinth.conf'
|
|
||||||
SETUP_WIKI = '/etc/ikiwiki/plinth-wiki.setup'
|
SETUP_WIKI = '/etc/ikiwiki/plinth-wiki.setup'
|
||||||
SETUP_BLOG = '/etc/ikiwiki/plinth-blog.setup'
|
SETUP_BLOG = '/etc/ikiwiki/plinth-blog.setup'
|
||||||
SITE_PATH = '/var/www/ikiwiki'
|
SITE_PATH = '/var/www/ikiwiki'
|
||||||
@ -43,10 +42,6 @@ def parse_arguments():
|
|||||||
# Setup ikiwiki site
|
# Setup ikiwiki site
|
||||||
subparsers.add_parser('setup', help='Perform first time setup operations')
|
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
|
# Enable ikiwiki site
|
||||||
subparsers.add_parser('enable', help='Enable ikiwiki site')
|
subparsers.add_parser('enable', help='Enable ikiwiki site')
|
||||||
|
|
||||||
@ -82,26 +77,14 @@ def subcommand_setup(_):
|
|||||||
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(_):
|
def subcommand_enable(_):
|
||||||
"""Enable ikiwiki site."""
|
"""Enable ikiwiki site."""
|
||||||
subprocess.check_call(['a2enconf', 'ikiwiki-plinth'])
|
action_utils.webserver_enable('ikiwiki-plinth')
|
||||||
action_utils.service_reload('apache2')
|
|
||||||
|
|
||||||
|
|
||||||
def subcommand_disable(_):
|
def subcommand_disable(_):
|
||||||
"""Disable ikiwiki site."""
|
"""Disable ikiwiki site."""
|
||||||
subprocess.check_call(['a2disconf', 'ikiwiki-plinth'])
|
action_utils.webserver_disable('ikiwiki-plinth')
|
||||||
action_utils.service_reload('apache2')
|
|
||||||
|
|
||||||
|
|
||||||
def subcommand_get_sites(_):
|
def subcommand_get_sites(_):
|
||||||
@ -158,10 +141,10 @@ def setup():
|
|||||||
if not os.path.exists(SITE_PATH):
|
if not os.path.exists(SITE_PATH):
|
||||||
os.makedirs(SITE_PATH)
|
os.makedirs(SITE_PATH)
|
||||||
|
|
||||||
subprocess.check_call(['a2enmod', 'cgi'])
|
with action_utils.WebserverChange() as webserver_change:
|
||||||
subprocess.check_call(['a2enmod', 'authnz_ldap'])
|
webserver_change.enable('cgi', kind='module')
|
||||||
subprocess.check_call(['a2enconf', 'ikiwiki-plinth'])
|
webserver_change.enable('authnz_ldap', kind='module')
|
||||||
action_utils.service_restart('apache2')
|
webserver_change.enable('ikiwiki-plinth')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -22,6 +22,7 @@ Plinth module to configure ikiwiki
|
|||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
|
from plinth import action_utils
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth import service as service_module
|
from plinth import service as service_module
|
||||||
|
|
||||||
@ -37,10 +38,12 @@ def init():
|
|||||||
menu.add_urlname(_('Wiki & Blog (Ikiwiki)'), 'glyphicon-edit',
|
menu.add_urlname(_('Wiki & Blog (Ikiwiki)'), 'glyphicon-edit',
|
||||||
'ikiwiki:index', 38)
|
'ikiwiki:index', 38)
|
||||||
|
|
||||||
output = actions.run('ikiwiki', ['get-enabled'])
|
|
||||||
enabled = (output.strip() == 'yes')
|
|
||||||
|
|
||||||
global service
|
global service
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
'ikiwiki', _('Ikiwiki wikis and blogs'), ['http', 'https'],
|
'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')
|
||||||
|
|||||||
@ -27,6 +27,7 @@ from gettext import gettext as _
|
|||||||
|
|
||||||
from .forms import IkiwikiForm, IkiwikiCreateForm
|
from .forms import IkiwikiForm, IkiwikiCreateForm
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
|
from plinth import action_utils
|
||||||
from plinth import package
|
from plinth import package
|
||||||
from plinth.modules import ikiwiki
|
from plinth.modules import ikiwiki
|
||||||
|
|
||||||
@ -76,9 +77,7 @@ def index(request):
|
|||||||
|
|
||||||
def get_status():
|
def get_status():
|
||||||
"""Get the current setting."""
|
"""Get the current setting."""
|
||||||
output = actions.run('ikiwiki', ['get-enabled'])
|
return {'enabled': ikiwiki.is_enabled()}
|
||||||
enabled = (output.strip() == 'yes')
|
|
||||||
return {'enabled': enabled}
|
|
||||||
|
|
||||||
|
|
||||||
def _apply_changes(request, old_status, new_status):
|
def _apply_changes(request, old_status, new_status):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user