mysql - 需要能够通过 HTTP 或 MySQL 在 openfire 中插入/删除新组

标签 mysql openfire

我知道如何通过 MySQL 插入一个新组,而且它在一定程度上有效。问题是如果您手动插入组,数据库更改不会加载到内存中。向进程发送 HUP 信号确实有效,但它很笨拙而且很乱。我渴望优雅:)

如果可能的话,我想做的是通过 MySQL 对组进行更改(添加/删除/更改),然后向 openfire 服务器发送 HTTP 请求以读取新的更改。或者,以类似于用户服务 工作方式的方式添加/删除/修改组。

如果有人能提供帮助,我将不胜感激。

最佳答案

在我看来,如果发送 HUP 信号对你有效,那么这实际上是让 Openfire 读取你的新组的一种非常简单、优雅和有效的方法,特别是如果你在 Openfire 服务器上使用以下命令执行此操作(并假设它运行的是 Linux/Unix 操作系统):

pkill -f -HUP openfire

如果您仍想发送 HTTP 请求以提示 Openfire 重新读取组,以下 Python 脚本应该可以完成这项工作。它针对 Openfire 3.8.2,并依赖于 Python 的 mechanize 库,在 Ubuntu 中它与 python-mechanize 包一起安装。该脚本登录到 Openfire 服务器,调出缓存摘要页面,选择组和组元数据缓存选项,启用提交按钮,然后提交表单以清除这两个缓存。

#!/usr/bin/python

import mechanize
import cookielib

# Customize to suit your setup
of_host = 'http://openfire.server:9090'
of_user = 'admin_username'
of_pass = 'admin_password'

# Initialize browser and cookie jar
br = mechanize.Browser()
br.set_cookiejar(cookielib.LWPCookieJar())

# Log into Openfire server
br.open(of_host + '/login.jsp')
br.select_form('loginForm')
br.form['username'] = of_user
br.form['password'] = of_pass
br.submit()

# Select which cache items to clear in the Cache Summary page
# On my server, 13 is Group and 14 is Group Metadata Cache
br.open(of_host + '/system-cache.jsp')
br.select_form('cacheForm')
br.form['cacheID'] = ['13','14']

# Activate the submit button and submit the form
c = br.form.find_control('clear')
c.readonly = False
c.disabled = False
r = br.submit()

# Uncomment the following line if you want to view results
#print r.read()

关于mysql - 需要能够通过 HTTP 或 MySQL 在 openfire 中插入/删除新组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18050658/

相关文章:

swift3 - 在 swift 3.0 中使用 XMPP openfire 发送消息

php - PHP 和 MySQL 无法登录

java - 无法使用java从sql数据库读取数据

php - 使用 CodeIgniter 运行基于另一个查询的查询

php - 如何使用openfire服务器接收消息?

android - openfire可以和mysql服务器合并吗

php - 数据库搜索 - 单个 AJAX 查询 + Javascript 过滤器

php - Google finance API - 无法获取货币汇率

xmpp - Openfire 附加用户字段

ssl - 使用 https 请求忽略 strophe js 中的自签名 ssl 证书