-
Notifications
You must be signed in to change notification settings - Fork 4
/
entrypoint.sh
executable file
·74 lines (59 loc) · 1.72 KB
/
entrypoint.sh
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
#!/bin/bash
# Ensure Apache is running
service apache2 start
# Ensure mysql is loaded
dockerize -wait tcp://$WORDPRESS_DB_HOST:3306 -timeout 1m
export PATH=~/.composer/vendor/bin:$PATH
if [ -d codeception.yml ]; then
rm -rf codeception.yml
fi
# Update our domain to just be the docker container's IP address
export WORDPRESS_DOMAIN=$( hostname -i )
export WORDPRESS_URL="http://$WORDPRESS_DOMAIN"
# Download WordPress
wp core download \
--quiet \
--allow-root
# Config WordPress
wp config create \
--dbname="$WORDPRESS_DB_NAME" \
--dbuser="$WORDPRESS_DB_USER" \
--dbpass="$WORDPRESS_DB_PASSWORD" \
--dbhost="$WORDPRESS_DB_HOST" \
--dbprefix="$WORDPRESS_TABLE_PREFIX" \
--dbcharset="$WORDPRESS_DB_CHARSET" \
--skip-check \
--quiet \
--allow-root
chown www-data:www-data wp-config.php
# Wipe out our database for good measure.
wp db clean --yes --allow-root
# Install WP if not yet installed
if ! $( wp core is-installed --allow-root ); then
wp core install \
--url=$WORDPRESS_URL \
--title='Test' \
--admin_user=$WORDPRESS_ADMIN_USERNAME \
--admin_password=$WORDPRESS_ADMIN_PASSWORD \
--admin_email=$WORDPRESS_ADMIN_EMAIL \
--allow-root
fi
# Ensure a .env file is present for those who use .env params in codeception tests
touch .env
chown www-data:www-data .env
# Export a database dump
mkdir -p wp-content
mkdir -p wp-content/mu-plugins
mkdir -p wp-content/plugins
mkdir -p wp-content/themes
chown www-data:www-data wp-content
chown www-data:www-data wp-content/mu-plugins
chown www-data:www-data wp-content/plugins
chown www-data:www-data wp-content/themes
wp db export wp-content/mysql.sql \
--skip-plugins \
--skip-themes \
--allow-root
chown www-data:www-data wp-content/mysql.sql
# Run the passed command
exec "$@"