Updated service configurations, added new services, removed deprecated ones, and improved gitignore patterns for better repository hygiene. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
122 lines
3.9 KiB
Bash
Executable file
122 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Script to create default auto-join rooms for Matrix
|
|
# Usage: ./create-default-rooms.sh <admin_username> <admin_password>
|
|
|
|
HOMESERVER="https://matrix.fig.systems"
|
|
USERNAME="${1}"
|
|
PASSWORD="${2}"
|
|
|
|
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
|
|
echo "Usage: $0 <admin_username> <admin_password>"
|
|
exit 1
|
|
fi
|
|
|
|
echo "🔐 Logging in as $USERNAME..."
|
|
# Get access token
|
|
LOGIN_RESPONSE=$(curl -s -X POST "${HOMESERVER}/_matrix/client/v3/login" \
|
|
-H 'Content-Type: application/json' \
|
|
-d "{
|
|
\"type\": \"m.login.password\",
|
|
\"identifier\": {
|
|
\"type\": \"m.id.user\",
|
|
\"user\": \"${USERNAME}\"
|
|
},
|
|
\"password\": \"${PASSWORD}\"
|
|
}")
|
|
|
|
ACCESS_TOKEN=$(echo "$LOGIN_RESPONSE" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
|
|
|
|
if [ -z "$ACCESS_TOKEN" ]; then
|
|
echo "❌ Login failed!"
|
|
echo "$LOGIN_RESPONSE" | jq . 2>/dev/null || echo "$LOGIN_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Login successful!"
|
|
echo ""
|
|
|
|
# Function to create a room
|
|
create_room() {
|
|
local ROOM_NAME=$1
|
|
local ROOM_ALIAS=$2
|
|
local ROOM_TOPIC=$3
|
|
local PRESET=$4 # public_chat or private_chat
|
|
|
|
echo "🏠 Creating room: $ROOM_NAME (#${ROOM_ALIAS}:fig.systems)"
|
|
|
|
ROOM_DATA="{
|
|
\"name\": \"${ROOM_NAME}\",
|
|
\"room_alias_name\": \"${ROOM_ALIAS}\",
|
|
\"topic\": \"${ROOM_TOPIC}\",
|
|
\"preset\": \"${PRESET}\",
|
|
\"visibility\": \"public\",
|
|
\"initial_state\": [
|
|
{
|
|
\"type\": \"m.room.history_visibility\",
|
|
\"content\": {
|
|
\"history_visibility\": \"shared\"
|
|
}
|
|
},
|
|
{
|
|
\"type\": \"m.room.guest_access\",
|
|
\"content\": {
|
|
\"guest_access\": \"can_join\"
|
|
}
|
|
}
|
|
],
|
|
\"power_level_content_override\": {
|
|
\"events_default\": 0,
|
|
\"invite\": 0,
|
|
\"state_default\": 50,
|
|
\"users_default\": 0,
|
|
\"redact\": 50,
|
|
\"kick\": 50,
|
|
\"ban\": 50
|
|
}
|
|
}"
|
|
|
|
RESPONSE=$(curl -s -X POST "${HOMESERVER}/_matrix/client/v3/createRoom" \
|
|
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
|
|
-H 'Content-Type: application/json' \
|
|
-d "$ROOM_DATA")
|
|
|
|
ROOM_ID=$(echo "$RESPONSE" | grep -o '"room_id":"[^"]*' | cut -d'"' -f4)
|
|
|
|
if [ -n "$ROOM_ID" ]; then
|
|
echo " ✅ Created: $ROOM_ID"
|
|
|
|
# Set room to be in directory
|
|
echo " 📋 Adding to room directory..."
|
|
curl -s -X PUT "${HOMESERVER}/_matrix/client/v3/directory/list/room/${ROOM_ID}" \
|
|
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"visibility": "public"}' > /dev/null
|
|
echo " ✅ Added to public room directory"
|
|
else
|
|
echo " ⚠️ Error or room already exists"
|
|
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "Creating default auto-join rooms..."
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
|
|
# Create the default rooms
|
|
create_room "General" "general" "General discussion and community hangout" "public_chat"
|
|
create_room "Announcements" "announcements" "Important server announcements and updates" "public_chat"
|
|
create_room "Support" "support" "Get help and ask questions" "public_chat"
|
|
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "✅ Default rooms created!"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo "These rooms will be automatically joined by new users:"
|
|
echo " • #general:fig.systems"
|
|
echo " • #announcements:fig.systems"
|
|
echo " • #support:fig.systems"
|
|
echo ""
|
|
echo "All rooms are also published in the room directory!"
|