-
Notifications
You must be signed in to change notification settings - Fork 18
/
install.sh
executable file
·198 lines (175 loc) · 5.13 KB
/
install.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
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SHELLPID=$$
trap cleanup SIGTERM SIGINT
die() {
printf '%s\n' "$1" >&2
exit 1
}
VERSION=2.0
# Determine the platform we are running on
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ $machine = Linux ]; then
echo
echo
echo "Installing JAMScript Version ${VERSION} on Linux....."
echo
echo
if [ -f "/etc/arch-release" ]; then
echo "Detected Arch"
PM_INSTALL="sudo pacman -S --needed"
MOSQUITTO="mosquitto"
REDIS="redis hiredis"
LIBEVENT="libevent"
NODE_SETUP=":"
NODE="nodejs-lts-hydrogen"
else
PM_INSTALL="sudo apt-get install -y"
MOSQUITTO="mosquitto mosquitto-clients libmosquitto-dev"
REDIS="redis-server redis-tools libhiredis-dev"
LIBEVENT="libevent-dev"
NODE_SETUP="curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh && sudo bash /tmp/nodesource_setup.sh"
NODE="nodejs"
sudo apt update
fi
# instal libevent
eval ${PM_INSTALL} ${LIBEVENT}
# install clang if not found
if ! command -v clang &> /dev/null; then
echo "Clang not found: installing..."
eval ${PM_INSTALL} clang
fi
# install mosquitto clients
if ! command -v mosquitto_pub &> /dev/null; then
echo "Mosquitto tools not found: installing..."
eval ${PM_INSTALL} ${MOSQUITTO}
fi
# install unzip
if ! command -v unzip &> /dev/null; then
echo "Unzip not found: installing..."
eval ${PM_INSTALL} unzip
fi
# install redis
if ! command -v redis-cli &> /dev/null; then
echo "Redis not found: installing..."
eval ${PM_INSTALL} ${REDIS}
fi
# install make
if ! command -v make &> /dev/null; then
echo "Make not found: installing..."
eval ${PM_INSTALL} make
fi
# install node
if ! command -v node &> /dev/null; then
echo "Node JS not found: install ...."
eval ${NODE_SETUP}
eval ${PM_INSTALL} ${NODE}
fi
# install tmux
if ! command -V tmux &> /dev/null; then
echo "tmux not found: install ...."
eval ${PM_INSTALL} tmux
fi
elif [ $machine = Mac ]; then
echo
echo
echo "Installing JAMScript Version ${VERSION} on MacOS....."
echo
echo
# Check for homebrew
if ! command -v brew &> /dev/null; then
echo "JAMScript install needs Homebrew. You can install Homebrew from -- https://brew.sh "
echo "Rerun JAMScript after installing Homebrew."
exit 1
fi
# install wget
if ! command -v wget &> /dev/null; then
echo "Wget not found: installing..."
brew install wget
fi
# install node
if ! command -v node &> /dev/null; then
echo "Node JS not found: install ..."
curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
fi
# install clang
if ! command -v clang &> /dev/null; then
echo "Clang not found: install ..."
xcode-select --install
fi
# install unzip
if ! command -v unzip &> /dev/null; then
echo "Unzip not found: installing..."
brew install unzip
fi
# install mosquitto
if ! command -v mosquitto &> /dev/null; then
echo "Mosquitto not found: installing..."
brew install mosquitto
fi
# install make
if ! command -v make &> /dev/null; then
echo "Make not found: installing..."
brew install make
fi
# install redis
if ! command -v redis-server &> /dev/null; then
echo "Redis not found: installing..."
brew install redis hiredis
fi
# install tmux
if ! command -v tmux &> /dev/null; then
echo "Tmux not found: installing..."
brew install tmux
fi
fi
#intialize carapi submmodule
cd $SCRIPT_DIR
git submodule update --init --recursive lib/
#install tinycbor
cd $SCRIPT_DIR/deps/tinycbor
git clone https://github.com/intel/tinycbor
cd tinycbor
make
sudo make install
#install mujs
cd $SCRIPT_DIR/deps/mujs2
make
sudo make install
# install the necessary npm packages
cd $SCRIPT_DIR
npm install
# compile the cside
cd $SCRIPT_DIR/lib/cside
make archive
cd $HOME
# create .jamruns and make the links
if [ ! -d .jamruns ]; then
mkdir .jamruns
fi
cd .jamruns
# relink or link the directories
rm clib
ln -s $SCRIPT_DIR/lib/cside clib
rm jamhome
ln -s $SCRIPT_DIR jamhome
rm node_modules
ln -s $SCRIPT_DIR/lib/jside node_modules
# go back to the starting location
cd $SCRIPT_DIR
echo
echo
echo "====================================================="
echo
echo "JAMScript Version 2.0 install complete."
echo
echo "Include ${SCRIPT_DIR}/tools in your executable path."
echo
echo "Goto https://citelab.github.io/JAMScript for more information on programming in JAMScript"
echo
echo "====================================================="