-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmac
executable file
·164 lines (129 loc) · 5.41 KB
/
mac
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
START_TIME=$(date +"%T")
# Get the some path - used to include other files
SCRIPT_PATH=`dirname "$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"`
PARENT_PATH=`dirname "$SCRIPT_PATH"`
CONFIG_PATH="$SCRIPT_PATH/config"
BIN_PATH="$SCRIPT_PATH/bin"
# set some vars to references from one place
FUNCTIONS="$BIN_PATH/functions.sh"
# work out which version of mac os we are running, as catalina is currently in beta
# and I want to limit what is installed
MAJOR_MAC_VERSION=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}')
if [ "$MAJOR_MAC_VERSION" == "10.14" ]; then
MAC_OS_NAME="mojave"
elif [ "$MAJOR_MAC_VERSION" == "10.15" ]; then
MAC_OS_NAME="catalina"
fi
BREWFILE="$CONFIG_PATH/Brewfile"
# import the functions
source "$FUNCTIONS"
echo "##################################################################"
echo " This is the bootstap script to setup your mac as a "
echo " development machine, to get you running asap "
echo " This is going to ask for your password. Only provide "
echo " it if you have read this script and fully understand "
echo " what is it going to do to your system "
echo " "
echo " **************** YOU HAVE BEEN WARNED ***************** "
echo " "
echo "##################################################################"
# shellcheck disable=SC2154
# Print out the failure when exiting the script
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
# exit if there is an error
set -e
echo "
#########################################################################
Your password (assuming you are setup as an admin) is need to install the
latest Max OS updates and to ensure permssions on homebrew are setup
correctly.
Please make sure you have read this script and are happy to provide
your password.
#########################################################################
"
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
########################[ INSTALL depending on OS ]############################
RUNNING_SYSTEM=`uname -s`
# We're on a Mac, install and setup using homebrew.
if [ "$RUNNING_SYSTEM" == "Darwin" ]
then
########################[ Updating Mac OS ]####################################
# Update mac software
echo "Updating mac os"
sudo softwareupdate -i -a
########################[ Command line xcode ]#################################
echo "Install Apple command line tools"
COMMANDLINE_TOOLS="/Library/Developer/CommandLineTools"
if [ ! -d "$COMMANDLINE_TOOLS" ]; then
xcode-select --install
fi
########################[ Check homebrew is installed ]########################
echo "Using homebrew to install software "
# Set the install location for homebrew... use the default.
HOMEBREW_PREFIX="/usr/local"
if [ -d "$HOMEBREW_PREFIX" ]; then
if ! [ -r "$HOMEBREW_PREFIX" ]; then
sudo chown -R "$LOGNAME:admin" /usr/local
fi
else
sudo mkdir "$HOMEBREW_PREFIX"
sudo chflags norestricted "$HOMEBREW_PREFIX"
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX"
fi
# Check to see if homebrew is installed, and if not then install it
if ! command -v brew >/dev/null; then
echo "Installing Homebrew ..."
#curl -fsS 'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
export PATH="/usr/local/bin:$PATH"
fi
if brew list | grep -Fq brew-cask; then
echo "Uninstalling old Homebrew-Cask ..."
brew uninstall --force brew-cask
fi
########################[ Install homebrew apps ]##############################
echo "Updating Homebrew formulae ..."
brew update --force # https://github.com/Homebrew/brew/issues/1151
echo "Updated forcefully"
echo "Installing apps from Brewfile"
# generic apps for all engineers
if brew bundle --file="$BREWFILE"; then
echo "All items in Brewfile were installed successfully."
else
echo "Some items in Brewfile were not installed successfully."
fi
########################[ Run user customisations ]############################
# run anything from the user local file
if [ -f "$USER.local" ]; then
echo "Running customisations using preferences from $USER.local"
# shellcheck disable=SC1090
sh "$USER.local"
fi
########################[ OSX Customisations ]#################################
# if [ -f "osx-customisations.sh" ]; then
# echo "Customising OSX... (inspired by https://github.com/mathiasbynens/dotfiles)"
# # shellcheck disable=SC1090
# sh osx-customisations.sh
# fi
###############################################################################
########################[ Linux Customisations ]###############################
elif [ "$RUNNING_SYSTEM" == "Linux" ]
then
echo "Install for Linux"
sh linux.sh
else
fail "Unfortunately your system is not currently supported with this script"
fi
########################[ GIT ]################################################
# echo "Setup github account on machine"
# sh git_config.sh
brew cleanup
rm -f -r /Library/Caches/Homebrew/*
END_TIME=$(date +"%T")
echo "Started at : $START_TIME"
echo "Ended at : $END_TIME"
echo "DONE!"