-
Notifications
You must be signed in to change notification settings - Fork 1
/
macdev.sh
executable file
·120 lines (101 loc) · 2.98 KB
/
macdev.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
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
#!/bin/bash
# Define directories.
dirCommandLineTools="/Library/Developer/CommandLineTools"
UNAME_MACHINE="$(/usr/bin/uname -m)"
if [[ "${UNAME_MACHINE}" == "arm64" ]]
then
# On ARM macOS, this script installs to /opt/homebrew only
binHomebrew="/opt/homebrew/bin/brew"
else
# On Intel macOS, this script installs to /usr/local only
binHomebrew="/usr/local/bin/brew"
fi
# Define apps.
app1Password="/Applications/1Password 7.app"
appDocker="/Applications/Docker.app"
appFirefox="/Applications/Firefox.app"
appGoogleChrome="/Applications/Google Chrome.app"
appiTerm="/Applications/iTerm.app"
appOpenLens="/Applications/OpenLens.app"
appPhpStorm="/Applications/PhpStorm.app"
appPostman="/Applications/Postman.app"
appSlack="/Applications/Slack.app"
# Define tools.
toolAWSIAM="/usr/local/opt/aws-iam-authenticator"
toolDDev="/usr/local/opt/ddev"
toolRename="/usr/local/opt/rename"
toolVim="/usr/local/opt/vim"
toolWget="/usr/local/opt/wget"
function checkRequirements() {
# Install XCode CommandLineTools.
if xcode-select --install 2>&1 | grep installed;
then
echo "XCode CommandLineTools already installed."
else
echo "XCode CommandLineTools not installed yet."
echo "Installing XCode CommandLineTools..."
fi
# Install or update Homebrew.
if [ ! -f "${binHomebrew}" ]
then
echo -e "Install Homebrew\n"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo -e "Add drud/ddev repository"
${binHomebrew} tap drud/ddev
elif [ -f "${binHomebrew}" ]
then
echo -e "Update Homebrew\n"
${binHomebrew} tap drud/ddev
${binHomebrew} update
else
echo -e "ERROR: Homebrew can't be installed or updated"
exit 1
fi
}
function checkApp() {
if [ ! -d "$1" ]
then
echo -e "Install $2\n"
${binHomebrew} install --cask $3
elif [ -d "$1" ]
then
echo -e "$2: already installed"
${binHomebrew} upgrade --cask $3
fi
}
function checkTool() {
if [ ! -e "$1" ]
then
echo -e "Install $2\n"
${binHomebrew} install $3
elif [ -d "$1" ]
then
echo -e "$2: already installed"
fi
}
# Run check requirements for MacDev script.
checkRequirements
# Install some helper tools.
checkTool "${toolRename}" "rename" "rename"
checkTool "${toolVim}" "Vim" "vim"
checkTool "${toolWget}" "wget" "wget"
# Install terminal related stuff.
checkApp "${appiTerm}" "iTerm" "iterm2"
# Install browsers.
checkApp "${appFirefox}" "Firefox" "firefox"
checkApp "${appGoogleChrome}" "Google Chrome" "google-chrome"
# Install docker.
checkTool "${toolAWSIAM}" "AWS IAM" "aws-iam-authenticator"
checkApp "${appDocker}" "Docker" "docker"
checkTool "${toolDDev}" "DDev" "ddev"
checkApp "${appLens}" "OpenLens" "openlens"
# Install IDE.
checkApp "${appPhpStorm}" "PhpStorm" "phpstorm"
# Install working helpers.
checkApp "${app1Password}" "1Password" "1password"
checkApp "${appPostman}" "Postman" "postman"
checkApp "${appSlack}" "Slack" "slack"
# Upgrade installed stuff.
${binHomebrew} upgrade
# Cleanup Homebrew.
${binHomebrew} cleanup