Skip to content

Commit 3125539

Browse files
committed
Updates and improvements
1 parent 1e93835 commit 3125539

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

nginx-fpm/startup/55-wordpress.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ PHP
5959
sudo -u www-data wp config set WP_AUTO_UPDATE_CORE 'minor'
6060
sudo -u www-data wp config set FS_METHOD 'direct'
6161
sudo -u www-data wp config set WP_MEMORY_LIMIT '96M'
62+
sudo -u www-data wp config set CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'
6263

6364
echo >&2 "Uninstall default plugins"
6465
sudo -u www-data wp plugin is-installed akismet && sudo -u www-data wp plugin uninstall akismet
@@ -96,11 +97,4 @@ PHP
9697
sudo -u www-data wp language core activate $WORDPRESS_LANGUAGE
9798
fi
9899

99-
else
100-
101-
echo "Setting DB Host"
102-
sudo -u www-data wp config set DB_HOST $WORDPRESS_DB_HOST
103-
echo >&2 "Configuring nginx cache path"
104-
sudo -u www-data wp config set RT_WP_NGINX_HELPER_CACHE_PATH '/var/run/nginx-cache'
105-
106100
fi

nginx-fpm/startup/56-cs-wp.sh

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,57 @@
11
#!/usr/bin/env bash
22

3-
echo >&2 "Configuring ComputeStacks path"
4-
sudo -u www-data wp --path=/var/www/html/wordpress config set CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'
3+
WP_INSTALL_PATH=$(/usr/local/bin/find-wordpress-installation)
4+
5+
if [ ! -f $WP_INSTALL_PATH/wp-config.php ]; then
6+
echo >&2 "Error: Missing wp-config.php file."
7+
exit 0
8+
fi
9+
10+
if [ ! -d $WP_INSTALL_PATH/wp-content ]; then
11+
echo >&2 "Error: Missing wp-content directory"
12+
exit 0
13+
fi
14+
15+
##
16+
# Some like to remove all comments from the wp-config file, we need that for
17+
# wp-cli to work properly. So we will re-add it.
18+
##
19+
if grep -q "/* That's all, stop editing!" $WP_INSTALL_PATH/wp-config.php; then
20+
echo "Anchor found in wp-config."
21+
else
22+
echo "wp-cli anchor missing from wp-config, adding it back in"
23+
sed -i "/wp-settings.php/i\/* That's all, stop editing! Happy publishing. *\/" $WP_INSTALL_PATH/wp-config.php
24+
fi
25+
26+
##
27+
# Configure our integrations
28+
##
29+
30+
echo >&2 "Setting DB Host"
31+
sudo -u www-data wp --path=$WP_INSTALL_PATH config set DB_HOST $WORDPRESS_DB_HOST
32+
echo >&2 "Configuring nginx cache path"
33+
sudo -u www-data wp --path=$WP_INSTALL_PATH config set RT_WP_NGINX_HELPER_CACHE_PATH '/var/run/nginx-cache'
34+
35+
echo >&2 "Configuring Cloudpress path"
36+
sudo -u www-data wp --path=$WP_INSTALL_PATH config CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'
37+
38+
# Remove old plugin
39+
if [ -f "$WP_INSTALL_PATH/wp-content/mu-plugins/cstacks-config.php" ]; then
40+
rm $WP_INSTALL_PATH/wp-content/mu-plugins/cstacks-config.php
41+
fi
542

643
if [ -f "/opt/cs-wordpress-plugin-main/cstacks-config.php" ]; then
744
echo >&2 "Updating ComputeStacks integration with latest version..."
8-
sudo -u www-data mkdir -p /var/www/html/wordpress/wp-content/mu-plugins
9-
sudo -u www-data cp /opt/cs-wordpress-plugin-main/cstacks-config.php /var/www/html/wordpress/wp-content/mu-plugins/
45+
sudo -u www-data mkdir -p $WP_INSTALL_PATH/wp-content/mu-plugins
46+
sudo -u www-data cp /opt/cs-wordpress-plugin-main/cstacks-config.php $WP_INSTALL_PATH/wp-content/mu-plugins/
1047
fi
1148

1249
echo >&2 "Configuring wordpress cron jobs..."
13-
sudo -u www-data wp --path=/var/www/html/wordpress config set DISABLE_WP_CRON true
50+
sudo -u www-data wp --path=$WP_INSTALL_PATH config set DISABLE_WP_CRON true
1451

1552
if [ -f /var/www/crontab ]; then
1653
if grep -Fq 'wp-cron' /var/www/crontab; then
17-
echo "wordpress user-cron configured, skipping..."
54+
echo >&2 "wordpress user-cron configured, skipping..."
1855
else
1956
cat << EOF >> '/var/www/crontab'
2057
@@ -24,7 +61,7 @@ EOF
2461
fi
2562
if [ -f /etc/cron.d/myapp ]; then
2663
if grep -Fq 'wp-cron' /etc/cron.d/myapp; then
27-
echo "wordpress system-cron configured, skipping..."
64+
echo >&2 "wordpress system-cron configured, skipping..."
2865
else
2966
cat << EOF >> '/etc/cron.d/myapp'
3067

0 commit comments

Comments
 (0)