various bugfixes during testing
This commit is contained in:
@@ -54,12 +54,6 @@ toggle_block "$OUTPUT_FILE" "# \[CINNY_START\]" "# \[CINNY_END\]" "$INCLUDE_CINN
|
|||||||
toggle_block "$OUTPUT_FILE" "# \[FLUFFYCHAT_START\]" "# \[FLUFFYCHAT_END\]" "$INCLUDE_FLUFFY"
|
toggle_block "$OUTPUT_FILE" "# \[FLUFFYCHAT_START\]" "# \[FLUFFYCHAT_END\]" "$INCLUDE_FLUFFY"
|
||||||
toggle_block "$OUTPUT_FILE" "# \[NGINX_START\]" "# \[NGINX_END\]" "$INCLUDE_NGINX"
|
toggle_block "$OUTPUT_FILE" "# \[NGINX_START\]" "# \[NGINX_END\]" "$INCLUDE_NGINX"
|
||||||
toggle_block "$OUTPUT_FILE" "# \[TRAEFIK_START\]" "# \[TRAEFIK_END\]" "$INCLUDE_TRAEFIK"
|
toggle_block "$OUTPUT_FILE" "# \[TRAEFIK_START\]" "# \[TRAEFIK_END\]" "$INCLUDE_TRAEFIK"
|
||||||
|
toggle_block "$OUTPUT_FILE" "# \[TRAEFIK_LABELS_START\]" "# \[TRAEFIK_LABELS_END\]" "$INCLUDE_TRAEFIK"
|
||||||
# Handle Traefik Labels
|
|
||||||
if [[ "$INCLUDE_TRAEFIK" == "true" ]]; then
|
|
||||||
sed -i "/# \[TRAEFIK_LABELS_START\]/d; /# \[TRAEFIK_LABELS_END\]/d" "$OUTPUT_FILE"
|
|
||||||
else
|
|
||||||
sed -i "/# \[TRAEFIK_LABELS_START\]/,/# \[TRAEFIK_LABELS_END\]/d" "$OUTPUT_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_info "Compose file generated: $OUTPUT_FILE"
|
log_info "Compose file generated: $OUTPUT_FILE"
|
||||||
|
|||||||
+48
-32
@@ -64,8 +64,8 @@ docker run -it --rm --network matrix_network \
|
|||||||
-e SYNAPSE_SERVER_NAME="$HOMESERVER_FQDN" \
|
-e SYNAPSE_SERVER_NAME="$HOMESERVER_FQDN" \
|
||||||
-e SYNAPSE_REPORT_STATS=no \
|
-e SYNAPSE_REPORT_STATS=no \
|
||||||
ghcr.io/element-hq/synapse:latest generate || { log_error "Synapse config generation failed"; exit 1; }
|
ghcr.io/element-hq/synapse:latest generate || { log_error "Synapse config generation failed"; exit 1; }
|
||||||
|
|
||||||
SYNAPSE_CFG="${VOLUME_PATH}/synapse/homeserver.yaml"
|
SYNAPSE_CFG="${VOLUME_PATH}/synapse/homeserver.yaml"
|
||||||
|
fix_ownership "${VOLUME_PATH}/synapse"
|
||||||
yq -y -i '.database.name = "psycopg2"' "$SYNAPSE_CFG"
|
yq -y -i '.database.name = "psycopg2"' "$SYNAPSE_CFG"
|
||||||
yq -y -i ".database.args.user = \"${PG_USER_MATRIX}\"" "$SYNAPSE_CFG"
|
yq -y -i ".database.args.user = \"${PG_USER_MATRIX}\"" "$SYNAPSE_CFG"
|
||||||
yq -y -i ".database.args.password = \"${PG_PASSWORD_MATRIX}\"" "$SYNAPSE_CFG"
|
yq -y -i ".database.args.password = \"${PG_PASSWORD_MATRIX}\"" "$SYNAPSE_CFG"
|
||||||
@@ -76,21 +76,19 @@ yq -y -i ".database.args.sslmode = \"prefer\"" "$SYNAPSE_CFG"
|
|||||||
yq -y -i ".public_baseurl = \"https://${HOMESERVER_FQDN}\"" "$SYNAPSE_CFG"
|
yq -y -i ".public_baseurl = \"https://${HOMESERVER_FQDN}\"" "$SYNAPSE_CFG"
|
||||||
yq -y -i ".server_name = \"${HOMESERVER_FQDN}\"" "$SYNAPSE_CFG"
|
yq -y -i ".server_name = \"${HOMESERVER_FQDN}\"" "$SYNAPSE_CFG"
|
||||||
|
|
||||||
fix_ownership "${VOLUME_PATH}/synapse"
|
|
||||||
|
|
||||||
log_info "Generating MAS configuration..."
|
log_info "Generating MAS configuration..."
|
||||||
docker run -it --rm --network matrix_network \
|
docker run -it --rm --network matrix_network \
|
||||||
-v "${VOLUME_PATH}/mas:/data" \
|
-v "${VOLUME_PATH}/mas:/data" \
|
||||||
ghcr.io/element-hq/matrix-authentication-service:latest config generate \
|
ghcr.io/element-hq/matrix-authentication-service:latest config generate \
|
||||||
| grep -v '^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' > "${VOLUME_PATH}/mas/config.yaml" || { log_error "Mas config generation failed"; exit 1; }
|
| grep -v '^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' > "${VOLUME_PATH}/mas/config.yaml" || { log_error "Mas config generation failed"; exit 1; }
|
||||||
|
|
||||||
MAS_CFG="${VOLUME_PATH}/mas/config.yaml"
|
MAS_CFG="${VOLUME_PATH}/mas/config.json"
|
||||||
if ! yq '.clients' "$MAS_CFG" > /dev/null 2>&1; then
|
if ! yq '.clients' "$MAS_CFG" > /dev/null 2>&1; then
|
||||||
yq -y -i '.clients = []' "$MAS_CFG"
|
yq -i '.clients = []' "$MAS_CFG"
|
||||||
fi
|
fi
|
||||||
yq -y -i ".public_base_url = \"https://${MAS_FQDN}\"" "$MAS_CFG"
|
yq -i ".public_base_url = \"https://${MAS_FQDN}\"" "$MAS_CFG"
|
||||||
yq -y -i ".http.listen = \"0.0.0.0:8000\"" "$MAS_CFG"
|
yq -i ".http.listen = \"0.0.0.0:8000\"" "$MAS_CFG"
|
||||||
yq -y -i ".database.uri = \"postgres://${PG_USER_MAS}:${PG_PASSWORD_MAS}@matrix-db:5432/auth?sslmode=prefer\"" "$MAS_CFG"
|
yq -i ".database.uri = \"postgres://${PG_USER_MAS}:${PG_PASSWORD_MAS}@matrix-db:5432/auth?sslmode=prefer\"" "$MAS_CFG"
|
||||||
|
|
||||||
fix_ownership "${VOLUME_PATH}/mas"
|
fix_ownership "${VOLUME_PATH}/mas"
|
||||||
|
|
||||||
@@ -103,31 +101,39 @@ log_info "Linking Synapse and MAS via OIDC..."
|
|||||||
CLIENT_ID="synapse-client"
|
CLIENT_ID="synapse-client"
|
||||||
CLIENT_SECRET=$(openssl rand -hex 32)
|
CLIENT_SECRET=$(openssl rand -hex 32)
|
||||||
|
|
||||||
TEMP_FILTER=$(mktemp)
|
#TEMP_FILTER=$(mktemp)
|
||||||
trap "rm -f $TEMP_FILTER" EXIT
|
#trap "rm -f $TEMP_FILTER" EXIT
|
||||||
|
|
||||||
cat > "$TEMP_FILTER" <<EOF
|
#cat > "$TEMP_FILTER" <<EOF
|
||||||
clients:
|
#clients:
|
||||||
- client_id: "${CLIENT_ID}"
|
# - client_id: "${CLIENT_ID}"
|
||||||
client_secret: "${CLIENT_SECRET}"
|
# client_secret: "${CLIENT_SECRET}"
|
||||||
redirect_uris:
|
# redirect_uris:
|
||||||
- "https://${HOMESERVER_FQDN}/_synapse/client/oidc/callback"
|
# - "https://${HOMESERVER_FQDN}/_synapse/client/oidc/callback"
|
||||||
grant_types:
|
# grant_types:
|
||||||
- "authorization_code"
|
# - "authorization_code"
|
||||||
- "refresh_token"
|
# - "refresh_token"
|
||||||
response_types:
|
# response_types:
|
||||||
- "code"
|
# - "code"
|
||||||
scopes:
|
# scopes:
|
||||||
- "openid"
|
# - "openid"
|
||||||
- "profile"
|
# - "profile"
|
||||||
- "email"
|
# - "email"
|
||||||
application_type: "web"
|
# application_type: "web"
|
||||||
EOF
|
#EOF
|
||||||
|
|
||||||
EXISTING_CLIENT=$(yq '.clients[] | select(.client_id == "'"${CLIENT_ID}"'")' "$MAS_CFG" 2>/dev/null || echo "")
|
EXISTING_CLIENT=$(yq '.clients[] | select(.client_id == "'"${CLIENT_ID}"'")' "$MAS_CFG" 2>/dev/null || echo "")
|
||||||
|
|
||||||
if [[ -z "$EXISTING_CLIENT" ]]; then
|
if [[ -z "$EXISTING_CLIENT" ]]; then
|
||||||
yq -y -i "$(cat "$TEMP_FILTER")" "$MAS_CFG" || { log_error "Failed to register Synapse client in MAS"; exit 1; }
|
yq -y -i ".clients += [{
|
||||||
|
\"client_id\": \"${CLIENT_ID}\",
|
||||||
|
\"client_secret\": \"${CLIENT_SECRET}\",
|
||||||
|
\"redirect_uris\": [\"https://${HOMESERVER_FQDN}/_synapse/client/oidc/callback\"],
|
||||||
|
\"grant_types\": [\"authorization_code\", \"refresh_token\"],
|
||||||
|
\"response_types\": [\"code\"],
|
||||||
|
\"scopes\": [\"openid\", \"profile\", \"email\"],
|
||||||
|
\"application_type\": \"web\"
|
||||||
|
}]" "$MAS_CFG" || { log_error "Failed to register Synapse client in MAS"; exit 1; }
|
||||||
log_info " -> Registered Synapse as OIDC client in MAS"
|
log_info " -> Registered Synapse as OIDC client in MAS"
|
||||||
else
|
else
|
||||||
log_info " -> Synapse client already registered in MAS, skipping"
|
log_info " -> Synapse client already registered in MAS, skipping"
|
||||||
@@ -137,12 +143,22 @@ ISSUER_URL="https://${MAS_FQDN}"
|
|||||||
|
|
||||||
fix_ownership "$SYNAPSE_CFG"
|
fix_ownership "$SYNAPSE_CFG"
|
||||||
|
|
||||||
cat > "$TEMP_FILTER" <<EOF
|
#cat > "$TEMP_FILTER" <<EOF
|
||||||
.oidc_providers += [{"idp_id": "mas", "idp_name": "Matrix Authentication Service", "idp_brand": "mas", "issuer": "${ISSUER_URL}", "client_id": "${CLIENT_ID}", "client_secret": "${CLIENT_SECRET}", "scopes": ["openid", "profile"], "skip_verification": false}]
|
#.oidc_providers += [{"idp_id": "mas", "idp_name": "Matrix Authentication Service", "idp_brand": "mas", "issuer": "${ISSUER_URL}", "client_id": "${CLIENT_ID}", "client_secret": "${CLIENT_SECRET}", "scopes": ["openid", "profile"], "skip_verification": false}]
|
||||||
EOF
|
#EOF
|
||||||
|
|
||||||
if ! yq '.oidc_providers' "$SYNAPSE_CFG" 2>/dev/null | grep -q "idp_id"; then
|
if ! yq '.oidc_providers' "$SYNAPSE_CFG" 2>/dev/null | grep -q "idp_id"; then
|
||||||
yq -y -i "$(cat "$TEMP_FILTER")" "$SYNAPSE_CFG" || { log_error "Failed to inject OIDC config"; exit 1; }
|
# # yq -y -i "$(cat "$TEMP_FILTER")" "$SYNAPSE_CFG" || { log_error "Failed to inject OIDC config"; exit 1; }
|
||||||
|
yq -y -i ".oidc_providers += [{
|
||||||
|
\"idp_id\": \"mas\",
|
||||||
|
\"idp_name\": \"Matrix Authentication Service\",
|
||||||
|
\"idp_brand\": \"mas\",
|
||||||
|
\"issuer\": \"${ISSUER_URL}\",
|
||||||
|
\"client_id\": \"${CLIENT_ID}\",
|
||||||
|
\"client_secret\": \"${CLIENT_SECRET}\",
|
||||||
|
\"scopes\": [\"openid\", \"profile\"],
|
||||||
|
\"skip_verification\": false
|
||||||
|
}]" "$SYNAPSE_CFG" || { log_error "Failed to inject OIDC config"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${INCLUDE_LIVEKIT:-FALSE}" == "TRUE" ]]; then
|
if [[ "${INCLUDE_LIVEKIT:-FALSE}" == "TRUE" ]]; then
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ toggle_block() {
|
|||||||
|
|
||||||
if [[ "$keep_markers" == "true" ]]; then
|
if [[ "$keep_markers" == "true" ]]; then
|
||||||
# Remove lines containing markers individually
|
# Remove lines containing markers individually
|
||||||
sed -i "/${start_marker}/d; /${end_marker}/d" "$target_file"
|
sed -i "\|${start_marker}|d; \|${end_marker}|d" "$target_file"
|
||||||
else
|
else
|
||||||
# Remove block from start to end
|
# Remove block from start to end
|
||||||
sed -i "/${start_marker},/${end_marker}/d" "$target_file"
|
sed -i "\|${start_marker}|,\|${end_marker}|d" "$target_file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,11 +140,11 @@ log_info "1. Generating Compose File..."
|
|||||||
log_info "2. Initializing Database & Configs..."
|
log_info "2. Initializing Database & Configs..."
|
||||||
"${SCRIPT_DIR}/init/scripts/config_gen.sh"
|
"${SCRIPT_DIR}/init/scripts/config_gen.sh"
|
||||||
|
|
||||||
log_info "3. Linking Services (OIDC)..."
|
#log_info "3. Linking Services (OIDC)..."
|
||||||
"${SCRIPT_DIR}/init/scripts/config_link.sh"
|
#"${SCRIPT_DIR}/init/scripts/config_link.sh"
|
||||||
|
|
||||||
if [[ ${WORKER_INPUT} -gt 1 ]]; then
|
if [[ ${WORKER_INPUT} -gt 1 ]]; then
|
||||||
log_info "4. Generating Workers (${WORKER_INPUT})..."
|
log_info "3. Generating Workers (${WORKER_INPUT})..."
|
||||||
"${SCRIPT_DIR}/init/scripts/worker_gen.sh" -c "$WORKER_INPUT"
|
"${SCRIPT_DIR}/init/scripts/worker_gen.sh" -c "$WORKER_INPUT"
|
||||||
fi
|
fi
|
||||||
log_info "=== Setup Complete ==="
|
log_info "=== Setup Complete ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user