-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinstallMAC_PKG_POSTINSTALL.sh
executable file
·437 lines (382 loc) · 15 KB
/
installMAC_PKG_POSTINSTALL.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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
#!/bin/bash
#mac installer
USERNAME="$(stat -f '%Su' $HOME)"
USERGROUP="$(id -gn $USERNAME)"
USERHOME="$HOME"
echo "USER ${USERNAME}, GROUP ${USERGROUP}, HOME ${USERHOME}"
PYTHON="$(which python3)"
profile_file="$HOME/.bash_profile" #default
if [[ ! -s "$HOME/.bash_profile" && -s "$HOME/.profile" ]] ; then
profile_file="$HOME/.profile"
else
profile_file="$HOME/.bash_profile"
fi
if [[ -s "$HOME/.zshrc" ]] ; then
profile_file="$HOME/.zshrc"
fi
if [[ -s "$HOME/.zprofile" ]] ; then
profile_file="$HOME/.zprofile"
fi
echo "SHELL IS: $SHELL"
if [ $SHELL = "/bin/zsh" ] ; then
profile_file="$HOME/.zshrc"
fi
source $profile_file
if [ $1 = "local" ] ; then
pwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
else
pwd="/Applications/HandyHost/HandyHost" #set to applications dir
fi
echo "Installer PWD: $pwd"
if [[ -s "$USERHOME/.HandyHost/handyhost.pid" ]] ; then
HANDYHOSTPID="$(cat $USERHOME/.HandyHost/handyhost.pid)"
if ps -p $HANDYHOSTPID > /dev/null
then
echo "###### STOPPING EXISTING HANDYHOST ######" && \
kill $HANDYHOSTPID
fi
fi
if [[ -s "$USERHOME/.HandyHost/handyhostDaemon.pid" ]] ; then
HANDYHOSTPID="$(cat $USERHOME/.HandyHost/handyhostDaemon.pid)"
if ps -p $HANDYHOSTPID > /dev/null
then
echo "###### STOPPING EXISTING HANDYHOST ######" && \
kill $HANDYHOSTPID
fi
fi
###
if [ "${arch_name}" = "x86_64" ]; then
which -s sysctl
if [[ $? != 0 ]] ; then
homebrew_prefix_default=/usr/local
else
if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then
##its still arm64, emulated to x86_64......
homebrew_prefix_default=/opt/homebrew
# if ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' "${profile_file}" ; then
# echo "###Editing ${profile_file} to add $homebrew_prefix_default/bin variables###"
# echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "${profile_file}"
# source $profile_file
# fi
else
homebrew_prefix_default=/usr/local
fi
fi
fi
if [ "${arch_name}" = "arm64" ]; then
homebrew_prefix_default=/opt/homebrew
# if ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' "${profile_file}" ; then
# echo "###Editing ${profile_file} to add $homebrew_prefix_default/bin variables###"
# echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "${profile_file}"
# source $profile_file
# fi
fi
###
if [[ "$(uname -m)" == "arm64" ]]
then
homebrew_prefix_default=/opt/homebrew
# if ! grep -q 'eval "$(/opt/homebrew/bin/brew shellenv)"' "${profile_file}" ; then
# echo "###Editing ${profile_file} to add $homebrew_prefix_default/bin variables###"
# echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "${profile_file}"
# source $profile_file
# fi
else
homebrew_prefix_default=/usr/local
fi
echo "########## Installing HandyHost Dependencies... ##########"
#NOTE: just have mac users install this themselves...
# xcode-select --install > /dev/null 2>&1
# if [ 0 == $? ]; then
# sleep 1
# osascript <<EOD
# tell application "System Events"
# tell process "Install Command Line Developer Tools"
# keystroke return
# click button "Agree" of window "License Agreement"
# end tell
# end tell
# EOD
# else
# echo "Command Line Developer Tools are already installed!"
# fi
#command -v brew
#if [[ $? != 0 ]] ; then
if [[ ! -s "$homebrew_prefix_default/bin/brew" ]] ; then
# Install Homebrew
echo "******* HOMEBREW IS REQUIRED, EXITING ***********"
exit 1;
# BREWGROUP=$(ls -ld "/usr/local/bin" | awk '{print $4}')
# git clone https://github.com/Homebrew/brew "$homebrew_prefix_default/Homebrew" && \
# chown -R $USERNAME:$BREWGROUP "$homebrew_prefix_default/Homebrew" && \
# ln -s "$homebrew_prefix_default/Homebrew/bin/brew" "$homebrew_prefix_default/bin"
else
echo "Homebrew Already Installed. Skipping Install."
if ! grep -q ":$homebrew_prefix_default/bin" "${profile_file}" ; then
echo "###Editing ${profile_file} to add $homebrew_prefix_default/bin variables###"
#echo "export PATH=$PATH:$homebrew_prefix_default/bin" >> "${profile_file}"
echo 'eval "$($homebrew_prefix_default/bin/brew shellenv)"' >> "${profile_file}"
source $profile_file
fi
echo "Updating Homebrew..."
su - $USERNAME -c "$homebrew_prefix_default/bin/brew update"
fi
which -s python3
if [[ $? != 0 ]] ; then
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install [email protected]" && \
PYTHON="$(which python3)"
fi
if [[ ! -d "$homebrew_prefix_default/opt/nvm" ]] ; then
# Install nvm
echo "installing nvm" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install nvm" && \
mkdir "$USERHOME/.nvm"
else
echo "nvm was present"
fi
export NVM_DIR=$USERHOME/.nvm && \
[ -s "$homebrew_prefix_default/opt/nvm/nvm.sh" ] && \. "$homebrew_prefix_default/opt/nvm/nvm.sh" && \
[ -s "$homebrew_prefix_default/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$homebrew_prefix_default/opt/nvm/etc/bash_completion.d/nvm" && \
echo "Configuring HandyHost in $pwd" && \
NPMVERSION="$(cat $pwd/.nvmrc)"
echo "NPM VERSION TO INSTALL ${NPMVERSION}" && \
echo "PYTHON VERSION IS ${PYTHON}" && \
cd $pwd
if [[ "$(uname -m)" == "arm64" ]]
then
export PATH="/usr/local/bin":$PATH
arch -x86_64 zsh
#fn m1 only likes > v14...
NPMVERSION="16.13.0"
echo "$NPMVERSION" > "$pwd/.nvmrc"
nvm install $NPMVERSION
else
nvm install $NPMVERSION
fi
chown -R "$USERNAME:$USERGROUP" "$USERHOME/.nvm"
nvm use && \
sudo chown -R "$USERNAME:$USERGROUP" $pwd && \
su - $USERNAME -c "[ -s \"$homebrew_prefix_default/opt/nvm/nvm.sh\" ] && \. \"$homebrew_prefix_default/opt/nvm/nvm.sh\" && cd $pwd && nvm install $NPMVERSION && nvm use && npm config set python $PYTHON && cd $pwd && npm update && npm install --build-from-source --python=$PYTHON" && \
sudo chown -R "$USERNAME:$USERGROUP" ./node_modules && \
sudo npm install -g bower && \
sudo npm install -g forever && \
BOWER=$(which bower) && \
echo "Bower: $BOWER" && \
su - $USERNAME -c "[ -s \"$homebrew_prefix_default/opt/nvm/nvm.sh\" ] && \. \"$homebrew_prefix_default/opt/nvm/nvm.sh\" && cd $pwd && nvm install $NPMVERSION && nvm use && cd $pwd/client && $BOWER install" && \
mkdir -p $HOME/.HandyHost && \
sudo chown -R "$USERNAME:$USERGROUP" $HOME/.HandyHost && \
################################
########### SIA ################
################################
architecture=$(uname -m)
arch_name="amd64"
if [ "${architecture}" = "arm64" ]; then
arch_name="arm64"
fi
which -s go
if [[ $? != 0 ]] ; then
echo "installing golang"
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install go"
# wget "https://golang.org/dl/go1.17.darwin-${arch_name}.pkg" && \
# sudo rm -rf /usr/local/go && \
# sudo tar -C /usr/local -xzf "go1.17.darwin-${arch_name}.pkg"
# sudo chown -R "$USERNAME:$USERGROUP" /usr/local/go
else
echo "golang already present"
fi
#export PATH=$PATH:/usr/local/go/bin && \
if [[ ! -d "$USERHOME/.HandyHost/siaRepo" ]] ; then
mkdir -p $USERHOME/.HandyHost/siaRepo && \
git clone https://github.com/SiaFoundation/siad $USERHOME/.HandyHost/siaRepo
sudo chown -R "$USERNAME:$USERGROUP" $USERHOME/.HandyHost/siaRepo
else
cd $USERHOME/.HandyHost/siaRepo && \
git fetch --all && \
git pull
fi
cd $USERHOME/.HandyHost/siaRepo && make dependencies && make && \
if ! grep -q "${USERHOME}/go/bin" "${profile_file}" ; then
echo "###Editing ${profile_file} to add go env variables###"
echo "export PATH=$PATH:${USERHOME}/go/bin" >> "${profile_file}"
source $profile_file
fi
if [[ ! -s "$HOME/.zshrc" ]] ; then
cp "${profile_file}" "$HOME/.zshrc"
fi
#################################
########### DVPN ################
#################################
echo "PATH::: $PATH"
which -s docker
if [[ $? != 0 ]] ; then
echo "****** DOCKER NOT FOUND, EXITING ********"
exit 1;
# echo "Installing Docker..."
# su - $USERNAME -c "$homebrew_prefix_default/bin/brew install --cask docker" && \
# xattr -d -r com.apple.quarantine /Applications/Docker.app && \
# sudo open -a /Applications/Docker.app
else
echo "Docker Already Installed. Skipping."
echo "Starting Docker, this may take a minute..."
if (! docker stats --no-stream ); then
# On Mac OS this would be the terminal command to launch Docker
open --background /Applications/Docker.app
fi
fi
while ! docker system info > /dev/null 2>&1; do sleep 1; done
mkdir -p ${HOME}/.HandyHost/sentinelData && \
if [[ ! -d ${HOME}/.HandyHost/sentinelData/dvpn-node ]] ; then
echo "installing DVPN"
git clone https://github.com/sentinel-official/dvpn-node.git ${HOME}/.HandyHost/sentinelData/dvpn-node && \
cd ${HOME}/.HandyHost/sentinelData/dvpn-node && \
commit=$(git rev-list --tags --max-count=1) && \
git checkout $(git describe --tags ${commit}) && \
sudo chown -R "$USERNAME:$USERGROUP" $HOME/.HandyHost/sentinelData && \
docker build --file Dockerfile \
--tag sentinel-dvpn-node \
--force-rm \
--no-cache \
--compress .
else
echo "DVPN already installed, skipping"
fi
# if [[ -d ${HOME}/.HandyHost/sentinelData/dvpn-node ]] ; then
# echo "dvpn already exists, removing"
# rm -rf ${HOME}/.HandyHost/sentinelData/dvpn-node
# fi
################################
########### AKT ################
################################
echo "installing akash dependencies..." && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install cdrtools" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install p7zip" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install whois" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install coreutils" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install gnupg" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install [email protected]" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install jq" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install nmap" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install virtualenv"
which -s kubectl
if [[ $? != 0 ]] ; then
echo "Installing Kubectl..."
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install kubectl"
else
echo "kubectl Already Installed. Skipping."
fi
LATEST_KUBESPRAY=$(jq -r 'map(select(.prerelease != true)) | first | .tag_name' <<< $(curl --silent "https://api.github.com/repos/kubernetes-sigs/kubespray/releases"))
mkdir -p "${HOME}/.HandyHost/aktData" && \
if [[ ! -d "${HOME}/.HandyHost/aktData/kubespray" ]] ; then
mkdir -p "${HOME}/.HandyHost/aktData/kubespray" && \
cd "${HOME}/.HandyHost/aktData/kubespray" && \
git clone https://github.com/kubernetes-sigs/kubespray.git . && \
git checkout "$LATEST_KUBESPRAY"
virtualenv --python="$homebrew_prefix_default/opt/[email protected]/bin/python3.9" venv
. venv/bin/activate
pip3 install -r requirements.txt
else
echo "kubespray already installed, check for updates" && \
cd ${HOME}/.HandyHost/aktData/kubespray && \
git fetch --all && \
LOCAL_KUBESPRAY=$(git describe --tags)
echo "LOCAL: ${LOCAL_KUBESPRAY}, REMOTE: ${LATEST_KUBESPRAY}"
if [[ "$LOCAL_KUBESPRAY" == "$LATEST_KUBESPRAY" ]]; then
echo "Kubespray is up to date"
else
echo "kubespray is out of date, updating" && \
git fetch --all
git checkout "$LATEST_KUBESPRAY"
virtualenv --python="$homebrew_prefix_default/opt/[email protected]/bin/python3.9" venv
. venv/bin/activate
pip3 uninstall -y ansible
pip3 install -r requirements.txt
fi
fi
if [[ ! -d ${HOME}/.HandyHost/aktData/ubuntu-autoinstall-generator ]] ; then
echo "installing ubuntu-autoinstall-generator"
cd ${HOME}/.HandyHost/aktData && \
git clone https://github.com/HandyOSS/ubuntu-autoinstall-generator.git && \
cd ubuntu-autoinstall-generator && \
chmod +x ubuntu-autoinstall-generator.sh
else
echo "check for ubuntu-autoinstall-generator updates"
cd ${HOME}/.HandyHost/aktData/ubuntu-autoinstall-generator && \
git fetch && \
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [[ "$LOCAL" == "$REMOTE" ]]; then
echo "ubuntu-autoinstall-generator is up to date"
else
echo "ubuntu-autoinstall-generator is out of date, updating" && \
git pull origin master
chmod +x ubuntu-autoinstall-generator.sh
fi
fi
cd $HOME/.HandyHost/aktData && \
echo "Finished Installing Akash Dependencies" && \
export AKASH_NET="https://raw.githubusercontent.com/ovrclk/net/master/mainnet"
export AKASH_VERSION=$(/bin/bash "$pwd/aktAPI/getAkashLatestVersion.sh")
export AKASH_CHAIN_ID="$(curl -s "$AKASH_NET/chain-id.txt")"
export AKASH_NODE="$(curl -s "$AKASH_NET/rpc-nodes.txt" | gshuf -n 1)"
if [[ ! -d "${USERHOME}/.HandyHost/aktData/akashRepo" ]] ; then
mkdir -p "${USERHOME}/.HandyHost/aktData/akashRepo" && \
cd "${USERHOME}/.HandyHost/aktData/akashRepo" && \
git clone https://github.com/ovrclk/akash.git . && \
git checkout "$AKASH_VERSION"
else
cd "${USERHOME}/.HandyHost/aktData/akashRepo" && \
git checkout "$AKASH_VERSION"
fi
chown -R "$USERNAME:$USERGROUP" "${USERHOME}/.HandyHost/aktData/akashRepo" && \
echo "installing akash software..." && \
cd $HOME/.HandyHost/aktData && \
curl https://raw.githubusercontent.com/ovrclk/akash/master/godownloader.sh | sh -s -- "$AKASH_VERSION" && \
sudo chown -R "$USERNAME:$USERGROUP" $pwd/aktAPI && \
sudo chown -R "$USERNAME:$USERGROUP" $HOME/.HandyHost/aktData
if [ ! $1 = "local" ] ; then
echo "Building HandyHost.app" && \
cd "/Applications/HandyHost" && \
which -s platypus
if [[ $? != 0 ]] ; then
echo "Installing Platypus"
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install --cask platypus" && \
xattr -d -r com.apple.quarantine /Applications/Platypus.app && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew install platypus" && \
su - $USERNAME -c "$homebrew_prefix_default/bin/brew link platypus"
else
echo "Platypus Installed. Skipping."
fi
if [[ -d "/Applications/HandyHost/HandyHost.app" ]] ; then
echo "removing old HandyHost App Build" && \
rm -rf "/Applications/HandyHost/HandyHost.app"
fi
#m1 mac fun
if [[ "$(uname -m)" == "arm64" ]]
then
#platypus still looks in /usr/local/share so we'll just link it there for a hot minute..
if [[ ! -d "/usr/local/share" ]] ; then
LOCALSHARELOC="/usr/local/share"
else
LOCALSHARELOC="/usr/local/share/platypus"
fi
ln -s "$homebrew_prefix_default/share" $LOCALSHARELOC
fi
platypus -P /Applications/HandyHost/HandyHost/MacOS_Resources/HandyHost.platypus HandyHost.app
#m1 mac fun
if [[ "$(uname -m)" == "arm64" ]]
then
unlink $LOCALSHARELOC
fi
cp "$pwd/MacOS_Resources/handyhost.startup.plist" "$USERHOME/Library/LaunchAgents/handyhost.startup.plist" && \
chown "$USERNAME:$USERGROUP" "$USERHOME/Library/LaunchAgents/handyhost.startup.plist" && \
su - $USERNAME -c "launchctl unload -w \"$USERHOME/Library/LaunchAgents/handyhost.startup.plist\""; \
sleep 1 && \
su - $USERNAME -c "launchctl load -w \"$USERHOME/Library/LaunchAgents/handyhost.startup.plist\"" && \
echo "Done Compiling HandyHost.app" && \
sleep 10 && \
su - $USERNAME -c "open /Applications/HandyHost/HandyHost.app"
else
echo "Finished setting up local build"
fi
su - $USERNAME -c "[ -s \"$homebrew_prefix_default/opt/nvm/nvm.sh\" ] && \. \"$homebrew_prefix_default/opt/nvm/nvm.sh\" && cd $pwd && nvm install $NPMVERSION && nvm use && node $pwd/rainbow.js" && \
exit 0