-
Notifications
You must be signed in to change notification settings - Fork 14
/
plugins.sh
executable file
·72 lines (59 loc) · 1.6 KB
/
plugins.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# List the plugins that should be installed:
declare -a PluginList=("query-monitor" "user-switching" "https://github.com/Yoast/yoast-test-helper" "https://github.com/Yoast/wordpress-seo")
#######################################
# Activate the plugin for all running containers.
# Globals:
# None
# Arguments:
# slug
# Outputs:
# None
#######################################
function activate_plugin {
# Get all the running containers and store the amount
running_containers=$(docker ps --filter "ancestor=wordpress" --filter "label=com.yoast.plugin-development-docker.mainwpinstance" --format "{{.Names}}")
for container in $running_containers; do
$(echo ./wp.sh $container plugin install $1 --activate)
done
}
#######################################
# Install a plugin from a Github repository.
# Globals:
# None
# Arguments:
# plugin
# Outputs:
# None
#######################################
function install_github_plugin {
plugin=$1
slug=${plugin##*/}
if [ ! -d "./plugins/$slug" ]; then
cd plugins
$(echo git clone $plugin $slug)
cd -
fi
cd plugins/$slug/
if [ -f "composer.json" ]; then
composer install
fi
if [ -f "package.json" ]; then
yarn
fi
cd -
activate_plugin $slug
}
# Loop through the list and install the plugins.
for plugin in "${PluginList[@]}"; do
echo Installing $plugin.
if [[ $plugin == "https://github.com"* ]]; then
install_github_plugin $plugin
else
if [ -d "./plugins/$plugin/.git" ]; then
echo "Git clone found, not installing from WordPress.org."
else
activate_plugin $plugin
fi
fi
done