-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathinstallF2MD
executable file
·302 lines (277 loc) · 12.1 KB
/
installF2MD
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
#!/bin/bash
package="installF2MD"
HELP="\n$HELP $package - used to automatically install F2MD\n"
HELP="$HELP \n"
HELP="$HELP $package [options]\n"
HELP="$HELP \n"
HELP="$HELP options:\n"
HELP="$HELP -h, --help show brief help\n"
HELP="$HELP -i, --install-dir DIR specify the install directory\n"
HELP="$HELP -is, --install-sumo set this flag to automatically install sumo\n"
HELP="$HELP -sv, --sumo-version SUMO_VERSION specify the version of sumo to install\n"
HELP="$HELP -io, --install-omnetpp set this flag to automatically install omnetpp\n"
HELP="$HELP -ov, --omnetpp-version OMNETPP_VERSION specify the version of omnetpp to install\n"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
printf "$HELP"
exit 0
shift # past argument
shift # past value
;;
-i|--install-dir)
INSTALL_DIR="$2"
shift # past argument
shift # past value
;;
-sv|--sumo-version)
SUMO_VERSION="$2"
shift # past argument
shift # past value
;;
-ov|--omnetpp-version)
OMNETPP_VERSION="$2"
shift # past argument
shift # past value
;;
-is|--install-sumo)
INSTALL_SUMO=YES
shift # past argument
;;
-io|--install-omnetpp)
INSTALL_OMNETPP=YES
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
RED='\033[0;31m'
NC='\033[0m'
### Check if a directory does not exist ###
if [[ $INSTALL_DIR != "" ]]
then
if [ ! -d "${INSTALL_DIR}" ]
then
read -r -p "Directory ${INSTALL_DIR} does not exist, do you want to create it? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
mkdir ${INSTALL_DIR}
else
echo "\nPlease select another directory."
exit 1
fi
fi
else
CUR_DIR=$(pwd)
read -r -p "Flag -i|--install-path not specified, do you want to install in the current directory ($CUR_DIR) ? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
INSTALL_DIR=${CUR_DIR}
else
echo "\nPlease specify the flag -i|--install-path."
exit 1
fi
fi
if [[ $INSTALL_SUMO == "YES" ]]
then
if [[ $PATH == *"sumo"* ]]
then
echo "SUMO appears to be already installed, you set the flag -is|--install-sumo which would install sumo again."
read -r -p "Are you sure you want to continue? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Please remove the flag -is|--install-sumo and restart the installation."
exit 1
fi
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' "wget"|grep "install ok installed")
if [ "" == "$PKG_OK" ]; then
sudo apt install -y wget
fi
SUMO_VERSION_LIST=$(wget -qO- https://sumo.dlr.de/releases | grep -Eoi '<a [^>]+>' | grep -Eo "[0-9\.]*")
echo -e "\n${RED}/!\ Warning /!\ ${NC}F2MD is tested and working with SUMO version 1.2.1$"
if [[ $SUMO_VERSION != "" ]]
then
if [[ ! $SUMO_VERSION_LIST =~ (^|[[:space:]])"$SUMO_VERSION"($|[[:space:]]) ]] ; then
echo "Your SUMO version \"$SUMO_VERSION\" does not exist in https://sumo.dlr.de/releases."
printf "\nPlease chose a sumo version from :\n$SUMO_VERSION_LIST\n"
exit 1
fi
else
printf "\nPlease select a SUMO version:\n"
select SUMO_VERSION in $SUMO_VERSION_LIST; do test -n "$SUMO_VERSION" && break; echo ">>> Invalid Selection"; done
fi
else
if [[ ! $PATH == *"sumo"* ]]
then
echo "SUMO does not appear to be already installed, you can install SUMO automatically by setting the flag -is|--install-sumo."
read -r -p "Are you sure you want to continue? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "\nPlease add the flag -is|--install-sumo and restart the installation."
exit 1
fi
fi
fi
if [[ $INSTALL_OMNETPP == "YES" ]]
then
if [[ $PATH == *"omnetpp"* ]]
then
echo "OMNETPP appears to be already installed, you set the flag -io|--install-omnetpp which would install omnetpp again."
read -r -p "Are you sure you want to continue? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "\nPlease remove the flag -io|--install-omnetpp and restart the installation."
exit 1
fi
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' "wget"|grep "install ok installed")
if [ "" == "$PKG_OK" ]; then
sudo apt install -y wget
fi
OMNETPP_VERSION_LIST=$(GET https://api.github.com/repos/omnetpp/omnetpp/releases | grep -Po '"tag_name": *"omnetpp-\K[^"]*(?=\"?)')
echo -e "\n${RED}/!\ Warning /!\ ${NC}F2MD is tested and working with OMNETPP version 5.6.2$"
if [[ $OMNETPP_VERSION != "" ]]
then
if [[ ! $OMNETPP_VERSION_LIST =~ (^|[[:space:]])"$OMNETPP_VERSION"($|[[:space:]]) ]] ; then
echo "Your OMNETPP version \"$OMNETPP_VERSION\" does not exist in https://omnetpp.dlr.de/releases."
printf "Please chose a omnetpp version from :\n$OMNETPP_VERSION_LIST\n"
exit 1
fi
else
printf "\nPlease select a OMNETPP version:\n"
select OMNETPP_VERSION in $OMNETPP_VERSION_LIST; do test -n "$OMNETPP_VERSION" && break; echo ">>> Invalid Selection"; done
fi
else
if [[ ! $PATH == *"omnetpp"* ]]
then
echo "OMNETPP does not appear to be already installed, you can install OMNETPP automatically by setting the flag -io|--install-omnetpp."
read -r -p "Are you sure you want to continue? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
printf "\nPlease add the flag -is|--install-omnetpp and restart the installation."
exit 1
fi
fi
fi
ECHO_VAR="Installing F2MD in ${INSTALL_DIR}"
if [[ $INSTALL_SUMO == "YES" ]];then
ECHO_VAR="$ECHO_VAR with SUMO version ${SUMO_VERSION}"
fi
if [[ $INSTALL_OMNETPP == "YES" ]];then
ECHO_VAR="$ECHO_VAR with OMNET++ version ${OMNETPP_VERSION}"
fi
printf "\n$ECHO_VAR.\n\n"
## Install f2md dependencies
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y git rapidjson-dev net-tools gnuplot python3 python3-dev python3-tk python-is-python3
if [[ $INSTALL_SUMO == "YES" ]]
then
# Install sumo dependencies
sudo apt-get install -y wget unzip
sudo apt-get install -y git cmake python2 g++ libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev swig
sudo apt-get install -y apt-utils python2-setuptools python3-setuptools libeigen3-dev default-jre
mkdir ${INSTALL_DIR}/Programs
# Install sumo
cd ${INSTALL_DIR}/Programs
wget https://sumo.dlr.de/releases/${SUMO_VERSION}/sumo-src-${SUMO_VERSION}.zip && unzip -q sumo-src-${SUMO_VERSION}.zip && rm sumo-src-${SUMO_VERSION}.zip
cd ${INSTALL_DIR}/Programs/sumo-${SUMO_VERSION}
if ! grep -Fq 'SUMO_HOME' $HOME/.bashrc
then
echo ' ' >> $HOME/.bashrc
echo '# set SUMO_HOME variable' >> $HOME/.bashrc
echo "if [ -d \"$INSTALL_DIR/Programs/sumo-${SUMO_VERSION}\" ] ; then" >> $HOME/.bashrc
echo " export SUMO_HOME=\"$INSTALL_DIR/Programs/sumo-${SUMO_VERSION}\"" >> $HOME/.bashrc
echo 'fi' >> $HOME/.bashrc
fi
if ! grep -Fq '/sumo' $PATH
then
echo ' ' >> $HOME/.bashrc
echo '# set PATH so it includes SUMO' >> $HOME/.bashrc
echo "if [ -d \"$INSTALL_DIR/Programs/sumo-${SUMO_VERSION}/bin\" ] ; then" >> $HOME/.bashrc
echo " PATH=\"$INSTALL_DIR/Programs/sumo-${SUMO_VERSION}/bin:\$PATH\"" >> $HOME/.bashrc
echo 'fi' >> $HOME/.bashrc
fi
export SUMO_HOME=${INSTALL_DIR}/Programs/sumo-${SUMO_VERSION}
export PATH="${INSTALL_DIR}/Programs/sumo-${SUMO_VERSION}/bin:${PATH}"
mkdir ${SUMO_HOME}/build/cmake-build
cd ${INSTALL_DIR}/Programs/sumo-${SUMO_VERSION}/build/cmake-build
cmake ../.. && make -j$(nproc)
fi
if [[ $INSTALL_OMNETPP == "YES" ]]
then
# Install omnetpp dependencies
sudo apt-get install -y wget unzip
sudo apt-get install -y build-essential gcc g++ bison flex perl
sudo apt-get install -y python2 python3 qt5-default libqt5opengl5-dev tcl-dev tk-dev
sudo apt-get install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
sudo apt-get install -y libxml2-dev zlib1g-dev default-jdk doxygen graphviz libwebkitgtk-3.0-0
sudo apt-get install -y openscenegraph-plugin-osgearth libosgearth-dev
sudo apt-get install -y openmpi-bin libopenmpi-dev libpcap-dev gnome-color-chooser nemiver
sudo apt-get install -y python3-pip
sudo pip3 install numpy scipy pandas matplotlib posix_ipc
# Install omnetpp
cd ${INSTALL_DIR}/Programs
if wget -q --method=HEAD https://github.com/omnetpp/omnetpp/releases/download/omnetpp-${OMNETPP_VERSION}/omnetpp-${OMNETPP_VERSION}-linux-x86_64.tgz;
then
wget https://github.com/omnetpp/omnetpp/releases/download/omnetpp-${OMNETPP_VERSION}/omnetpp-${OMNETPP_VERSION}-linux-x86_64.tgz && tar zxf omnetpp-${OMNETPP_VERSION}-linux-x86_64.tgz && rm omnetpp-${OMNETPP_VERSION}-linux-x86_64.tgz
else
wget https://github.com/omnetpp/omnetpp/releases/download/omnetpp-${OMNETPP_VERSION}/omnetpp-${OMNETPP_VERSION}-src-linux.tgz && tar zxf omnetpp-${OMNETPP_VERSION}-src-linux.tgz && rm omnetpp-${OMNETPP_VERSION}-src-linux.tgz
fi
cd ${INSTALL_DIR}/Programs/omnetpp-${OMNETPP_VERSION}
if ! grep -Fq '/omnetpp' $PATH
then
echo ' ' >> $HOME/.bashrc
echo '# set PATH so it includes Omnet++' >> $HOME/.bashrc
echo "if [ -d \"$INSTALL_DIR/Programs/omnetpp-${OMNETPP_VERSION}/bin\" ] ; then" >> $HOME/.bashrc
echo " PATH=\"$INSTALL_DIR/Programs/omnetpp-${OMNETPP_VERSION}/bin:\$PATH\"" >> $HOME/.bashrc
echo 'fi' >> $HOME/.bashrc
fi
export PATH="${INSTALL_DIR}/Programs/omnetpp-${OMNETPP_VERSION}/bin:${PATH}"
setenvdot = ". setenv"
setenvsource = "source setenv"
bash -c $setenvdot
bash -c $setenvsource
./configure WITH_OSGEARTH=no WITH_OSG=no && make -j$(nproc)
fi
# Install F2MD
cd ${INSTALL_DIR}/
git clone --recurse-submodules https://github.com/josephkamel/F2MD.git
# Build inet
cd ${INSTALL_DIR}/F2MD/inet
export INET_ROOT=${INSTALL_DIR}/F2MD/inet
if ! grep -Fq 'INET_ROOT' $HOME/.bashrc
then
echo ' ' >> $HOME/.bashrc
echo '# set INET variables' >> $HOME/.bashrc
echo "if [ -d \"$INSTALL_DIR/F2MD/inet\" ] ; then" >> $HOME/.bashrc
echo " export INET_ROOT=\"$INSTALL_DIR/F2MD/inet\"" >> $HOME/.bashrc
echo " export INET_NED_PATH=\"\$INET_ROOT/src:\$INET_ROOT/tutorials:\$INET_ROOT/showcases:\$INET_ROOT/examples\"" >> $HOME/.bashrc
echo " export INET_OMNETPP_OPTIONS=\"-n \$INET_NED_PATH --image-path=\$INET_ROOT/images\"" >> $HOME/.bashrc
echo " export INET_GDB_OPTIONS=\"-quiet -ex run --args\"" >> $HOME/.bashrc
echo " export INET_VALGRIND_OPTIONS=\"-v --tool=memcheck --leak-check=yes --show-reachable=no --leak-resolution=high --num-callers=40 --freelist-vol=4000000\"" >> $HOME/.bashrc
echo 'fi' >> $HOME/.bashrc
fi
export INET_NED_PATH="${INET_ROOT}/src:${INET_ROOT}/tutorials:${INET_ROOT}/showcases:${INET_ROOT}/examples"
export INET_OMNETPP_OPTIONS="-n ${INET_NED_PATH} --image-path=${INET_ROOT}/images"
export INET_GDB_OPTIONS="-quiet -ex run --args"
export INET_VALGRIND_OPTIONS="-v --tool=memcheck --leak-check=yes --show-reachable=no --leak-resolution=high --num-callers=40 --freelist-vol=4000000"
make makefiles && make -j$(nproc) WITH_OSGEARTH=no MODE=debug && make -j$(nproc) MODE=release all
# Build veins
cd ${INSTALL_DIR}/F2MD/veins-f2md
./configure && make -j$(nproc) MODE=release all
# Build veins_inet3
cd ${INSTALL_DIR}/F2MD/veins-f2md/subprojects/veins_inet3
./configure && make -j$(nproc) MODE=release all
# Build simulte
cd ${INSTALL_DIR}/F2MD/simulte-f2md
make makefiles && make -j$(nproc) MODE=release all
printf "\nThe installation is complete, you can now run a scenario using the ./F2MD/runScenario.sh\n"