-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-install.sh
More file actions
executable file
·114 lines (96 loc) · 3.27 KB
/
Copy pathtest-install.sh
File metadata and controls
executable file
·114 lines (96 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# WordPress Installation Test Script
set -e
echo "=== WordPress Enterprise Installation Test ==="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "test-docker.yml" ]; then
print_error "test-docker.yml not found. Please run from the correct directory."
exit 1
fi
# Check if MySQL and Redis are running
print_status "Checking external services..."
if ! docker exec wordpress-mysql mysql -uroot -proot -e "SELECT 1;" > /dev/null 2>&1; then
print_error "MySQL is not accessible"
exit 1
fi
if ! docker exec wordpress-redis redis-cli ping > /dev/null 2>&1; then
print_error "Redis is not accessible"
exit 1
fi
print_status "External services are running correctly"
# Create a test container
print_status "Creating test container..."
docker run -d --name wordpress-test-installer \
--network wordpress-network \
--privileged \
-v $(pwd):/workspace \
-w /workspace \
ubuntu:22.04 \
sleep infinity
# Install dependencies in the container
print_status "Installing dependencies..."
docker exec wordpress-test-installer bash -c "
export DEBIAN_FRONTEND=noninteractive
apt-get update > /dev/null 2>&1
apt-get install -y \
python3 python3-pip sudo systemd curl wget \
ca-certificates apt-transport-https gnupg2 \
software-properties-common lsb-release \
> /dev/null 2>&1
python3 -m pip install ansible --break-system-packages > /dev/null 2>&1
ansible-galaxy collection install \
community.general community.mysql ansible.posix \
> /dev/null 2>&1
"
# Run the WordPress installation
print_status "Running WordPress installation..."
docker exec wordpress-test-installer bash -c "
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook test-docker.yml --connection=local -v
" || {
print_error "Ansible playbook failed"
docker rm -f wordpress-test-installer
exit 1
}
# Check if WordPress is installed
print_status "Verifying WordPress installation..."
if docker exec wordpress-test-installer bash -c "[ -f /var/www/wordpress/wp-config.php ]"; then
print_status "WordPress configuration file found!"
else
print_warning "WordPress configuration file not found"
fi
# Check if web server is running
if docker exec wordpress-test-installer bash -c "systemctl is-active nginx > /dev/null 2>&1"; then
print_status "Nginx is running!"
else
print_warning "Nginx is not running"
fi
# Test database connectivity
print_status "Testing database connectivity from WordPress container..."
docker exec wordpress-test-installer bash -c "
mysql -hmysql -uwordpress -pwordpress -e 'SELECT 1;' wordpress
" && print_status "Database connection successful!" || print_warning "Database connection failed"
# Clean up
print_status "Cleaning up test container..."
docker rm -f wordpress-test-installer
print_status "WordPress installation test completed!"
echo ""
echo "To access the site:"
echo "- Start a new container with ports exposed:"
echo " docker run -d --name wordpress-live --network wordpress-network -p 8080:80 wordpress-ansible:dev"
echo ""