From 5eb3bc98f75ca4b0e2012b3261fffb5e56846595 Mon Sep 17 00:00:00 2001 From: FrankLi123 Date: Wed, 9 Oct 2024 01:27:47 +0800 Subject: [PATCH 1/3] feat: add a fundamental shell script for the creation of mastodon instances --- config.yaml | 445 +++++++++++++++++++++++++++++++++++++++++++++ deploy_mastodon.sh | 250 +++++++++++++++++++++++++ 2 files changed, 695 insertions(+) create mode 100644 config.yaml create mode 100755 deploy_mastodon.sh diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..70fe239 --- /dev/null +++ b/config.yaml @@ -0,0 +1,445 @@ +environment: production +type: beta + +discovery: + operator: + evm_address: 0x8725eb313134e592cd573b82887423ff24c9f23b + signature: + server: + endpoint: + global_indexer_endpoint: https://gi.rss3.io/ + access_token: test + +database: + driver: postgres + partition: true + uri: postgres://postgres:password@localhost:5432/postgres + +stream: + enable: false + driver: kafka + topic: rss3.node.activities + uri: localhost:9092 + +redis: + endpoints: + - localhost:6379 + username: + password: + disable_cache: true + tls: + enabled: false + ca_file: /path/to/ca.crt + cert_file: /path/to/client.crt + key_file: /path/to/client.key + insecure_skip_verify: false + +observability: + opentelemetry: + metrics: + enable: true + endpoint: 0.0.0.0:9090 + traces: + enable: true + insecure: true + endpoint: localhost:4318 + +endpoints: + mastodon: + url: 34.16.147.19:9092 + farcaster: + url: https://farcaster.mainnet.rss3.io + ethereum: + url: https://ethereum.blockpi.network/v1/rpc/4926ff8018353b261139b1ec6ea7b7ec5cc5d692 + polygon: + url: https://rpc.ankr.com/polygon + avax: + url: https://rpc.ankr.com/avalanche + optimism: + url: https://rpc.ankr.com/optimism + arbitrum: + url: https://rpc.ankr.com/arbitrum + gnosis: + url: https://rpc.ankr.com/gnosis + linea: + url: https://rpc.linea.build + savm: + url: https://alpha-rpc-node-http.svmscan.io + binance-smart-chain: + url: https://rpc.ankr.com/bsc + base: + url: https://rpc.ankr.com/base + http2_disabled: true + crossbell: + url: https://rpc.crossbell.io + vsl: + url: https://rpc.rss3.io + arweave: + url: https://arweave.net +component: +# rss: +# network: rss +# endpoint: https://rsshub.app/ +# worker: rsshub +# parameters: +# authentication: +# access_key: + federated: + - id: mastodon-core + network: mastodon + worker: mastodon + endpoint: mastodon + parameters: + kafka_topic: activitypub_events + decentralized: + - id: ethereum-core + network: ethereum + worker: core + endpoint: ethereum + parameters: + block_start: +# - id: ethereum-uniswap +# network: ethereum +# worker: uniswap +# endpoint: ethereum +# parameters: +# block_start: 19977617 +# - id: ethereum-rss3 +# network: ethereum +# worker: rss3 +# endpoint: ethereum +# parameters: +# block_start: +# block_target: +# - id: polygon-lens +# network: polygon +# worker: lens +# endpoint: polygon +# ipfs_gate logways: +# parameters: +# block_start: +# - id: ethereum-opensea +# network: ethereum +# worker: opensea +# endpoint: ethereum +# parameters: +# block_start: +# - id: ethereum-optimism +# network: ethereum +# worker: optimism +# endpoint: ethereum +# parameters: +# block_start: +# - id: polygon-aavegotchi +# network: polygon +# worker: aavegotchi +# endpoint: polygon +# parameters: +# block_start: 48300005 +# - id: ethereum-highlight +# network: ethereum +# worker: highlight +# endpoint: ethereum +# parameters: +# block_start: +# - id: arbitrum-highlight +# network: arbitrum +# worker: highlight +# endpoint: arbitrum +# parameters: +# block_start: +# - id: polygon-highlight +# network: polygon +# worker: highlight +# endpoint: polygon +# parameters: +# block_start: +# - id: optimism-highlight +# network: optimism +# worker: highlight +# endpoint: optimism +# parameters: +# block_start: +# - id: crossbell-crossbell +# network: crossbell +# worker: crossbell +# endpoint: https://rpc.crossbell.io +# parameters: +# block_start: +# # farcaster +# - id: farcaster-core +# network: farcaster +# worker: core +# endpoint: farcaster +# parameters: +# api_key: +# # arweave +# - id: arweave-mirror +# network: arweave +# endpoint: arweave +# worker: mirror +# ipfs_gateways: +# parameters: +# block_start: +# concurrent_block_requests: +# - id: arweave-paragraph +# network: arweave +# endpoint: arweave +# worker: paragraph +# ipfs_gateways: +# parameters: +# block_start: +# concurrent_block_requests: +# - id: ethereum-looksrare +# network: ethereum +# worker: looksrare +# endpoint: ethereum +# parameters: +# block_start: +# - id: optimism-matters +# network: optimism +# worker: matters +# endpoint: optimism +# parameters: +# block_start: +# - id: arweave-momoka +# network: arweave +# worker: momoka +# endpoint: polygon +# parameters: +# block_start: +# concurrent_block_requests: +# - id: ethereum-aave +# network: ethereum +# endpoint: ethereum +# worker: aave +# parameters: +# block_start: +# - id: polygon-aave +# network: polygon +# endpoint: polygon +# worker: aave +# parameters: +# block_start: +# - id: avax-aave +# network: avax +# endpoint: avax +# worker: aave +# parameters: +# block_start: +# - id: base-aave +# network: base +# endpoint: base +# worker: aave +# parameters: +# block_start: +# - id: optimism-aave +# network: optimism +# endpoint: optimism +# worker: aave +# parameters: +# block_start: +# - id: arbitrum-aave +# network: arbitrum +# endpoint: arbitrum +# worker: aave +# parameters: +# block_start: +# - id: polygon-iqwiki +# network: polygon +# worker: iqwiki +# endpoint: polygon +# parameters: +# block_start: +# - id: ethereum-lido +# network: ethereum +# endpoint: ethereum +# worker: lido +# parameters: +# block_start: +# - id: ethereum-ens +# network: ethereum +# endpoint: ethereum +# worker: ens +# parameters: +# block_start: +# - id: ethereum-1inch +# network: ethereum +# worker: 1inch +# endpoint: ethereum +# parameters: +# block_start: +# - id: vsl-core +# network: vsl +# endpoint: vsl +# worker: core +# parameters: +# block_start: +# - id: optimism-kiwistand +# network: optimism +# endpoint: optimism +# worker: kiwistand +# parameters: +# block_start: +# - id: savm-core +# network: savm +# endpoint: savm +# worker: core +# parameters: +# block_start: +# - id: savm-uniswap +# network: savm +# endpoint: savm +# worker: uniswap +# parameters: +# block_start: +# - id: savm-savm +# network: savm +# endpoint: savm +# worker: savm +# parameters: +# block_start: +# - id: optimism-core +# network: optimism +# endpoint: optimism +# worker: core +# parameters: +# block_start: +# - id: polygon-core +# network: polygon +# endpoint: polygon +# worker: core +# parameters: +# block_start: +# - id: arbitrum-core +# network: arbitrum +# endpoint: arbitrum +# worker: core +# parameters: +# block_start: +# - id: base-core +# network: base +# endpoint: base +# worker: core +# parameters: +# block_start: +# - id: binance-smart-chain-core +# network: binance-smart-chain +# endpoint: binance-smart-chain +# worker: core +# parameters: +# block_start: 34436412 +# concurrent_block_requests: 1 +# - id: gnosis-core +# network: gnosis +# endpoint: gnosis +# worker: core +# parameters: +# block_start: +# - id: linea-core +# network: linea +# endpoint: linea +# worker: core +# parameters: +# block_start: +# - id: linea-uniswap +# network: linea +# endpoint: linea +# worker: uniswap +# parameters: +# block_start: +# - id: vsl-rss3 +# network: vsl +# endpoint: vsl +# worker: rss3 +# - id: ethereum-vsl +# network: ethereum +# worker: vsl +# endpoint: ethereum +# parameters: +# block_start: +# - id: ethereum-stargate +# network: ethereum +# worker: stargate +# endpoint: ethereum +# parameters: +# block_start: +# - id: arbitrum-stargate +# network: arbitrum +# worker: stargate +# endpoint: arbitrum +# parameters: +# block_start: +# - id: linea-stargate +# network: linea +# endpoint: linea +# worker: stargate +# parameters: +# block_start: +# - id: binance-smart-chain-stargate +# network: binance-smart-chain +# endpoint: binance-smart-chain +# worker: stargate +# parameters: +# block_start: +# - id: base-stargate +# network: base +# endpoint: base +# worker: stargate +# parameters: +# block_start: +# - id: optimism-stargate +# network: optimism +# endpoint: optimism +# worker: stargate +# parameters: +# block_start: +# - id: polygon-stargate +# network: polygon +# worker: stargate +# endpoint: polygon +# parameters: +# block_start: +# - id: avax-stargate +# network: avax +# endpoint: avax +# worker: stargate +# parameters: +# block_start: +# - id: ethereum-curve +# network: ethereum +# worker: curve +# endpoint: ethereum +# parameters: +# block_start: +# - id: arbitrum-curve +# network: arbitrum +# worker: curve +# endpoint: arbitrum +# parameters: +# block_start: +# - id: avax-curve +# network: avax +# endpoint: avax +# worker: curve +# parameters: +# block_start: +# - id: gnosis-curve +# network: gnosis +# endpoint: gnosis +# worker: curve +# parameters: +# block_start: +# - id: optimism-curve +# network: optimism +# worker: curve +# endpoint: optimism +# parameters: +# block_start: +# - id: polygon-curve +# network: polygon +# worker: curve +# endpoint: polygon +# parameters: +# block_start: +# \ No newline at end of file diff --git a/deploy_mastodon.sh b/deploy_mastodon.sh new file mode 100755 index 0000000..235e5aa --- /dev/null +++ b/deploy_mastodon.sh @@ -0,0 +1,250 @@ +#!/bin/bash + +# Mastodon Deployment Script +SCRIPT_VERSION="v0.2.0" +MASTODON_VERSION="v4.2.10" + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Check for required tools +for cmd in docker docker-compose curl certbot; do + if ! command_exists $cmd; then + echo "❌ $cmd is not installed. Please install it and run this script again." + exit 1 + fi +done + +# Function to generate a random string +generate_random_string() { + openssl rand -base64 32 | tr -d /=+ | cut -c -"$1" +} + +# Function to check DNS propagation +check_dns() { + local domain="$1" + local ip="$2" + local dns_ip=$(dig +short $domain) + + if [ "$dns_ip" = "$ip" ]; then + return 0 + else + return 1 + fi +} + +# Main script starts here +echo "🚀 Welcome to the Mastodon Deployment Script $SCRIPT_VERSION" +echo "This script will guide you through setting up a Mastodon instance." + +# Gather necessary information +read -p "Enter your domain name (e.g., mastodon.example.com): " DOMAIN_NAME +read -p "Enter your server's public IP address: " IP_ADDRESS + +# Check DNS setup +echo "Checking DNS setup..." +if check_dns "$DOMAIN_NAME" "$IP_ADDRESS"; then + echo "✅ DNS is correctly set up." +else + echo "❌ DNS is not set up correctly. Please ensure your domain points to your server's IP address." + echo "You can check DNS propagation at https://www.whatsmydns.net/#A/$DOMAIN_NAME" + read -p "Have you set up the DNS correctly now? (yes/no): " dns_setup + if [[ $dns_setup != "yes" ]]; then + echo "Please set up DNS and run this script again." + exit 1 + fi +fi + +# Set up SSL/TLS +echo "Setting up SSL/TLS certificate..." +sudo certbot certonly --standalone -d $DOMAIN_NAME + +if [ $? -ne 0 ]; then + echo "❌ Failed to obtain SSL/TLS certificate. Please ensure your domain is correctly set up and try again." + exit 1 +fi + +# Generate random passwords +DB_PASSWORD=$(generate_random_string 32) +REDIS_PASSWORD=$(generate_random_string 32) + +# Create .env.production file +cat << EOF > .env.production +# Federation +LOCAL_DOMAIN=$DOMAIN_NAME +SINGLE_USER_MODE=false +ENABLE_REGISTRATIONS=true + +# Redis +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_PASSWORD=$REDIS_PASSWORD + +# PostgreSQL +DB_HOST=db +DB_PORT=5432 +DB_NAME=mastodon +DB_USER=mastodon +DB_PASS=$DB_PASSWORD + +# Secrets (generated automatically) +SECRET_KEY_BASE=$(generate_random_string 128) +OTP_SECRET=$(generate_random_string 128) + +# VAPID keys (generated automatically) +VAPID_PRIVATE_KEY=$(openssl ecparam -name prime256v1 -genkey -noout -out /dev/null 2>&1 | openssl ec -in /dev/stdin -outform DER 2>/dev/null | tail -c +8 | head -c 32 | base64) +VAPID_PUBLIC_KEY=$(echo -n "$VAPID_PRIVATE_KEY" | openssl ec -in /dev/stdin -inform DER -pubout -outform DER 2>/dev/null | tail -c 65 | base64) + +# Sending mail (update with your SMTP details) +SMTP_SERVER=smtp.example.com +SMTP_PORT=587 +SMTP_LOGIN=your_smtp_login +SMTP_PASSWORD=your_smtp_password +SMTP_FROM_ADDRESS=mastodon@$DOMAIN_NAME + +# File storage (local) +PAPERCLIP_ROOT_PATH=/opt/mastodon/public/system +EOF + +# Create docker-compose.yml file +cat << EOF > docker-compose.yml +version: '3' +services: + db: + image: postgres:14-alpine + restart: always + environment: + - POSTGRES_USER=mastodon + - POSTGRES_DB=mastodon + - POSTGRES_PASSWORD=$DB_PASSWORD + volumes: + - ./postgres:/var/lib/postgresql/data + + redis: + image: redis:7-alpine + restart: always + command: redis-server --requirepass $REDIS_PASSWORD + volumes: + - ./redis:/data + + web: + image: tootsuite/mastodon:$MASTODON_VERSION + restart: always + env_file: .env.production + command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" + ports: + - "127.0.0.1:3000:3000" + depends_on: + - db + - redis + volumes: + - ./public/system:/mastodon/public/system + + streaming: + image: tootsuite/mastodon:$MASTODON_VERSION + restart: always + env_file: .env.production + command: node ./streaming + ports: + - "127.0.0.1:4000:4000" + depends_on: + - db + - redis + + sidekiq: + image: tootsuite/mastodon:$MASTODON_VERSION + restart: always + env_file: .env.production + command: bundle exec sidekiq + depends_on: + - db + - redis + volumes: + - ./public/system:/mastodon/public/system +EOF + +# Set up Nginx +echo "Setting up Nginx..." +sudo tee /etc/nginx/sites-available/mastodon << EOF +server { + listen 80; + listen [::]:80; + server_name $DOMAIN_NAME; + return 301 https://\$server_name\$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name $DOMAIN_NAME; + + ssl_certificate /etc/letsencrypt/live/$DOMAIN_NAME/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/$DOMAIN_NAME/privkey.pem; + + root /opt/mastodon/public; + + location / { + try_files \$uri @proxy; + } + + location @proxy { + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + proxy_pass_header Server; + + proxy_pass http://127.0.0.1:3000; + proxy_buffering off; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /api/v1/streaming { + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + + proxy_pass http://127.0.0.1:4000; + proxy_buffering off; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /system { + add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Strict-Transport-Security "max-age=31536000"; + } + + error_page 500 501 502 503 504 /500.html; +} +EOF + +sudo ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/ +sudo nginx -t && sudo systemctl reload nginx + +# Start Docker containers +echo "Starting Docker containers..." +docker-compose up -d + +# Create first admin user +echo "Creating first admin user..." +docker-compose run --rm web bash -c "RAILS_ENV=production bundle exec rails mastodon:make_admin USERNAME=admin EMAIL=admin@$DOMAIN_NAME" + +# Final messages +echo "✅ Mastodon deployment completed successfully!" +echo "🌐 Your Mastodon instance is now available at https://$DOMAIN_NAME" +echo "👤 An admin user has been created with the following credentials:" +echo " Username: admin" +echo " Email: admin@$DOMAIN_NAME" +echo "⚠️ Please log in and change the admin password immediately!" +echo "📚 For more information on managing your Mastodon instance, visit: https://docs.joinmastodon.org/" \ No newline at end of file From c42bd1c8187691a2f3cd1b9daecabee2ee5eedd2 Mon Sep 17 00:00:00 2001 From: FrankLi123 Date: Thu, 10 Oct 2024 18:26:45 +0800 Subject: [PATCH 2/3] feat:generate federated worker containers --- pkg/cmd/cmd.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 1da37c2..f3488f9 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -52,6 +52,7 @@ Then, with a single command, you create and start all the services from your con composeFile := compose.NewCompose( compose.WithWorkers(cfg.Component.Decentralized), + compose.WithWorkers(cfg.Component.Federated), compose.SetDependsOnAlloyDB(), compose.SetNodeVersion(version), compose.SetNodeVolume(), From 2c17af3db2289b6e8623629825b7536d411b2e61 Mon Sep 17 00:00:00 2001 From: FrankLi123 Date: Thu, 10 Oct 2024 18:31:39 +0800 Subject: [PATCH 3/3] fix: remove unused files --- config.yaml | 445 --------------------------------------------- deploy_mastodon.sh | 250 ------------------------- 2 files changed, 695 deletions(-) delete mode 100644 config.yaml delete mode 100755 deploy_mastodon.sh diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 70fe239..0000000 --- a/config.yaml +++ /dev/null @@ -1,445 +0,0 @@ -environment: production -type: beta - -discovery: - operator: - evm_address: 0x8725eb313134e592cd573b82887423ff24c9f23b - signature: - server: - endpoint: - global_indexer_endpoint: https://gi.rss3.io/ - access_token: test - -database: - driver: postgres - partition: true - uri: postgres://postgres:password@localhost:5432/postgres - -stream: - enable: false - driver: kafka - topic: rss3.node.activities - uri: localhost:9092 - -redis: - endpoints: - - localhost:6379 - username: - password: - disable_cache: true - tls: - enabled: false - ca_file: /path/to/ca.crt - cert_file: /path/to/client.crt - key_file: /path/to/client.key - insecure_skip_verify: false - -observability: - opentelemetry: - metrics: - enable: true - endpoint: 0.0.0.0:9090 - traces: - enable: true - insecure: true - endpoint: localhost:4318 - -endpoints: - mastodon: - url: 34.16.147.19:9092 - farcaster: - url: https://farcaster.mainnet.rss3.io - ethereum: - url: https://ethereum.blockpi.network/v1/rpc/4926ff8018353b261139b1ec6ea7b7ec5cc5d692 - polygon: - url: https://rpc.ankr.com/polygon - avax: - url: https://rpc.ankr.com/avalanche - optimism: - url: https://rpc.ankr.com/optimism - arbitrum: - url: https://rpc.ankr.com/arbitrum - gnosis: - url: https://rpc.ankr.com/gnosis - linea: - url: https://rpc.linea.build - savm: - url: https://alpha-rpc-node-http.svmscan.io - binance-smart-chain: - url: https://rpc.ankr.com/bsc - base: - url: https://rpc.ankr.com/base - http2_disabled: true - crossbell: - url: https://rpc.crossbell.io - vsl: - url: https://rpc.rss3.io - arweave: - url: https://arweave.net -component: -# rss: -# network: rss -# endpoint: https://rsshub.app/ -# worker: rsshub -# parameters: -# authentication: -# access_key: - federated: - - id: mastodon-core - network: mastodon - worker: mastodon - endpoint: mastodon - parameters: - kafka_topic: activitypub_events - decentralized: - - id: ethereum-core - network: ethereum - worker: core - endpoint: ethereum - parameters: - block_start: -# - id: ethereum-uniswap -# network: ethereum -# worker: uniswap -# endpoint: ethereum -# parameters: -# block_start: 19977617 -# - id: ethereum-rss3 -# network: ethereum -# worker: rss3 -# endpoint: ethereum -# parameters: -# block_start: -# block_target: -# - id: polygon-lens -# network: polygon -# worker: lens -# endpoint: polygon -# ipfs_gate logways: -# parameters: -# block_start: -# - id: ethereum-opensea -# network: ethereum -# worker: opensea -# endpoint: ethereum -# parameters: -# block_start: -# - id: ethereum-optimism -# network: ethereum -# worker: optimism -# endpoint: ethereum -# parameters: -# block_start: -# - id: polygon-aavegotchi -# network: polygon -# worker: aavegotchi -# endpoint: polygon -# parameters: -# block_start: 48300005 -# - id: ethereum-highlight -# network: ethereum -# worker: highlight -# endpoint: ethereum -# parameters: -# block_start: -# - id: arbitrum-highlight -# network: arbitrum -# worker: highlight -# endpoint: arbitrum -# parameters: -# block_start: -# - id: polygon-highlight -# network: polygon -# worker: highlight -# endpoint: polygon -# parameters: -# block_start: -# - id: optimism-highlight -# network: optimism -# worker: highlight -# endpoint: optimism -# parameters: -# block_start: -# - id: crossbell-crossbell -# network: crossbell -# worker: crossbell -# endpoint: https://rpc.crossbell.io -# parameters: -# block_start: -# # farcaster -# - id: farcaster-core -# network: farcaster -# worker: core -# endpoint: farcaster -# parameters: -# api_key: -# # arweave -# - id: arweave-mirror -# network: arweave -# endpoint: arweave -# worker: mirror -# ipfs_gateways: -# parameters: -# block_start: -# concurrent_block_requests: -# - id: arweave-paragraph -# network: arweave -# endpoint: arweave -# worker: paragraph -# ipfs_gateways: -# parameters: -# block_start: -# concurrent_block_requests: -# - id: ethereum-looksrare -# network: ethereum -# worker: looksrare -# endpoint: ethereum -# parameters: -# block_start: -# - id: optimism-matters -# network: optimism -# worker: matters -# endpoint: optimism -# parameters: -# block_start: -# - id: arweave-momoka -# network: arweave -# worker: momoka -# endpoint: polygon -# parameters: -# block_start: -# concurrent_block_requests: -# - id: ethereum-aave -# network: ethereum -# endpoint: ethereum -# worker: aave -# parameters: -# block_start: -# - id: polygon-aave -# network: polygon -# endpoint: polygon -# worker: aave -# parameters: -# block_start: -# - id: avax-aave -# network: avax -# endpoint: avax -# worker: aave -# parameters: -# block_start: -# - id: base-aave -# network: base -# endpoint: base -# worker: aave -# parameters: -# block_start: -# - id: optimism-aave -# network: optimism -# endpoint: optimism -# worker: aave -# parameters: -# block_start: -# - id: arbitrum-aave -# network: arbitrum -# endpoint: arbitrum -# worker: aave -# parameters: -# block_start: -# - id: polygon-iqwiki -# network: polygon -# worker: iqwiki -# endpoint: polygon -# parameters: -# block_start: -# - id: ethereum-lido -# network: ethereum -# endpoint: ethereum -# worker: lido -# parameters: -# block_start: -# - id: ethereum-ens -# network: ethereum -# endpoint: ethereum -# worker: ens -# parameters: -# block_start: -# - id: ethereum-1inch -# network: ethereum -# worker: 1inch -# endpoint: ethereum -# parameters: -# block_start: -# - id: vsl-core -# network: vsl -# endpoint: vsl -# worker: core -# parameters: -# block_start: -# - id: optimism-kiwistand -# network: optimism -# endpoint: optimism -# worker: kiwistand -# parameters: -# block_start: -# - id: savm-core -# network: savm -# endpoint: savm -# worker: core -# parameters: -# block_start: -# - id: savm-uniswap -# network: savm -# endpoint: savm -# worker: uniswap -# parameters: -# block_start: -# - id: savm-savm -# network: savm -# endpoint: savm -# worker: savm -# parameters: -# block_start: -# - id: optimism-core -# network: optimism -# endpoint: optimism -# worker: core -# parameters: -# block_start: -# - id: polygon-core -# network: polygon -# endpoint: polygon -# worker: core -# parameters: -# block_start: -# - id: arbitrum-core -# network: arbitrum -# endpoint: arbitrum -# worker: core -# parameters: -# block_start: -# - id: base-core -# network: base -# endpoint: base -# worker: core -# parameters: -# block_start: -# - id: binance-smart-chain-core -# network: binance-smart-chain -# endpoint: binance-smart-chain -# worker: core -# parameters: -# block_start: 34436412 -# concurrent_block_requests: 1 -# - id: gnosis-core -# network: gnosis -# endpoint: gnosis -# worker: core -# parameters: -# block_start: -# - id: linea-core -# network: linea -# endpoint: linea -# worker: core -# parameters: -# block_start: -# - id: linea-uniswap -# network: linea -# endpoint: linea -# worker: uniswap -# parameters: -# block_start: -# - id: vsl-rss3 -# network: vsl -# endpoint: vsl -# worker: rss3 -# - id: ethereum-vsl -# network: ethereum -# worker: vsl -# endpoint: ethereum -# parameters: -# block_start: -# - id: ethereum-stargate -# network: ethereum -# worker: stargate -# endpoint: ethereum -# parameters: -# block_start: -# - id: arbitrum-stargate -# network: arbitrum -# worker: stargate -# endpoint: arbitrum -# parameters: -# block_start: -# - id: linea-stargate -# network: linea -# endpoint: linea -# worker: stargate -# parameters: -# block_start: -# - id: binance-smart-chain-stargate -# network: binance-smart-chain -# endpoint: binance-smart-chain -# worker: stargate -# parameters: -# block_start: -# - id: base-stargate -# network: base -# endpoint: base -# worker: stargate -# parameters: -# block_start: -# - id: optimism-stargate -# network: optimism -# endpoint: optimism -# worker: stargate -# parameters: -# block_start: -# - id: polygon-stargate -# network: polygon -# worker: stargate -# endpoint: polygon -# parameters: -# block_start: -# - id: avax-stargate -# network: avax -# endpoint: avax -# worker: stargate -# parameters: -# block_start: -# - id: ethereum-curve -# network: ethereum -# worker: curve -# endpoint: ethereum -# parameters: -# block_start: -# - id: arbitrum-curve -# network: arbitrum -# worker: curve -# endpoint: arbitrum -# parameters: -# block_start: -# - id: avax-curve -# network: avax -# endpoint: avax -# worker: curve -# parameters: -# block_start: -# - id: gnosis-curve -# network: gnosis -# endpoint: gnosis -# worker: curve -# parameters: -# block_start: -# - id: optimism-curve -# network: optimism -# worker: curve -# endpoint: optimism -# parameters: -# block_start: -# - id: polygon-curve -# network: polygon -# worker: curve -# endpoint: polygon -# parameters: -# block_start: -# \ No newline at end of file diff --git a/deploy_mastodon.sh b/deploy_mastodon.sh deleted file mode 100755 index 235e5aa..0000000 --- a/deploy_mastodon.sh +++ /dev/null @@ -1,250 +0,0 @@ -#!/bin/bash - -# Mastodon Deployment Script -SCRIPT_VERSION="v0.2.0" -MASTODON_VERSION="v4.2.10" - -# Function to check if a command exists -command_exists() { - command -v "$1" >/dev/null 2>&1 -} - -# Check for required tools -for cmd in docker docker-compose curl certbot; do - if ! command_exists $cmd; then - echo "❌ $cmd is not installed. Please install it and run this script again." - exit 1 - fi -done - -# Function to generate a random string -generate_random_string() { - openssl rand -base64 32 | tr -d /=+ | cut -c -"$1" -} - -# Function to check DNS propagation -check_dns() { - local domain="$1" - local ip="$2" - local dns_ip=$(dig +short $domain) - - if [ "$dns_ip" = "$ip" ]; then - return 0 - else - return 1 - fi -} - -# Main script starts here -echo "🚀 Welcome to the Mastodon Deployment Script $SCRIPT_VERSION" -echo "This script will guide you through setting up a Mastodon instance." - -# Gather necessary information -read -p "Enter your domain name (e.g., mastodon.example.com): " DOMAIN_NAME -read -p "Enter your server's public IP address: " IP_ADDRESS - -# Check DNS setup -echo "Checking DNS setup..." -if check_dns "$DOMAIN_NAME" "$IP_ADDRESS"; then - echo "✅ DNS is correctly set up." -else - echo "❌ DNS is not set up correctly. Please ensure your domain points to your server's IP address." - echo "You can check DNS propagation at https://www.whatsmydns.net/#A/$DOMAIN_NAME" - read -p "Have you set up the DNS correctly now? (yes/no): " dns_setup - if [[ $dns_setup != "yes" ]]; then - echo "Please set up DNS and run this script again." - exit 1 - fi -fi - -# Set up SSL/TLS -echo "Setting up SSL/TLS certificate..." -sudo certbot certonly --standalone -d $DOMAIN_NAME - -if [ $? -ne 0 ]; then - echo "❌ Failed to obtain SSL/TLS certificate. Please ensure your domain is correctly set up and try again." - exit 1 -fi - -# Generate random passwords -DB_PASSWORD=$(generate_random_string 32) -REDIS_PASSWORD=$(generate_random_string 32) - -# Create .env.production file -cat << EOF > .env.production -# Federation -LOCAL_DOMAIN=$DOMAIN_NAME -SINGLE_USER_MODE=false -ENABLE_REGISTRATIONS=true - -# Redis -REDIS_HOST=redis -REDIS_PORT=6379 -REDIS_PASSWORD=$REDIS_PASSWORD - -# PostgreSQL -DB_HOST=db -DB_PORT=5432 -DB_NAME=mastodon -DB_USER=mastodon -DB_PASS=$DB_PASSWORD - -# Secrets (generated automatically) -SECRET_KEY_BASE=$(generate_random_string 128) -OTP_SECRET=$(generate_random_string 128) - -# VAPID keys (generated automatically) -VAPID_PRIVATE_KEY=$(openssl ecparam -name prime256v1 -genkey -noout -out /dev/null 2>&1 | openssl ec -in /dev/stdin -outform DER 2>/dev/null | tail -c +8 | head -c 32 | base64) -VAPID_PUBLIC_KEY=$(echo -n "$VAPID_PRIVATE_KEY" | openssl ec -in /dev/stdin -inform DER -pubout -outform DER 2>/dev/null | tail -c 65 | base64) - -# Sending mail (update with your SMTP details) -SMTP_SERVER=smtp.example.com -SMTP_PORT=587 -SMTP_LOGIN=your_smtp_login -SMTP_PASSWORD=your_smtp_password -SMTP_FROM_ADDRESS=mastodon@$DOMAIN_NAME - -# File storage (local) -PAPERCLIP_ROOT_PATH=/opt/mastodon/public/system -EOF - -# Create docker-compose.yml file -cat << EOF > docker-compose.yml -version: '3' -services: - db: - image: postgres:14-alpine - restart: always - environment: - - POSTGRES_USER=mastodon - - POSTGRES_DB=mastodon - - POSTGRES_PASSWORD=$DB_PASSWORD - volumes: - - ./postgres:/var/lib/postgresql/data - - redis: - image: redis:7-alpine - restart: always - command: redis-server --requirepass $REDIS_PASSWORD - volumes: - - ./redis:/data - - web: - image: tootsuite/mastodon:$MASTODON_VERSION - restart: always - env_file: .env.production - command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" - ports: - - "127.0.0.1:3000:3000" - depends_on: - - db - - redis - volumes: - - ./public/system:/mastodon/public/system - - streaming: - image: tootsuite/mastodon:$MASTODON_VERSION - restart: always - env_file: .env.production - command: node ./streaming - ports: - - "127.0.0.1:4000:4000" - depends_on: - - db - - redis - - sidekiq: - image: tootsuite/mastodon:$MASTODON_VERSION - restart: always - env_file: .env.production - command: bundle exec sidekiq - depends_on: - - db - - redis - volumes: - - ./public/system:/mastodon/public/system -EOF - -# Set up Nginx -echo "Setting up Nginx..." -sudo tee /etc/nginx/sites-available/mastodon << EOF -server { - listen 80; - listen [::]:80; - server_name $DOMAIN_NAME; - return 301 https://\$server_name\$request_uri; -} - -server { - listen 443 ssl http2; - listen [::]:443 ssl http2; - server_name $DOMAIN_NAME; - - ssl_certificate /etc/letsencrypt/live/$DOMAIN_NAME/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/$DOMAIN_NAME/privkey.pem; - - root /opt/mastodon/public; - - location / { - try_files \$uri @proxy; - } - - location @proxy { - proxy_set_header Host \$host; - proxy_set_header X-Real-IP \$remote_addr; - proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - proxy_set_header Proxy ""; - proxy_pass_header Server; - - proxy_pass http://127.0.0.1:3000; - proxy_buffering off; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Upgrade \$http_upgrade; - proxy_set_header Connection "upgrade"; - } - - location /api/v1/streaming { - proxy_set_header Host \$host; - proxy_set_header X-Real-IP \$remote_addr; - proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - proxy_set_header Proxy ""; - - proxy_pass http://127.0.0.1:4000; - proxy_buffering off; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Upgrade \$http_upgrade; - proxy_set_header Connection "upgrade"; - } - - location /system { - add_header Cache-Control "public, max-age=31536000, immutable"; - add_header Strict-Transport-Security "max-age=31536000"; - } - - error_page 500 501 502 503 504 /500.html; -} -EOF - -sudo ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/ -sudo nginx -t && sudo systemctl reload nginx - -# Start Docker containers -echo "Starting Docker containers..." -docker-compose up -d - -# Create first admin user -echo "Creating first admin user..." -docker-compose run --rm web bash -c "RAILS_ENV=production bundle exec rails mastodon:make_admin USERNAME=admin EMAIL=admin@$DOMAIN_NAME" - -# Final messages -echo "✅ Mastodon deployment completed successfully!" -echo "🌐 Your Mastodon instance is now available at https://$DOMAIN_NAME" -echo "👤 An admin user has been created with the following credentials:" -echo " Username: admin" -echo " Email: admin@$DOMAIN_NAME" -echo "⚠️ Please log in and change the admin password immediately!" -echo "📚 For more information on managing your Mastodon instance, visit: https://docs.joinmastodon.org/" \ No newline at end of file