-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
Β·183 lines (148 loc) Β· 4.42 KB
/
run.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
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
#!/usr/bin/env bash
set -e
# this runs the no-op command 'true' as super user in order to prompt for the password in the beginning
sudo true
function load_secrets {
local COMPONENT=$1
if [ -f ./"${COMPONENT}/secrets-example.sh" -a ! -f ./"${COMPONENT}/secrets.sh" ]
then
echo " π The secrets.sh file not found for ${COMPONENT}"
return 1
fi
if [ -f ./"${COMPONENT}/secrets.sh" ]
then
source ./"${COMPONENT}/secrets.sh"
echo " π Loaded secrets for ${COMPONENT}"
fi
}
function brew_install {
local FORMULA=$1
local INSTALL_GUARD_PATH=$2
local NAME=$3
if [ "$2" == "" ]
then
INSTALL_GUARD_PATH=/opt/homebrew/bin/${FORMULA}
fi
if [ "$3" == "" ]
then
NAME=${FORMULA}
fi
echo "π¦ Installing ${NAME} (brew) ..."
if [ -f "${INSTALL_GUARD_PATH}" ]
then
echo " π ${NAME} already installed"
return
fi
# load secrets, if any
load_secrets "${FORMULA}"
# any custom preinstall steps
if [ -f ./"${FORMULA}/preinstall.sh" ]
then
echo " π Running preinstall script for ${NAME}"
./"${FORMULA}/preinstall.sh"
fi
# main installation
brew install --quiet "${FORMULA}"
# any custom setup steps
if [ -f ./"${FORMULA}/setup.sh" ]
then
./"${FORMULA}/setup.sh"
echo " π ${NAME} configured"
fi
echo " β
${NAME} installed"
}
function configure {
local TARGET=$1
local CONFIGURE_GUARD_PATH=$2
echo "π Configuring ${TARGET} ..."
if [ -f "${CONFIGURE_GUARD_PATH}" ]
then
echo " π ${TARGET} already configured"
return
fi
# load secrets, if any
load_secrets "${TARGET}"
if [ $? -ne 0 ]
then
return 1
fi
# check for setup script
if [ ! -f ./"${TARGET}/setup.sh" ]
then
echo " π No setup script found for ${TARGET}"
return 2
fi
# run the setup script
./"${TARGET}/setup.sh"
echo " βοΈ ${TARGET} configured"
}
echo "π¦ Installing Homebrew ..."
if [ ! -f "/opt/homebrew/bin/brew" ]
then
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo '# Homebrew environment variable setup' >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
echo " β
Homebrew installed"
else
echo " π Homebrew already installed"
fi
# disable a few Homebrew features as they don't make sense during onboarding
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
#
# brew_install <formula> <install_guard_path> <name>
#
# tools
brew_install dos2unix
brew_install jq
brew_install yq
brew_install tree
brew_install watch
brew_install gh
brew_install fly
brew_install terraform
brew_install tmux
brew_install openconnect
brew install wget
#brew install openfortivpn
#brew_install forticlient-vpn "/Applications/FortiClient.app/Contents/MacOS/FortiClient" "FortiClient VPN"
brew_install google-chrome "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "Google Chrome"
brew_install visual-studio-code "/opt/homebrew/bin/code" "VS Code"
brew_install iterm2 "/Applications/iTerm.app/Contents/MacOS/iTerm2" iTerm2
brew_install microsoft-outlook "/Applications/Microsoft Outlook.app/Contents/MacOS/Microsoft Outlook" "Microsoft Outlook"
brew_install microsoft-teams "/Applications/Microsoft Teams.app/Contents/MacOS/Teams" "Microsoft Teams"
# Teleport issues:
# - Homebrew teleport is the latest version and this is not compatible with our old server
# - our teleport config point to /usr/local/bin/tsh which means an extra symlink would be required
#brew_install teleport "/opt/homebrew/bin/tsh"
brew_install awscli "/opt/homebrew/bin/aws"
brew_install "cloudfoundry/tap/cf-cli@7" "/opt/homebrew/bin/cf" "cf CLI"
#brew install s3cmd
#brew install bitwarden-cli
# programming languages and frameworks
brew_install lazydocker
brew_install kubectl
brew_install kubectx
brew_install k9s
brew_install stern
#brew install minikube
brew_install node "/opt/homebrew/bin/node" Node.js
#brew install nvm
brew_install python "/opt/homebrew/bin/python3" Python
brew_install go
#brew_install helm
#
# configure <target> [<configure_guard_path>]
#
configure zsh
configure ohmyzsh
configure iterm2
configure vim
configure git
# Note: this should be removed once Homebrew teleport is supported
configure teleport
configure docker
configure visual-studio-code
configure microsoft-company-portal "/Applications/Company Portal.app/Contents/MacOS/Company Portal"
configure keychain