From 305cc3218d55bc33fcf2cf8a219a0a0a3369369c Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Sun, 18 Sep 2016 12:00:54 +0530
Subject: [PATCH] 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.
---
actions/xmpp | 34 ++++---------------
.../apache2/conf-available/jwchat-plinth.conf | 8 +----
plinth/modules/xmpp/__init__.py | 23 ++++++-------
plinth/modules/xmpp/templates/xmpp.html | 2 +-
4 files changed, 19 insertions(+), 48 deletions(-)
diff --git a/actions/xmpp b/actions/xmpp
index 958190f56..66f27511d 100755
--- a/actions/xmpp
+++ b/actions/xmpp
@@ -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'])
diff --git a/data/etc/apache2/conf-available/jwchat-plinth.conf b/data/etc/apache2/conf-available/jwchat-plinth.conf
index b256b7c9c..4ef50ca0e 100644
--- a/data/etc/apache2/conf-available/jwchat-plinth.conf
+++ b/data/etc/apache2/conf-available/jwchat-plinth.conf
@@ -1,10 +1,4 @@
-Alias /jwchat /usr/share/jwchat/www
-
-
- Options +Indexes +Multiviews +FollowSymLinks
-
-
-# proxy for BOSH server
+# Proxy for BOSH server
ProxyPass /http-bind/ http://localhost:5280/http-bind/
ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
diff --git a/plinth/modules/xmpp/__init__.py b/plinth/modules/xmpp/__init__.py
index 901681c5d..b796e415b 100644
--- a/plinth/modules/xmpp/__init__.py
+++ b/plinth/modules/xmpp/__init__.py
@@ -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 web '
- 'client or any other '
+ _('To actually communicate, you can use the web client or any other '
'XMPP client.')
]
@@ -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
diff --git a/plinth/modules/xmpp/templates/xmpp.html b/plinth/modules/xmpp/templates/xmpp.html
index 3f3903ec8..a44c49bfb 100644
--- a/plinth/modules/xmpp/templates/xmpp.html
+++ b/plinth/modules/xmpp/templates/xmpp.html
@@ -37,7 +37,7 @@
-
+
{% trans "Launch web client" %}
{% endblock %}