For use with Local by Flywheel (Pressmatic) Volumes Addon to create symlinks for better IDE integration
#! /bin/bash | |
# Usage: | |
# | |
# local-sync.sh sitename -- add symlinks | |
# local-sync.sh sitename delete -- delete all symlinks, synced folders, or other | |
# | |
# The value for sitename must match the folder you have for the site. | |
# | |
# Requires Local by Flywheel Volumes Add-on | |
# https://github.com/getflywheel/local-addon-volumes | |
# | |
# You MUST add each item in your plugins, mu_plugins, and themes in as a local addon path. | |
# Yes it sucks | |
if [[ $1 = 'lezwatchtv' ]];then | |
plugins=( | |
'repositories/lwtv-plugin' | |
'repositories/lwcom-plugin' | |
'wordpress/plugins-git/bury-your-queers' | |
) | |
mu_plugins=( | |
'repositories/lezwatch-mu-plugins' | |
) | |
themes=( | |
'repositories/lwtv-genesis' | |
'repositories/lwcom-2017' | |
) | |
elif [[ $1 = 'plugins' ]];then | |
plugins=( | |
'wordpress/plugins-git/light-fingered-fish' | |
'wordpress/plugins-git/impostercide' | |
) | |
mu_plugins=( | |
) | |
themes=( | |
) | |
elif [[ $1 = 'dreamhost' ]];then | |
plugins=( | |
'wordpress/plugins-git/dreamobjects' | |
'wordpress/plugins-git/dreamspeed-cdn' | |
'wordpress/plugins-git/varnish-http-purge' | |
) | |
mu_plugins=( | |
) | |
themes=( | |
) | |
else | |
echo "There is no site named $1 to sync." | |
exit 1 | |
fi | |
devsites=( | |
$1 | |
) | |
# Change these to your setup. | |
# By default, Local is installed in /Users/YOURNAME/Local Site | |
devsource="/Users/mika/Development" | |
local_path="/Users/mika/Sites/Local Sites" | |
# You probably won't need to change these, unless WP is in a subfolder | |
docker_plugin_path="app/public/wp-content/plugins" | |
docker_mu_plugin_path="app/public/wp-content/mu-plugins" | |
docker_theme_path="app/public/wp-content/themes" | |
# Do not edit below this line | |
if [[ -n $2 && "delete" == $2 ]]; then | |
delete=true | |
else | |
delete=false | |
fi | |
for site in ${devsites[@]}; do | |
# Copy Plugins | |
for plugin in ${plugins[@]}; do | |
# if file exists then delete | |
if [[ -e "$local_path"/${site}/${docker_plugin_path}/${plugin##*/} ]]; then | |
rm -r "$local_path"/${site}/${docker_plugin_path}/${plugin##*/} | |
fi | |
# if not file exists AND not delete, make symlink | |
if [[ ! -e "$local_path"/${site}/${docker_plugin_path}/${plugin##*/} && $delete = false ]]; then | |
echo ${plugin##*/} 'symlink created' | |
ln -s $devsource/${plugin} "$local_path"/${site}/${docker_plugin_path} | |
fi | |
done | |
# Copy Themes | |
for theme in ${themes[@]}; do | |
# if file exists then delete | |
if [[ -e "$local_path"/${site}/${docker_theme_path}/${theme##*/} ]]; then | |
rm -r "$local_path"/${site}/${docker_theme_path}/${theme##*/} | |
fi | |
# if not file exists AND not delete, make symlink | |
if [[ ! -e "$local_path"/${site}/${docker_theme_path}/${theme##*/} && $delete = false ]]; then | |
echo ${theme##*/} 'symlink created' | |
ln -s $devsource/${theme} "$local_path"/${site}/${docker_theme_path} | |
fi | |
done | |
# Copy MU Plugins | |
for mu_plugin in ${mu_plugins[@]}; do | |
# if file exists then delete | |
if [[ -e "$local_path"/${site}/${docker_mu_plugin_path} ]]; then | |
rm -r "$local_path"/${site}/${docker_mu_plugin_path} | |
fi | |
# if not file exists AND not delete, make symlink | |
if [[ ! -e "$local_path"/${site}/${docker_mu_plugin_path} && $delete = false ]]; then | |
echo 'MU-Plugins symlink created' | |
ln -s $devsource/${mu_plugin} "$local_path"/${site}/${docker_mu_plugin_path} | |
fi | |
done | |
done |
This comment has been minimized.
This comment has been minimized.
Shouldn't the my-plugins section use Very clever. I like passing site name as parameter. |
This comment has been minimized.
This comment has been minimized.
Thanks a lot for the script. It helped me to complete my integration. (Flywheel, Netbeans & Git) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Fork of https://gist.github.com/afragen/748e4780b6057d4c41cf9e466557042a
Changes are mostly around
${plugin##*/}
type code, which was needed because I have my dev code in different places. That grabs the LAST value in a string, sowordpress/plugins-git/light-fingered-fish
becomeslight-fingered-fish