-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·53 lines (38 loc) · 963 Bytes
/
install.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
#!/bin/sh
set -o nounset -o pipefail -o errexit
# Load all variables from .env and export them all for Ansible to read
set -o allexport
source "$(dirname $0)/.env"
set +o allexport
installHomeBrew() {
if ! [[ $(which brew) ]]; then
echo "\n=> Installing Homebrew\n"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
installAnsible() {
echo "\n=> Installing Ansible\n"
brew install ansible
}
buildAnsible() {
echo "\n=> Building Ansible Playbooks\n"
exec ansible-playbook ansible/main.yml -i ansible/hosts -v -K $@
}
run() {
installHomeBrew
if ! [[ $(which ansible) ]]; then
installAnsible
buildAnsible $@
else
buildAnsible $@
fi
echo "\n=> Finished!\n"
}
# Run...
cd $(dirname $0) # Run script from script root no matter where it's called
if [ -f $(pwd)/.env ]; then
run $@
else
echo "\n=> Missing '$(pwd)/.env'. Make one first! Goodbye."
fi
exit 0