forked from UCSD-E4E/baboons-on-the-move
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli-mac
executable file
·43 lines (33 loc) · 1.27 KB
/
cli-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
#!/bin/bash
function BrewInstallCask {
brew list --cask | grep $1 > /dev/null
if [ $? -ne 0 ]
then
brew install --cask $1
fi
}
# Install dependencies
BrewInstallCask xquartz
BrewInstallCask virtualbox
BrewInstallCask vagrant
MEMORY=`sysctl -a | grep '^hw\.m' | awk -F": " '/hw.memsize:/ { print $2 }'`
VAGRANT_MEMORY=`echo "($MEMORY*0.6)/(1024^2)" | bc`
CPUS=`sysctl -a | grep '^machdep\.cpu\.core_count' | awk -F": " '/machdep.cpu.core_count:/ { print $2 }'`
VAGRANT_CPUS=$(( $CPUS / 2 ))
echo "vb:" > env.yml
echo " cpus: $VAGRANT_CPUS" >> env.yml
echo " memory: $VAGRANT_MEMORY" >> env.yml
WIDTH=`system_profiler SPDisplaysDataType | grep Resolution | awk -F": " '/Resolution:/ { print $2 }' | awk -F" x " '{ print $1 }'`
HEIGHT=`system_profiler SPDisplaysDataType | grep Resolution | awk -F": " '/Resolution:/ { print $2 }' | awk -F" x " '{ print $2 }' | awk -F" " '{ print $ 1 }'`
vagrant status | grep 'running' > /dev/null
if [ $? -ne 0 ]
then
vagrant up
fi
vagrant -Y ssh -- -X -t "export WIDTH=$WIDTH; export HEIGHT=$HEIGHT; cd /baboon-tracking; ./cli $@"
# macOS ps -A includes the grep 'vagrant', we check to see if any of the lines do not include grep.
ps -A | grep 'vagrant' | grep -v grep > /dev/null
if [ $? -ne 0 ]
then
vagrant suspend
fi