-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
61 lines (53 loc) · 1.04 KB
/
setup.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
export PATH="/opt/homebrew/bin:$PATH"
collect_scripts() {
section=pre_scripts
while IFS=' ' read -r method arg _; do
arg=${arg#\"}
arg=${arg%\"}
case $method in
''|'#'*)
continue
;;
script)
if [ "$section" = pre_scripts ]; then
pre_scripts="$pre_scripts $arg"
else
section=post_scripts
post_scripts="$post_scripts $arg"
fi
;;
*)
if [ "$section" = post_scripts ]; then
echo "invalid formula $arg post_scripts section"
exit 1
fi
section=formula
;;
esac
done < "profiles/$1.rb"
}
collect_brewfile() {
brewfile="$brewfile
$(grep -Ev '^script +' "profiles/$1.rb")"
}
print_header() {
tput rev
echo "$1"
tput sgr0
}
run_scripts() {
for script in $1; do
print_header "$script"
bash "scripts/${script}.sh"
done
}
collect_scripts base
collect_scripts "$PROFILE"
collect_brewfile base
collect_brewfile "$PROFILE"
run_scripts "$pre_scripts"
print_header "bundle"
brew bundle --no-upgrade --no-lock --file=<(echo "$brewfile")
run_scripts "$post_scripts"