forked from divad12/khan-dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 18
/
mac-setup-elevated.sh
executable file
·94 lines (71 loc) · 2.57 KB
/
mac-setup-elevated.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# We need elevated permissions for a small subset of setup tasks. Isolate these
# here so that we can test/qa scripts without babysitting them.
# Bail on any errors
set -e
SCRIPT=$(basename $0)
usage() {
cat << EOF
usage: $SCRIPT [options]
--root <dir> Use specified directory as root (instead of HOME).
EOF
}
# Install in $HOME by default, but can set an alternate destination via $1.
ROOT="${ROOT:-$HOME}"
# Process command line arguments
while [[ "$1" != "" ]]; do
case $1 in
-r | --root)
shift
ROOT=$1
;;
-h | --help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
shift
done
# The directory to which all repositories will be cloned.
REPOS_DIR="$ROOT/khan"
# Derived path location constants
DEVTOOLS_DIR="$REPOS_DIR/devtools"
# Load shared setup functions.
. "$DEVTOOLS_DIR"/khan-dotfiles/shared-functions.sh
install_protoc() {
# If the user has a homebrew version of protobuf installed, uninstall it so
# we can manually install our own version in /usr/local.
if brew list --formula | grep -q '^protobuf$'; then
echo "Uninstalling homebrew version of protobuf\n"
brew uninstall protobuf
fi
brew install -q wget
# The mac and linux installation process is the same from here on out aside
# from the platform-dependent zip archive.
install_protoc_common https://github.com/protocolbuffers/protobuf/releases/download/v3.4.0/protoc-3.4.0-osx-x86_64.zip
}
# TODO(ericbrown): Detect pre-requisites (i.e. brew, etc.)
# Run sudo once at the beginning to get the necessary permissions.
echo "This setup script needs your password to install things as root."
sudo sh -c 'echo Thanks'
if [[ $(uname -m) = "arm64" ]]; then
# install rosetta on M1 (required for openjdk and other things)
# This will work here, but it requires input and I'd rather just have it in docs
#sudo softwareupdate --install-rosetta
# Add homebrew to path on M1 macs
export PATH=/opt/homebrew/bin:$PATH
fi
"$DEVTOOLS_DIR"/khan-dotfiles/bin/install-mac-homebrew.py
# Other brew related installers that require sudo
"$DEVTOOLS_DIR"/khan-dotfiles/bin/install-mac-mkcert.py
"$DEVTOOLS_DIR"/khan-dotfiles/bin/edit-system-config.sh
# It used to be we needed to install xcode-tools, now homebrew does this for us
#"$DEVTOOLS_DIR"/khan-dotfiles/bin/install-mac-gcc.sh
install_protoc
# We use java for our google cloud dataflow jobs that live in webapp
# (as well as in khan-linter for linting those jobs)
install_mac_java