97 lines
3.4 KiB
Bash
97 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Setting up WordPress/WooCommerce environment for shuffleandskirmish.co.uk..."
|
|
|
|
# Check if .env file exists
|
|
if [ ! -f .env ]; then
|
|
echo "❌ Error: .env file not found!"
|
|
echo "Please create a .env file with the following variables:"
|
|
echo " DB_ROOT_PASSWORD=your_root_password"
|
|
echo " DB_NAME=your_database_name"
|
|
echo " DB_USER=your_database_user"
|
|
echo " DB_PASSWORD=your_database_password"
|
|
echo " WORDPRESS_DEBUG=0"
|
|
exit 1
|
|
fi
|
|
|
|
# Create directories with proper permissions
|
|
echo "Creating necessary directories..."
|
|
mkdir -p wp-content/themes wp-content/plugins wp-content/uploads mysql/data
|
|
|
|
# Set ownership of current directory to current user
|
|
echo "Setting permissions..."
|
|
chown -R $USER:$USER .
|
|
|
|
# Set directory permissions
|
|
chmod -R 755 wp-content/
|
|
chmod -R 755 mysql/
|
|
chmod 644 .env
|
|
|
|
# Check if Docker is running
|
|
if ! docker info > /dev/null 2>&1; then
|
|
echo "❌ Docker is not running. Please start Docker first."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if traefik-public network exists
|
|
if ! docker network inspect traefik-public > /dev/null 2>&1; then
|
|
echo "❌ Error: traefik-public network does not exist!"
|
|
echo "Please ensure Traefik is properly set up with the traefik-public network."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if user is in docker group
|
|
if groups $USER | grep -q '\bdocker\b'; then
|
|
echo "User is in docker group, proceeding without sudo..."
|
|
DOCKER_COMPOSE_CMD="docker compose"
|
|
else
|
|
echo "User not in docker group, using sudo..."
|
|
DOCKER_COMPOSE_CMD="sudo docker compose"
|
|
fi
|
|
|
|
# Pull latest images
|
|
echo "Pulling latest Docker images..."
|
|
$DOCKER_COMPOSE_CMD pull
|
|
|
|
# Build and start containers
|
|
echo "Building and starting containers..."
|
|
$DOCKER_COMPOSE_CMD up -d
|
|
|
|
echo "Waiting for containers to initialize..."
|
|
sleep 20
|
|
|
|
# Check if containers are running
|
|
if $DOCKER_COMPOSE_CMD ps | grep -q "running"; then
|
|
echo ""
|
|
echo "✅ WordPress/WooCommerce environment is ready!"
|
|
echo ""
|
|
echo "🌐 WordPress Site: https://shuffleandskirmish.co.uk"
|
|
echo "🌐 WordPress Site (www): https://www.shuffleandskirmish.co.uk"
|
|
echo "📊 phpMyAdmin: https://pma.shuffleandskirmish.co.uk"
|
|
echo ""
|
|
echo "⚠️ IMPORTANT SETUP STEPS:"
|
|
echo "1. Visit https://shuffleandskirmish.co.uk to complete WordPress installation"
|
|
echo "2. Install WooCommerce plugin from WordPress admin"
|
|
echo "3. Configure SSL settings in WordPress (should be automatic with Traefik)"
|
|
echo "4. Update DNS records to point to this server:"
|
|
echo " - shuffleandskirmish.co.uk -> Server IP"
|
|
echo " - www.shuffleandskirmish.co.uk -> Server IP"
|
|
echo " - pma.shuffleandskirmish.co.uk -> Server IP"
|
|
echo ""
|
|
echo "🔒 Security Notes:"
|
|
echo " - phpMyAdmin is exposed at pma.shuffleandskirmish.co.uk"
|
|
echo " - Consider restricting access or disabling it in production"
|
|
echo " - Change default database passwords in .env file"
|
|
echo ""
|
|
echo "📝 Useful commands:"
|
|
echo " View logs: $DOCKER_COMPOSE_CMD logs -f"
|
|
echo " View specific service: $DOCKER_COMPOSE_CMD logs -f wordpress"
|
|
echo " Stop: $DOCKER_COMPOSE_CMD stop"
|
|
echo " Start: $DOCKER_COMPOSE_CMD start"
|
|
echo " Restart: $DOCKER_COMPOSE_CMD restart"
|
|
echo " Remove: $DOCKER_COMPOSE_CMD down"
|
|
echo " Remove with volumes: $DOCKER_COMPOSE_CMD down -v"
|
|
else
|
|
echo "❌ Some containers failed to start. Check logs with: $DOCKER_COMPOSE_CMD logs"
|
|
exit 1
|
|
fi |