xmpp: Replace jwchat with jsxc

- Update action to not configure jwchat anymore.

- Update action to not disable jwchat apache configuration.  Since the
  package is no longer installed, this could cause failures.

- Update action to no refer to jwchat in comments.

- Update jwchat-plinth Apache configuration to not include jwchat
  anymore.  Keep this file name for now instead of renaming it to
  jsxc-plinth as this would introduce additional complexity with little
  benefit.

- Install package libjs-jsxc instead of jwchat during xmpp setup.

- Create jsxc front page shortcut instead of for jwchat.

- Perform diagnostics on /http-bind/ URL needed for jwchat instead of
  /jwchat.

- Update links that launch XMPP web client.
This commit is contained in:
Sunil Mohan Adapa 2016-09-18 12:00:54 +05:30 committed by James Valleroy
parent e57aa2ae85
commit 305cc3218d
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
4 changed files with 19 additions and 48 deletions

View File

@ -26,13 +26,11 @@ import os
import shutil
import socket
import subprocess
import re
import ruamel.yaml
from plinth import action_utils
JWCHAT_CONFIG = '/etc/jwchat/config.js'
EJABBERD_CONFIG = '/etc/ejabberd/ejabberd.yml'
EJABBERD_BACKUP = '/var/log/ejabberd/ejabberd.dump'
EJABBERD_BACKUP_NEW = '/var/log/ejabberd/ejabberd_new.dump'
@ -51,8 +49,8 @@ def parse_arguments():
'--domainname',
help='The domain name that will be used by the XMPP service.')
# Setup jwchat apache conf
subparsers.add_parser('setup', help='Setup jwchat apache conf')
# Setup ejabberd configuration
subparsers.add_parser('setup', help='Setup ejabberd configuration')
subparsers.add_parser('enable', help='Enable XMPP service')
subparsers.add_parser('disable', help='Disable XMPP service')
@ -74,10 +72,10 @@ def parse_arguments():
hostname_change.add_argument('--new-hostname',
help='New hostname')
# Update ejabberd and jwchat with new domainname
# Update ejabberd with new domainname
domainname_change = subparsers.add_parser(
'change-domainname',
help='Update ejabberd and jwchat with new domainname')
help='Update ejabberd with new domainname')
domainname_change.add_argument('--domainname', help='New domainname')
return parser.parse_args()
@ -93,13 +91,10 @@ def subcommand_pre_install(arguments):
subprocess.check_output(
['debconf-set-selections'],
input=b'ejabberd ejabberd/hostname string ' + domainname.encode())
subprocess.check_output(
['debconf-set-selections'],
input=b'jwchat jwchat/ApacheServerName string ' + domainname.encode())
def subcommand_setup(_):
"""Enabled LDAP authentication and setup jwchat apache conf"""
"""Enabled LDAP authentication"""
with open(EJABBERD_CONFIG, 'r') as file_handle:
conf = ruamel.yaml.round_trip_load(file_handle, preserve_quotes=True)
@ -121,7 +116,6 @@ def subcommand_setup(_):
print('Failed to restart ejabberd with new configuration: %s', err)
with action_utils.WebserverChange() as webserver_change:
webserver_change.disable('jwchat', kind='site')
webserver_change.enable('jwchat-plinth')
@ -158,7 +152,7 @@ def subcommand_pre_change_hostname(arguments):
def subcommand_change_hostname(arguments):
"""Update ejabberd and jwchat with new hostname"""
"""Update ejabberd with new hostname"""
if not shutil.which('ejabberdctl'):
print('ejabberdctl not found. Is ejabberd installed?')
return
@ -188,7 +182,7 @@ def subcommand_change_hostname(arguments):
def subcommand_change_domainname(arguments):
"""Update ejabberd and jwchat with new domainname"""
"""Update ejabberd with new domainname"""
if not shutil.which('ejabberdctl'):
print('ejabberdctl not found. Is ejabberd installed?')
return
@ -198,20 +192,6 @@ def subcommand_change_domainname(arguments):
# If new domainname is blank, use hostname instead.
domainname = socket.gethostname()
# update jwchat's sitename, if it's installed
if os.path.exists(JWCHAT_CONFIG):
with open(JWCHAT_CONFIG, 'r') as conffile:
lines = conffile.readlines()
with open(JWCHAT_CONFIG, 'w') as conffile:
for line in lines:
if re.match(r'\s*var\s+SITENAME', line):
conffile.write('var SITENAME = "' + domainname + '";\n')
else:
conffile.write(line)
else:
print('Skipping configuring jwchat sitename: %s not found',
JWCHAT_CONFIG)
action_utils.service_stop('ejabberd')
subprocess.call(['pkill', '-u', 'ejabberd'])

View File

@ -1,10 +1,4 @@
Alias /jwchat /usr/share/jwchat/www
<Directory /usr/share/jwchat/www>
Options +Indexes +Multiviews +FollowSymLinks
</Directory>
# proxy for BOSH server
# Proxy for BOSH server
ProxyPass /http-bind/ http://localhost:5280/http-bind/
ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
<Proxy http://localhost:5280/http-bind/*>

View File

@ -19,6 +19,7 @@
Plinth module to configure XMPP server
"""
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
import logging
import socket
@ -38,7 +39,7 @@ depends = ['apps']
managed_services = ['ejabberd']
managed_packages = ['jwchat', 'ejabberd']
managed_packages = ['libjs-jsxc', 'ejabberd']
title = _('Chat Server (XMPP)')
@ -46,8 +47,7 @@ description = [
_('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 other '
_('To actually communicate, you can use the web client or any other '
'<a href=\'http://xmpp.org/xmpp-software/clients/\' target=\'_blank\''
'>XMPP client</a>.')
]
@ -90,8 +90,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('jwchat', _('Chat Client (JWChat)'), '/jwchat',
'glyphicon-comment')
frontpage.add_shortcut('jsxc', _('Chat Client (jsxc)'),
reverse_lazy('xmpp:jsxc'), 'glyphicon-comment')
frontpage.add_shortcut('xmpp', title, None, 'glyphicon-comment',
description)
@ -117,7 +117,7 @@ def enable():
def disable():
"""Enable the module."""
actions.superuser_run('xmpp', ['disable'])
frontpage.remove_shortcut('jwchat')
frontpage.remove_shortcut('jsxc')
frontpage.remove_shortcut('xmpp')
@ -135,9 +135,7 @@ def on_pre_hostname_change(sender, old_hostname, new_hostname, **kwargs):
def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
"""
Update ejabberd and jwchat config after hostname is changed.
"""
"""Update ejabberd config after hostname change."""
del sender # Unused
del kwargs # Unused
@ -149,9 +147,7 @@ def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
def on_domainname_change(sender, old_domainname, new_domainname, **kwargs):
"""
Update ejabberd and jwchat config after domain name is changed.
"""
"""Update ejabberd config after domain name change."""
del sender # Unused
del old_domainname # Unused
del kwargs # Unused
@ -172,6 +168,7 @@ def diagnose():
results.append(action_utils.diagnose_port_listening(5269, 'tcp6'))
results.append(action_utils.diagnose_port_listening(5280, 'tcp4'))
results.append(action_utils.diagnose_port_listening(5280, 'tcp6'))
results.extend(action_utils.diagnose_url_on_all('http://{host}/jwchat'))
results.extend(
action_utils.diagnose_url_on_all('http://{host}/http-bind/'))
return results

View File

@ -37,7 +37,7 @@
</p>
<p>
<a href='/jwchat' target='_blank' class='btn btn-primary'>
<a href='{% url "xmpp:jsxc" %}' target='_blank' class='btn btn-primary'>
{% trans "Launch web client" %}</a>
</p>
{% endblock %}