Merge pull request #351 from prasket/matrix-change-user-admin-status

Matrix change user admin status
This commit is contained in:
Slavi Pantaleev
2020-01-23 10:35:28 +02:00
committed by GitHub
5 changed files with 37 additions and 26 deletions

View File

@ -73,13 +73,19 @@
mode: 0750
when: matrix_postgres_enabled|bool
- name: Ensure matrix-make-user-admin script created
- name: Ensure matrix-change-user-admin-status script created
template:
src: "{{ role_path }}/templates/usr-local-bin/matrix-make-user-admin.j2"
dest: "/usr/local/bin/matrix-make-user-admin"
src: "{{ role_path }}/templates/usr-local-bin/matrix-change-user-admin-status.j2"
dest: "/usr/local/bin/matrix-change-user-admin-status"
mode: 0750
when: matrix_postgres_enabled|bool
- name: (Migration) Ensure old matrix-make-user-admin script deleted
file:
path: "/usr/local/bin/matrix-make-user-admin"
state: absent
when: matrix_postgres_enabled|bool
- name: Ensure matrix-postgres-update-user-password-hash script created
template:
src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-update-user-password-hash.j2"
@ -146,6 +152,6 @@
state: absent
with_items:
- matrix-postgres-cli
- matrix-make-user-admin
- matrix-change-user-admin-status
- matrix-postgres-update-user-password-hash
when: "not matrix_postgres_enabled|bool"

View File

@ -0,0 +1,19 @@
#jinja2: lstrip_blocks: "True"
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: "$0" <username> <0/1>"
echo "Usage: 0 = non-admin"
echo "Usage: 1 = admin"
exit 1
fi
docker run \
-it \
--rm \
--user=991:991 \
--cap-drop=ALL \
--env-file=/matrix/postgres/env-postgres-psql \
--network matrix \
postgres:12.1-alpine \
psql -h matrix-postgres -c "UPDATE users set admin=$2 WHERE name like '@$1:{{ matrix_domain }}'"

View File

@ -1,17 +0,0 @@
#jinja2: lstrip_blocks: "True"
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: "$0" <username>"
exit 1
fi
docker run \
-it \
--rm \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--env-file={{ matrix_postgres_base_path }}/env-postgres-psql \
--network {{ matrix_docker_network }} \
{{ matrix_postgres_docker_image_to_use }} \
psql -h {{ matrix_postgres_connection_hostname }} -c "UPDATE users set admin=1 WHERE name like '@$1:{{ matrix_domain }}'"