Skip to main content
Glama
wp-setup.shโ€ข3.68 kB
#!/bin/bash set -e echo "๐Ÿš€ Starting WordPress automated setup for contract testing..." # Wait for WordPress files to be ready echo "โณ Waiting for WordPress files to be ready..." counter=0 max_attempts=30 until [ -f /var/www/html/wp-config.php ]; do if [ $counter -ge $max_attempts ]; then echo "โŒ WordPress files timeout after $max_attempts attempts" exit 1 fi echo " Waiting for WordPress files... (attempt $((counter + 1))/$max_attempts)" sleep 5 counter=$((counter + 1)) done echo "โœ… WordPress files are ready, installing WordPress..." # Install WordPress (it won't be installed yet) echo "๐Ÿ“ฆ Installing WordPress..." wp core install \ --url="http://localhost:8081" \ --title="Contract Test Site" \ --admin_user="testuser" \ --admin_password="test-password-123" \ --admin_email="test@example.com" \ --path=/var/www/html \ --allow-root echo "โœ… WordPress installation complete!" echo "๐Ÿ”‘ Setting up authentication..." # Create application password for testing echo "๐Ÿ“ฑ Creating application password..." wp user application-password create testuser "Contract Testing" \ --path=/var/www/html \ --allow-root \ --porcelain > /tmp/app_password.txt APP_PASSWORD=$(cat /tmp/app_password.txt) echo "Generated App Password: $APP_PASSWORD" # Create test content for contract testing echo "๐Ÿ“ Creating test content..." # Create test posts wp post create \ --post_title="Test Post 1" \ --post_content="This is test content for contract testing" \ --post_status="publish" \ --post_author=1 \ --path=/var/www/html \ --allow-root wp post create \ --post_title="Test Post 2" \ --post_content="Another test post for pagination testing" \ --post_status="publish" \ --post_author=1 \ --path=/var/www/html \ --allow-root # Create test media directory with proper permissions echo "๐Ÿ–ผ๏ธ Creating test media directory..." # First ensure the uploads directory exists and has correct ownership mkdir -p /var/www/html/wp-content/uploads/ chown -R www-data:www-data /var/www/html/wp-content/ chmod -R 755 /var/www/html/wp-content/uploads/ # Create test media subdirectory mkdir -p /var/www/html/wp-content/uploads/test-media chown -R www-data:www-data /var/www/html/wp-content/uploads/ # Create a small test image echo "๐Ÿ“ Creating test image..." # Create a simple 1x1 pixel PNG for testing echo "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" | base64 -d > /var/www/html/wp-content/uploads/test-media/test-image.png # Set final permissions chown -R www-data:www-data /var/www/html/wp-content/uploads/ chmod -R 755 /var/www/html/wp-content/uploads/ # Enable REST API (should be enabled by default, but just to be sure) echo "๐Ÿ”Œ Ensuring REST API is enabled..." wp rewrite structure '/%postname%/' --path=/var/www/html --allow-root wp rewrite flush --path=/var/www/html --allow-root # Output configuration for tests echo "๐Ÿ“‹ WordPress setup complete! Configuration:" echo "URL: http://localhost:8081" echo "Username: testuser" echo "Password: test-password-123" echo "App Password: $APP_PASSWORD" echo "REST API: http://localhost:8081/wp-json/wp/v2/" # Save configuration to a file that can be read by tests cat > /var/www/html/test-config.json << EOF { "url": "http://localhost:8081", "username": "testuser", "password": "test-password-123", "app_password": "$APP_PASSWORD", "rest_api": "http://localhost:8081/wp-json/wp/v2/", "setup_complete": true, "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" } EOF echo "โœ… WordPress contract testing environment is ready!"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server