-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·58 lines (45 loc) · 1.3 KB
/
bootstrap.sh
File metadata and controls
executable file
·58 lines (45 loc) · 1.3 KB
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
#!/usr/bin/env bash
set -euo pipefail
readonly INSTALL_CHECK_INTERVAL_SECONDS=5
is_xcode_command_line_tools_installed() {
xcode-select -p >/dev/null 2>&1
}
start_xcode_command_line_tools_installation() {
local output
local exit_code
echo "Xcode Command Line Tools are not installed."
echo "Starting the installer..."
if output="$(xcode-select --install 2>&1)"; then
[ -z "$output" ] || printf '%s\n' "$output"
return
else
exit_code=$?
fi
case "$output" in
*"already installed"* | *"already been requested"*)
printf '%s\n' "$output"
;;
*)
[ -z "$output" ] || printf '%s\n' "$output" >&2
echo "Failed to start the Xcode Command Line Tools installer." >&2
exit "$exit_code"
;;
esac
}
wait_for_xcode_command_line_tools_installation() {
echo "Waiting for Xcode Command Line Tools installation to complete."
echo "Press Ctrl+C to stop waiting."
until is_xcode_command_line_tools_installed; do
sleep "$INSTALL_CHECK_INTERVAL_SECONDS"
done
echo "Xcode Command Line Tools installation is complete."
}
main() {
if is_xcode_command_line_tools_installed; then
echo "Xcode Command Line Tools are already installed."
exit 0
fi
start_xcode_command_line_tools_installation
wait_for_xcode_command_line_tools_installation
}
main "$@"