Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit ad8faa2

Browse files
committed
Fixes on shared scenario when WP upgrade is needed
1 parent d0973a4 commit ad8faa2

File tree

9 files changed

+78
-7
lines changed

9 files changed

+78
-7
lines changed

modules/wordpress/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ data "template_file" "install_wp" {
3333

3434
vars = {
3535
wp_working_dir = var.wp_working_dir
36+
wp_version = var.wp_version
3637
}
3738
}
3839

modules/wordpress/scripts/install_wp.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
echo "Starting Wordpress installation..."
55
cd ${wp_working_dir}/www/
6-
wget https://wordpress.org/latest.tar.gz
7-
tar zxvf latest.tar.gz
8-
rm -rf html/ latest.tar.gz
6+
wget https://wordpress.org/wordpress-${wp_version}.tar.gz
7+
tar zxvf wordpress-${wp_version}.tar.gz
8+
rm -rf html/ wordpress-${wp_version}.tar.gz
9+
#wget https://wordpress.org/latest.tar.gz
10+
#tar zxvf latest.tar.gz
11+
#rm -rf html/ latest.tar.gz
912
mv wordpress html
1013
chown apache. -R html
1114
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 512M/g' /etc/php.ini

modules/wordpress/scripts/setup_fss.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
export use_shared_storage='${use_shared_storage}'
55

66
if [[ $use_shared_storage == "true" ]]; then
7-
echo "Mount NFS share for WP-CONTENT directory."
7+
echo "Mount NFS share for WP-CONTENT, WP-ADMIN, WP-INCLUDES directories."
88
yum install -y -q nfs-utils
99
mkdir -p ${wp_shared_working_dir}
1010
echo '${mt_ip_address}:${wp_shared_working_dir} ${wp_shared_working_dir} nfs nosharecache,context="system_u:object_r:httpd_sys_rw_content_t:s0" 0 0' >> /etc/fstab
1111
setsebool -P httpd_use_nfs=1
1212
mount ${wp_shared_working_dir}
1313
mount
14-
echo "NFS share for WP-CONTENT directory mounted."
14+
echo "NFS share for WP-CONTENT, WP-ADMIN, WP-INCLUDES directories mounted."
1515
fi

modules/wordpress/scripts/setup_wp.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,39 @@ if [[ $use_shared_storage == "true" ]]; then
6262
ls -latr ${wp_shared_working_dir}/wp-content/
6363
chown -R apache:apache /sharedwp
6464
echo "WP-CONTENT in shared NFS space."
65+
66+
echo "Using shared storage, moving WP-ADMIN and WP-INCLUDES directories to shared NFS space."
67+
mkdir ${wp_shared_working_dir}/wp-admin/
68+
mkdir ${wp_shared_working_dir}/wp-includes/
69+
70+
echo "... moving WP-ADMIN/* ..."
71+
cp -r ${wp_working_dir}/www/html/wp-admin/* ${wp_shared_working_dir}/wp-admin/
72+
rm -rf ${wp_working_dir}/www/html/wp-admin/
73+
ln -s ${wp_shared_working_dir}/wp-admin ${wp_working_dir}/www/html/wp-admin
74+
chown -R apache:apache ${wp_shared_working_dir}/wp-admin
75+
chown -R apache:apache ${wp_working_dir}/www/html/wp-admin
76+
ls -latr ${wp_shared_working_dir}/wp-admin
77+
echo "... WP-ADMIN/* moved to NFS..."
78+
79+
echo "... moving WP-INCLUDES/* ..."
80+
cp -r ${wp_working_dir}/www/html/wp-includes/* ${wp_shared_working_dir}/wp-includes/
81+
rm -rf ${wp_working_dir}/www/html/wp-includes/
82+
ln -s ${wp_shared_working_dir}/wp-includes ${wp_working_dir}/www/html/wp-includes
83+
chown -R apache:apache ${wp_shared_working_dir}/wp-includes
84+
chown -R apache:apache ${wp_working_dir}/www/html/wp-includes
85+
ls -latr ${wp_shared_working_dir}/wp-includes
86+
echo "... WP-INCLUDES/* moved to NFS..."
87+
88+
echo "... coping rest of the root level PHP files and .htaccess ..."
89+
cp -r ${wp_working_dir}/www/html/*.php ${wp_shared_working_dir}/
90+
cp -r ${wp_working_dir}/www/html/.htaccess ${wp_shared_working_dir}/
91+
chown -R apache:apache ${wp_shared_working_dir}/*.php
92+
chown -R apache:apache ${wp_working_dir}/www/html/*.php
93+
ls -latr ${wp_shared_working_dir}/*.php
94+
ls -latr ${wp_shared_working_dir}/.htaccess
95+
echo "... root level PHP files and .htaccess copied to NFS..."
96+
97+
echo "... Changing /etc/httpd/conf/httpd.conf with Document set to new shared NFS space ..."
98+
sed -i 's/"\/var\/www\/html"/"\/sharedwp"/g' /etc/httpd/conf/httpd.conf
99+
echo "... /etc/httpd/conf/httpd.conf with Document set to new shared NFS space ..."
65100
fi

modules/wordpress/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ variable "vm_user" {
143143
default = "opc"
144144
}
145145

146+
variable "wp_version" {
147+
description = "WordPress version"
148+
default = "5.8"
149+
}
150+
146151
variable "wp_name" {
147152
description = "WordPress Database User Name."
148153
}

schema.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ variableGroups:
7575
and:
7676
- show_advanced
7777
variables:
78+
- wp_version
7879
- wp_site_admin_email
7980
- wp_site_admin_user
8081
- wp_plugins
@@ -488,6 +489,26 @@ variables:
488489
maxLength: 14
489490
pattern: "^[a-zA-Z][a-zA-Z0-9]+$"
490491

492+
wp_version:
493+
type: enum
494+
required: false
495+
visible: false
496+
title: "WordPress Version"
497+
description: "WordPress Version"
498+
default: "5.8.3"
499+
enum:
500+
- "5.9"
501+
- "5.8.3"
502+
- "5.8.2"
503+
- "5.8.1"
504+
- "5.8"
505+
- "5.7.5"
506+
- "5.7.4"
507+
- "5.7.3"
508+
- "5.7.2"
509+
- "5.7.1"
510+
- "5.7"
511+
491512
wp_name:
492513
type: string
493514
required: false

tags.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "oci_identity_tag" "ArchitectureCenterTag" {
2424

2525
validator {
2626
validator_type = "ENUM"
27-
values = ["release", "1.4.1"]
27+
values = ["release", "1.4.2"]
2828
}
2929

3030
provisioner "local-exec" {

variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variable "flex_lb_max_shape" {
2929

3030
variable "release" {
3131
description = "Reference Architecture Release (OCI Architecture Center)"
32-
default = "1.4.1"
32+
default = "1.4.2"
3333
}
3434

3535
variable "vcn" {
@@ -110,6 +110,11 @@ variable "mysql_is_highly_available" {
110110
default = false
111111
}
112112

113+
variable "wp_version" {
114+
description = "WordPress version"
115+
default = "5.8"
116+
}
117+
113118
variable "wp_name" {
114119
description = "WordPress Database User Name."
115120
default = "wp"

wordpress.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "wordpress" {
2424
admin_password = var.admin_password
2525
admin_username = var.admin_username
2626
wp_schema = var.wp_schema
27+
wp_version = var.wp_version
2728
wp_name = var.wp_name
2829
wp_password = var.wp_password
2930
wp_plugins = split(",", var.wp_plugins)

0 commit comments

Comments
 (0)