Azure / wordpress-linux-appservice

MIT License
113 stars 71 forks source link

/home/site/wwwroot is overwritten when modified by startup.sh #63

Closed askpatrickw closed 1 year ago

askpatrickw commented 1 year ago

I'm using /home/dev/startup.sh to move Wordpress to a subfolder as per these instructions.

#!/bin/bash

logfile="/home/LogFiles/logfile.txt"
# Redirect all subsequent output to logfile
exec >> "$logfile"

echo "Update wp-config.php to include blog directory in WP_HOME"
sed -i "s/define('WP_HOME', \$http_protocol \. \$_SERVER\['HTTP_HOST'\]);/define('WP_HOME', \$http_protocol \. \$_SERVER\['HTTP_HOST'\] \. '\/blog\/');/" /home/site/wwwroot/wp-config.php

echo "create blog directory if it does not exist"
if [ ! -d /home/site/wwwroot/blog ]; then
    mkdir /home/site/wwwroot/blog
fi

echo "move all other files and directories to blog directory"
find /home/site/wwwroot -maxdepth 1 -not \( -name blog -o -name .htaccess -o -name index.php -o -name wwwroot \) -exec mv {} /home/site/wwwroot/blog \;

echo "copy .htaccess and index.php to blog directory"
cp /home/site/wwwroot/.htaccess /home/site/wwwroot/blog/
cp /home/site/wwwroot/index.php /home/site/wwwroot/blog/

# Close logfile
exec >&-

And it works, for a hot minute, but then something comes along and puts all the files back at /home/site/wwwroot.

askpatrickw commented 1 year ago

This is by design....

Unison is syncing WORDPRESS_HOME to HOME_SITE_LOCAL_STG

NOTE: HOME_SITE_LOCAL_STG is /var/www/wordpress

If you run top in your container you will see unison is running to sync files between the persisted storage in /home and the /var/www which is where Nginx is then updated to run from by app services.

unison /home/site/wwwroot /var/www/wordpress -auto -batch -times -copythreshold 1000 -prefer /home/site/wwwroot -repeat watch -ignore Path wp-content/uploads -perms 0 -log=false