mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-18 08:33:41 +00:00
Use package framework for installing ejabberd and jwchat
This commit is contained in:
parent
c7f27e493e
commit
b3e8e53c73
33
actions/xmpp
33
actions/xmpp
@ -38,10 +38,6 @@ def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
# Get whether ejabberd is installed
|
||||
subparsers.add_parser('get-installed',
|
||||
help='Get whether ejabberd is installed')
|
||||
|
||||
# Prepare ejabberd for hostname change
|
||||
pre_hostname_change = subparsers.add_parser(
|
||||
'pre-change-hostname',
|
||||
@ -77,17 +73,8 @@ def parse_arguments():
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def subcommand_get_installed(_):
|
||||
"""Get whether ejabberd is installed"""
|
||||
print('installed' if get_installed() else 'not installed')
|
||||
|
||||
|
||||
def subcommand_pre_change_hostname(arguments):
|
||||
"""Prepare ejabberd for hostname change"""
|
||||
if not get_installed():
|
||||
print('Failed to update XMPP hostname: ejabberd is not installed.')
|
||||
return
|
||||
|
||||
old_hostname = arguments.old_hostname
|
||||
new_hostname = arguments.new_hostname
|
||||
|
||||
@ -104,10 +91,6 @@ def subcommand_pre_change_hostname(arguments):
|
||||
|
||||
def subcommand_change_hostname(arguments):
|
||||
"""Update ejabberd and jwchat with new hostname"""
|
||||
if not get_installed():
|
||||
print('Failed to update XMPP hostname: ejabberd is not installed.')
|
||||
return
|
||||
|
||||
subprocess.call(['service', 'ejabberd', 'stop'])
|
||||
subprocess.call(['pkill', '-u', 'ejabberd'])
|
||||
|
||||
@ -134,10 +117,6 @@ def subcommand_change_hostname(arguments):
|
||||
|
||||
def subcommand_change_domainname(arguments):
|
||||
"""Update ejabberd and jwchat with new domainname"""
|
||||
if not get_installed():
|
||||
print('Failed to update XMPP domainname: ejabberd is not installed.')
|
||||
return
|
||||
|
||||
domainname = arguments.domainname
|
||||
fqdn = socket.gethostname() + '.' + domainname
|
||||
|
||||
@ -172,10 +151,6 @@ def subcommand_change_domainname(arguments):
|
||||
|
||||
def subcommand_register(arguments):
|
||||
"""Register a new user account"""
|
||||
if not get_installed():
|
||||
print('Failed to register XMPP account: ejabberd is not installed.')
|
||||
return
|
||||
|
||||
username = arguments.username
|
||||
password = arguments.password
|
||||
fqdn = socket.getfqdn()
|
||||
@ -188,14 +163,6 @@ def subcommand_register(arguments):
|
||||
print('Failed to register XMPP account:', e.output.decode())
|
||||
|
||||
|
||||
def get_installed():
|
||||
"""Check if ejabberd is installed"""
|
||||
with open('/dev/null', 'w') as file_handle:
|
||||
status = subprocess.call(['which', 'ejabberdctl'], stdout=file_handle)
|
||||
|
||||
return not status
|
||||
|
||||
|
||||
def main():
|
||||
"""Parse arguments and perform all duties"""
|
||||
arguments = parse_arguments()
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if is_installed %}
|
||||
|
||||
<p>XMPP is an open and standardized communication protocol. Here you
|
||||
can run and configure your XMPP server, called ejabberd. To actually
|
||||
communicate, you can use the <a href='/jwchat'>web client</a> or any
|
||||
@ -33,16 +31,4 @@
|
||||
<p><a href='/jwchat' target='_blank'class='btn btn-primary'> Launch web
|
||||
client</a></p>
|
||||
|
||||
{% else %}
|
||||
|
||||
<h2>XMPP Server</h2>
|
||||
|
||||
<p>The XMPP server <i>ejabberd</i> is not installed.</p>
|
||||
|
||||
<p>ejabberd comes pre-installed with {{ cfg.box_name }}. On any Debian-based
|
||||
system (such as {{ cfg.box_name }}) you may install it using the command
|
||||
<code>aptitude install ejabberd</code>.</p>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -25,6 +25,7 @@ import logging
|
||||
|
||||
from plinth import actions
|
||||
from plinth import cfg
|
||||
from plinth import package
|
||||
from plinth import service
|
||||
from plinth.signals import pre_hostname_change, post_hostname_change
|
||||
from plinth.signals import domainname_change
|
||||
@ -61,21 +62,12 @@ def init():
|
||||
|
||||
|
||||
@login_required
|
||||
@package.required('jwchat', 'ejabberd')
|
||||
def index(request):
|
||||
"""Serve XMPP page"""
|
||||
is_installed = actions.superuser_run(
|
||||
'xmpp',
|
||||
['get-installed']).strip() == 'installed'
|
||||
|
||||
if is_installed:
|
||||
index_subsubmenu = subsubmenu
|
||||
else:
|
||||
index_subsubmenu = None
|
||||
|
||||
return TemplateResponse(request, 'xmpp.html',
|
||||
{'title': _('XMPP Server'),
|
||||
'is_installed': is_installed,
|
||||
'subsubmenu': index_subsubmenu})
|
||||
'subsubmenu': subsubmenu})
|
||||
|
||||
|
||||
class ConfigureForm(forms.Form): # pylint: disable-msg=W0232
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user