-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwick-run
executable file
·52 lines (39 loc) · 1.42 KB
/
wick-run
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
#!/usr/bin/env bash
wickOnLoad wickAddCommand run wickRun "Execute the formulas for a given role"
# Public: Runs a single role and passes additional arguments to the role.
#
# $1 - Role to execute
# $2-@ - Arguments to pass to the role's script.
#
# Returns true on success, 1 if there are problems with the role.
wickRun() {
local formula formulaNumber i
if [[ -z "${1-}" ]]; then
echo "You must specify a role to execute." >&2
return 1
fi
# Set up the KV store. This must be migrated to the destination machine
# when Wick gets split into a provisioner/provisionee model.
wickKvInit
# Run the role.
wickLoadRole "$@"
if [[ ${#WICK_FORMULA_COMMANDS[@]} -eq 0 ]]; then
echo "No formulas listed or no run scripts found for the formulas."
# This is not an error with Wick.
return 0
fi
i=0
while [[ $i -lt ${#WICK_FORMULA_COMMANDS[@]} ]]; do
# Use echo here - do not log this list to a file because the commands
# may have arguments that contain sensitive information.
echo "Order of formulas to execute [$((i + 1))]: ${WICK_FORMULA_COMMANDS[$i]}"
i=$((i + 1))
done
formulaNumber=1
for formula in "${WICK_FORMULA_COMMANDS[@]}"; do
# CAREFUL - keep the formula quoted here.
wickRunFormula "$formula" "$formulaNumber"
formulaNumber=$((formulaNumber + 1))
done
echo "Done."
}