-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.bash
85 lines (74 loc) · 2.01 KB
/
install.bash
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
#!/usr/bin/env bash
# Installs the platform-sdk package.
#
# Copyright 2017-2019, Voxel51, Inc.
# voxel51.com
#
# Show usage information
usage() {
echo "Usage: bash $0 [-h] [-f] [-n]
Getting help:
-h Display this help message.
Install options:
-f Whether to perform a full ETA install. The default is a lite install.
-n Don't install ETA. By default, ETA is installed
"
}
# Parse flags
SHOW_HELP=false
LITE_ETA_INSTALL=true
INSTALL_ETA=true
while getopts "hfn" FLAG; do
case "${FLAG}" in
h) SHOW_HELP=true ;;
f) LITE_ETA_INSTALL=false ;;
n) INSTALL_ETA=false ;;
*) usage ;;
esac
done
[ ${SHOW_HELP} = true ] && usage && exit 0
# Install platform-sdk
echo "Installing platform-sdk"
pip install -r requirements.txt
pip install -e .
# Install ETA, if necessary
if [ ${INSTALL_ETA} = true ]; then
# Initialize submodules
echo "Initializing submodules"
git submodule init
git submodule update
# Install ETA
cd eta
if [ ${LITE_ETA_INSTALL} = true ]; then
echo "Installing ETA lite"
bash install.bash -l
else
echo "Installing ETA"
bash install.bash
fi
cp config-example.json config.json
cd ..
fi
# Install local test server
echo "Installing local test server"
command -v npm &> /dev/null
if [ $? -ne 0 ]; then
echo "Installing Node.js"
INSTALLED_NODE=true
# Install nvm
unset NVM_DIR
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Install node
nvm install node
else
echo "Node.js is already installed"
INSTALLED_NODE=false
fi
cd tests/platform
npm install
if [ ${INSTALLED_NODE} = true ]; then
printf "\n***** You must restart your terminal or source your .bashrc/.bash_profile before you can use the local test server *****\n\n"
fi