fix(synapse): tolerate existing users in matrix-synapse-create-users script
Agent-Logs-Url: https://github.com/naturallaw777/staging_alpha/sessions/f76f46da-0836-4295-8e26-c656acc38e3f Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
90ddd5812e
commit
570a767636
@@ -153,7 +153,7 @@ EOF
|
|||||||
};
|
};
|
||||||
path = [ pkgs.pwgen pkgs.matrix-synapse pkgs.curl pkgs.coreutils pkgs.jq ];
|
path = [ pkgs.pwgen pkgs.matrix-synapse pkgs.curl pkgs.coreutils pkgs.jq ];
|
||||||
script = ''
|
script = ''
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
|
|
||||||
# Wait for Synapse to be fully responsive
|
# Wait for Synapse to be fully responsive
|
||||||
for i in {1..30}; do
|
for i in {1..30}; do
|
||||||
@@ -177,16 +177,26 @@ EOF
|
|||||||
TEST_USER="test"
|
TEST_USER="test"
|
||||||
TEST_PASS=$(pwgen -s 24 1)
|
TEST_PASS=$(pwgen -s 24 1)
|
||||||
|
|
||||||
# Create Admin user
|
ADMIN_CREATED=true
|
||||||
register_new_matrix_user -c /run/matrix-synapse/runtime-config.yaml \
|
TEST_CREATED=true
|
||||||
-u "$ADMIN_USER" -p "$ADMIN_PASS" -a http://localhost:8008
|
|
||||||
|
|
||||||
# Create Test user (non-admin)
|
# Create Admin user (tolerate "already exists")
|
||||||
register_new_matrix_user -c /run/matrix-synapse/runtime-config.yaml \
|
if ! register_new_matrix_user -c /run/matrix-synapse/runtime-config.yaml \
|
||||||
-u "$TEST_USER" -p "$TEST_PASS" --no-admin http://localhost:8008
|
-u "$ADMIN_USER" -p "$ADMIN_PASS" -a http://localhost:8008 2>&1; then
|
||||||
|
echo "Admin user already exists, skipping."
|
||||||
|
ADMIN_CREATED=false
|
||||||
|
fi
|
||||||
|
|
||||||
# Save the credentials
|
# Create Test user (tolerate "already exists")
|
||||||
cat > "$CREDS_FILE" << CREDS
|
if ! register_new_matrix_user -c /run/matrix-synapse/runtime-config.yaml \
|
||||||
|
-u "$TEST_USER" -p "$TEST_PASS" --no-admin http://localhost:8008 2>&1; then
|
||||||
|
echo "Test user already exists, skipping."
|
||||||
|
TEST_CREATED=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write credentials file
|
||||||
|
if [ "$ADMIN_CREATED" = true ] && [ "$TEST_CREATED" = true ]; then
|
||||||
|
cat > "$CREDS_FILE" << CREDS
|
||||||
Matrix (Element) Credentials
|
Matrix (Element) Credentials
|
||||||
════════════════════════════
|
════════════════════════════
|
||||||
Homeserver URL: https://$DOMAIN
|
Homeserver URL: https://$DOMAIN
|
||||||
@@ -199,9 +209,24 @@ Password: $ADMIN_PASS
|
|||||||
Username: @$TEST_USER:$DOMAIN
|
Username: @$TEST_USER:$DOMAIN
|
||||||
Password: $TEST_PASS
|
Password: $TEST_PASS
|
||||||
CREDS
|
CREDS
|
||||||
|
else
|
||||||
|
cat > "$CREDS_FILE" << CREDS
|
||||||
|
Matrix (Element) Credentials
|
||||||
|
════════════════════════════
|
||||||
|
Homeserver URL: https://$DOMAIN
|
||||||
|
|
||||||
|
[ Admin Account ]
|
||||||
|
Username: @$ADMIN_USER:$DOMAIN
|
||||||
|
Password: $(if [ "$ADMIN_CREATED" = true ]; then echo "$ADMIN_PASS"; else echo "(pre-existing — password set during original setup)"; fi)
|
||||||
|
|
||||||
|
[ Test Account ]
|
||||||
|
Username: @$TEST_USER:$DOMAIN
|
||||||
|
Password: $(if [ "$TEST_CREATED" = true ]; then echo "$TEST_PASS"; else echo "(pre-existing — password set during original setup)"; fi)
|
||||||
|
CREDS
|
||||||
|
fi
|
||||||
|
|
||||||
chmod 600 "$CREDS_FILE"
|
chmod 600 "$CREDS_FILE"
|
||||||
echo "Matrix users created successfully."
|
echo "Matrix users setup completed."
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user