-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·254 lines (204 loc) · 7.04 KB
/
install.sh
File metadata and controls
executable file
·254 lines (204 loc) · 7.04 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/env bash
#
# To install:
#
# /bin/bash -c "$(curl -fsSL wac.fyi/mac)"
#
{ # this ensures the entire script is downloaded #
GITHUB_REPO="https://raw.githubusercontent.com/WeAllCode/laptop/main"
output() {
printf "\n\n✅ %s\n" "$1"
# TODO: Is this okay? https://unix.stackexchange.com/a/452568
# setopt local_options no_notify no_monitor
say -r 300 "$1" &
}
# install all software updates
runSoftwareUpdate() {
output "Installing software updates"
sudo softwareupdate -i -a
}
enableGuestAccount() {
output "Enabling guest account"
sudo sysadminctl -guestAccount on
}
setAutoLoginUser() {
output "Setting auto-login user"
sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser -string "Guest"
}
disableAutoLoginUser() {
output "Disabling auto-login user"
sudo defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
}
enableFastUserSwitching() {
output "Enabling fast user switching"
sudo defaults write /Library/Preferences/.GlobalPreferences MultipleSessionEnabled -bool YES
# TODO: figure out how to enable fast user switching menu extra
# output "Enabling fast user switching menu extra"
# sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool YES
# # enable icon in menu bar
# sudo defaults write com.apple.systemuiserver menuExtras -array-add "/System/Library/CoreServices/Menu Extras/User.menu"
}
installHomebrew() {
# Check if Homebrew is installed
if ! command -v brew >/dev/null; then
output "Installing Homebrew"
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
output "Homebrew already installed"
fi
}
tapHomebrew() {
output "Tapping $1"
brew tap "$1"
}
brewCaskPin() {
output "Pinning $1"
brew cu pin "$2"
}
disableHomebrewAnalytics() {
output "Disabling Homebrew analytics"
brew analytics off
}
updateBrew() {
output "Updating Homebrew"
brew update
}
upgradeBrew() {
output "Upgrading Homebrew"
brew cu --quiet --force --yes
}
brewUntap() {
if brew tap | grep "^$1$" >/dev/null; then
output "Untapping $1"
brew untap "$1"
else
output "$1 already untapped"
fi
}
brewInstall() {
NAME=$1
FORMULA_NAME=$2
SPECIFIC_URL=$3
# Check if $NAME is installed
if ! brew list -1 | grep "^$FORMULA_NAME$" >/dev/null; then
output "Installing $NAME"
if [ -z "$SPECIFIC_URL" ]; then
brew install "$FORMULA_NAME"
else
# shellcheck disable=2086
brew install $SPECIFIC_URL
fi
else
output "$NAME already installed"
# output "Upgrading $NAME"
# if [ -z "$SPECIFIC_URL" ]; then
# brew upgrade "$FORMULA_NAME"
# else
# # shellcheck disable=2086
# brew upgrade $SPECIFIC_URL
# fi
fi
}
brewUninstall() {
NAME=$1
FORMULA_NAME=$2
# Check if $NAME is installed
if brew list -1 | grep "^$FORMULA_NAME$" >/dev/null; then
output "Uninstalling $NAME"
brew uninstall --force "$FORMULA_NAME"
else
output "$NAME already uninstalled"
fi
}
installPurePrompt() {
# Install Pure Prompt if not installed
output "Installing Pure Prompt"
npm install --global pure-prompt
}
updateZshRC() {
output "Updating .zshrc"
curl -fsSL "$GITHUB_REPO/.zshrc" -o "$HOME/.zshrc"
}
installXCode() {
# Install XCode if not installed
if ! command -v xcode-select >/dev/null; then
output "Installing XCode"
# brew install mas
# mas install 497799835
xcode-select --install
else
output "XCode already installed"
fi
}
installPythonPackage() {
# Upgrade pip
output "Upgrade pip"
python3 -m pip install --upgrade --force-reinstall pip
# Install python packages
output "Install python packages"
python3 -m pip install --upgrade --force-reinstall weallcode_robot
pip3 install --upgrade --force-reinstall weallcode_robot
}
updateDock() {
output "Updating Dock"
dockutil --remove all \
--add /Applications/Google\ Chrome.app \
--add /Applications/Visual\ Studio\ Code.app
}
setLogonScript() {
logonScriptLocation="/Users/Shared/logon.script.sh"
logonScriptURL="$GITHUB_REPO/logon.script.sh"
output "Downloading logon script"
sudo curl -fsSL "$logonScriptURL" -o "$logonScriptLocation"
sudo chown root "$logonScriptLocation"
sudo chmod +x "$logonScriptLocation"
# ---------------------------------------------
logonPlistLocation="/Library/LaunchAgents/org.weallcode.logon.plist"
logonPlistURL="$GITHUB_REPO/org.weallcode.logon.plist"
# Download logon plist
output "Downloading logon plist"
sudo curl -fsSL "$logonPlistURL" -o "$logonPlistLocation"
if launchctl list | grep -q "org.weallcode.logon"; then
output "Unloading org.weallcode.logon"
sudo launchctl unload -w "$logonPlistLocation"
launchctl unload -w "$logonPlistLocation"
fi
output "Enabling logon plist"
sudo chown root "$logonPlistLocation"
sudo launchctl load -w "$logonPlistLocation"
launchctl load -w "$logonPlistLocation"
}
# runSoftwareUpdate # Runs slow
enableGuestAccount
# setAutoLoginUser # disabled for now
disableAutoLoginUser
enableFastUserSwitching
installHomebrew
disableHomebrewAnalytics
installXCode
updateBrew
brewUninstall "NextDNS" "nextdns"
brewUninstall "Firefox" "firefox"
brewUntap "homebrew/core"
brewUntap "homebrew/cask"
tapHomebrew "buo/cask-upgrade" # brew cu
brewInstall "Google Chrome" "google-chrome"
brewInstall "Visual Studio Code" "visual-studio-code"
brewInstall "Git" "git"
# brewInstall "Vim" "vim"
brewInstall "Wallpaper Changer" "wallpaper"
brewInstall "Python 3.x" "python3"
# brewInstall "Node" "node"
# brewInstall "Unity" "unity" "--cask https://raw.githubusercontent.com/Homebrew/homebrew-cask/4dc5194f3806a9b10a289cf4eaf68f7eb5528691/Casks/unity.rb" # 2022.1.23f1,9636b062134a
brewCaskPin "Unity" "unity"
tapHomebrew "hpedrorodrigues/tools"
brewUninstall "Dockutil" "dockutil"
brewUptap "hpedrorodrigues/tools/dockutil"
brewInstall "Dockutil" "dockutil"
installPurePrompt
updateZshRC
upgradeBrew
installPythonPackage
updateDock
setLogonScript
}