-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestWpUsage.sh
executable file
·176 lines (148 loc) · 3.88 KB
/
testWpUsage.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#! /bin/bash -e
scriptDir=$( dirname $( readlink -f $0 ) )
workspaceDir="/tmp/myMassWordpressWorkspace"
cd $scriptDir/src/mby.fr/mass
go install
rm -rf -- "$workspaceDir"
massCmd="mass"
# Init a workspace
$massCmd init workspace $workspaceDir
cd $workspaceDir
# Init git repo
git init .
# Init some projects
$massCmd init project wp
# Init some images
mass init image wp/wordpress wp/db
cat <<EOF > wp/wordpress/Dockerfile
FROM wordpress:6.0-php8.0-apache
RUN echo foo
RUN echo bar
RUN echo baz
EOF
cat <<EOF > wp/db/Dockerfile
FROM mariadb:10.7-focal
RUN echo pif
RUN echo paf
RUN echo pouf
ADD src/docker-entrypoint-initdb.d /docker-entrypoint-initdb.d
EOF
cat <<EOF > wp/wordpress/config.yaml
labels:
component: frontend
tags:
component: frontend
buildArgs:
EOF
cat <<EOF > wp/db/config.yaml
labels:
component: db
tags:
component: db
buildArgs:
EOF
cat <<EOF > wp/config.yaml
labels:
app: wordpress
tags:
app: wordpress
environment:
MYSQL_ROOT_PASSWORD: mypassword
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
EOF
cat <<EOF > wp/compose.yaml
services:
db:
#image: mariadb:10.6.4-focal
image: wp/db:0.0.1
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE=\${WORDPRESS_DB_NAME}
- MYSQL_USER=\${WORDPRESS_DB_USER}
- MYSQL_PASSWORD=\${WORDPRESS_DB_PASSWORD}
expose:
- 3306
- 33060
wordpress:
#image: wordpress:latest
image: wp/wordpress:0.0.1
volumes:
- wp_site:/var/www/html:rw
ports:
- 8000:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
- WORDPRESS_DB_NAME
#- WORDPRESS_CONFIG_EXTRA=define( 'WP_CONTENT_URL', 'http://localhost/wp-content' ); define( 'WP_HOME', 'http://localhost' ); define( 'WP_SITEURL', 'http://localhost' );
- WORDPRESS_CONFIG_EXTRA=define( 'WP_HOME', 'http://localhost:8000' ); define( 'WP_SITEURL', 'http://localhost:8000' );
wait-db:
image: mariadb:10.6.4-focal
command: /bin/sh -c 'while ! mysql -h db -u \${WORDPRESS_DB_USER} --password=\${WORDPRESS_DB_PASSWORD}; do sleep 1; echo .; done'
depends_on:
- db
cli:
image: wordpress:cli-2.6
command: |
bash -c "
while ! mysql -h db -u \${WORDPRESS_DB_USER} --password=\${WORDPRESS_DB_PASSWORD}; do sleep 1; echo .; done ; sleep 2 ;
wp db repair ;
wp theme delete --all --force ;
wp db optimize ;
wp core update-db ;
wp theme install shuttle-clean ;
wp theme activate shuttle-clean ;
wp plugin install wp-optimize wordpress-seo disable-comments login-lockdown imsanity;
"
#wp search-replace old-site-url.co.uk new-site-url.co.uk ;
working_dir: /var/www/html
user: "33:33"
volumes:
- wp_site:/var/www/html:rw
environment:
- HOME=/tmp
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER
- WORDPRESS_DB_PASSWORD
depends_on:
- db
volumes:
db_data:
wp_site:
EOF
tree -Ca $workspaceDir
# Display configs
$massCmd config i/wp/wordpress i/wp/db
# Add DB initialization
initDbDir="wp/db/src/docker-entrypoint-initdb.d"
confDbDir="wp/db/src/conf.d"
mkdir -p "$initDbDir" "$confDbDir"
cp ~/Documents/ede_backup_2020-01/ecrindes_phtest.sql $initDbDir/10-init-ede-db.sql
echo "update wp_users set user_pass=md5('password') where user_login = 'nathalie';" > $initDbDir/20-change-admin-password.sql
#$massCmd build --no-cache p/wp
#$massCmd build p/wp
$massCmd up p/wp || true
echo "Will execute mass down in 10 seconds ..."
for k in $( seq 10 ); do
echo -n .
sleep 1
done
echo
$massCmd down p/wp
echo "Will execute mass down --volumes in 10 seconds ..."
for k in $( seq 10 ); do
echo -n .
sleep 1
done
echo
$massCmd down --volumes p/wp
echo
echo SUCCESS