-
Notifications
You must be signed in to change notification settings - Fork 827
Expand file tree
/
Copy pathprovisioners.sh
More file actions
172 lines (152 loc) · 5 KB
/
Copy pathprovisioners.sh
File metadata and controls
172 lines (152 loc) · 5 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
. "/srv/provision/provisioners.sh"
export VVV_LOG=""
function vvv_run_provisioner() {
local STATUS
bash $@
STATUS=$?
if [ "${STATUS}" -eq 0 ]; then
return $STATUS
fi
exit $STATUS
}
# provisioners
function pre_hook() {
# provison-pre.sh
#
# acts as a pre-hook to our default provisioning script. Anything that
# should run before the shell commands laid out in provision.sh (or your provision-custom.sh
# file) should go in this script. If it does not exist, no extra provisioning will run.
if [[ -f "/srv/provision/provision-pre.sh" ]]; then
VVV_LOG="pre"
vvv_run_provisioner /srv/provision/provision-pre.sh
fi
}
function post_hook() {
# provision-post.sh
#
# acts as a post-hook to the default provisioning. Anything that should
# run after the shell commands laid out in provision.sh or provision-custom.sh should be
# put into this file. This provides a good opportunity to install additional packages
# without having to replace the entire default provisioning script.
if [[ -f "/srv/provision/provision-post.sh" ]]; then
VVV_LOG="post"
vvv_run_provisioner /srv/provision/provision-post.sh
fi
}
function provision_dashboard() {
local dashboard_repo=$(get_config_value "dashboard.repo" "https://github.com/Varying-Vagrant-Vagrants/dashboard.git")
local dashboard_branch=$(get_config_value "dashboard.branch" "master")
VVV_LOG="dashboard"
vvv_run_provisioner /srv/provision/provision-dashboard.sh "${dashboard_repo}" "${dashboard_branch}"
}
function provision_utility_sources() {
local name=()
local repo=()
local branch=()
local key="utility-sources"
local utilities=$(get_config_type "${key}")
if [[ "${utilities}" == "struct" ]]; then
utilities=($(get_config_keys "${key}"))
else
utilities=$(get_config_value "${key}")
if [[ ! -z "${utilities}" ]]; then
vvv_error "Malformed ${key} config"
fi
utilities=()
fi
containsElement "core" "${utilities}"
if [[ $? -ne 0 ]]; then
name+=("core")
repo+=("https://github.com/Varying-Vagrant-Vagrants/vvv-utilities.git")
branch+=("master")
fi
local utility
for utility in "${utilities[@]}"; do
type=$(get_config_type "${key}.${utility}")
name+=(${utility})
if [[ "${type}" == "str" ]]; then
repo+=($(get_config_value "${key}.${utility}"))
branch+=(master)
else
repo+=($(get_config_value "${key}.${utility}.repo"))
branch+=($(get_config_value "${key}.${utility}.branch" "master"))
fi
done
local i
for i in ${!name[@]}; do
VVV_LOG="utility-source-${name[$i]}"
vvv_run_provisioner /srv/provision/provision-utility-source.sh "${name[$i]}" "${repo[$i]}" "${branch[$i]}"
done
}
function provision_utilities() {
local groups=($(get_config_keys utilities))
local group
local utility
for group in ${groups[@]}; do
local utilities=($(get_config_values utilities."${group}"))
for utility in ${utilities[@]}; do
provision_utility "${group}" "${utility}"
done
done
}
function provision_utility() {
local group=$1
local utility=$2
VVV_LOG="utility-${group}-${utility}"
vvv_run_provisioner /srv/provision/provision-utility.sh "${group}" "${utility}"
}
function provision_sites() {
local sites=($(get_config_keys sites))
local site
for site in ${sites[@]}; do
provision_site "${site}"
done
}
function provision_site() {
local site=$1
local skip_provisioning=$(get_config_value "sites.${site}.skip_provisioning" "False")
if [[ $skip_provisioning == "True" ]]; then
return
fi
local repo=$(get_config_type "sites.${site}")
if [[ "${repo}" == "str" ]]; then
repo=$(get_config_value "sites.${site}" "")
else
repo=$(get_config_value "sites.${site}.repo" "")
fi
local branch=$(get_config_value "sites.${site}.branch" "master")
local vm_dir=$(get_config_value "sites.${site}.vm_dir" "/srv/www/${site}")
local nginx_upstream=$(get_config_value "sites.${site}.nginx_upstream" "php")
VVV_LOG="site-${site}"
vvv_run_provisioner /srv/provision/provision-site.sh "${site}" "${repo}" "${branch}" "${vm_dir}" "${skip_provisioning}" "${nginx_upstream}"
}
function provision_main() {
# provision.sh or provision-custom.sh
#
# By default, Vagrantfile is set to use the provision.sh bash script located in the
# provision directory. If it is detected that a provision-custom.sh script has been
# created, that is run as a replacement. This is an opportunity to replace the entirety
# of the provisioning provided by default.
if [[ -f "/srv/provision/provision-custom.sh" ]]; then
VVV_LOG="main-custom"
vvv_run_provisioner /srv/provision/provision-custom.sh
else
VVV_LOG="main"
vvv_run_provisioner /srv/provision/provision.sh
fi
# refresh VVV_CONFIG, as the main provisioner actually creates the /srv/vvv/config.yml
configs=(
/srv/vvv/config.yml
/vagrant/config.yml
/vagrant/vvv-config.yml
)
VVV_CONFIG=/srv/vvv/config.yml
for item in ${configs[*]}; do
if [[ -f $item ]]; then
VVV_CONFIG=$item
break
fi
done
export VVV_CONFIG
}