【问题标题】:How start ejabberdctl from bash script properly?如何从 bash 脚本正确启动 ejabberdctl?
【发布时间】:2021-05-26 22:06:08
【问题描述】:

我需要从 csv 文件在 ejabberd 中注册成千上万的用户。为此,我编写了一个简单的脚本。

#!/bin/sh
OLDIFS=$IFS
IFS=','
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read username domain pass p1 p2 p3 p4
do
    echo "ejabberdctl register $username $domain $pass"
    ejabberdctl register $username $domain $pass
done < users.csv
IFS=$OLDIFS

但最后,答案是:Error: cannot_register 如果我只是运行从输出复制的行,一切都很好。用户创建正常。

【问题讨论】:

    标签: bash ubuntu ejabberd


    【解决方案1】:

    这只是稍后的一个小技巧:一旦你的循环工作,如果你认为 ejabberdctl 太慢,你可以尝试使用 ReST API。在处理许多请求时,这应该会快很多。

    像这样临时配置(记得在完成后删除它):

    listen:
      -
        port: 5280
        module: ejabberd_http
        tls: false 
        request_handlers:
          /api: mod_http_api
    
    api_permissions:
      "console commands":
        from:
          - ejabberd_ctl
          - mod_http_api
        who: all
        what: "*"
    
    modules:
      mod_http_api: {}
    

    然后在shell中执行这个来注册一个帐户:

    curl 'localhost:5280/api/register?user=user2&host=localhost&password=somepass123'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-12
      相关资源
      最近更新 更多