-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhomebrew.sh
executable file
·71 lines (45 loc) · 1.55 KB
/
homebrew.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
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "../utils.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_homebrew_git_config_file_path() {
local path=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if path="$(brew --repository 2> /dev/null)/.git/config"; then
printf "%s" "$path"
return 0
else
print_error "Homebrew (get config file path)"
return 1
fi
}
install_homebrew() {
if ! cmd_exists "brew"; then
ask_for_sudo
printf "\n" | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" &> /dev/null
fi
}
opt_out_of_analytics() {
local path=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Try to get the path of the `Homebrew` git config file.
path="$(get_homebrew_git_config_file_path)" \
|| return 1
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Opt-out of Homebrew's analytics.
if [ "$(git config --file="$path" --get homebrew.analyticsdisabled)" != "true" ]; then
git config --file="$path" --replace-all homebrew.analyticsdisabled true &> /dev/null
print_result $? "Homebrew (opt-out of analytics)"
fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
main() {
print_info "• Homebrew"
install_homebrew
opt_out_of_analytics
brew_update
brew_upgrade
brew_external_sources
print_success "Homebrew installed"
}
main