Skip to content

Commit

Permalink
Updates and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatson committed Feb 27, 2024
1 parent 1e93835 commit 3125539
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
8 changes: 1 addition & 7 deletions nginx-fpm/startup/55-wordpress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ PHP
sudo -u www-data wp config set WP_AUTO_UPDATE_CORE 'minor'
sudo -u www-data wp config set FS_METHOD 'direct'
sudo -u www-data wp config set WP_MEMORY_LIMIT '96M'
sudo -u www-data wp config set CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'

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

else

echo "Setting DB Host"
sudo -u www-data wp config set DB_HOST $WORDPRESS_DB_HOST
echo >&2 "Configuring nginx cache path"
sudo -u www-data wp config set RT_WP_NGINX_HELPER_CACHE_PATH '/var/run/nginx-cache'

fi
51 changes: 44 additions & 7 deletions nginx-fpm/startup/56-cs-wp.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,57 @@
#!/usr/bin/env bash

echo >&2 "Configuring ComputeStacks path"
sudo -u www-data wp --path=/var/www/html/wordpress config set CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'
WP_INSTALL_PATH=$(/usr/local/bin/find-wordpress-installation)

if [ ! -f $WP_INSTALL_PATH/wp-config.php ]; then
echo >&2 "Error: Missing wp-config.php file."
exit 0
fi

if [ ! -d $WP_INSTALL_PATH/wp-content ]; then
echo >&2 "Error: Missing wp-content directory"
exit 0
fi

##
# Some like to remove all comments from the wp-config file, we need that for
# wp-cli to work properly. So we will re-add it.
##
if grep -q "/* That's all, stop editing!" $WP_INSTALL_PATH/wp-config.php; then
echo "Anchor found in wp-config."
else
echo "wp-cli anchor missing from wp-config, adding it back in"
sed -i "/wp-settings.php/i\/* That's all, stop editing! Happy publishing. *\/" $WP_INSTALL_PATH/wp-config.php
fi

##
# Configure our integrations
##

echo >&2 "Setting DB Host"
sudo -u www-data wp --path=$WP_INSTALL_PATH config set DB_HOST $WORDPRESS_DB_HOST
echo >&2 "Configuring nginx cache path"
sudo -u www-data wp --path=$WP_INSTALL_PATH config set RT_WP_NGINX_HELPER_CACHE_PATH '/var/run/nginx-cache'

echo >&2 "Configuring Cloudpress path"
sudo -u www-data wp --path=$WP_INSTALL_PATH config CS_PLUGIN_DIR '/opt/cs-wordpress-plugin-main'

# Remove old plugin
if [ -f "$WP_INSTALL_PATH/wp-content/mu-plugins/cstacks-config.php" ]; then
rm $WP_INSTALL_PATH/wp-content/mu-plugins/cstacks-config.php
fi

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

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

if [ -f /var/www/crontab ]; then
if grep -Fq 'wp-cron' /var/www/crontab; then
echo "wordpress user-cron configured, skipping..."
echo >&2 "wordpress user-cron configured, skipping..."
else
cat << EOF >> '/var/www/crontab'
Expand All @@ -24,7 +61,7 @@ EOF
fi
if [ -f /etc/cron.d/myapp ]; then
if grep -Fq 'wp-cron' /etc/cron.d/myapp; then
echo "wordpress system-cron configured, skipping..."
echo >&2 "wordpress system-cron configured, skipping..."
else
cat << EOF >> '/etc/cron.d/myapp'
Expand Down

0 comments on commit 3125539

Please sign in to comment.