|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
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 |
5 | 42 |
|
6 | 43 | if [ -f "/opt/cs-wordpress-plugin-main/cstacks-config.php" ]; then |
7 | 44 | 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/ |
10 | 47 | fi |
11 | 48 |
|
12 | 49 | 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 |
14 | 51 |
|
15 | 52 | if [ -f /var/www/crontab ]; then |
16 | 53 | if grep -Fq 'wp-cron' /var/www/crontab; then |
17 | | - echo "wordpress user-cron configured, skipping..." |
| 54 | + echo >&2 "wordpress user-cron configured, skipping..." |
18 | 55 | else |
19 | 56 | cat << EOF >> '/var/www/crontab' |
20 | 57 |
|
|
24 | 61 | fi |
25 | 62 | if [ -f /etc/cron.d/myapp ]; then |
26 | 63 | 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..." |
28 | 65 | else |
29 | 66 | cat << EOF >> '/etc/cron.d/myapp' |
30 | 67 |
|
|
0 commit comments