-
Notifications
You must be signed in to change notification settings - Fork 5
/
start.sh
executable file
·61 lines (48 loc) · 1.23 KB
/
start.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
#!/bin/bash
set -e
readonly REPOSITORY="https://github.com/pivovarit/mac-os-playbook"
TARGET="$(pwd)"
RED=""
GREEN=""
BLUE=""
RESET=""
error() {
echo "${RED}""Error: $@""${RESET}" >&2
exit 1
}
ok() {
echo "${GREEN}""Info | OK | $@""${RESET}"
}
installing() {
echo "${BLUE}""Info | Install | $@""${RESET}"
}
generate_temp_dir() {
PLAYBOOK_LOCATION=$(mktemp -d -t playbook)
trap 'rm -rf "$PLAYBOOK_LOCATION"' EXIT
git clone -q --depth=1 "${REPOSITORY}" "$PLAYBOOK_LOCATION" || error "git clone of playbook repo failed, run with --local if already cloned"
TARGET="$PLAYBOOK_LOCATION"
}
if [ -t 1 ]; then
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
BLUE=$(printf '\033[34m')
RESET=$(printf '\033[m')
fi
[[ "$1" = "--local" ]] || generate_temp_dir
if [[ $(/usr/bin/gcc 2>&1) =~ "no developer tools were found" ]] || [[ ! -x /usr/bin/gcc ]];
then
installing "xcode"
xcode-select --install
else
ok "xcode"
fi
if [[ ! -x /usr/local/bin/ansible ]];
then
installing "ansible"
brew update
brew install ansible
else
ok "ansible"
fi
export PATH=/usr/local/bin:$PATH
cd "$TARGET" && ansible-playbook playbook.yml -K