Skip to content

Commit

Permalink
Merge pull request #215 from Automattic/speedup-mu-plugins
Browse files Browse the repository at this point in the history
refactor(vip-go-mu-plugins): speed up installation a bit
  • Loading branch information
sjinks authored Jun 1, 2024
2 parents cf962ef + 2510a69 commit bcfc447
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion features/src/vip-go-mu-plugins/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "vip-go-mu-plugins",
"name": "VIP Go MU Plugins",
"version": "2.0.1",
"version": "2.0.2",
"description": "Installs VIP Go MU Plugins into the Dev Environment",
"options": {
"enabled": {
Expand Down
17 changes: 5 additions & 12 deletions features/src/vip-go-mu-plugins/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,26 @@ if [ "$(id -u || true)" -ne 0 ]; then
exit 1
fi

: "${_REMOTE_USER:?"_REMOTE_USER is required"}"
: "${ENABLED:=}"
: "${BRANCH:=staging}"
: "${DEVELOPMENT_MODE:=false}"

if [ "${ENABLED}" != "false" ]; then
echo '(*) Installing VIP Go mu-plugins...'

if [ -z "${_REMOTE_USER}" ] || [ "${_REMOTE_USER}" = "root" ]; then
WEB_USER=www-data
else
WEB_USER="${_REMOTE_USER}"
fi

mkdir -p /wp/wp-content/mu-plugins
git clone --depth=1 --recurse-submodules --shallow-submodules https://github.com/Automattic/vip-go-mu-plugins.git /tmp/mu-plugins --branch "${BRANCH}" --single-branch
git clone --depth=1 https://github.com/Automattic/vip-go-mu-plugins-ext.git /tmp/mu-plugins-ext
git clone --depth=1 --recurse-submodules --shallow-submodules https://github.com/Automattic/vip-go-mu-plugins.git /tmp/mu-plugins --branch "${BRANCH}" --single-branch -j4
git clone --depth=1 https://github.com/Automattic/vip-go-mu-plugins-ext.git /tmp/mu-plugins-ext --single-branch
if [ "${DEVELOPMENT_MODE}" != 'true' ]; then
rsync -a /tmp/mu-plugins/ /tmp/mu-plugins-ext/ /wp/wp-content/mu-plugins --exclude-from="/tmp/mu-plugins/.dockerignore" --exclude-from="/tmp/mu-plugins-ext/.dockerignore"
find /wp/wp-content/mu-plugins -name .svn -type d -exec rm -rfv {} \; 2> /dev/null
find /wp/wp-content/mu-plugins -name .github -type d -exec rm -rfv {} \; 2> /dev/null
find /wp/wp-content/mu-plugins -name ".git*" -exec rm -rfv {} \; 2> /dev/null
find /wp/wp-content/mu-plugins \( -name .svn -o -name .github -o -name ".git*" \) -type d -exec rm -rfv {} \; 2> /dev/null
else
rsync -a /tmp/mu-plugins/ /tmp/mu-plugins-ext/ /wp/wp-content/mu-plugins
fi

rm -rf /tmp/mu-plugins /tmp/mu-plugins-ext

chown -R "${WEB_USER}:${WEB_USER}" /wp/wp-content/mu-plugins
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /wp/wp-content/mu-plugins
echo 'Done!'
fi

0 comments on commit bcfc447

Please sign in to comment.