### Start ejabberd (System Install) Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Start the ejabberd service when installed system-wide. This command uses the ejabberdctl script located in the system's sbin directory. ```bash ejabberdctl start /sbin/ejabberdctl start ``` -------------------------------- ### Configure ejabberd container startup commands Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Use `CTL_ON_CREATE` for one-time setup commands and `CTL_ON_START` for commands executed on every container start. Prefix commands with `!` to ignore failures. ```yaml environment: - CTL_ON_CREATE=register admin localhost asd - CTL_ON_START=stats registeredusers ; check_password admin localhost asd ; ! change_password bot123 localhost qqq ; status ``` -------------------------------- ### Start ejabberd Interactively Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Start ejabberd interactively for development or testing without a formal installation or OTP release build. This is useful for quick checks. ```bash make relive ``` -------------------------------- ### Start Module Source: https://context7.com/processone/ejabberd/llms.txt Starts a specific module for a given virtual host at runtime. ```APIDOC ## ejabberdctl start_module ### Description Starts a specific module for a given virtual host at runtime. ### Usage ejabberdctl start_module ### Parameters - **host** (string) - Required - The virtual host for which to start the module. - **module_name** (string) - Required - The name of the module to start. ``` -------------------------------- ### Install a module Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Compile and install any of the contributed modules using `ejabberdctl module_install`. ```APIDOC ## Install a module Compile and install any of the contributed modules, for example: ```bash docker exec ejabberd ejabberdctl module_install mod_statsdx ``` Module `mod_statsdx` has been installed and started. It's configured in the file: `/opt/ejabberd/.ejabberd-modules/mod_statsdx/conf/mod_statsdx.yml`. Configure the module in that file, or remove it and configure in your main `ejabberd.yml`. ``` -------------------------------- ### ejabberd Command-Line Help Source: https://github.com/processone/ejabberd/blob/master/README.md Get help on ejabberdctl commands after installation. ```bash ejabberdctl help ``` -------------------------------- ### ejabberdapi register example Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Example of using the `ejabberdapi` executable to register a new account. ```APIDOC ### ejabberdapi When the container is running (and thus ejabberd), you can exec commands inside the container using `ejabberdctl` or any other of the available interfaces. Additionally, the container image includes the `ejabberdapi` executable. Please check the [ejabberd-api homepage](https://github.com/processone/ejabberd-api) for configuration and usage details. For example, if you configure ejabberd like this: ```yaml listen: - port: 5282 module: ejabberd_http request_handlers: "/api": mod_http_api acl: loopback: ip: - 127.0.0.0/8 - ::1/128 - ::FFFF:127.0.0.1/128 api_permissions: "admin access": who: access: allow: acl: loopback what: - "register" ``` Then you could register new accounts with this query: ```bash docker exec -it ejabberd ejabberdapi register --endpoint=http://127.0.0.1:5282/ --jid=admin@localhost --password=passw0rd ``` ``` -------------------------------- ### Prepare Ejabberd Configuration Directory Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Create a directory for ejabberd configuration and copy the example configuration file into it. ```bash mkdir conf && cp ejabberd.yml.example conf/ejabberd.yml ``` -------------------------------- ### Install and Build ejabberd Source: https://context7.com/processone/ejabberd/llms.txt Steps to clone, configure, compile, and install ejabberd from source. Includes options for building a production release or running in interactive development mode. ```bash # Clone and generate configure script (if needed) git clone https://github.com/processone/ejabberd.git cd ejabberd ./autogen.sh # only needed when configure script is absent # Configure, compile, and install ./configure make sudo make install # Or build a self-contained OTP production release (no system install) ./configure make prod # Start/stop via ejabberdctl ejabberdctl start ejabberdctl status ejabberdctl stop # Interactive development mode (no install required) make relive # Explore all Makefile targets make help ./configure --help ``` -------------------------------- ### Install git for dependencies Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Install `git` in the container image to resolve dependency issues when installing modules that require external libraries. ```APIDOC ## Install git for dependencies Some modules depend on erlang libraries, but the container images do not include `git` or `mix` to download them. Consequently, when you attempt to install such a module, there will be error messages. The solution is to install `git` in the container image: ```bash docker exec --user root ejabberd apk add git ``` And now you can upgrade the module: ```bash docker exec ejabberd ejabberdctl module_upgrade ejabberd_observer_cli ``` ``` -------------------------------- ### Start ejabberd Server Source: https://context7.com/processone/ejabberd/llms.txt Use this command to start the ejabberd server process on the local node. ```bash ejabberdctl start ``` -------------------------------- ### Run ejabberd Container with Podman Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Run an ejabberd container using Podman. This example starts a detached container and maps port 5222. ```bash podman run --name eja1 -d -p 5222:5222 localhost/ejabberd ``` -------------------------------- ### Start ejabberd with Custom Configuration and Data Volume Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Starts ejabberd interactively, mounting a custom configuration file and a directory for database storage. Ensure the mounted volumes grant appropriate permissions to the 'ejabberd' user (UID 9000). ```bash mkdir conf && cp ejabberd.yml.example conf/ejabberd.yml mkdir database && chown ejabberd database docker run --name ejabberd -it \ -v $(pwd)/conf/ejabberd.yml:/opt/ejabberd/conf/ejabberd.yml \ -v $(pwd)/database:/opt/ejabberd/database \ -p 5222:5222 ghcr.io/processone/ejabberd live ``` -------------------------------- ### List Installed Modules Source: https://context7.com/processone/ejabberd/llms.txt Lists all community modules currently installed on the server. ```APIDOC ## ejabberdctl modules_installed ### Description Lists all community modules currently installed on the server. ``` -------------------------------- ### List Available Modules Source: https://context7.com/processone/ejabberd/llms.txt Lists all community modules available for installation. ```APIDOC ## ejabberdctl modules_available ### Description Lists all community modules available for installation. ``` -------------------------------- ### Install your custom module Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Steps to package and install your own custom ejabberd module into the container. ```APIDOC ## Install your module If you developed an ejabberd module, you can install it in your container image: 1. Create a local directory for `ejabberd-modules`: ``` sh mkdir docker-modules ``` 2. Then create the directory structure for your custom module: ``` sh cd docker-modules mkdir -p sources/mod_hello_world/ touch sources/mod_hello_world/mod_hello_world.spec mkdir sources/mod_hello_world/src/ mv mod_hello_world.erl sources/mod_hello_world/src/ mkdir sources/mod_hello_world/conf/ echo -e "modules:\n mod_hello_world: {{}}" > sources/mod_hello_world/conf/mod_hello_world.yml cd .. ``` 3. Grant ownership of that directory to the UID that ejabberd will use inside the Docker image: ``` sh sudo chown 9000 -R docker-modules/ ``` 4. Start ejabberd in the container: ``` sh sudo docker run \ --name hellotest \ -d \ --volume "$(pwd)/docker-modules:/home/ejabberd/.ejabberd-modules/" \ -p 5222:5222 \ -p 5280:5280 \ ejabberd/ecs ``` 5. Check the module is available for installing, and then install it: ``` sh sudo docker exec -it hellotest ejabberdctl modules_available mod_hello_world [] sudo docker exec -it hellotest ejabberdctl module_install mod_hello_world ``` 6. If the module works correctly, you will see `Hello` in the ejabberd logs when it starts: ``` sh sudo docker exec -it hellotest grep Hello logs/ejabberd.log ``` ``` -------------------------------- ### Start ejabberd with custom modules volume Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Run the ejabberd Docker container, mounting the local custom modules directory to the container's module path. This makes your custom module available for installation. ```bash sudo docker run \ --name hellotest \ -d \ --volume "$(pwd)/docker-modules:/home/ejabberd/.ejabberd-modules/" \ -p 5222:5222 \ -p 5280:5280 \ ejabberd/ecs ``` -------------------------------- ### Install Community Module Source: https://context7.com/processone/ejabberd/llms.txt Installs a community module from the ejabberd-contrib repository. ```APIDOC ## ejabberdctl module_install ### Description Installs a community module from the ejabberd-contrib repository. ### Usage ejabberdctl module_install ### Parameters - **module_name** (string) - Required - The name of the module to install. ``` -------------------------------- ### Configure ejabberd container startup commands with Podman Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Demonstrates setting `CTL_ON_CREATE` and `CTL_ON_START` environment variables for ejabberd container initialization and startup using Podman. Includes example output showing command execution and results. ```bash $ podman run -it \ --env CTL_ON_CREATE="register admin localhost asd" \ --env CTL_ON_START="stats registeredusers ; \ check_password admin localhost asd ; \ ! change_password bot123 localhost qqq ; \ status" \ ghcr.io/processone/ejabberd ... :> ejabberdctl register admin localhost asd User admin@localhost successfully registered :> ejabberdctl stats registeredusers 1 :> ejabberdctl check_password admin localhost asd :> ejabberdctl change_password bot123 localhost qqq {not_found,"unknown_user"} :> FAILURE in command 'change_password bot123 localhost qqq' !!! Ignoring result :> ejabberdctl status The node ejabberd@localhost is started. Status: started ejabberd 25.10.0 is running in that node ``` -------------------------------- ### Start ejabberd (OTP Release) Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Start the ejabberd service when built as an OTP production release. This command uses the ejabberdctl script within the release's binary directory. ```bash _build/prod/rel/ejabberd/bin/ejabberdctl start _build/prod/rel/ejabberd/bin/ejabberdctl live ``` -------------------------------- ### Verify custom module installation Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Confirm that your custom module is running correctly by searching for its startup message in the ejabberd logs. This helps verify the installation and configuration. ```bash sudo docker exec -it hellotest grep Hello logs/ejabberd.log 2020-10-06 13:40:13.154335+00:00 [info] <0.492.0>@mod_hello_world:start/2:15 Hello, ejabberd world! ``` -------------------------------- ### Install ejabberd System-Wide Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Install ejabberd into the system after compilation. This command requires administrator privileges and places files in standard system directories. ```bash sudo make install ``` -------------------------------- ### Configure ejabberd Compilation Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Run the configure script to set up the build environment. Use '--help' to see available configuration options for features and installation paths. ```bash ./configure ./configure --help ``` -------------------------------- ### Docker Run: ejabberd Single Node Quickstart Source: https://context7.com/processone/ejabberd/llms.txt Run a single ejabberd node using the Docker Hub image. This command exposes standard ejabberd ports and sets up an initial admin user. ```bash # Run with Docker Hub image (single node, quickstart) docker run --name ejabberd \ -p 5222:5222 -p 5269:5269 -p 5280:5280 -p 5443:5443 \ -e ERLANG_NODE_ARG=ejabberd@localhost \ -e CTL_ON_CREATE="register admin localhost adminpass" \ ejabberd/ecs:latest ``` -------------------------------- ### List and install custom ejabberd module Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Check if your custom module is available using `ejabberdctl modules_available` and then install it using `ejabberdctl module_install`. This makes the module active in your ejabberd instance. ```bash sudo docker exec -it hellotest ejabberdctl modules_available mod_hello_world [] sudo docker exec -it hellotest ejabberdctl module_install mod_hello_world ``` -------------------------------- ### Ejabberd Custom Module Implementation Source: https://context7.com/processone/ejabberd/llms.txt Example of implementing a custom ejabberd module using the `gen_mod` behavior. This demonstrates how to start, stop, and handle events within a module. ```erlang -module(mod_hello_world). -behaviour(gen_mod). -export([start/2, stop/1, reload/3, depends/2, mod_options/1, mod_doc/0]). %% Called when the module starts for a given virtual host start(Host, _Opts) -> %% Register hooks, IQ handlers, commands, etc. ejabberd_hooks:add(user_send_packet, Host, ?MODULE, on_user_send, 50), ok. stop(Host) -> ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, on_user_send, 50), ok. reload(_Host, _NewOpts, _OldOpts) -> ok. depends(_Host, _Opts) -> []. %% List required modules: [{mod_roster, hard}] mod_options(_Host) -> []. %% Declare module options with defaults mod_doc() -> #{desc => "A hello world example module"}. on_user_send({Packet, C2SState}) -> io:format("User sent packet: ~p~n", [Packet]), {Packet, C2SState}. ``` -------------------------------- ### ejabberd CLI and REST API Command Examples Source: https://context7.com/processone/ejabberd/llms.txt Demonstrates how to invoke registered commands via the `ejabberdctl` command-line interface and the REST API. ```bash # After registering, the command is immediately available: ejabberdctl greet_user alice example.org # And via REST API: curl -s -k -u "admin@example.org:pass" \ -H "Content-Type: application/json" \ -d '{"user":"alice","server":"example.org"}' \ -X POST "https://localhost:5443/api/greet_user" # Generate API documentation for all registered commands ejabberdctl gen_markdown_doc_for_commands /tmp/api.md "" "json" ejabberdctl gen_html_doc_for_commands /tmp/api.html "" "java,json" ``` -------------------------------- ### Install Mnesia fallback backup Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Command to install the converted Mnesia backup file as a fallback in the new ejabberd container. ```bash docker exec -it $NEWCONTAINER ejabberdctl install_fallback $NEWFILE ``` -------------------------------- ### Install ejabberd module Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Use `ejabberdctl module_install` to compile and install contributed modules. The module will be configured in its own YAML file or can be configured in the main `ejabberd.yml`. ```bash docker exec ejabberd ejabberdctl module_install mod_statsdx Module mod_statsdx has been installed and started. It's configured in the file: /opt/ejabberd/.ejabberd-modules/mod_statsdx/conf/mod_statsdx.yml Configure the module in that file, or remove it and configure in your main ejabberd.yml ``` -------------------------------- ### MQTT Client Testing with mosquitto Source: https://context7.com/processone/ejabberd/llms.txt Examples using mosquitto_pub and mosquitto_sub to test the ejabberd MQTT broker, including authentication and topic subscription. ```bash # Connect and test with mosquitto clients mosquitto_pub -h example.org -p 1883 \ -u alice@example.org -P s3cr3t \ -t "home/temperature" -m "22.5" mosquitto_sub -h example.org -p 1883 \ -u alice@example.org -P s3cr3t \ -t "home/#" -v # MQTT over WebSocket (via ejabberd_http_ws + mod_mqtt_ws) # ws://example.org:5443/mqtt or wss://example.org:5443/mqtt ``` -------------------------------- ### Start ejabberd with Erlang Console Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Starts ejabberd interactively with an attached Erlang console. Uses default configuration and XMPP domain 'localhost'. ```bash docker run --name ejabberd -it -p 5222:5222 ghcr.io/processone/ejabberd live ``` -------------------------------- ### Upgrade ejabberd module after installing git Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md After installing `git`, you can upgrade modules that have external dependencies. This command fetches dependencies using git and then installs the module. ```bash docker exec ejabberd ejabberdctl module_upgrade ejabberd_observer_cli I'll download "recon" using git because I can't use Mix to fetch from hex.pm: /bin/sh: mix: not found Fetching dependency observer_cli: Cloning into 'observer_cli'... Fetching dependency os_stats: Cloning into 'os_stats'... Fetching dependency recon: Cloning into 'recon'... Inlining: inline_size=24 inline_effort=150 Old inliner: threshold=0 functions=[{insert,2},{merge,2}] Module ejabberd_observer_cli has been installed. Now you can configure it in your ejabberd.yml I'll download "recon" using git because I can't use Mix to fetch from hex.pm: /bin/sh: mix: not found ``` -------------------------------- ### Install CAPTCHA Dependencies Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Install necessary libraries for ejabberd CAPTCHA functionality within the container. This command requires root privileges. ```bash docker exec --user root ejabberd apk add imagemagick ghostscript-fonts bash ``` -------------------------------- ### Install git for module dependencies Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Some ejabberd modules require external libraries that are not included in the base container image. Install `git` using `apk add git` to resolve dependency issues when installing modules that fetch from external sources. ```bash docker exec --user root ejabberd apk add git fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz (1/3) Installing pcre2 (10.43-r0) (2/3) Installing git (2.47.2-r0) (3/3) Installing git-init-template (2.47.2-r0) Executing busybox-1.37.0-r12.trigger OK: 27 MiB in 42 packages ``` -------------------------------- ### Generate Configure Script Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md If the source code lacks a 'configure' script, use this command to generate it. Ensure 'autoconf' is installed first. ```bash ./autogen.sh ``` -------------------------------- ### ejabberdctl User Management Commands Source: https://context7.com/processone/ejabberd/llms.txt Command-line examples for managing user accounts using `ejabberdctl`, including checking passwords, changing passwords, and managing bans. ```bash # Check/manage users via ejabberdctl ejabberdctl check_password alice example.org s3cr3t ejabberdctl check_password_hash alice example.org HASH_HEX md5 ejabberdctl change_password alice example.org newpassword ejabberdctl ban_account alice example.org "Spam" ejabberdctl unban_account alice example.org ejabberdctl get_ban_details alice example.org ``` -------------------------------- ### Start ejabberd Test Databases with Docker Compose Source: https://github.com/processone/ejabberd/blob/master/test/docker/README.md Launches MySQL, MSSQL, PostgreSQL, and Redis databases using Docker Compose. Keep the console attached to monitor logs. Stop with CTRL-C. ```bash mkdir test/docker/db/mysql/data mkdir test/docker/db/postgres/data (cd test/docker; docker compose up) ``` -------------------------------- ### Create new ejabberd container for Mnesia migration Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Command to start a new ejabberd container with the same database volume binded, ready to receive the converted Mnesia backup. ```bash docker run \ --name $NEWCONTAINER \ -d \ -p 5222:5222 \ -v $(pwd)/database:/opt/ejabberd/database \ ghcr.io/processone/ejabberd:latest ``` -------------------------------- ### Setup old ejabberd container for Mnesia migration Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Commands to set up an older ejabberd container (23.01 or older) with a binded database directory and register an account, preparing for Mnesia node name change. ```bash OLDCONTAINER=ejaold NEWCONTAINER=ejanew mkdir database sudo chown 9000:9000 database docker run -d --name $OLDCONTAINER -p 5222:5222 \ -v $(pwd)/database:/opt/ejabberd/database \ ghcr.io/processone/ejabberd:23.01 docker exec -it $OLDCONTAINER ejabberdctl started docker exec -it $OLDCONTAINER ejabberdctl register user1 localhost somepass docker exec -it $OLDCONTAINER ejabberdctl registered_users localhost ``` -------------------------------- ### Get Help on ejabberdctl Command Source: https://context7.com/processone/ejabberd/llms.txt Displays help information for a specific ejabberdctl command, explaining its usage and options. ```bash ejabberdctl help register ``` ```bash ejabberdctl help send_message ``` -------------------------------- ### Run ejabberd as a Daemon Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Starts ejabberd in a detached mode (daemon). Uses default configuration and XMPP domain 'localhost'. ```bash docker run --name ejabberd -d -p 5222:5222 ghcr.io/processone/ejabberd ``` -------------------------------- ### Start and Stop Command Registration Source: https://context7.com/processone/ejabberd/llms.txt Register commands during module startup with `ejabberd_commands:register_commands/1` and unregister them on shutdown with `ejabberd_commands:unregister_commands/1`. ```erlang start(_Host, _Opts) -> ejabberd_commands:register_commands(get_commands_spec()), ok. stop(_Host) -> ejabberd_commands:unregister_commands(get_commands_spec()), ok. ``` -------------------------------- ### Upgrade Community Module Source: https://context7.com/processone/ejabberd/llms.txt Upgrades an installed community module. ```APIDOC ## ejabberdctl module_upgrade ### Description Upgrades an installed community module. ### Usage ejabberdctl module_upgrade ### Parameters - **module_name** (string) - Required - The name of the module to upgrade. ``` -------------------------------- ### Run ejabberd container with Erlang cookie Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Use this command to start an ejabberd container, exporting necessary ports and setting the Erlang cookie from the host's cookie file. ```sh docker run --name ejabberd -it \ -e ERLANG_COOKIE=`cat $HOME/.erlang.cookie` \ -p 5210:5210 -p 5222:5222 \ ghcr.io/processone/ejabberd ``` -------------------------------- ### Get Roster with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Retrieves the roster for a specific user. Requires username and domain. ```bash ejabberdctl get_roster alice example.org ``` -------------------------------- ### ejabberd Core Configuration Source: https://context7.com/processone/ejabberd/llms.txt A minimal production example of the ejabberd.yml configuration file. Shows settings for hosts, logging, TLS certificates, various network listeners (XMPP, HTTP, MQTT, STUN/TURN), access control lists, API permissions, and traffic shaping. ```yaml # /etc/ejabberd/ejabberd.yml (minimal production example) hosts: - "example.org" loglevel: info # TLS certificates (Let's Encrypt compatible) certfiles: - /etc/letsencrypt/live/example.org/fullchain.pem - /etc/letsencrypt/live/example.org/privkey.pem listen: # XMPP client connections (STARTTLS) - port: 5222 ip: "::" module: ejabberd_c2s max_stanza_size: 262144 shaper: c2s_shaper access: c2s starttls_required: true # XMPP client connections (Direct TLS) - port: 5223 ip: "::" module: ejabberd_c2s tls: true # XMPP server-to-server federation - port: 5269 ip: "::" module: ejabberd_s2s_in max_stanza_size: 524288 shaper: s2s_shaper # HTTPS: Web Admin + REST API + BOSH + WebSocket + File Upload - port: 5443 ip: "::" module: ejabberd_http tls: true request_handlers: /admin: ejabberd_web_admin /api: mod_http_api /bosh: mod_bosh /upload: mod_http_upload /ws: ejabberd_http_ws # HTTP (ACME challenges, plain Web Admin) - port: 5280 ip: "::" module: ejabberd_http request_handlers: /admin: ejabberd_web_admin /.well-known/acme-challenge: ejabberd_acme # MQTT broker - port: 1883 ip: "::" module: mod_mqtt backlog: 1000 # STUN/TURN for WebRTC - port: 5478 ip: "::" transport: udp module: ejabberd_stun use_turn: true s2s_use_starttls: optional # Access Control Lists acl: local: user_regexp: "" loopback: ip: - 127.0.0.0/8 - ::1/128 access_rules: local: { allow: local } c2s: [{ deny: blocked }, { allow: all }] announce: { allow: admin } configure: { allow: admin } muc_create: { allow: local } trusted_network: { allow: loopback } # API permission model api_permissions: "console commands": from: ejabberd_ctl who: all what: "*" "http access": from: mod_http_api who: access: allow: - acl: loopback - acl: admin oauth: scope: "ejabberd:admin" access: allow: - acl: loopback - acl: admin what: - "*" - "!stop" - "!start" "public commands": who: ip: 127.0.0.1/8 what: - status - connected_users_number # Traffic shaping shaper: normal: { rate: 3000, burst_size: 20000 } fast: 100000 shaper_rules: max_user_sessions: 10 max_user_offline_messages: { 5000: admin, 100: all } c2s_shaper: { none: admin, normal: all } s2s_shaper: fast ``` -------------------------------- ### Get ejabberd Mnesia Information with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Displays information about the ejabberd Mnesia database, including table sizes and status. ```bash ejabberdctl mnesia_info ``` -------------------------------- ### ejabberd Authentication Configuration Source: https://context7.com/processone/ejabberd/llms.txt YAML examples for configuring various authentication methods in ejabberd, including Mnesia, SQL, LDAP, external scripts, JWT, and PAM. Supports multiple simultaneous backends. ```yaml # ejabberd.yml — authentication configuration examples # Internal Mnesia storage (default) auth_method: mnesia # SQL database backend auth_method: sql default_db: sql sql_type: pgsql sql_server: "db.example.org" sql_database: ejabberd sql_username: ejabberd sql_password: "dbpassword" # LDAP authentication auth_method: ldap ldap_servers: - ldap.example.org ldap_base: "ou=Users,dc=example,dc=org" ldap_uids: - uid ldap_filter: "(objectClass=posixAccount)" # External script authentication auth_method: external extauth_program: /usr/lib/ejabberd/bin/auth-script.sh # JWT (JSON Web Token) authentication auth_method: jwt jwt_key: /etc/ejabberd/jwt_secret.pem jwt_algorithm: "RS256" jwt_jid_field: "sub" # PAM (Linux Pluggable Authentication Modules) auth_method: pam pam_service: ejabberd # Multiple backends simultaneously (checked in order) auth_method: - sql - ldap # Password storage format auth_password_format: scram # Options: plain | scram | scram256 | scram512 ``` -------------------------------- ### Create and List MUC Rooms via ejabberd REST API Source: https://context7.com/processone/ejabberd/llms.txt Examples of using curl to interact with the ejabberd REST API for creating rooms and listing online rooms. ```bash # REST API examples curl -s -k -u "admin@example.org:pass" \ -H "Content-Type: application/json" \ -d '{"name":"lobby","service":"conference.example.org","host":"example.org"}' \ -X POST "https://localhost:5443/api/create_room" curl -s -k -u "admin@example.org:pass" \ -H "Content-Type: application/json" \ -d '{"host":"global"}' \ -X POST "https://localhost:5443/api/muc_online_rooms" # ["lobby@conference.example.org", "support@conference.example.org"] ``` -------------------------------- ### Configure ejabberd container with environment variables for clustering Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Example of setting environment variables in a docker-compose.yml file to configure Erlang node name and cookie for a clustered ejabberd node. ```yaml environment: - ERLANG_NODE_ARG=ejabberd@node7 - ERLANG_COOKIE=dummycookie123 ``` -------------------------------- ### Docker Compose Configuration for Ejabberd Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Defines a Docker Compose setup for ejabberd, including environment variables for host and admin, admin password, startup commands, port mappings, and volume mounts for configuration and database. ```yaml version: '3.7' services: main: image: ghcr.io/processone/ejabberd container_name: ejabberd environment: - EJABBERD_MACRO_HOST=example.com - EJABBERD_MACRO_ADMIN=admin@example.com - REGISTER_ADMIN_PASSWORD=somePassw0rd - CTL_ON_START=registered_users example.com ; status ports: - "5222:5222" - "5269:5269" - "5280:5280" - "5443:5443" volumes: - ./conf/ejabberd.yml:/opt/ejabberd/conf/ejabberd.yml:ro - ./database:/opt/ejabberd/database ``` -------------------------------- ### View Build Targets Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Display a list of all available targets for the 'make' command, including options for building and managing the project. ```bash make help ``` -------------------------------- ### Prepare Database Directory for Docker Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Create a directory for the ejabberd database and set the correct ownership for Docker to access it. ```bash mkdir database && sudo chown 9000:9000 database ``` -------------------------------- ### Prepare Database Directory for Podman Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Create a directory for the ejabberd database and set the correct ownership for Podman to access it using `podman unshare`. ```bash mkdir database && podman unshare chown 9000:9000 database ``` -------------------------------- ### Set up ejabberd database volume with Docker Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Ensure the database directory has the correct ownership for the ejabberd user when using Docker bind mounts. ```bash mkdir database sudo chown 9000:9000 database ``` -------------------------------- ### Create MSSQL Database and User for ejabberd Tests Source: https://github.com/processone/ejabberd/blob/master/test/docker/README.md Initializes the MSSQL database, creates a login and user, and sets up the ejabberd schema. Requires SA credentials. ```bash docker exec ejabberd-mssql /opt/mssql-tools18/bin/sqlcmd -U SA -P ejabberd_Test1 -S localhost -i /initdb_mssql.sql -C ``` ```bash docker exec ejabberd-mssql /opt/mssql-tools18/bin/sqlcmd -U SA -P ejabberd_Test1 -S localhost -d ejabberd_test -i /mssql.sql -C ``` -------------------------------- ### Get Connected Users Count via HTTP API Source: https://context7.com/processone/ejabberd/llms.txt Uses curl to send a POST request to the /api/connected_users_number endpoint to get the count of active user sessions. ```bash curl -s -k -u "$ADMIN" -X POST "$BASE/connected_users_number" # {"num_sessions": 42} ``` -------------------------------- ### View ejabberd Configuration Manual Source: https://github.com/processone/ejabberd/blob/master/README.md Display the manual page for ejabberd's main configuration file. ```bash man ejabberd.yml ``` -------------------------------- ### Get Roster Source: https://context7.com/processone/ejabberd/llms.txt Retrieves the roster for a given user. ```APIDOC ## POST /get_roster ### Description Retrieves the roster for a given user. ### Method POST ### Endpoint /get_roster ### Request Body - **user** (string) - Required - Username of the user - **server** (string) - Required - Server hostname ### Request Example ```json { "user": "alice", "server": "example.org" } ``` ``` -------------------------------- ### Set up ejabberd database volume with Podman Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Ensure the database directory has the correct ownership for the ejabberd user when using Podman bind mounts, utilizing `podman unshare` for user namespace remapping. ```bash mkdir database podman unshare chown 9000:9000 database ``` -------------------------------- ### Configure ejabberd Build Source: https://github.com/processone/ejabberd/blob/master/README.md Use this command to view available configuration options when compiling ejabberd from source. ```bash ./configure --help ``` -------------------------------- ### Get Connected Users Number Source: https://context7.com/processone/ejabberd/llms.txt Retrieves the number of currently connected users. Supports OAuth token authentication. ```APIDOC ## POST /connected_users_number ### Description Retrieves the number of currently connected users. Supports OAuth token authentication. ### Method POST ### Endpoint /connected_users_number ### Authentication Bearer Token ### Request Body - **(empty)** - The request body can be empty. ### Request Example ```json {} ``` ``` -------------------------------- ### Get Registered Users (v2) Source: https://context7.com/processone/ejabberd/llms.txt Retrieves a list of registered users for a specific host, using API version 2. ```APIDOC ## POST /v2/registered_users ### Description Retrieves a list of registered users for a specific host, using API version 2. ### Method POST ### Endpoint /v2/registered_users ### Request Body - **host** (string) - Required - The hostname to query for registered users. ### Request Example ```json { "host": "example.org" } ``` ``` -------------------------------- ### Get Connected Users Count with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Returns the total number of currently connected user sessions on the ejabberd server. ```bash ejabberdctl connected_users_number ``` -------------------------------- ### Docker Run: ejabberd with GitHub Container Registry Source: https://context7.com/processone/ejabberd/llms.txt Run ejabberd using the GitHub Container Registry image, mounting local configuration and certificate directories. Supports multi-arch builds. ```bash # Run with GitHub Container Registry image (multi-arch: x64 + arm64) docker run --name ejabberd \ -p 5222:5222 -p 5443:5443 \ -v $(pwd)/ejabberd.yml:/home/ejabberd/conf/ejabberd.yml \ -v $(pwd)/certs:/home/ejabberd/conf/certs \ ghcr.io/processone/ejabberd:latest ``` -------------------------------- ### Build ejabberd OTP Production Release Source: https://github.com/processone/ejabberd/blob/master/COMPILE.md Build a self-contained OTP release of ejabberd. This package includes all dependencies and is suitable for deployment without system-wide installation. ```bash make prod ``` -------------------------------- ### Register New User with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Use this command to register a new user account on the ejabberd server. Requires username, domain, and password. ```bash ejabberdctl register alice example.org s3cr3t ``` -------------------------------- ### Create ejabberd module directory structure Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Prepare the directory structure for a custom ejabberd module. This includes creating specification, source, and configuration files. ```sh mkdir docker-modules cd docker-modules mkdir -p sources/mod_hello_world/ touch sources/mod_hello_world/mod_hello_world.spec mkdir sources/mod_hello_world/src/ mv mod_hello_world.erl sources/mod_hello_world/src/ mkdir sources/mod_hello_world/conf/ echo -e "modules:\n mod_hello_world: {{}}" > sources/mod_hello_world/conf/mod_hello_world.yml cd .. ``` -------------------------------- ### Get MUC Room Occupants with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Lists all users currently present in a specific Multi-User Chat room. Requires room name and conference service. ```bash ejabberdctl get_room_occupants lobby conference.example.org ``` -------------------------------- ### Get Erlang node name from ejabberd container Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Various methods to determine the Erlang node name of a running ejabberd container, useful for Mnesia migration. ```bash ls database/ | grep ejabberd@ docker exec -it $OLDCONTAINER ejabberdctl status docker exec -it $OLDCONTAINER grep "started in the node" logs/ejabberd.log ``` -------------------------------- ### Register account using ejabberdapi Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Register a new account using the `ejabberdapi` executable within the container. This requires the ejabberd API to be configured in `ejabberd.yml` with appropriate request handlers and permissions. ```bash docker exec -it ejabberd ejabberdapi register --endpoint=http://127.0.0.1:5282/ --jid=admin@localhost --password=passw0rd ``` -------------------------------- ### Change ownership of module directory Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Grant ownership of the custom module directory to the UID used by ejabberd inside the Docker container (typically 9000) before starting the container. ```sh sudo chown 9000 -R docker-modules/ ``` -------------------------------- ### Create MUC Room with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Creates a new Multi-User Chat room. Requires room name, conference service, and owner. ```bash ejabberdctl create_room lobby conference.example.org example.org ``` -------------------------------- ### ejabberd.yml Per-Module Database Override Source: https://context7.com/processone/ejabberd/llms.txt Override the default database configuration for specific modules. This example sets `mod_mam` and `mod_roster` to use SQL, while `mod_last` uses Mnesia. ```yaml modules: mod_mam: db_type: sql mod_roster: db_type: sql mod_last: db_type: mnesia # keep last-activity in fast in-memory store ``` -------------------------------- ### Register New User via HTTP API Source: https://context7.com/processone/ejabberd/llms.txt Uses curl to send a POST request with JSON payload to the /api/register endpoint to create a new user. Requires user, host, and password. ```bash curl -s -k -u "$ADMIN" \ -H "Content-Type: application/json" \ -d '{"user": "alice", "host": "example.org", "password": "s3cr3t"}' \ -X POST "$BASE/register" # 0 ``` -------------------------------- ### Backup ejabberd Mnesia Database with ejabberdctl Source: https://context7.com/processone/ejabberd/llms.txt Creates a backup of the ejabberd Mnesia database to a specified file path. ```bash ejabberdctl backup_mnesia /var/backups/ejabberd.backup ``` -------------------------------- ### Ejabberd Module Management Commands Source: https://context7.com/processone/ejabberd/llms.txt Commands to manage custom and community modules within ejabberd. These allow for dynamic loading, unloading, and installation of modules without server restarts. ```bash # Enable the custom module in ejabberd.yml: # modules: # mod_hello_world: {} ``` ```bash # Start/stop a module at runtime without restarting ejabberdctl start_module example.org mod_hello_world ejabberdctl stop_module example.org mod_hello_world ``` ```bash # List all loaded modules for a host ejabberdctl loaded_modules example.org ``` ```bash # Install a community module from the ejabberd-contrib repository ejabberdctl module_install mod_statsdx ejabberdctl module_upgrade mod_statsdx ejabberdctl module_uninstall mod_statsdx ejabberdctl modules_available ejabberdctl modules_installed ``` -------------------------------- ### ejabberdctl Data Migration and Conversion Commands Source: https://context7.com/processone/ejabberd/llms.txt Commands for exporting and importing data using PIEFXIS XML format, converting configuration files between formats, and performing Mnesia-specific operations. ```bash # Migrate data between backends ejabberdctl export_piefxis /tmp/export.xml # export to PIEFXIS XML ejabberdctl import_piefxis /tmp/export.xml # import from PIEFXIS XML ejabberdctl export_piefxis_host /tmp/export.xml example.org # Convert ejabberd config between formats ejabberdctl convert_to_yaml /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberd.yml # Mnesia-specific operations ejabberdctl dump_mnesia /tmp/ejabberd.dump ejabberdctl load_mnesia /tmp/ejabberd.dump ejabberdctl backup_mnesia /var/backups/ejabberd.backup ejabberdctl restore_mnesia /var/backups/ejabberd.backup ejabberdctl install_fallback_mnesia /var/backups/ejabberd.backup ejabberdctl mnesia_info ejabberdctl mnesia_table_info roster ejabberdctl mnesia_change_nodename oldnode@oldhost newnode@newhost \ /tmp/old.backup /tmp/new.backup ``` -------------------------------- ### Start Shell Inside ejabberd Container Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Access a shell environment within the running ejabberd container. This allows for direct interaction with the container's file system and utilities. ```bash docker exec -it ejabberd sh ``` -------------------------------- ### Docker Compose for Ejabberd Clustering Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Use this docker-compose.yml file to set up a two-node ejabberd cluster. The 'main' service initializes the cluster and registers an admin user, while the 'replica' service joins the cluster after the main service is healthy. Ports are exposed on the replica for external access. ```yaml version: '3.7' services: main: image: ghcr.io/processone/ejabberd container_name: main environment: - ERLANG_NODE_ARG=ejabberd@main - ERLANG_COOKIE=dummycookie123 - CTL_ON_CREATE=! register admin localhost asd healthcheck: test: netstat -nl | grep -q 5222 start_period: 5s interval: 5s timeout: 5s retries: 120 replica: image: ghcr.io/processone/ejabberd container_name: replica depends_on: main: condition: service_healthy environment: - ERLANG_NODE_ARG=ejabberd@replica - ERLANG_COOKIE=dummycookie123 - CTL_ON_CREATE=join_cluster ejabberd@main - CTL_ON_START=registered_users localhost ; status ports: - "5222:5222" - "5269:5269" - "5280:5280" - "5443:5443" ``` -------------------------------- ### Run ejabberd Container with Auto-Registration Source: https://github.com/processone/ejabberd/blob/master/CONTAINER.md Use this command to run the ejabberd container and automatically register an admin account. Set `EJABBERD_MACRO_HOST`, `EJABBERD_MACRO_ADMIN`, and `REGISTER_ADMIN_PASSWORD` to configure the account details. ```bash podman run -it \ --env EJABBERD_MACRO_HOST=example.org \ --env EJABBERD_MACRO_ADMIN=juliet@example.org \ --env REGISTER_ADMIN_PASSWORD=somePassw0rd \ ghcr.io/processone/ejabberd ``` -------------------------------- ### Delete Old Messages via ejabberd REST API Source: https://context7.com/processone/ejabberd/llms.txt Example using curl to call the ejabberd REST API for deleting messages older than a specified number of days. ```bash # REST API curl -s -k -u "admin@example.org:pass" \ -H "Content-Type: application/json" \ -d '{"days": 90}' \ -X POST "https://localhost:5443/api/delete_old_messages" ``` -------------------------------- ### List Loaded Modules Source: https://context7.com/processone/ejabberd/llms.txt Lists all modules currently loaded for a specific virtual host. ```APIDOC ## ejabberdctl loaded_modules ### Description Lists all modules currently loaded for a specific virtual host. ### Usage ejabberdctl loaded_modules ### Parameters - **host** (string) - Required - The virtual host to query. ```