#!/bin/bash # Quick setup script for ActivityPub testing set -e echo "======================================" echo "ActivityPub Testing Setup" echo "======================================" echo "" # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color # Configuration SOLAR_DOMAIN="solar.local" SOLAR_PORT="5000" MASTODON_DOMAIN="mastodon.local" MASTODON_PORT="3001" echo -e "${YELLOW}1. Checking prerequisites...${NC}" # Check if Docker is installed if ! command -v docker &> /dev/null; then echo -e "${RED}Error: Docker is not installed${NC}" exit 1 fi # Check if docker-compose is installed if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then echo -e "${RED}Error: docker-compose is not installed${NC}" exit 1 fi # Check if psql is installed if ! command -v psql &> /dev/null; then echo -e "${RED}Error: PostgreSQL client (psql) is not installed${NC}" exit 1 fi echo -e "${GREEN}✓ All prerequisites found${NC}" echo "" echo -e "${YELLOW}2. Updating /etc/hosts...${NC}" # Backup hosts file sudo cp /etc/hosts /etc/hosts.backup # Check if entries already exist if ! grep -q "$SOLAR_DOMAIN" /etc/hosts; then echo "127.0.0.1 $SOLAR_DOMAIN" | sudo tee -a /etc/hosts > /dev/null echo -e "${GREEN}✓ Added $SOLAR_DOMAIN to hosts${NC}" else echo -e "${YELLOW}⊙ $SOLAR_DOMAIN already in hosts${NC}" fi if ! grep -q "$MASTODON_DOMAIN" /etc/hosts; then echo "127.0.0.1 $MASTODON_DOMAIN" | sudo tee -a /etc/hosts > /dev/null echo -e "${GREEN}✓ Added $MASTODON_DOMAIN to hosts${NC}" else echo -e "${YELLOW}⊙ $MASTODON_DOMAIN already in hosts${NC}" fi echo "" echo -e "${YELLOW}3. Generating secrets for Mastodon...${NC}" SECRET_KEY_BASE=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-32) OTP_SECRET=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-32) cat > .env.mastodon < docker-compose.mastodon-test.yml <