Skip to content

Instantly share code, notes, and snippets.

@horazont
Last active January 12, 2022 15:33
Show Gist options
  • Save horazont/1e80c64315dc67dc091ad037914cafd1 to your computer and use it in GitHub Desktop.
Save horazont/1e80c64315dc67dc091ad037914cafd1 to your computer and use it in GitHub Desktop.
Handy shell commands for Snikket

DANGER

Using any of this may void your warranty!

# If you want to invite the user into a circle, you first need to
# get the circle's internal ID. You can find it by navigating to the
# circle's page in the web portal and taking the ID from the URL.
#
# A circle's page URL looks like this:
#
# https://snikket-test.jssfr-testspace.dedyn.io/admin/circle/XyZ23
#
# The XyZ23 is the the ID (which is usually longer).
#
# If you use snikket-selfhosted, you can now simply run (replace
# the ID accordingly):
./scripts/new-invite.sh --role prosody:restricted --group XyZ23
# If you do not use snikket-selfhosted, enter your snikket directory
# on the server (where your docker-compose.yml is) and run (insert
# the ID and replace snikket.example with your snikket domain):
docker-compose run -it snikket prosodyctl mod_invites generate snikket.example --role prosody:restricted --group XyZ23
# If something went wrong, you can try this.
# Don't try this often... There are rate limits.
docker-compose exec snikket_certs su letsencrypt -- -c "certbot renew --config-dir /snikket/letsencrypt --cert-path /etc/ssl/certbot --force-renew
# This grants a user ownership of the chat room associated with a circle.
# This allows them to set the avatar and do other fun things such as removing users (although you definitely should do that via the web interface instead to avoid issues).
# MUCJID: The room address as shown on the circles web admin page
# USER@DOMAIN: your full snikket address (or the address of the user you want to make owner… can also be from another service if you dare :))
docker exec -it snikket prosodyctl shell 'muc:room("MUCJID"):set_affiliation(true, "USER@DOMAIN", "owner");'
# Caveats: Circle operations may remove ownership again.
# This command removes a user from all circles.
# DO NOT RUN THIS FOR USERS WHICH HAVE not BEEN DELETED FROM THE SERVER YET!
# replace:
# DOMAIN with your snikket domain (e.g. chat.domain.example)
# USER with the name of the user you want to remove
docker exec -it snikket prosodyctl shell '>local mod_groups=hosts["DOMAIN"].modules["groups_internal"]; for group in mod_groups:groups() do mod_groups.remove_member(group, "USER"); end'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment