-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
133 lines (108 loc) · 3.23 KB
/
setup.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
#!/bin/bash
echo "Installing nodejs, modules required for mqtt server and ffmpeg"
# function for linux setup
function install_Nodejs_and_dependencies {
echo "Nodejs and its dependencies"
echo "if you have used Chris Lea's Node.js PPA. Enter "1" for yes and "0" for no"
read Nodejs_hist
if [ $Nodejs_hist -eq 1 ]
then
sudo add-apt-repository -y -r ppa:chris-lea/node.js
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save
fi
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
VERSION=node_6.x
DISTRO="$(lsb_release -s -c)"
echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs
}
function install_other_dependencies {
sudo apt update
sudo apt-get install python3-pip
pip3 install numpy
pip3 install paho-mqtt
sudo apt install libzmq3-dev libkrb5-dev
sudo apt install ffmpeg
sudo apt-get install cmake
}
function install_npm {
sudo apt install npm
cd webservice/server
npm install
cd ../ui
npm install
# if
# sudo npm install npm -g
# rm -rf node_modules
# npm cache clean
# npm config set registry "http:https://registry.npmjs.org"
# npm install
}
# Mac function to install nodejs
function mac_install_nodejs {
# update brew
brew update
brew doctor
# installing node and npm
brew install node
# print the version of node installed
node -v
#print the version of npm installed
npm -v
}
# Mac function to install modules
function mac_install_dep {
pip3 install numpy
pip3 install paho-mqtt
brew install cmake
brew install zeromq
}
# Mac function to install FFmpeg's ffserver
function mac_install_ff {
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
git checkout 2ca65fc7b74444edd51d5803a2c1e05a801a6023
./configure
make -j4
}
# obtain os type
p_name=`uname`
echo $p_name
if [ "$p_name" == 'Linux' ]
then
echo $(lsb_release -i -s)
# install_Nodejs_and_dependencies
install_Nodejs_and_dependencies
# install_other_dependencies
install_other_dependencies
# install_npm
install_npm
elif [ "$p_name" == 'Darwin']
then
echo "I am a Mac"
# Return 1 if python version is ≥ 3.5, otherwise return 0 if python < 3.5 or doesn't exist.
py_version=$(python -c"import sys; print(0) if sys.version_info.major < 3 and sys.version_info.minor < 5 else print(1)")
# if python version is ≥ 3.5, do
if [ $py_version == 1 ]
then
# install nodejs
mac_install_nodejs
# install dependencies
mac_install_dep
# install ffserver
mac_install_ff
# if python version is < 3.5 or python isn't installed
else
# use brew to install python
brew install python3
# install nodejs
mac_install_nodejs
# install dependencies
mac_install_dep
# install ffserver
mac_install_ff
fi
fi